Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ali Rouhi" <arouhi@sitime.com>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v16 13/13] dpll: sit9531x: model the inter-PLL sync line as a pair of pins
Date: Fri, 20 Nov 2026 22:58:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-226329@kernel.org> (raw)
In-Reply-To: <20261119225752.41846-14-arouhi@sitime.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] dpll: sit9531x: lost global disable error in
  __sit9531x_intsync_disable()
- [Medium] dpll: sit9531x: sticky intsync_partial in
  sit9531x_intsync_readback()
- [Medium] dpll: sit9531x: stale partial state on INTSYNC source set
  failure
- [Medium] dpll: sit9531x: hidden INTSYNC selection in
  sit9531x_dpll_pin_snapshot()
--

commit cfe63c19d5fe92b45accc9dad92f48789a062ff1
Author: Oleg Zadorozhnyi <Oleg.Zadorozhnyi@devoxsoftware.com>

dpll: sit9531x: model the inter-PLL sync line as a pair of pins

This commit models the internal inter-PLL sync line (INTSYNC) as a source
pin and a destination input pin on each DPLL, adding hardware detection,
enable/disable sequences, and resume state recovery.

> diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c
> index 5ec9d2a48fcbf..ca42940796d3d 100644
> --- a/drivers/dpll/sit9531x/core.c
> +++ b/drivers/dpll/sit9531x/core.c
[ ... ]
> @@ -2620,6 +2639,574 @@ static int sit9531x_clear_notifications(struct sit9531x_dev *sitdev)
>  	return 0;
>  }
>  
[ ... ]
> +int sit9531x_intsync_readback(struct sit9531x_dev *sitdev)
> +{
> +	bool partial = sitdev->intsync_partial;
> +	s8 src = sitdev->intsync_src;
> +	int rc;
> +
> +	rc = sit9531x_intsync_src_detect(sitdev);
> +	if (rc)
> +		return rc;
> +
> +	if (partial && !sitdev->intsync_foreign &&
> +	    (sitdev->intsync_src < 0 ||
> +	     (sitdev->intsync_src == src && !sitdev->intsync_partial))) {
> +		sitdev->intsync_src = src;
> +		sitdev->intsync_partial = true;
> +		sitdev->intsync_foreign = false;
> +	}
> +
> +	return 0;
> +}

[Severity: Medium]
As reported by Jakub Kicinski on v15 [1], does sit9531x_intsync_readback()
clobber the freshly scanned hardware profile on resume whenever
sitdev->intsync_partial was set before suspend?

sit9531x_resume() calls sit9531x_intsync_readback() without clearing
sitdev->intsync_partial first.  If the reloaded hardware profile has no
INTSYNC source, sit9531x_intsync_readback() restores the stale pre-suspend
partial record, blocking other PLLs from connecting INTSYNC (-EBUSY).  If
the reloaded profile has the same PLL actively driving INTSYNC, it forces
sitdev->intsync_partial back to true, causing sit9531x_intsync_owner() to
return -1 and the source pin to report DPLL_PIN_STATE_DISCONNECTED.

Also, if INTSYNC was driven before suspend with a destination PLL locked to
it and the reloaded profile disables INTSYNC, sit9531x_resume() does not set
chan->intsync_dropped, so sit9531x_intsync_driven() continues returning true
from the pre-suspend sample until the periodic poll runs.

[ ... ]
> +static int __sit9531x_intsync_disable(struct sit9531x_dev *sitdev,
> +				      u8 src_pll_idx, bool restore,
> +				      bool *owner_kept, bool *touched)
> +{
[ ... ]
> +	rc = sit9531x_write_u8(sitdev, SIT9531X_REG_INTSYNC_GLOBAL,
> +			       val & ~BIT(SIT9531X_INTSYNC_EN_BIT));
> +	if (rc)
> +		goto restore_global;
> +	/* A sample taken before this write can still show a lock. */
> +	for (i = 0; i < SIT9531X_NUM_PLLS; i++)
> +		if (sitdev->chan[i].routed_ref == SIT9531X_INTSYNC_PIN_ID)
> +			sitdev->chan[i].intsync_dropped = true;
> +
> +	rc = sit9531x_write_u8(sitdev, SIT9531X_REG_GLOBAL_UPDATE,
> +			       SIT9531X_SMALL_UPDATE_CMD);
> +	usleep_range(1000, 2000);
> +	if (rc)
> +		goto restore_global;
[ ... ]
> +restore_global:
> +	/*
> +	 * Finish the disable if the page holds the disable pattern; restore
> +	 * the global enable only if it still holds the enable pattern. Set
> +	 * over part of the pattern, the enable may drive the line, so it stays
> +	 * clear.
> +	 */
> +	if (restore) {
> +		bool off, on;
> +
> +		if (!in_window &&
> +		    sit9531x_write_u8(sitdev,
> +				      SIT9531X_REG(ext_page,
> +						   SIT9531X_PLL_REG_DEBUG),
> +				      SIT9531X_PLL_DEBUG_UNLOCK)) {
> +			if (owner_kept)
> +				*owner_kept = true;
> +			goto relock;
> +		}
> +		if (sit9531x_intsync_page_state(sitdev, ext_page, &off, &on) ||
> +		    (!off && !on)) {
> +			if (owner_kept)
> +				*owner_kept = true;
> +			goto relock;
> +		}
> +		if (off) {
> +			rc = sit9531x_pll_small_update(sitdev, src_pll_idx);
> +			if (rc && owner_kept)
> +				*owner_kept = true;
> +			goto relock;
> +		}
> +	}

[Severity: Medium]
If clearing SIT9531X_REG_INTSYNC_GLOBAL or latching
SIT9531X_REG_GLOBAL_UPDATE fails when the EXT page already holds the disable
pattern (off == true, for example after an earlier partial disable or failed
enable rollback), does the "if (off)" branch overwrite rc with 0 when
sit9531x_pll_small_update() succeeds?

__sit9531x_intsync_disable() then returns 0 even though the global enable bit
was never cleared or latched.  In
sit9531x_dpll_intsync_src_state_on_dpll_set(), rc == 0 clears
sitdev->intsync_partial before calling sit9531x_intsync_readback(); with the
global enable bit still set and no EXT page holding the enable pattern,
sit9531x_intsync_src_detect() sets sitdev->intsync_foreign = true and locks
out all future INTSYNC connects.

> diff --git a/drivers/dpll/sit9531x/dpll.c b/drivers/dpll/sit9531x/dpll.c
> index 0f2b3d446cb5f..d831bafacf107 100644
> --- a/drivers/dpll/sit9531x/dpll.c
> +++ b/drivers/dpll/sit9531x/dpll.c
[ ... ]
> @@ -652,6 +679,355 @@ sit9531x_dpll_output_pin_direction_get(const struct dpll_pin *pin,
[ ... ]
> +static int
> +sit9531x_dpll_intsync_src_state_on_dpll_set(const struct dpll_pin *pin,
> +					    void *pin_priv,
> +					    const struct dpll_device *dpll,
> +					    void *dpll_priv,
> +					    enum dpll_pin_state state,
> +					    struct netlink_ext_ack *extack)
> +{
[ ... ]
> +	/* A disconnect reads back through the partial record */
> +	if (changed)
> +		detect_rc = state == DPLL_PIN_STATE_DISCONNECTED ?
> +			    sit9531x_intsync_readback(sitdev) :
> +			    sit9531x_intsync_src_detect(sitdev);
> +	if (changed && rc) {
> +		if (owner_kept ||
> +		    (state == DPLL_PIN_STATE_CONNECTED &&
> +		     (detect_rc || sitdev->intsync_src == sitdpll->id))) {
> +			sitdev->intsync_src = sitdpll->id;
> +			sitdev->intsync_partial = true;
> +			sitdev->intsync_foreign = false;
> +		} else if (detect_rc) {
> +			sitdev->intsync_stale = true;
> +		}
> +	} else if (changed && detect_rc && sitdev->intsync_conflict) {
> +		sitdev->intsync_stale = true;
> +		sitdev->intsync_ntf_pending = true;
> +	}

[Severity: Medium]
When sit9531x_intsync_enable() or sit9531x_intsync_disable() fails, can this
error recovery leave a false partial record wedged or falsely report an
active source as disconnected?

Because setting sitdev->intsync_stale = true is in an "else if (detect_rc)"
branch, if sit9531x_intsync_enable() fails (even after a clean rollback) and
sit9531x_intsync_src_detect() also hits a transient bus error (detect_rc !=
0), the first branch sets sitdev->intsync_src = sitdpll->id and
sitdev->intsync_partial = true while leaving sitdev->intsync_stale false, so
sit9531x_intsync_refresh() never re-reads the hardware.

Conversely, on DPLL_PIN_STATE_DISCONNECTED, if the very first write to
SIT9531X_REG_INTSYNC_GLOBAL in __sit9531x_intsync_disable() fails before any
register is changed and unlocking the debug window in restore_global also
fails, *owner_kept is set to true; even when sit9531x_intsync_readback()
then succeeds and sees that the PLL is still a complete, active source,
"if (owner_kept || ...)" forces sitdev->intsync_partial = true and emits a
notification reporting the source pin as disconnected while the PLL is still
driving the line.

[ ... ]
> +static int
> +sit9531x_dpll_intsync_dst_state_on_dpll_get(const struct dpll_pin *pin,
> +					    void *pin_priv,
> +					    const struct dpll_device *dpll,
> +					    void *dpll_priv,
> +					    enum dpll_pin_state *state,
> +					    struct netlink_ext_ack *extack)
> +{
> +	struct sit9531x_dpll *sitdpll = dpll_priv;
> +	struct sit9531x_dev *sitdev = sitdpll->dev;
> +	int rc;
> +
> +	mutex_lock(&sitdev->multiop_lock);
> +	rc = sit9531x_dpll_intsync_refresh(sitdev, extack);
> +	if (rc) {
> +		mutex_unlock(&sitdev->multiop_lock);
> +		return rc;
> +	}
> +	if (sitdev->intsync_src == sitdpll->id)
> +		*state = DPLL_PIN_STATE_DISCONNECTED;
> +	else
> +		sit9531x_dpll_selection_state_get(sitdev, sitdpll,
> +						  SIT9531X_INTSYNC_PIN_ID,
> +						  state);
> +	mutex_unlock(&sitdev->multiop_lock);
> +
> +	return 0;
> +}

[Severity: Medium]
As reported by Jakub Kicinski on v15 [2], should
sit9531x_dpll_intsync_dst_state_on_dpll_get() (and
sit9531x_dpll_pin_snapshot()) force *state = DPLL_PIN_STATE_DISCONNECTED
when sitdev->intsync_src == sitdpll->id?

When sitdev->intsync_partial is true on a PLL whose priority table or manual
selection also lists INTSYNC, both the source pin and the destination pin on
that PLL report DPLL_PIN_STATE_DISCONNECTED.  Connecting the source pin on
that PLL then fails in sit9531x_dpll_intsync_src_state_on_dpll_set() via
sit9531x_dpll_intsync_selected() with -EBUSY ("PLL selects INTSYNC as a
reference; it cannot drive it"), while hiding that the destination pin is
actually selectable (or connected in manual mode).

[1] https://lore.kernel.org/r/20261117021827.2220456-1-kuba@kernel.org
[2] https://lore.kernel.org/r/20261117021827.2220456-1-kuba@kernel.org

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119225752.41846-1-arouhi@sitime.com?part=13

      reply	other threads:[~2026-11-20 22:58 UTC|newest]

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

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=sashiko-outbox-226329@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arouhi@sitime.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.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