Re: [PATCH net-next v16 09/13] dpll: sit9531x: add support to get and set frequency on pins

From: netdev-bot+sashiko

Date: Mon Nov 23 2026 - 19:42:05 EST


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

Critical: 0 · High: 0 · Medium: 5 · Low: 1

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] The output frequency getter reports Fvco/DIVO even when the
driver itself says that Fvco is not the PLL's real rate.
- [Medium] The loops_open retry sends the loop-lock command with the Page
3 debug key locked.
- [Medium] The reported output frequency can fall outside the frequency
range the pin advertises.
- [Medium] In sit9531x_output_phase_flush(), the register-triggered phase
flush is documented in regs.h as 'DIVO_PHASE_SEL_REG selects the…
- [Medium] dpll: sit9531x: unretried NVM update in sit9531x_prg_commit()
on error
- [Low] The patch deletes the inline comments on struct sit9531x_dev's
two mutexes ('/* Serializes multi-step register sequences */' above…

--

dpll: sit9531x: add support to get and set frequency on pins

This patch reports an input pin's frequency from the firmware description
and an output pin's frequency as Fvco / DIVO. It sets an output's
frequency by writing a new DIVO inside the programming state. The write
is followed by a loop lock, a settling delay and a per-PLL phase flush.

> diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c
> index bbc17a514c5ce..d3f6955b3bbd0 100644
> --- a/drivers/dpll/sit9531x/core.c
> +++ b/drivers/dpll/sit9531x/core.c

[ ... ]

> @@ -1139,6 +1239,504 @@ int sit9531x_input_prio_add(struct sit9531x_dev *sitdev, u8 pll_idx,
>
> #define SIT9531X_DIVO_MAX GENMASK_ULL(33, 0)
>

[ ... ]

> + /*
> + * Outside the PLL's VCO band, Fref * DIVN is usually not the rate the
> + * PLL runs at, as for a PLL fed from another PLL.
> + */
> + if (!sit9531x_fvco_in_band(pll_idx, *fvco) &&
> + !(sitdev->fvco_band_warned & BIT(pll_idx))) {
> + sitdev->fvco_band_warned |= BIT(pll_idx);
> + dev_warn(sitdev->dev,
> + "PLL%c: Fref * DIVN = %llu Hz is outside its VCO band\n",
> + 'A' + pll_idx, *fvco);
> + }
> +
> + return 0;
> +}

[Severity: Medium]
If Fref * DIVN is above the low-band minimum but outside this PLL's own
band, sit9531x_get_fvco() warns once and still returns 0. The comment
above says such a value is usually not the rate the PLL runs at.

For that PLL, sit9531x_output_freq_get() then reports and caches
div64_u64(fvco, divo). sit9531x_output_divo_calc() rejects the same
Fvco:

if (!sit9531x_fvco_in_band(pll_idx, fvco)) {
dev_dbg(sitdev->dev,
"out%u: PLL%c Fvco %llu Hz is outside its VCO band, rate not settable\n",
...
return -EINVAL;
}

So would a cascaded PLL report a nonzero DPLL_A_PIN_FREQUENCY that the
driver itself treats as wrong?

The commit message says "An output whose divider chain does not resolve
reports 0 Hz". Should sit9531x_output_freq_get() apply the same band
check and return -ENODATA?

The later patch "dpll: sit9531x: add support to adjust output phase"
adds the comment "Fref * DIVN outside the VCO band is not the rate the
PLL runs at" in sit9531x_output_phase_adjust_set(). Even so,
sit9531x_output_freq_get() still has no band check at the end of the
series.

[ ... ]

> + orig = ctrl & ~SIT9531X_DIVO_PHASE_TRIG;
> + ctrl = orig | SIT9531X_DIVO_PHASE_SEL_REG;
> + rc = sit9531x_write_u8(sitdev, SIT9531X_REG_GPIO_FUNC_CTRL1, ctrl);
> + if (rc)
> + goto restore;
> +
> + /*
> + * No delay between set and clear; one I2C transfer is longer than the
> + * minimum pulse width.
> + */
> + rc = sit9531x_write_u8(sitdev, SIT9531X_REG_GPIO_FUNC_CTRL1,
> + ctrl | SIT9531X_DIVO_PHASE_TRIG);
> +
> +restore:
> + ret = sit9531x_write_u8(sitdev, SIT9531X_REG_GPIO_FUNC_CTRL1, orig);
> + if (ret && !rc)
> + rc = ret;

[Severity: Medium]
regs.h describes the flush as "DIVO_PHASE_SEL_REG selects the register
trigger; pulsing DIVO_PHASE_TRIG high then low flushes".

Here, the final write of orig clears DIVO_PHASE_TRIG and restores
DIVO_PHASE_SEL_REG in the same transfer. Suppose the profile had the pin
trigger selected, so SEL_REG is clear in orig. Then the register
trigger's high-to-low transition happens at the same moment the mux
switches back to the external pin.

If the flush acts on the falling edge, can the flush be missed while
sit9531x_output_freq_set() still reports success? Would it help to write
ctrl (SEL_REG set, TRIG clear) before restoring orig?

The same ordering is still there at the end of the series in
sit9531x_phase_flush_undo(), which writes the original ctrl straight
after the TRIG-high write.

[ ... ]

> + rc = sit9531x_get_fvco(sitdev, pll_idx, &fvco);
> + if (!rc)
> + rc = sit9531x_output_divo_read(sitdev, out_idx, &divo);
> + if (rc) {
> + if (rc == -ENODATA)
> + sitdev->out[out_idx].freq = 0;
> + return rc;
> + }
> +
> + *frequency = div64_u64(fvco, divo);
> + sitdev->out[out_idx].freq = *frequency;

[Severity: Medium]
Suppose the UPDATE_NVM write fails here but one of the LOOP_LOCK
attempts that follow succeeds. sitdev->loops_open then ends up false,
and nothing records that the bank update was never issued. Neither the
retry in sit9531x_dev_chan_states_update() nor the one in
sit9531x_dev_stop() will run, since both key on loops_open.

sit9531x_output_freq_set() returns the error, but the five DIVO bytes
from sit9531x_output_divo_write() stay in the registers. The back flag
that sit9531x_output_divo_write() fills in is never checked.

On that error, sit9531x_dpll_output_pin_frequency_set() calls
sit9531x_output_freq_get(). That reads the new DIVO bytes back through
sit9531x_output_divo_read() and caches Fvco / DIVO in
sitdev->out[].freq. If the result differs from the old value, the
setter then sends __dpll_pin_change_ntf().

If the divider only takes effect once UPDATE_NVM is written, user space
gets an error together with a notification for a rate the part is not
running. The cached freq follows the uncommitted register contents
rather than the hardware.

Should a failed UPDATE_NVM be tracked as pending and retried by the
poll worker? Or should sit9531x_output_freq_set() restore the old DIVO
bytes before it closes the programming state?

At the end of the series the retry path is sit9531x_prg_relock(), which
does not repeat the bank update either.

[Severity: Medium]
Can this value fall outside the range the pin advertises? For an output
without supported-frequencies-hz, sit9531x_pin_props_get() advertises:

ranges[j].min = 1;
ranges[j].max = 1000000000ULL; /* 1 GHz */

Fvco is at least SIT9531X_FVCO_LOWBAND_MIN (4.9152 GHz). A profile with
DIVO of 4 or less therefore gives a reported frequency above 1 GHz. When
there is a DT list, the truncated Fvco / DIVO also need not match any
listed value.

dpll_pin_freq_set() in the core calls dpll_pin_is_freq_supported() before
its freq == old_freq shortcut. Writing back the value just read would
then fail with "frequency is not supported by the device". Is that
intended?

The 1 GHz cap is unchanged at the end of the series.

[ ... ]

> @@ -1845,6 +2443,10 @@ sit9531x_dev_chan_states_update(struct sit9531x_dev *sitdev)
> bool answered = false;
> int i, rc;
>
> + /* Retry pending writes first so the reads below see their result */
> + if (sitdev->loops_open)
> + sit9531x_prg_commit(sitdev);
> +
> sit9531x_input_off_retry(sitdev);

[Severity: Medium]
Does this retry run with the Page 3 debug key locked?

When every LOOP_LOCK attempt fails, sit9531x_prg_commit() sets
loops_open but still relocks the key at the end:

sitdev->loops_open = !!rc2;

msleep(100);
...
rc3 = sit9531x_write_close(sitdev, SIT9531X_REG_OUTSYS_DEBUG,
SIT9531X_DEBUG_LOCK_VAL);

This retry calls sit9531x_prg_commit() directly, and so does the one in
sit9531x_dev_stop(). Neither does the unlock that sit9531x_prg_enter()
performs before every other PRG_DIR_GEN write:

rc = sit9531x_write_u8(sitdev, SIT9531X_REG_OUTSYS_DEBUG,
SIT9531X_DEBUG_UNLOCK_VAL);

If PRG_DIR_GEN commands only take effect while the key is unlocked, the
LOOP_LOCK write would be ACKed but have no effect, and loops_open would
be cleared anyway. sit9531x_dev_stop() would then skip its "output loops
left unlocked at removal" warning, and later readers of loops_open would
treat the loops as closed.

This retry also sends UPDATE_NVM again, outside the PRG_CMD sequence.

The later patch "dpll: sit9531x: implement output pin state on a DPLL"
changes the retry to sit9531x_prg_relock(), which drops the UPDATE_NVM.
It still writes LOOP_LOCK without opening the debug window, though.

[ ... ]

> diff --git a/drivers/dpll/sit9531x/core.h b/drivers/dpll/sit9531x/core.h
> index 57ba682b07a93..669f9f9b960c3 100644
> --- a/drivers/dpll/sit9531x/core.h
> +++ b/drivers/dpll/sit9531x/core.h

[ ... ]

> struct sit9531x_dev {
> struct device *dev;
> struct i2c_client *client;
> struct regmap *regmap;
> const struct sit9531x_chip_info *info;
> - /* Serializes multi-step register sequences */
> struct mutex multiop_lock;
> - /* Serializes a page select and the transfer it is for */
> struct mutex page_lock;

[Severity: Low]
This isn't a bug, but removing these two comments looks unrelated to
frequency get/set, and the commit message doesn't mention it.

The block comment above the struct is not kernel-doc, so checkpatch
--strict will report "struct mutex definition without comment" for both
locks. The comments are still missing at the end of the series.

[ ... ]

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