Netdev List
 help / color / mirror / Atom feed
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 06/13] dpll: sit9531x: register DPLL devices and pins
Date: Thu, 19 Nov 2026 21:20:17 +0000	[thread overview]
Message-ID: <20261119212014.13180-4-arouhi@sitime.com> (raw)
In-Reply-To: <20261117021814.2220156-1-kuba@kernel.org>

On Mon, 16 Nov 2026 18:18:14 -0800, Jakub Kicinski wrote:

> > +
> > +	rc = sit9531x_prio_table_read(sitdev, pll_idx, srcs);
> > +	if (rc)
> > +		return rc;
> > +
> > +	sit9531x_prio_mask_build(sitdev, pll_idx, srcs);
>
> [Severity: Low]
> This runs once per PLL on every 500 ms tick. That means each of the three
> global page 0 status registers (SIT9531X_REG_OUTER_LOL_STATUS,
> SIT9531X_REG_PLL_INNER_LOL_STATUS and SIT9531X_REG_HO_FREEZE_STATUS) is
> read four times per tick, when one read would cover all PLLs. Could they
> be read once in sit9531x_dev_chan_states_update() and passed down?
>
> The 11-slot priority table is also re-read for every PLL on every tick.
> At this point in the series the only thing built from it is prio_mask,
> and nothing consumes prio_mask yet.
>
> Add the input reads, the eight notification writes and the page selects,
> and the poll issues roughly 100 I2C transactions per tick, even with no
> DPLL listener. The commit message says the poll keeps a netlink call from
> turning into "a burst of I2C transfers", but it does not mention this
> ongoing load. The redundant per-PLL reads of the global registers are
> still there at the end of the series.

Correct, nine of the transfers are redundant, out of about a hundred a
tick. Each PLL reads its own status because the per-PLL fetch also runs
alone after a priority table write; sharing the three bytes would need a
second path for that case, and nine transfers every 500 ms do not
justify it. No change. The table is read every tick on purpose: that is
how a reloaded configuration is noticed. The commit message now states
the bus load of a tick.

> > +	 * Clear the W1C notification latches on pages 0 and 6 after acting on
> > +	 * them; while set they keep INTRB asserted.
> > +	 */
> > +	mutex_lock(&sitdev->multiop_lock);
> > +	rc = sit9531x_clear_notifications(sitdev);
> > +	mutex_unlock(&sitdev->multiop_lock);
>
> [Severity: Medium]
> Are any of these latches read before they are cleared?
>
> sit9531x_clear_notifications() writes 0xFF to the sticky outer LOL,
> holdover freeze, inner LOL and clock monitor notification registers on
> pages 0 and 6. The lock and holdover state, though, comes only from the
> live status bits that sit9531x_chan_state_fetch() reads.
>
> So a loss of lock or a holdover entry that recovers before the next
> status read is acknowledged in hardware here and never reported through
> dpll_device_change_ntf(). The same goes for an event that latches between
> sit9531x_dev_chan_states_update() and this clear.
>
> The interrupt path has the same problem, because sit9531x_irq_thread_fn()
> clears the latches before it queues the poll:
>
> sit9531x_irq_thread_fn()
>     sit9531x_clear_notifications()     <- latch that raised INTRB erased
>     kthread_mod_delayed_work(..., 0)
> sit9531x_dev_periodic_work()
>     sit9531x_chan_state_fetch()        <- sees only the recovered live bits
>
> Could the notification registers be read and folded into the reported
> state before they are acknowledged? At the end of the series these NOTIF
> registers are still only written, never read. EEPROM_NOTIF is the only
> notification register the driver reads.

The driver reports the state it samples every 500 ms, as the other DPLL
drivers do, and clears the latches only so that INTRB is released. A
loss of lock shorter than one poll period is therefore not reported.
Folding the latches into the reported state would need a rule for what
to notify when the live state is already back, and I prefer to add that
as a follow-up. The commit message now says that a transition inside one
poll period is not reported.

> > +		dev_err(sitdev->dev,
> > +			"IRQ %d disabled: notifications cannot be cleared, polling only\n",
> > +			irq);
> > +		disable_irq_nosync(irq);
> > +		return IRQ_NONE;
> > +	}
>
> [Severity: Medium]
> Can a brief I2C glitch disable this interrupt for the life of the
> binding?
>
> On failure the handler returns IRQ_NONE without queueing the early poll.
> With IRQF_ONESHOT and a level-triggered INTRB that stays asserted, the
> line fires again as soon as the thread returns. The eight attempts
> allowed by SIT9531X_IRQ_ACK_TRIES therefore happen back to back.
>
> After that, disable_irq_nosync() is called and nothing re-enables the
> line. irq_ack_fails is reset only by a successful acknowledge in this
> handler, which can no longer run. That stays true even after the poll
> later clears the same latches successfully.
>
> Suspend/resume does not recover it either: the disable_irq() and
> enable_irq() pair there leaves the extra disable depth from
> disable_irq_nosync() in place. The handler is unchanged at the end of the
> series.

Correct, and intended: after the failed acknowledgements the line stays
disabled and the driver runs on its poll, which reports the same state
at most 500 ms later. The interrupt only brings a tick forward, so a
path to re-enable it is not worth the code. No change.

> > +
> > +	sitdev->irq_ack_fails = 0;
> > +
> > +	kthread_mod_delayed_work(sitdev->kworker, &sitdev->work, 0);
> > +	return IRQ_HANDLED;
> > +}
>
> [Severity: Medium]
> Is returning IRQ_HANDLED here correct when nothing confirms that INTRB
> actually deasserted?
>
> The driver does not program the INTRB mask registers, so the EEPROM/GUI
> profile decides which latches can drive INTRB. Meanwhile
> sit9531x_clear_notifications() clears only a fixed set of eight
> registers. One example of a latch outside that set is the sticky EEPROM
> NOTIFY_4 register (page 0 0x97): sit9531x_eeprom_state_report() reads it
> at probe and deliberately leaves it set.
>
> If the profile routes such a latch to INTRB, a level-triggered line with
> IRQF_ONESHOT would re-fire immediately and indefinitely. Every pass
> returns IRQ_HANDLED, so the spurious IRQ detector never trips. Every pass
> also calls kthread_mod_delayed_work(..., 0), so the full poll would run
> continuously. On an edge-triggered line the interrupt would never fire
> again.
>
> This depends on the profile, so it may not be reachable with current
> configurations. The handler is unchanged at the end of the series.

Correct for a configuration that routes to INTRB a latch outside the
registers the handler clears, such as NOTIFY_4. A guard against it is
postponed to a follow-up.

> > +	sitdev->clock_id = SIT9531X_OUI << 24 | (u64)adap << 8 |
> > +			   sitdev->client->addr;
>
> [Severity: Low]
> Is i2c_adapter_id() stable enough to build the clock_id from?
>
> Adapter numbers are assigned dynamically unless the DT provides an i2cN
> alias. The clock_id that userspace uses to identify the DPLL devices and
> pins could therefore change across boots, or when adapters probe in a
> different order.
>
> The value is also laid out as an EUI-64 under the SiTime OUI, which
> implies global uniqueness. In practice every board with the part at the
> same bus number and address gets the same ID. This is unchanged at the
> end of the series.

Correct that the bus number and address identify the part only within
its system. That is the scope in which the core matches a clock_id, and
an i2c alias keeps them the same across boots, as the commit message
says. No change.

> > +	 */
> > +	sitdev->reset_gpio = devm_gpiod_get_optional(sitdev->dev, "reset",
> > +						     GPIOD_ASIS);
> > +	if (IS_ERR(sitdev->reset_gpio))
> > +		return dev_err_probe(sitdev->dev, PTR_ERR(sitdev->reset_gpio),
> > +				     "Failed to request reset gpio\n");
>
> [Severity: Medium]
> This reworks the probe ordering added by the earlier commit "dpll: add
> basic SiTime SiT9531x support". There, the reset GPIO was requested with
> GPIOD_OUT_LOW after the XO was enabled. Here it is requested GPIOD_ASIS
> before devm_clk_get_optional_enabled(), and released later with
> gpiod_direction_output().
>
> The new comment presents this as a fix for a probe deferral that gates
> the XO of a running part. Should the fix go into the earlier commit
> instead? As things stand, that commit still has the behaviour the comment
> describes, which matters for bisection.
>
> The commit message also leaves out several other additions in this
> patch:
>
>   - the system sleep PM ops, sit9531x_suspend() and sit9531x_resume(),
>     which disable the IRQ, cancel the poll and drop the page cache
>   - the EEPROM profile ID and CRC readout in
>     sit9531x_eeprom_state_report()
>   - the 0xFF writes to eight write-1-to-clear notification registers in
>     sit9531x_clear_notifications(), on every poll tick and every INTRB
>
> Could these be described in the commit message, or split out?

Agreed on both. The reset line is requested before the XO in the patch
that adds the probe, so no patch of the series has the order the comment
warns about, and the message of this patch will list the PM ops, the
EEPROM report and the notification clears.

> > +
> > +	/* Every rate the driver derives starts from the XO feeding XIN. */
> > +	xtal_clk = devm_clk_get_optional_enabled(sitdev->dev, "xtal");
> > +	if (IS_ERR(xtal_clk))
> > +		return dev_err_probe(sitdev->dev, PTR_ERR(xtal_clk),
> > +				     "Failed to get xtal clock\n");
>
> [Severity: Medium]
> Can the XO still be gated when probe fails later on?
>
> The reset GPIO request moved ahead of this call so that a deferral would
> not gate the XO of a running part. But this patch adds many failure
> points after the XO is enabled: sit9531x_derive_clock_id(),
> devm_mutex_init(), sit9531x_devm_dpll_init() (kthread creation, the I2C
> reads in sit9531x_dev_state_fetch(), DPLL device and pin registration),
> and devm_request_threaded_irq().
>
> If any of those fails, devres unwinds and calls clk_disable_unprepare()
> on the XO:
>
> sit9531x_dev_probe()
>     devm_clk_get_optional_enabled()     <- XO enabled
>     sit9531x_devm_dpll_init()
>         sit9531x_dev_start()
>             sit9531x_dev_state_fetch()  <- I2C error
>     return rc                           <- devres disables the XO
>
> The part is deliberately never reset, so it keeps running its PLLs and
> outputs from the loaded profile, now without its reference. Driver unbind
> takes the same path.

This is the behavior the cover letter states under "Clocks and
supplies": the driver holds a reference while bound and returns it on
unbind or a failed probe, and an XO that must run without a driver bound
is CLK_IS_CRITICAL at its provider, as for any part configured before
Linux runs. The request order only avoids taking and dropping the
reference on the common deferral.

> > +	if (sitdev->irq > 0)
> > +		enable_irq(sitdev->irq);
> > +	kthread_queue_delayed_work(sitdev->kworker, &sitdev->work, 0);
> > +
> > +	return 0;
> > +}
>
> [Severity: Medium]
> The comment allows for the part losing power over suspend. In that case,
> is dropping the page cache enough?
>
> After releasing reset, probe waits fsleep(10000) for the internal boot.
> Resume has no such wait: it re-enables INTRB and queues an I2C poll right
> away.
>
> Resume also does not re-read the static configuration that
> sit9531x_dev_state_fetch() cached at probe: ref[].sig_mode, out[].cmos,
> out[].routed and out[].pll_idx, chan[].manual_input and ref[].pll_mask.
>
> Suppose the configuration was pushed over I2C before probe (a case
> sit9531x_eeprom_state_report() detects and logs) and power is lost. The
> part then comes back with a different configuration. The driver would
> keep reporting the old mode and routing, and sit9531x_input_get_regs()
> would pick the DE or SE force/state registers based on a stale sig_mode.
>
> At the end of the series, resume re-reads phase, INTSYNC and output mute
> state, but still not these fields, and there is still no boot delay.

Correct for a part that loses power over suspend: it then needs the boot
delay, and if it comes back with another configuration the pins
registered at probe describe the old one, which re-reading a few fields
would not make right. Power loss over suspend will be handled together
with the regulators, in the follow-up for the supplies. The resume
comment now says that the configuration read at probe is not read again.

> > +				       enum dpll_pin_state *state,
> > +				       struct netlink_ext_ack *extack)
> > +{
> > +	*state = DPLL_PIN_STATE_CONNECTED;
> > +	return 0;
> > +}
>
> [Severity: Medium]
> Should this report CONNECTED unconditionally?
>
> include/uapi/linux/dpll.h defines DPLL_PIN_STATE_CONNECTED as "pin
> connected, active input of phase locked loop".
> Documentation/driver-api/dpll.rst allows CONNECTED in automatic mode only
> for pins with DPLL_PIN_CAPABILITIES_STATE_CONNECTED_OVERRIDE.
>
> sit9531x_pin_props_get() sets the XO capabilities to 0, and
> sit9531x_dpll_mode_get() reports DPLL_MODE_AUTOMATIC for any PLL without
> manual_input. The driver also already reads the PLL's active source from
> CLK_ACTIVESEL into chan->selected_ref. The OCXO code there maps to
> SIT9531X_MAX_INPUTS, and the OCXO can appear in the priority table.
>
> The result is that userspace sees the XO as the active input even while
> the PLL is locked to an external reference. This is still the case at
> the end of the series. There, sit9531x_dpll_selection_state_get() also
> reports the routed input as CONNECTED on a manual-input PLL, so that PLL
> shows two CONNECTED inputs at once. On an automatic PLL, the XO shows
> CONNECTED while the other listed inputs show SELECTABLE.
>
> Could this state be derived from chan->selected_ref instead?

The XO is the reference of the inner loop of every PLL and is in use
while the outer loop tracks an input, so the XO pin is CONNECTED next to
that input, with no capabilities and no state setter. CONNECTED is the
state the uAPI has for an input in use that the user cannot change; the
pin-state contract in dpll.c and the cover letter state it.

  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 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 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 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 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 [this message]
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 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 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 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 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 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 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
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-4-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