The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: arouhi@sitime.com
Cc: jiri@resnulli.us, ivecera@redhat.com, vadim.fedorenko@linux.dev,
	arkadiusz.kubalewski@intel.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,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v17 08/13] dpll: sit9531x: add support to get and set priority on input pins
Date: Thu, 03 Dec 2026 00:39:09 +0000	[thread overview]
Message-ID: <179625834984.3146.5434082265561517682@kernel.org> (raw)
In-Reply-To: <20261201235202.97645-9-arouhi@sitime.com>

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

Critical: 0 · High: 0 · Medium: 3 · Low: 4

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] Changing the priority of a standby input that the PLL does not
  track still runs the whole table-commit sequence in…
- [Medium] Pin ops are chosen once, at registration, in
  sit9531x_dpll_pin_ops_get() ('As read at probe').
- [Medium] The commit message says a table 'rewritten outside the driver,
  by a profile reload or an I2C tool, becomes the new configuration'.
- [Low] The subject says this patch adds priority get/set, but it also
  changes behaviour that the previous patch in the same unmerged series…
- [Low] sit9531x_dpll_input_pin_prio_set() updates only dpin->prio on
  success.
- [Low] Comments added by this patch state the wrong locking invariant
  for sitdpll->pins.
- [Low] sit9531x_prio_table_commit() now calls sit9531x_chan_lock_fetch()
  before forcing holdover whenever the new table is non-empty, and…

--

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

This commit adds prio_get and prio_set pin callbacks to the sit9531x DPLL
driver. It keeps a configured priority for each input and PLL, and rebuilds
the Page 1 priority table when a priority is set. It also makes table writes
prefer the routed source as the active selection, reports the XO priority
read-only, and reworks the poll so it notifies changes against a baseline
taken at registration and after state requests.

> A table rewritten outside the driver, by a profile reload or an I2C
> tool, becomes the new configuration.

[Severity: Medium]
How does the driver stay in step with the device's page select register when
an I2C tool rewrites the table?

sit9531x_page_select() caches the selected page and skips the PAGE_SEL write
when the cache matches:

drivers/dpll/sit9531x/core.c:sit9531x_page_select() {
    ...
	if (sitdev->page == page)
		return 0;
    ...
}

The cache is only dropped on a regmap error or on resume. An external tool
has to write PAGE_SEL to rewrite the Page 1 table. If it leaves PAGE_SEL on
a page other than the cached one, the next driver access to the cached page
goes to the same offset on the wrong page.

The poll would then read OUTER_LOL, HO_FREEZE, CLKMON and the priority table
from another page. sit9531x_chan_state_fetch() could then adopt a "table"
read from the wrong page as the new configuration through
sit9531x_prio_cfg_seed().

Writes such as HO_CTRL, the debug keys, the input FORCE/STATE bits and the
priority slots could also land on unrelated registers.

Can the I2C tool case be supported while the page is cached, or should the
commit message leave it out?

> diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c
> index d0305cbf12d5a..6e06e99e5ff82 100644
> --- a/drivers/dpll/sit9531x/core.c
> +++ b/drivers/dpll/sit9531x/core.c

[ ... ]

> @@ -780,6 +808,13 @@ static u8 sit9531x_prio_activesel_pick(struct sit9531x_dev *sitdev,
>  	    (idle || top != sit9531x_prio_top_live(sitdev, old)))
>  		return sit9531x_prio_table_code(sitdev, srcs, top);
>  
> +	if (sit9531x_prio_src_usable(routed) &&
> +	    sit9531x_prio_src_live(sitdev, routed)) {
> +		code = sit9531x_prio_table_code(sitdev, srcs, routed);
> +		if (code != SIT9531X_PRIO_SRC_NONE)
> +			return code;
> +	}
> +

[Severity: Low]
This isn't a bug at the head of the series, but this patch also changes
behaviour added by the previous patch, "dpll: sit9531x: implement input pin
state on a DPLL":

- The pick now prefers the routed source over the selection nibble. At the
  earlier commit, the device could fall back from A to B while the nibble
  still named A. An unrelated state request that rewrote the table then
  latched A again.

- Every table commit, including SELECTABLE and DISCONNECTED requests, now
  runs sit9531x_chan_lock_fetch() first.

- The pin->seen baseline is replaced, because the earlier poll re-notified
  changes that the core had already notified for a state request.

These look like fixes to the earlier patch. Could they be folded into it, so
that bisecting to that commit doesn't hit the old behaviour?

[ ... ]

> @@ -818,6 +853,16 @@ static int sit9531x_prio_table_commit(struct sit9531x_dev *sitdev, u8 pll_idx,
>  	memcpy(back, chan->table_pending ? chan->table_back : chan->prio_srcs,
>  	       sizeof(back));
>  
> +	/*
> +	 * Sample the lock state and the routed source for the pick before the
> +	 * forced holdover changes them.
> +	 */
> +	if (!empty) {
> +		rc = sit9531x_chan_lock_fetch(sitdev, pll_idx);
> +		if (rc)
> +			return rc;
> +	}

[Severity: Low]
Should a failure here abort the whole priority or state request?

On a tracking PLL, sit9531x_chan_lock_fetch() calls
sit9531x_chan_routed_ref_read(). That function opens the PLL debug window
and ends with:

	return rc ? rc : lock_rc;

So the request fails even when only the final re-lock fails and the routed
source was read correctly. The routed source is only a hint for the
selection nibble, and sit9531x_prio_activesel_pick() already handles
SIT9531X_PRIO_SRC_NONE.

A failed re-lock also leaves the debug key open (key_pending). Before this
patch, this path only touched HO_CTRL and the priority registers.

Could a failed sample fall back to no routed source instead of failing the
request?

[ ... ]

> @@ -1043,6 +1096,59 @@ static int sit9531x_prio_table_apply(struct sit9531x_dev *sitdev, u8 pll_idx,

[ ... ]

> +	chan = &sitdev->chan[pll_idx];
> +	old_prio = chan->cfg_prio[input_idx];
> +	old_known = chan->cfg_known;
> +	chan->cfg_prio[input_idx] = prio;
> +	chan->cfg_known |= BIT(input_idx);
> +
> +	if (!(chan->prio_mask & BIT(input_idx)))
> +		return 0;
> +
> +	rc = sit9531x_prio_table_apply(sitdev, pll_idx, chan->prio_mask);

[Severity: Medium]
The commit message says:

  A table write that leaves the best live source unchanged keeps as the
  active selection the source the PLL tracks, read at the write, or the
  selected one it acquires, so the PLL does not restart acquisition for
  it.

Is that accurate for this path? A priority change that only reorders standby
sources still goes through
sit9531x_prio_table_apply()->sit9531x_prio_table_commit(). That sequence:

- sets HO_FORCE on the locked PLL
- rewrites the table
- latches through sit9531x_prio_prg_commit()
- releases holdover

Right after the latch, the driver records:

	/* A latch starts a new acquisition; see sit9531x_reselect(). */
	if (!prg_rc) {
		chan->tracked = false;
		chan->stall_polls = 0;
	}

sit9531x_reselect() also says that a latch restarts acquisition.

The routed-source preference in sit9531x_prio_activesel_pick() stops the
latch from naming a different source. It doesn't avoid the forced holdover
or the re-latch.

So would swapping the priorities of two backup inputs, while a
higher-priority source stays active, still disturb the active reference?

Before this patch, only state requests and the poll's re-select reached this
sequence. If the forced holdover and latch are part of the hardware
table-write procedure, could the commit message say so?

[ ... ]

> @@ -2387,13 +2511,24 @@ static int sit9531x_dpll_pins_register(struct sit9531x_dpll *sitdpll)

[ ... ]

> -		/* List changes are made under multiop_lock */
> +		/*
> +		 * Earlier pins are already reachable from netlink, and the
> +		 * walks over this list run under multiop_lock.
> +		 */
>  		mutex_lock(&sitdpll->dev->multiop_lock);
>  		list_add(&pin->list, &sitdpll->pins);
>  		mutex_unlock(&sitdpll->dev->multiop_lock);

[Severity: Low]
Is this comment accurate? The same applies to the one added in
sit9531x_dpll_pins_unregister() ("Detached under multiop_lock, which
callbacks walking the list hold").

sit9531x_dpll_pins_unregister() walks sitdpll->pins without the lock. The
new second loop in sit9531x_dpll_changes_check() walks the list after
dropping multiop_lock:

	mutex_unlock(&sitdev->multiop_lock);

	list_for_each_entry(pin, &sitdpll->pins, list) {
		if (!pin->ntf_pending)
			continue;

No dpll_pin_ops callback seems to walk this list. The walks look safe
because the poll is queued after registration and cancelled with
kthread_cancel_delayed_work_sync() before unregister. multiop_lock is not
what protects them.

Could the comments describe that instead?

> diff --git a/drivers/dpll/sit9531x/dpll.c b/drivers/dpll/sit9531x/dpll.c
> index 5d16183aa1aeb..3a31d0707127a 100644
> --- a/drivers/dpll/sit9531x/dpll.c
> +++ b/drivers/dpll/sit9531x/dpll.c

[ ... ]

> @@ -414,11 +426,82 @@ sit9531x_dpll_input_pin_state_on_dpll_set(const struct dpll_pin *pin,

[ ... ]

> +	mutex_lock(&sitdev->multiop_lock);
> +	if (sit9531x_chan_state_get(sitdev, sitdpll->id)->manual_input) {
> +		mutex_unlock(&sitdev->multiop_lock);
> +		return sit9531x_dpll_manual_select_refuse(extack);
> +	}
> +	rc = sit9531x_input_prio_set(sitdev, sitdpll->id,
> +				     sit9531x_input_hw_src(dpin->id),
> +				     (u8)prio);
> +	if (!rc)
> +		dpin->prio = prio;
> +	mutex_unlock(&sitdev->multiop_lock);

[Severity: Low]
Should this re-baseline the pin, the way
sit9531x_dpll_input_pin_state_on_dpll_set() does? The core also notifies a
successful prio_set:

dpll_pin_prio_set()
    ops->prio_set()
    __dpll_pin_change_ntf(pin)

The table rewrite can change this pin's operstate, and the core's
notification already carries the new value. pin->pin_state and
pin->operstate still hold the values from before the request. The next
sit9531x_dpll_changes_check() would then send a second notification for the
same change.

Would calling sit9531x_dpll_pin_baseline(dpin) here avoid that?

[ ... ]

> @@ -482,19 +575,82 @@ const struct dpll_pin_ops *

[ ... ]

> +/* Caller must hold sitdev->multiop_lock. */
> +static void sit9531x_dpll_pin_snapshot(struct sit9531x_dpll *sitdpll,
> +				       const struct sit9531x_dpll_pin *pin,
> +				       enum dpll_pin_state *state,
> +				       enum dpll_pin_operstate *operstate,
> +				       u8 *prio)
> +{
> +	struct sit9531x_dev *sitdev = sitdpll->dev;
> +	u8 id = pin->id;
> +
> +	sit9531x_dpll_selection_state_get(sitdev, sitdpll, id, state);
> +	sit9531x_dpll_selection_operstate_get(sitdev, sitdpll, id, operstate);
> +	/* A PLL on manual input select reports no priority */
> +	if (sit9531x_chan_state_get(sitdev, sitdpll->id)->manual_input ||
> +	    sit9531x_input_prio_get(sitdev, sitdpll->id,
> +				    sit9531x_input_hw_src(id), prio))
> +		*prio = pin->prio;
> +}

[Severity: Medium]
Can this disagree with what sit9531x_dpll_input_pin_prio_get() reports?

The ops are chosen once, at registration, in sit9531x_dpll_pin_ops_get().
sit9531x_resume() can still find a PLL on manual input select. It updates
chan->manual_input and only warns that the pins keep the callbacks they were
registered with.

In that state, the automatic-mode .prio_get still returns chan->cfg_prio[].
It is also installed in sit9531x_dpll_xo_pin_ops.
sit9531x_chan_state_fetch() still reseeds cfg_prio[] through
sit9531x_prio_cfg_seed() when the hardware table changes.

For a manual PLL, this function and sit9531x_dpll_xo_prio_update() both keep
the old pin->prio.

If the table is then rewritten outside the driver, the PRIO attribute that
userspace reads changes. The poll never sees a difference, so it never calls
dpll_pin_change_ntf().

Should prio_get and the snapshot apply the same manual_input check?

[ ... ]

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

  reply	other threads:[~2026-12-03  0:39 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 23:52 [PATCH net-next v17 00/13] dpll: add SiTime SiT9531x DPLL clock driver Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 01/13] dpll: omit pin phase attributes the driver has no value for Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 02/13] dt-bindings: vendor-prefixes: add SiTime Corporation Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 03/13] dt-bindings: dpll: add SiTime SiT95316 clock generator Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 04/13] dpll: add basic SiTime SiT9531x support Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 06/13] dpll: sit9531x: register DPLL devices and pins Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 05/13] dpll: sit9531x: read DPLL types and pin properties from system firmware Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 07/13] dpll: sit9531x: implement input pin state on a DPLL Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 08/13] dpll: sit9531x: add support to get and set priority on input pins Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko [this message]
2026-12-01 23:52 ` [PATCH net-next v17 10/13] dpll: sit9531x: implement output pin state on a DPLL Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 09/13] dpll: sit9531x: add support to get and set frequency on pins Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 12/13] dpll: sit9531x: add support to get phase offset on the connected input Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 11/13] dpll: sit9531x: add support to adjust output phase Ali Rouhi
2026-12-03  0:39   ` netdev-bot+sashiko
2026-12-01 23:52 ` [PATCH net-next v17 13/13] dpll: sit9531x: model the inter-PLL sync line as a pair of pins Ali Rouhi
2026-12-03  0:39   ` 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=179625834984.3146.5434082265561517682@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