From: Ali Rouhi <arouhi@sitime.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "jiri@resnulli.us" <jiri@resnulli.us>,
"vadim.fedorenko@linux.dev" <vadim.fedorenko@linux.dev>,
"arkadiusz.kubalewski@intel.com" <arkadiusz.kubalewski@intel.com>,
"ivecera@redhat.com" <ivecera@redhat.com>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"robh@kernel.org" <robh@kernel.org>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"cjubran@nvidia.com" <cjubran@nvidia.com>,
"Oleg.Zadorozhnyi@devoxsoftware.com"
<Oleg.Zadorozhnyi@devoxsoftware.com>,
"prabhakar.mahadev-lad.rj@bp.renesas.com"
<prabhakar.mahadev-lad.rj@bp.renesas.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v15 13/13] dpll: sit9531x: model the inter-PLL sync line as a pair of pins
Date: Thu, 19 Nov 2026 21:20:21 +0000 [thread overview]
Message-ID: <20261119212014.13180-10-arouhi@sitime.com> (raw)
In-Reply-To: <20261117021827.2220456-1-kuba@kernel.org>
On Mon, 16 Nov 2026 18:18:27 -0800, Jakub Kicinski wrote:
> > + { 0x54, 0x02, 0x00 },
> > + { 0x55, 0x28, 0x20 },
> > + { 0x5C, 0x0F, 0x00 },
> > + { 0x5D, 0xFF, 0x00 },
> > + { 0x6C, 0xDD, 0x00 },
> > +};
>
> [Severity: Low]
> This isn't a bug, but the commit message says:
>
> Taking the line writes a pattern to the source's EXT page and sets a
> global enable; giving it up writes the disable pattern.
>
> The pattern is eight unnamed offset/value pairs. They are written after
> the EXT page debug window is unlocked with SIT9531X_PLL_DEBUG_UNLOCK. The
> comment on sit9531x_intsync_debug_lock() says that key "opens every debug
> register on the page". There are no register defines and no datasheet or
> vendor reference for these values.
>
> sit9531x_intsync_src_detect() also opens the debug window on all four EXT
> pages at probe, on resume and on every refresh.
>
> Could the commit message mention this? Could the registers get names or a
> reference?
>
> The order in the message is also the reverse of what
> sit9531x_intsync_enable() does, which sets the global enable first and
> writes the pattern second.
>
> The message also describes "an output pin on the source PLL". However,
> sit9531x_dpll_pin_is_registrable() now registers the SYNCOUT pin on every
> DPLL:
>
> if (index == SIT9531X_INTSYNC_OUT_PIN_ID)
> return true;
>
> sit9531x_drive_pins_ntf() also notes "The source pin is one pin registered
> on every DPLL".
>
> Could the description match the pin model that userspace sees?
Agreed. The table comment now names the reference sequence the values
come from, and the message now matches the code, in its order and in how
the source pin is registered.
> > + sitdev->intsync_partial = true;
> > + sitdev->intsync_foreign = false;
> > + }
> > +
> > + return 0;
> > +}
>
> [Severity: Medium]
> Does this sticky partial record make sense on the resume path?
>
> The comment in sit9531x_resume() says "A part that lost power returns
> with its profile's INTSYNC routing". It then calls
> sit9531x_intsync_readback(), not a fresh sit9531x_intsync_src_detect().
>
> If a partial record existed before suspend, the new scan result is
> overridden in two cases: the scan finds no source, or it finds the same
> PLL fully enabled. In both cases intsync_foreign is also forced to false.
>
> The kernel-doc reason, "a page reads the same latched or not", only holds
> while the driver's own unlatched writes may still be in the page. After a
> power loss and profile reload, the page holds the profile's real latched
> values.
>
> Some possible results:
>
> - The profile fully enables INTSYNC from the recorded PLL, but that PLL's
> SYNCOUT pin reports DPLL_PIN_STATE_DISCONNECTED while the line is
> driven.
>
> - The profile has no INTSYNC, but other PLLs still get "INTSYNC is already
> sourced by another PLL". The recorded PLL's destination also cannot be
> made selectable.
>
> - The profile sets the global enable with no recognized page. Detect sets
> intsync_foreign = true and readback clears it. A later CONNECTED on the
> recorded PLL then passes every check, and sit9531x_intsync_enable()
> drives the line alongside the unrecognized configuration.
>
> Would a plain detect be a better fit for resume?
Partly agreed. The driver cannot tell whether the part kept power. With
power kept, the partial record is the only trace that the latched state
may differ from what the page reads, and a plain detect would allow a
second PLL to be enabled alongside it; so the record stays, and after a
power loss one disconnect request clears it. The third case is fixed: a
scan that finds the global enable set with no page holding the pattern
is no longer overridden, so the connect is refused.
> > + goto relock_err;
> > + }
> > +
> > + rc = sit9531x_pll_small_update(sitdev, src_pll_idx);
> > + if (rc)
> > + goto relock_err;
>
> [Severity: Medium]
> Should the EXT page pattern be written and latched before the global
> enable is set?
>
> Here the global enable is set and applied with the page-0 small update
> first. The restore path in __sit9531x_intsync_disable() notes "The page-0
> small update applies the global enable". Only after that is the EXT page
> unlocked, written, and latched with sit9531x_pll_small_update().
>
> So for several milliseconds of I2C traffic the gate is live while no EXT
> page holds a latched source configuration. sit9531x_intsync_src_detect()
> treats exactly this state (global enable set, no page pattern) as foreign
> and refuses connects in it.
>
> Destination PLLs that list INTSYNC could select or lock to the line during
> that window. If a pattern write fails, the line was also live with no
> configured source until the rollback. The disable path already uses the
> safe order: gate first, then page.
>
> Unless the hardware requires the gate first, would it be safer to latch
> the page before applying the global enable? What the part does with the
> gate set and no latched pattern isn't documented in the tree.
Fixed in the next revision: the page pattern and the PLL small update
first, the global enable last, and the reverse to disable.
> > + if (lock_rc)
> > + dev_warn(sitdev->dev,
> > + "PLL%c: INTSYNC enabled but the debug window was left open: %d\n",
> > + 'A' + src_pll_idx, lock_rc);
> > +
> > + return rc;
>
> [Severity: Low]
> Can the EXT page debug window be left unlocked with nothing retrying the
> close?
>
> If sit9531x_intsync_debug_lock() still fails after the SIT9531X_CLOSE_TRIES
> retries in sit9531x_write_close(), this path only warns and still returns
> 0. The relock label in __sit9531x_intsync_disable() does the same.
>
> The caller, sit9531x_dpll_intsync_src_state_on_dpll_set(), runs
> sit9531x_intsync_src_detect() afterwards, which acts as one more close
> attempt. If that detect also fails, intsync_stale is only set when there
> is a conflict:
>
> } else if (changed && detect_rc && sitdev->intsync_conflict) {
> sitdev->intsync_stale = true;
> }
>
> So after a successful enable or disable, the poll never tries the close
> again.
>
> The main PLL page already has this covered by chan->key_pending and
> sit9531x_tap_back_retry(). That path writes sit9531x_pll_page(pll_idx),
> though, not the EXT page.
>
> Should the EXT page lock be tracked the same way?
Correct. It takes the closing write to fail on every retry and the
detect after it to fail too; the driver logs it, and the next INTSYNC
request or resume closes the window. Tracking the EXT page as the main
page is tracked is postponed to a follow-up.
> > + /* The page-0 small update applies the global enable */
> > + ret = sit9531x_write_close(sitdev,
> > + SIT9531X_REG_GLOBAL_UPDATE,
> > + SIT9531X_SMALL_UPDATE_CMD);
> > + usleep_range(1000, 2000);
> > + }
>
> [Severity: Medium]
> What state is the line in after this rollback?
>
> Suppose one of the dis_val writes fails partway. in_window is then true,
> and the page holds some disable values followed by the remaining enable
> values. sit9531x_pll_small_update() has not latched them.
>
> sit9531x_intsync_page_off() reports that the page is not off, so the code
> falls through. It then sets and applies the global enable again over that
> mixed page.
>
> Next, the caller runs sit9531x_intsync_src_detect(). It sees a page with
> both patterns and records intsync_src = pll with intsync_partial = true.
> After that, sit9531x_dpll_intsync_src_connected() reports disconnected and
> sit9531x_intsync_driven() treats the line as not driven.
>
> There are two possibilities:
>
> - If only the PLL small update latches EXT page writes, the line is still
> driven from the original latched pattern under the restored gate, while
> the driver reports it as not driven.
>
> - If the page-0 update latches them too, the gate is on over a
> half-written configuration.
>
> Would it be more consistent to rewrite the full enable pattern before
> restoring the gate, or to leave the gate off?
Fixed in the next revision: after a failed disable the page is read
back, and the global enable is restored only over a page that still
holds the whole enable pattern; over a mixed page it stays clear.
> > + }
> > + if (sitdev->flush_ctrl_pending) {
> > + dev_warn(sitdev->dev,
> > + "flush trigger source select pending before suspend, dropped\n");
> > + sitdev->flush_ctrl_pending = false;
> > + }
>
> [Severity: Medium]
> Is it intended to drop these pending writes on every resume?
>
> Nothing here checks that the part actually lost power. sit9531x_suspend()
> only stops the IRQ and the poll:
>
> if (sitdev->irq > 0)
> disable_irq(sitdev->irq);
> kthread_cancel_delayed_work_sync(&sitdev->work);
>
> The DT binding patch also says boards so far keep the part powered. In the
> usual case, then, the registers survive suspend.
>
> Before this patch, the poll retried these writes after resume through
> sit9531x_retime_retry(), sit9531x_flush_retry() and
> sit9531x_phase_flush_undo_retry(). The last of these writes the original
> GPIO_FUNC_CTRL1 trigger select and the per-PLL PHFL enables back, and it
> does nothing once the flags are clear:
>
> if (!sitdev->flush_ctrl_pending && !sitdev->flush_arm_pending)
> return 0;
>
> With the flags cleared here, a pending delay re-time or realignment is
> abandoned. So is the undo of a phase-flush trigger or enable change.
> GPIO_FUNC_CTRL1 and PHFL_CTRL can then stay at the driver's temporary
> values, and nothing retries them.
>
> The commit message only says "Resume re-reads the line owner, the output
> mutes and the output delays".
>
> This pending-write policy is unrelated to INTSYNC. Could it go in a
> separate patch with its own rationale?
Intended, and each drop is logged. The driver cannot tell a part that
kept power from one that returned with a reloaded configuration, and
running a write left pending before suspend against registers that
configuration replaced is the worse outcome; with power kept the cost is
a realignment or an undo not completed, which the log names. It stays in
this patch because the writes it drops are added by this series; the
commit message now describes it.
> > + * selection naming the lost one. On manual input select, the routed input is
> > + * CONNECTED. The INTSYNC destination has signal while the driver's record shows
> > + * a PLL driving the line. An output or the INTSYNC source is CONNECTED while
> > + * driven and DISCONNECTED otherwise; SELECTABLE is refused. The XO pin is
> > + * always CONNECTED.
> > */
>
> [Severity: Low]
> This isn't a bug, but this sentence doesn't match sit9531x_intsync_driven().
> That function also returns true when no complete source is recorded but a
> PLL is locked to the line:
>
> if (chan->routed_ref == SIT9531X_INTSYNC_PIN_ID &&
> chan->locked && !chan->ho_freeze &&
> !chan->stale && !chan->intsync_dropped)
> return true;
>
> So in the foreign or stale cases, the destination reports signal rather
> than DPLL_PIN_OPERSTATE_NO_SIGNAL.
>
> The comment on sit9531x_dpll_selection_no_signal() ("a PLL driving or
> locked to the line") does match the code. Could the contract block say
> the same?
Yes, the contract block now says the same as the code: a PLL driving the
line or a PLL locked to it.
> > + sitdev->intsync_src != sitdpll->id) {
> > + NL_SET_ERR_MSG(extack,
> > + "INTSYNC is already sourced by another PLL");
> > + rc = -EBUSY;
> > + break;
> > + }
>
> [Severity: Medium]
> Can a partial record cause refusals that userspace has no way to see?
>
> sit9531x_intsync_src_detect() records intsync_src = pll with
> intsync_partial = true when it finds a page with both patterns, or the
> whole pattern under a clear global enable. The error handling later in
> this function also sets intsync_partial = true after an I2C failure in
> enable or disable.
>
> With that record:
>
> - sit9531x_dpll_intsync_src_connected() returns false, so every SYNCOUT pin
> reports DPLL_PIN_STATE_DISCONNECTED.
>
> - CONNECTED on any other PLL's SYNCOUT still fails here with -EBUSY.
>
> - sit9531x_dpll_intsync_dst_state_on_dpll_get() and the existing
> sit9531x_dpll_pin_snapshot() force the recorded PLL's INTSYNC
> destination to disconnected. This happens even when its priority table
> lists INTSYNC and prio_get reports a slot:
>
> if (sitdev->intsync_src == sitdpll->id)
> *state = DPLL_PIN_STATE_DISCONNECTED;
>
> - sit9531x_dpll_intsync_dst_state_on_dpll_set() refuses SELECTABLE on that
> destination with "PLL cannot lock to the INTSYNC it drives", although
> its source pin says it is not driving.
>
> The only way out is a disconnect request on a SYNCOUT pin that already
> reads disconnected. Nothing tells userspace to send it.
>
> The foreign case (global enable set, no page with the pattern,
> intsync_src == -1) seems to have no way out at all. A disconnect request
> does nothing:
>
> case DPLL_PIN_STATE_DISCONNECTED:
> if (sitdev->intsync_src != sitdpll->id)
> break;
>
> A connect request is refused, and nothing clears the global enable. The
> source function then stays unusable until a profile reload or reboot.
>
> The commit message only mentions refusals for an unrecognized enable and
> for two pages. Should the partial state be reported consistently, or
> exposed some other way?
Agreed for the partial record: the two refusals now say that the PLL
holds a partial source and that a disconnect of its source pin clears
it. The foreign case is refused on purpose and stays so: that enable was
set by the loaded configuration, and the driver does not clear a routing
it did not make. The commit message will describe both.
> > + "PLL selects INTSYNC as a reference; it cannot drive it");
> > + rc = -EBUSY;
> > + break;
> > + }
> > + rc = sit9531x_intsync_enable(sitdev, sitdpll->id, &owner_kept,
> > + &changed);
>
> [Severity: Medium]
> Does this guard cover a PLL in manual input mode?
>
> sit9531x_input_prio_present() only tests chan->prio_mask, and a manual
> input PLL ignores its priority table.
>
> sit9531x_chan_select_fetch() can set manual_ref to SIT9531X_INTSYNC_PIN_ID
> when the select register holds the SIT9531X_PRIO_SRC_INTSYNC code:
>
> if (sel & SIT9531X_MAN_IN_SEL_FROM_REG) {
> sel = FIELD_GET(SIT9531X_MAN_IN_SEL_MASK, sel);
> chan->manual_ref =
> sit9531x_hw_src_input(sit9531x_prio_src_canon(sitdev,
> sel));
>
> With pin-based select, sit9531x_chan_state_fetch() can also report
> routed_ref == SIT9531X_INTSYNC_PIN_ID. In neither case does INTSYNC have
> to appear in prio_mask.
>
> sit9531x_dpll_pin_ops_get() gives a manual PLL's SYNCOUT pin the same
> sit9531x_dpll_intsync_src_pin_ops. So with no recorded source, no conflict
> and no foreign enable, a connect request passes every check.
> sit9531x_intsync_enable() then makes that PLL the line source while it is
> using the line as its reference.
>
> Automatic mode has the same gap while chan->table_pending is set. In that
> case prio_mask is built from table_back, and routed_ref can still be
> INTSYNC.
>
> Should this also check chan->routed_ref and chan->manual_ref against
> SIT9531X_INTSYNC_PIN_ID?
Fixed in the next revision: the guard also refuses a PLL that is routed
from the line or whose manual select names it.
next prev parent reply other threads:[~2026-11-19 21:20 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 20:26 [PATCH net-next v15 00/13] dpll: add SiTime SiT9531x DPLL clock driver Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 01/13] dpll: omit pin phase attributes the driver has no value for Ali Rouhi
2026-11-11 15:35 ` Ivan Vecera
2026-11-10 20:26 ` [PATCH net-next v15 02/13] dt-bindings: vendor-prefixes: add SiTime Corporation Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 04/13] dpll: add basic SiTime SiT9531x support Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 03/13] dt-bindings: dpll: add SiTime SiT95316 clock generator Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 06/13] dpll: sit9531x: register DPLL devices and pins Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 05/13] dpll: sit9531x: read DPLL types and pin properties from system firmware Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 07/13] dpll: sit9531x: implement input pin state on a DPLL Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 09/13] dpll: sit9531x: add support to get and set frequency on pins Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 08/13] dpll: sit9531x: add support to get and set priority on input pins Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 10/13] dpll: sit9531x: implement output pin state on a DPLL Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 12/13] dpll: sit9531x: add support to get phase offset on the connected input pin Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 11/13] dpll: sit9531x: add support to adjust output phase Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi
2026-11-10 20:26 ` [PATCH net-next v15 13/13] dpll: sit9531x: model the inter-PLL sync line as a pair of pins Ali Rouhi
2026-11-17 2:18 ` Jakub Kicinski
2026-11-19 21:20 ` Ali Rouhi [this message]
2026-11-17 9:27 ` [PATCH net-next v15 00/13] dpll: add SiTime SiT9531x DPLL clock driver Paolo Abeni
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=20261119212014.13180-10-arouhi@sitime.com \
--to=arouhi@sitime.com \
--cc=Oleg.Zadorozhnyi@devoxsoftware.com \
--cc=arkadiusz.kubalewski@intel.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®