mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: arouhi@sitime.com
Cc: jiri@resnulli.us, vadim.fedorenko@linux.dev,
	arkadiusz.kubalewski@intel.com, ivecera@redhat.com,
	kuba@kernel.org, pabeni@redhat.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org,
	prabhakar.mahadev-lad.rj@bp.renesas.com, cjubran@nvidia.com,
	Oleg.Zadorozhnyi@devoxsoftware.com, devicetree@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v14 07/12] dpll: sit9531x: add support to get and set priority on input pins
Date: Tue, 20 Oct 2026 03:09:46 +0000	[thread overview]
Message-ID: <179246578667.3135.9023338680952688439@kernel.org> (raw)
In-Reply-To: <20261016005823.13690-8-arouhi@sitime.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] A priority that the device has latched can be rolled back in
  the driver's records and reported to userspace as refused.
- [Medium] A priority change confined to standby inputs can move the PLL
  off a healthy fallback reference.
- [Low] The default priority for a source a PLL has never listed is
  SIT9531X_PRIO_MAX_SLOTS - 1 = 10.

--

dpll: sit9531x: add support to get and set priority on input pins

This patch adds prio_get and prio_set callbacks for the sit9531x input
pins. Both work on a per-PLL configured priority, and the Page 1 table is
rebuilt in priority order when a listed input's priority changes. The
poll now also watches priority and operational state, and the baseline
for that comparison is taken when each pin is registered.

> diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c
> index 1aad598930d72..f3dbe949f219b 100644
> --- a/drivers/dpll/sit9531x/core.c
> +++ b/drivers/dpll/sit9531x/core.c
> @@ -671,6 +671,44 @@ bool sit9531x_input_prio_present(struct sit9531x_dev *sitdev, u8 pll_idx,
>  	return !!(sitdev->chan[pll_idx].prio_mask & BIT(input_idx));
>  }
>  
> +/*
> + * sit9531x_input_prio_get - read an input's priority for a PLL
> + * @input_idx:	input source in hardware encoding (see
> + *		sit9531x_input_hw_src())
> + * @prio:	output priority (lower is preferred)
> + *
> + * Reports the priority configured for the source on this PLL, which is
> + * kept whether or not the source is currently in the table: state and
> + * priority are separate attributes, so disconnecting an input and
> + * connecting it again must not change the priority it reports.  The
> + * value is seeded from the hardware table, and re-seeded whenever the
> + * read-back shows the table was rewritten by something other than this
> + * driver.  A source that was never listed reports the lowest slot.

[ ... ]

> +	chan = &sitdev->chan[pll_idx];
> +	if (chan->cfg_known & BIT(input_idx))
> +		*prio = chan->cfg_prio[input_idx];
> +	else
> +		*prio = SIT9531X_PRIO_MAX_SLOTS - 1;
> +
> +	return 0;
> +}

[Severity: Low]
Is "the lowest slot" still accurate now that priorities from 0 to 255 are
accepted?

The default for a source the PLL has never listed is
SIT9531X_PRIO_MAX_SLOTS - 1, which is 10. sit9531x_prio_cfg_seed() seeds
it the same way:

	chan->cfg_prio[src] = SIT9531X_PRIO_MAX_SLOTS - 1;
	chan->cfg_known |= BIT(src);

The commit message says the same thing:

  "An input the PLL has never listed reports the lowest slot, the
  priority it would be connected at."

However, sit9531x_dpll_input_pin_prio_set() accepts values up to U8_MAX:

	if (prio > U8_MAX) {
		NL_SET_ERR_MSG(extack, "Priority out of range (0-255)");

sit9531x_prio_table_build() sorts members by cfg_prio and uses
prio_last only to break ties:

	kc = (chan->cfg_known & BIT(cur)) ?
	     chan->cfg_prio[cur] : U8_MAX;

Here is an example. IN0 is listed and is set to 50. IN1 has never been
listed and keeps the default of 10. Connecting IN1 then goes through
sit9531x_input_prio_add()->sit9531x_prio_table_apply()->
sit9531x_prio_table_build(), which puts IN1 in slot 0, ahead of IN0.
sit9531x_prio_activesel_pick() may then move the PLL to it.

Should the default follow the real lowest priority (U8_MAX, for example),
or should the comments and commit message stop promising "lowest"?

[ ... ]

> diff --git a/drivers/dpll/sit9531x/dpll.c b/drivers/dpll/sit9531x/dpll.c
> index 4c7cae4ce93ec..0400444d91a55 100644
> --- a/drivers/dpll/sit9531x/dpll.c
> +++ b/drivers/dpll/sit9531x/dpll.c

[ ... ]

> +static int
> +sit9531x_dpll_input_pin_prio_set(const struct dpll_pin *pin, void *pin_priv,
> +				 const struct dpll_device *dpll,
> +				 void *dpll_priv, u32 prio,
> +				 struct netlink_ext_ack *extack)
> +{

[ ... ]

> +	mutex_lock(&sitdev->multiop_lock);
> +	rc = sit9531x_input_prio_set(sitdev, sitdpll->id,
> +				     sit9531x_input_hw_src(dpin->id),
> +				     (u8)prio);

[Severity: Medium]
Can a priority change that only touches standby inputs move the PLL off
a healthy fallback reference?

sit9531x_prio_table_commit() takes the current source from the
CLK_ACTIVESEL nibble it reads back, not from the reference actually
routed to the PLL:

		u8 sel = sit9531x_prio_slot_get(val, slot + 1);
		...
		sel = sit9531x_prio_activesel_pick(sitdev, chan->prio_srcs,
						   srcs, sel);

The driver's comments say that when the selected source A loses its
signal, the device fails over to B on its own and leaves the selection
naming A. Suppose A then recovers while the PLL is still on B.

Now a prio_set that only reorders inputs below A and B rewrites the
table. In sit9531x_prio_activesel_pick(), A is the top live source in
both the old and the new table, so the function falls through to:

	if (sit9531x_prio_src_usable(cur) &&
	    sit9531x_prio_src_live(sitdev, cur))
		for (i = 0; i < SIT9531X_PRIO_MAX_SLOTS; i++)
			if (srcs[i] == cur)
				return cur;

It returns A, and latching that selection moves the PLL from B to A.

Doesn't that contradict "a change further down the table leaves the PLL
where it is" in the commit message? The comment above the pick also
says "a change further down the table must not pull a PLL off a healthy
reference".

The selection logic came with the previous patch, for state changes.
This patch adds prio_set as a new way to reach it. When the top is
unchanged, would keeping the routed reference (chan->routed_ref) rather
than the stale selection nibble avoid the switch?

> +	if (!rc)
> +		dpin->prio = prio;
> +	mutex_unlock(&sitdev->multiop_lock);
> +
> +	if (rc) {
> +		NL_SET_ERR_MSG(extack, "Failed to set input priority");
> +		return rc;
> +	}

[Severity: Medium]
Can the driver's record of this priority end up disagreeing with what
the device latched?

In sit9531x_prio_table_commit(), the slot writes and the latch can
succeed. The new table is then recorded as the read-back baseline:

	if (!rc) {
		sit9531x_prio_mask_build(sitdev, pll_idx, srcs);
		memcpy(chan->seen_srcs, srcs, sizeof(chan->seen_srcs));
		chan->seen_valid = true;
	}

The holdover release runs after that. If all SIT9531X_HO_CLEAR_TRIES
attempts fail:

	if (ho_rc) {
		...
		if (!rc)
			rc = ho_rc;
	}
	chan->ho_release_pending = !!ho_rc;

sit9531x_ho_release_retry() clears HO_FORCE later from the poll, so the
PLL ends up running the new order.

Meanwhile sit9531x_input_prio_set() sees rc != 0 and reverts:

	rc = sit9531x_prio_table_apply(sitdev, pll_idx, chan->prio_mask);
	if (rc) {
		chan->cfg_prio[input_idx] = old_prio;
		chan->cfg_known = old_known;
	}

sit9531x_dpll_input_pin_prio_set() then returns the error and leaves
dpin->prio as it was.

sit9531x_chan_state_fetch() re-seeds only when the read-back differs
from seen_srcs:

	if (!chan->seen_valid ||
	    memcmp(srcs, chan->seen_srcs, sizeof(chan->seen_srcs)))
		sit9531x_prio_cfg_seed(sitdev, pll_idx, srcs);

seen_srcs already holds the new table, so the poll never repairs this.
The getter and the poll snapshot keep reporting the old priority while
the device holds the new order, and no notification is sent.

The next sit9531x_prio_table_apply() for some unrelated reason, such as a
sibling's state change, builds from the reverted cfg_prio. That reorders
the device back without anyone asking, and
sit9531x_prio_activesel_pick() may move the PLL off its reference.

A latch failure in sit9531x_prio_prg_commit(), or a rollback that fails
part-way, looks like it ends in the same split. In both cases seen_srcs
comes from the read-back table while cfg_prio has been reverted.

The commit message says:

  "A priority the table write refused is not kept: the configured
  value goes back to what it was, so nothing reports a priority the
  device never took."

On this path, isn't the driver reporting the opposite of what the device
holds? Could the rollback be based on what the read-back table actually
encodes, rather than on the errno?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261016005823.13690-1-arouhi%40sitime.com

  reply	other threads:[~2026-10-20  3:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  0:58 [PATCH net-next v14 00/12] dpll: add SiTime SiT9531x DPLL clock driver Ali Rouhi
2026-10-16  0:58 ` [PATCH net-next v14 01/12] dt-bindings: vendor-prefixes: add SiTime Corporation Ali Rouhi
2026-10-16  0:58 ` [PATCH net-next v14 03/12] dpll: add basic SiTime SiT9531x support Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 02/12] dt-bindings: dpll: add SiTime SiT95316 clock generator Ali Rouhi
2026-10-16 13:53   ` Rob Herring (Arm)
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 04/12] dpll: sit9531x: read DPLL types and pin properties from system firmware Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 06/12] dpll: sit9531x: implement input pin state on a DPLL Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 05/12] dpll: sit9531x: register DPLL devices and pins Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 07/12] dpll: sit9531x: add support to get and set priority on input pins Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko [this message]
2026-10-16  0:58 ` [PATCH net-next v14 08/12] dpll: sit9531x: add support to get and set frequency on pins Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 09/12] dpll: sit9531x: implement output pin state on a DPLL Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 10/12] dpll: sit9531x: add support to adjust output phase Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 11/12] dpll: sit9531x: add support to get phase offset on the connected input pin Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko
2026-10-16  0:58 ` [PATCH net-next v14 12/12] dpll: sit9531x: model the inter-PLL sync net as a pair of pins Ali Rouhi
2026-10-20  3:09   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179246578667.3135.9023338680952688439@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=Oleg.Zadorozhnyi@devoxsoftware.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=arouhi@sitime.com \
    --cc=cjubran@nvidia.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ivecera@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh@kernel.org \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®