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 v17 13/13] dpll: sit9531x: model the inter-PLL sync line as a pair of pins
Date: Wed, 02 Dec 2026 23:53:00 +0000 [thread overview]
Message-ID: <sashiko-outbox-246779@kernel.org> (raw)
In-Reply-To: <20261201235202.97645-14-arouhi@sitime.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] dpll: sit9531x: stale routing and error test in
sit9531x_retime_kept()
- [Medium] dpll: sit9531x: per-PLL drop of flush_arm_pending in
sit9531x_resume()
- [Medium] dpll: sit9531x: premature pin notification on read failure in
sit9531x_resume()
- [Low] dpll: sit9531x: masked INTSYNC selection state on source PLL
--
commit da914769c051305f662b4b8daf460009252cad07
Author: Oleg Zadorozhnyi <Oleg.Zadorozhnyi@devoxsoftware.com>
dpll: sit9531x: model the inter-PLL sync line as a pair of pins
This commit models the inter-PLL synchronization line (INTSYNC) as a
source pin and a destination pin on each DPLL, and updates the resume
path to re-read INTSYNC ownership, output delays, and pending state.
> diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c
> index 1f4ed3365ffe1..9761f11a3ec30 100644
> --- a/drivers/dpll/sit9531x/core.c
> +++ b/drivers/dpll/sit9531x/core.c
[ ... ]
> @@ -4891,6 +5521,41 @@ static const struct of_device_id sit9531x_of_match[] = {
> };
> MODULE_DEVICE_TABLE(of, sit9531x_of_match);
>
> +/*
> + * Compare the delay bytes of an output with its pending re-time, decoded as the
> + * delay setter does: 1 if they hold the request, 0 if not or if the request has
> + * no encoding for the divider, <0 if a read failed. Caller must hold
> + * sitdev->multiop_lock.
> + */
> +static int sit9531x_retime_kept(struct sit9531x_dev *sitdev, u8 out_idx)
> +{
> + struct sit9531x_out *out = &sitdev->out[out_idx];
> + u8 bytes[SIT9531X_OUT_PRG_BYTES], fine, old_fine;
> + u64 fvco, divo, coarse, old_coarse;
> + s32 phase_adj;
> + int rc;
> +
> + if (!out->routed)
> + return 0;
> +
> + rc = sit9531x_get_fvco(sitdev, out->pll_idx, &fvco);
> + if (!rc)
> + rc = sit9531x_output_divo_read(sitdev, out_idx, &divo);
> + if (rc)
> + return rc == -ENODATA ? 0 : rc;
> +
> + if (sit9531x_output_phase_encode(fvco, divo, out->retime_ps, &coarse,
> + &fine, &phase_adj))
> + return 0;
> +
> + rc = sit9531x_output_phase_bytes_read(sitdev, out_idx, bytes);
> + if (rc)
> + return rc;
> + sit9531x_output_phase_bytes_decode(bytes, &old_coarse, &old_fine);
> +
> + return old_coarse == coarse && old_fine == fine;
> +}
> +
> /*
> * Stop the poll and the IRQ across suspend so no paged I2C sequence reaches a
> * suspended adapter; the poll worker is not freezable.
> @@ -4908,9 +5573,12 @@ static int sit9531x_suspend(struct device *dev)
>
> static int sit9531x_resume(struct device *dev)
> {
> + u16 outs_was = 0, outs_now = 0, outs_unread = 0, outs_moved = 0;
> struct sit9531x_dev *sitdev = dev_get_drvdata(dev);
> struct sit9531x_dpll *sitdpll;
> - u8 modes_moved = 0;
> + u8 modes_moved = 0, kept = 0;
> + bool src_moved;
> + s8 owner;
> int rc;
> u8 i;
>
> @@ -4924,6 +5592,81 @@ static int sit9531x_resume(struct device *dev)
> mutex_lock(&sitdev->multiop_lock);
> /* One re-select for a source lost and restored between samples */
> sit9531x_reselect_arm(sitdev);
> + /*
> + * Drop and report the pending writes to registers a reloaded profile
> + * sets. Keep a delay re-time whose bytes still hold the request, and
> + * the undo of a state the driver set: loops or a debug key left open,
> + * debug taps left selected, a table write-back under forced holdover.
> + */
> + for (i = 0; i < SIT9531X_NUM_PLLS; i++) {
> + struct sit9531x_chan *chan = &sitdev->chan[i];
> + bool retime = false, flush, arm;
> + u8 j, ho;
> +
> + /*
> + * A table write-back is pending only under forced holdover;
> + * once that is cleared, the next poll reads the table from the
> + * registers.
> + */
> + if ((chan->table_pending || chan->ho_release_pending) &&
> + !sit9531x_read_pll_u8(sitdev, i, SIT9531X_PLL_REG_HO_CTRL,
> + &ho) &&
> + !(ho & BIT(SIT9531X_PLL_HO_FORCE_BIT))) {
> + dev_warn(sitdev->dev,
> + "PLL%c: forced holdover cleared over suspend, priority table restore dropped\n",
> + 'A' + i);
> + chan->table_pending = false;
> + chan->ho_release_pending = false;
> + }
> +
> + for (j = 0; j < sitdev->info->num_outputs; j++) {
> + if (!sitdev->out[j].retime_pending ||
> + sitdev->out[j].pll_idx != i)
> + continue;
> + if (sit9531x_retime_kept(sitdev, j)) {
> + kept |= BIT(i);
> + continue;
> + }
> + sitdev->out[j].retime_pending = false;
> + retime = true;
> + }
[Severity: Medium]
Can sit9531x_retime_kept() leave out->retime_pending permanently stuck at
true on resume?
sit9531x_retime_kept() runs here before sit9531x_out_state_fetch()
refreshes out->routed and out->pll_idx further down in sit9531x_resume(),
and testing its return value with if (sit9531x_retime_kept(sitdev, j))
also treats a negative I2C error return as kept. If the output became
unrouted over suspend (or a read fails here and sit9531x_out_state_fetch()
then finds it unrouted), the resume delay readback skips the output
because out->retime_pending is still set, and every later poll in
sit9531x_retime_retry() -> sit9531x_output_phase_adjust_set() returns
-ENODEV without clearing out->retime_pending.
> + /*
> + * A re-time left pending ends in a flush, which first restores
> + * the trigger select and the flush enable: keep them pending.
> + */
> + flush = !(kept & BIT(i)) && chan->flush_pending;
> + arm = !(kept & BIT(i)) && (sitdev->flush_arm_pending & BIT(i));
> + if (!retime && !flush && !arm)
> + continue;
> + dev_warn(sitdev->dev,
> + "PLL%c: pending before suspend, dropped:%s%s%s\n",
> + 'A' + i, retime ? " output delay" : "",
> + flush ? " output realignment" : "",
> + arm ? " on-demand flush enable" : "");
> + if (kept & BIT(i))
> + continue;
> + chan->flush_pending = false;
> + sitdev->flush_arm_pending &= ~BIT(i);
> + }
> + if (sitdev->flush_ctrl_pending && !kept) {
> + dev_warn(sitdev->dev,
> + "flush trigger source select pending before suspend, dropped\n");
> + sitdev->flush_ctrl_pending = false;
> + }
[Severity: Medium]
As reported by Jakub Kicinski on v15 [1], does clearing
sitdev->flush_arm_pending per PLL when !(kept & BIT(i)) lose the undo of
sibling PLLs parked by an earlier phase flush?
sit9531x_output_phase_flush() parks every armed sibling PLL by clearing
SIT9531X_PLL_PHFL_ON_DEMAND_EN and records any failed restore in
sitdev->flush_arm_pending. If one PLL has a kept re-time while another
PLL without a kept re-time has its bit set in sitdev->flush_arm_pending,
clearing that bit in the per-PLL loop prevents
sit9531x_phase_flush_undo_retry() from restoring it before the kept
re-time's flush reads SIT9531X_PLL_REG_PHFL_CTRL across all four PLLs,
and when kept == 0 on a part that kept power across suspend, dropping
flush_arm_pending and flush_ctrl_pending abandons the undo of the
driver's temporary register values.
[ ... ]
> @@ -4982,14 +5729,62 @@ static int sit9531x_resume(struct device *dev)
> "out%u: state not read on resume: %d\n",
> i, rc);
> out->state_stale = true;
> + outs_unread |= BIT(i);
> }
> - if (out->routed != routed || out->pll_idx != pll_idx)
> + if (out->routed != routed || out->pll_idx != pll_idx) {
> dev_warn(sitdev->dev,
> "out%u: routing changed over suspend; its pin stays on the DPLL it was registered on\n",
> i);
> + outs_moved |= BIT(i);
> + }
> + if (out->enabled)
> + outs_now |= BIT(i);
> }
> + for (i = 0; i < sitdev->info->num_outputs; i++) {
> + struct sit9531x_out *out = &sitdev->out[i];
> + bool beyond, none;
> + s64 phase_ps;
> +
> + /* Bytes of a pending re-time are not a delay the part runs */
> + if (out->retime_pending)
> + continue;
> +
> + rc = sit9531x_output_phase_read(sitdev, i, &phase_ps,
> + &beyond);
> + /* Unrouted or with no valid Fvco, no delay, as at probe */
> + none = rc == -ENODATA;
> + if (none) {
> + phase_ps = 0;
> + beyond = false;
> + rc = 0;
> + }
> + if (rc) {
> + dev_warn(sitdev->dev,
> + "out%u: delay not read on resume: %d\n",
> + i, rc);
> + out->phase_stale = true;
> + outs_unread |= BIT(i);
> + continue;
> + }
> + if (out->phase_adj != phase_ps || out->phase_stale ||
> + out->phase_none != none)
> + outs_moved |= BIT(i);
> + out->phase_none = none;
> + out->phase_adj = phase_ps;
> + out->phase_armed = !beyond && phase_ps;
> + out->phase_stale = false;
> + }
> + rc = sit9531x_intsync_readback(sitdev);
> + if (rc)
> + dev_warn(sitdev->dev,
> + "INTSYNC source not re-detected on resume: %d\n", rc);
> + sitdev->intsync_stale = rc != 0;
> + src_moved = rc || owner != sit9531x_intsync_owner(sitdev);
> mutex_unlock(&sitdev->multiop_lock);
>
> + sit9531x_drive_pins_ntf(sitdev,
> + (outs_was ^ outs_now) | outs_unread |
> + outs_moved, src_moved);
[Severity: Medium]
When sit9531x_output_phase_read() or sit9531x_intsync_readback() fails on
resume, does calling sit9531x_drive_pins_ntf() right away lose the retry
notification or send stale state?
sit9531x_drive_pins_ntf() only sets out->ntf_pending or
sitdev->intsync_ntf_pending when dpll_pin_change_ntf() returns an error.
However, when out->phase_stale is true and the read fails again inside
dpll_pin_change_ntf(), sit9531x_dpll_output_pin_phase_adjust_get() returns
-ENODATA, which dpll_msg_add_pin_phase_adjust() treats as 0;
dpll_pin_change_ntf() then succeeds without setting out->ntf_pending, so
sit9531x_dpll_output_ntf_pending() never retries or notifies once the bus
recovers. Similarly, sit9531x_dpll_intsync_src_state_on_dpll_get()
ignores errors from sit9531x_intsync_refresh() and returns 0, so a failed
readback on resume immediately notifies the stale pre-suspend owner (or
serializes conflicting owners across the four DPLLs if the refresh recovers
mid-walk).
> diff --git a/drivers/dpll/sit9531x/dpll.c b/drivers/dpll/sit9531x/dpll.c
> index 3fe65e2d5aecc..096749b39f1e1 100644
> --- a/drivers/dpll/sit9531x/dpll.c
> +++ b/drivers/dpll/sit9531x/dpll.c
[ ... ]
> +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;
> +
> + mutex_lock(&sitdev->multiop_lock);
> + sit9531x_intsync_refresh(sitdev);
> + 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: Low]
As reported by Jakub Kicinski on v15 [2], does forcing the INTSYNC
destination pin to DPLL_PIN_STATE_DISCONNECTED whenever
sitdev->intsync_src == sitdpll->id (here and in
sit9531x_dpll_pin_snapshot()) hide that the PLL still selects INTSYNC?
When a PLL has a partial or unenabled INTSYNC pattern on its EXT page
(sitdev->intsync_partial is true) and also lists INTSYNC in its priority
table or manual selection, both its source pin and its destination pin
report DPLL_PIN_STATE_DISCONNECTED, yet connecting the source pin on that
PLL 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").
[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/20261201235202.97645-1-arouhi@sitime.com?part=13
prev parent reply other threads:[~2026-12-02 23:53 UTC|newest]
Thread overview: 18+ 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 02/13] dt-bindings: vendor-prefixes: add SiTime Corporation 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 03/13] dt-bindings: dpll: add SiTime SiT95316 clock generator Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 04/13] dpll: add basic SiTime SiT9531x support Ali Rouhi
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-01 23:52 ` [PATCH net-next v17 06/13] dpll: sit9531x: register DPLL devices and pins Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 07/13] dpll: sit9531x: implement input pin state on a DPLL Ali Rouhi
2026-12-02 23:52 ` sashiko-bot
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-02 23:52 ` sashiko-bot
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-01 23:52 ` [PATCH net-next v17 10/13] dpll: sit9531x: implement output pin state on a DPLL Ali Rouhi
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-01 23:52 ` [PATCH net-next v17 11/13] dpll: sit9531x: add support to adjust output phase Ali Rouhi
2026-12-02 23:52 ` sashiko-bot
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-02 23:53 ` 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-246779@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.