On Tue, 24 Nov 2026 00:40:52 +0000, netd…@kernel.org wrote:
> > +undo: > > + touched = parked; > > + if (armed_here && !(armed_mask & BIT(pll_idx))) > > + touched |= BIT(pll_idx); > > + ret = sit9531x_phase_flush_undo(sitdev, ctrl_back, orig, touched, > > + armed_mask);
> > [Severity: Medium] > Is it safe to mark the flush as fired here, before the falling edge of the > pulse? regs.h describes the flush as pulsing DIVO_PHASE_TRIG high then low. > The low write now happens in sit9531x_phase_flush_undo(), through > sit9531x_write_close(). > > If every attempt of that write fails, flush_ctrl_pending is set and TRIG > stays high. sit9531x_phase_flush_undo() still goes on to re-arm every > parked PLL: > > if (ctrl_back) { > rc = sit9531x_write_close(sitdev, SIT9531X_REG_GPIO_FUNC_CTRL1, > ctrl); > sitdev->flush_ctrl_pending = !!rc; > sitdev->flush_ctrl = ctrl; > } > > for (i = 0; i < SIT9531X_NUM_PLLS; i++) { > ... > ret = sit9531x_update_pll_close(sitdev, i, > SIT9531X_PLL_REG_PHFL_CTRL, en, > (armed & BIT(i)) ? en : 0); > > The deferred write of orig then runs from the poll, or at the start of the > next sit9531x_output_phase_flush() before any parking. At that point every > PLL the profile arms is armed. > > If the hardware acts on the falling edge, could this restart the dividers > of PLLs that nobody asked to flush? The target PLL's chan->flush_pending > would also already be cleared. > > Before this patch, a failed restore was completed by the next flush's > "orig | SIT9531X_DIVO_PHASE_SEL_REG" write, which runs after parking.
No. In v17 the flush is marked fired only after the falling edge is written, and a failed restore of the trigger select returns before the parked PLLs are armed again.
> > + rc = sit9531x_get_fvco(sitdev, sitdev->out[out_idx].pll_idx, &fvco); > > + if (rc) > > + return rc;
> > [Severity: Low] > Should this readback apply the same sit9531x_fvco_in_band() check that > sit9531x_output_phase_adjust_set() does? > > When the PLL is out of band, sit9531x_get_fvco() only warns. Its comment > says Fref * DIVN is then usually not the rate the PLL runs at, but it > still returns 0. > > As written, sit9531x_dev_state_fetch(), the getter, the notification path > and sit9531x_output_freq_set() all cache and report a delay converted with > that rate. They also set phase_armed from it.
Yes. In v17 sit9531x_get_fvco() refuses a product outside the band, so the readback fails and the getter leaves the attribute out.
> > + return rc; > > + sit9531x_output_phase_bytes_decode(old_bytes, &coarse, &fine); > > + beyond = !out->retime_pending && !out->phase_armed && out->phase_adj; > > + if (out->retime_pending || out->phase_armed || > > + ((coarse || fine) && !beyond)) { > > + held = out->retime_pending ? out->retime_ps : out->phase_adj;
> > [Severity: Low] > The comment above says only an advance needs re-encoding. However, > out->phase_adj holds the nearer-to-zero form from > sit9531x_output_phase_encode(): > > if (abs_ps > t_out_ps - abs_ps) > *phase_adj = -(s32)(t_out_ps - abs_ps); > > Take T_out = 10 ns and a request of +7000 ps. About 7 ns of cycles is > programmed, and phase_adj is cached as -3000 with phase_armed set. > > If the rate is then halved (T_out = 20 ns), held = -3000 is re-encoded as > an advance: abs_ps = 20000 - 3000 = 17000 ps. Leaving the cycle count > alone would have kept the 7 ns. > > Is it intended that any positive delay above half the period becomes an > advance on the next rate change? If so, could the comment be updated? The > code re-encodes delays and advances the same way.
Agreed. The v17 comment says a rate change re-encodes the delay in the form nearer to zero, so a delay above half the old period becomes an advance. The driver keeps no other record of the request.
> > + same = !memcmp(old_bytes, new_bytes, sizeof(new_bytes)) && > > + !out->phase_stale; > > + if (same && !chan->flush_pending) { > > + rc = 0; > > + goto cache; > > + }
> > [Severity: Medium] > Does this raw-byte comparison match the decoder? > sit9531x_output_phase_bytes_decode() treats register values from 0 up to > SIT9531X_OUT_PRG_DIVO_CYCLES as no delay: > > *coarse = (prg_coarse > SIT9531X_OUT_PRG_DIVO_CYCLES) ? > prg_coarse - SIT9531X_OUT_PRG_DIVO_CYCLES : 0; > > sit9531x_output_phase_bytes_build(), however, always writes coarse + 2. > > Suppose the profile left PRG_RST_DELAY at 0, which is reported as 0 ps. A > request that quantizes to zero, such as 10 ps, builds PROG2 = 2 and fails > the memcmp. > > Would this then rewrite the bytes and call sit9531x_output_phase_flush()? > That restarts the divider phase of every output on the PLL, or issues > SIT9531X_PLL_DIRECTIVE_RESTART when PHFL is off. The realized delay does > not change. > > dpll_pin_phase_adj_set() short-circuits an exact 0 ps request, because the > getter reports 0. Small non-zero requests still reach the driver. > > Would comparing the decoded coarse and fine values avoid this?
No. In v17 the skip test compares the decoded coarse and fine values, so every encoding of no delay matches and a request that rounds to zero over a zero register writes nothing.
> > + &bytes_back); > > + bytes_in = !rc; > > + if (!rc) > > + rc = sit9531x_write_u8(sitdev, SIT9531X_REG_PRG_DIR_GEN, > > + SIT9531X_SMALL_UPDATE_CMD); > > + sit9531x_outsys_debug_close(sitdev);
> > [Severity: Medium] > The small-change update goes only to page 3's copy of PRG_Directives > (SIT9531X_REG_PRG_DIR_GEN). This includes slots 6-11, whose delay bytes > are on page 4, and regs.h notes that every page has a copy at offset 0x0F. > > Does the page 3 update cover the page 4 delay registers? > > The flush also follows right after the key is closed, with no wait. The > INTSYNC paths sleep 1-2 ms after a small update. > > If the flush lands before the update latches, would the dividers restart > against the old delay? phase_adj would still be cached as the new value, > with neither phase_stale nor flush_pending set. > > This depends on hardware behaviour that the source doesn't show, so it may > be fine if Dely_program_output.py does the same.
The driver follows the reference delay sequence: the delay bytes on page 3 or 4, one small-change update at page 3 0x0F for either page, then the PLL page update and the flush, with no wait between them. The v17 comment cites the sequence. No change.
> > + if (rc) { > > + if (bytes_in) { > > + out->phase_stale = true; > > + out->retime_ps = phase_ps; > > + out->retime_pending = true;
> > [Severity: Medium] > In this branch the bytes landed but the small update failed. retime_ps now > holds the new request and retime_pending is set, while out->phase_adj > keeps the old value. > > sit9531x_dpll_output_pin_phase_adjust_get() skips the readback while > retime_pending is set, so it returns the old value. > > If userspace then asks for that old value, for example to revert, > dpll_pin_phase_adj_set() returns before calling the driver: > > if (!ret && phase_adj == old_phase_adj) > return 0; > > retime_pending and retime_ps are never cleared, so the next poll runs: > > sit9531x_dev_chan_states_update() > sit9531x_retime_retry() > sit9531x_output_phase_adjust_set(sitdev, out_idx, out->retime_ps) > > Can this program the request the user had just replaced, even though the > replacing request returned success? > > The getter comment "Bytes waiting for a re-time are for the old rate" > fits the freq_set path. Here the bytes are already for the current rate.
In v17 the getter leaves the attribute out while a delay waits for its update, and patch 1 lets the core pass a request through when the current value is absent, so a request for the old delay reaches the driver and replaces the pending one.
> > } > > > > +/* > > + * Re-time the output delay after a failed rate change. Caller must hold > > + * sitdev->multiop_lock. > > + */
> > [Severity: Low] > This isn't a bug, but this comment and the @retime_pending kernel-doc in > core.h ("re-timed delay not yet applied") only cover the failed rate > change case. > > sit9531x_output_phase_adjust_set() also sets retime_pending and retime_ps > when the small update fails after a plain delay write. In that case the > poll applies a new user request rather than re-timing an existing delay. > > Could the comments cover that case too?
Agreed. In v17 the comment and the @retime_pending kernel-doc cover both cases: a delay waiting after a rate change, and a delay whose small-change update failed.
> > + was = out->phase_adj; > > + if (!sit9531x_output_phase_adjust_set(sitdev, out_idx, out->retime_ps)) > > + dev_info(sitdev->dev, "out%u: delay re-timed\n", out_idx); > > + if (out->phase_adj != was || out->phase_stale) > > + out->ntf_pending = true;
> > [Severity: Medium] > retime_pending is only ever set together with phase_stale = true. > > sit9531x_output_phase_adjust_set() can fail before it reaches the cache > label. Examples are -ENODEV from get_fvco or divo_read, -ERANGE from the > encode, a bus error, or the bytes_in branch, which sets phase_stale again. > In each case phase_stale stays true, so this condition is always true. > > sit9531x_dpll_output_ntf_pending() skips the re-read while retime_pending > is set, clears ntf_pending and returns true. sit9531x_dpll_changes_check() > then calls dpll_pin_change_ntf(). > > Does this send a pin-change notification on every poll for as long as the > retry keeps failing, even though nothing on the pin changed?
Yes. In v17 the retry asks for a notification only when retime_pending clears and the getter has a value again.
> > @@ -2977,6 +3666,32 @@ static void sit9531x_dev_stop(struct sit9531x_dev *sitdev) > > } else if (sitdev->outsys_key_pending) { > > sit9531x_outsys_debug_close(sitdev); > > } > > + for (i = 0; i < sitdev->info->num_outputs; i++) { > > + sit9531x_retime_retry(sitdev, i);
> > [Severity: Low] > The last retry of the output-system debug key close runs before this > loop. > > Each sit9531x_retime_retry() can call sit9531x_output_phase_adjust_set(). > That opens the key again with sit9531x_outsys_debug_open() and closes it > with sit9531x_outsys_debug_close(). > > If that close fails, only outsys_key_pending is set. Nothing later in > sit9531x_dev_stop() closes the key again. > > Can the device be left at removal with the output-system debug registers > unlocked? The same ordering seems to carry over to > sit9531x_dev_pending_retry() later in the series, which the probe failure > path also uses.
Agreed. In v17 removal closes the output-system debug key after the re-time loop, and the poll does the same.
> > + * A profile delay on a slow output can exceed the s32 attribute; leave > > + * it out. > > + */ > > + if (phase_adj > S32_MAX) > > + return -ENODATA; > > + *phase_adjust = phase_adj;
> > [Severity: Medium] > sit9531x_pin_props_get() advertises a phase_range of > +/-SIT9531X_OUT_PHASE_ADJ_MAX_PS (1e9 ps), but this check only drops > values above S32_MAX. > > sit9531x_output_phase_read() flags a decode above 1e9 ps in *beyond but > still returns it. Take a profile delay between 1 ms and about 2.147 ms on > a slow output, such as 1.5 ms on a 1 PPS output. It would be reported > above the DPLL_A_PIN_PHASE_ADJUST_MAX sent in the same message. > > Writing that value back then fails in dpll_pin_phase_adj_set(): > > if (phase_adj > pin->prop.phase_range.max || > phase_adj < pin->prop.phase_range.min) { > > Should the getter filter on the advertised range, or on the beyond flag, > instead of S32_MAX?
The advertised range bounds a request. A delay the loaded configuration set is reported as the registers hold it, and left out only when it does not fit in s32; clamping it would report a delay the output does not have. No change.
> > + bool beyond; > > + s64 phase_ps; > > + > > + if (sit9531x_output_phase_read(sitdev, pin->id, &phase_ps, > > + &beyond)) > > + return false;
> > [Severity: Low] > On any sit9531x_output_phase_read() error, this returns false before > out->ntf_pending is cleared. > > phase_read returns -ENODATA when the output is not routed, or when > sit9531x_get_fvco() returns -ENODATA. Both can last indefinitely: a state > refresh can clear routed, and an outside reconfiguration can change DIVN. > In that state phase_stale is never cleared. > > Would a pending pin-change notification for this output then never be > sent, even one for an unrelated state change? Elsewhere the patch treats > -ENODATA as an absent value.
Agreed. In v17 -ENODATA counts as a result with no delay value: the record is cleared and the pin is notified. Only a bus error defers the notification.
> > + /* > > + * The 30 ps fine step is not advertised; requests are rounded > > + * to the nearest achievable delay. > > + */ > > + props->dpll_props.phase_gran = 1;
> > [Severity: Low] > Is 1 ps the right value for DPLL_A_PIN_PHASE_ADJUST_GRAN? > > The hardware grid is whole VCO cycles plus 30 ps steps, folded modulo the > output period. sit9531x_output_phase_encode() rounds every request to that > grid, so a request the core accepts as a multiple of 1 ps reads back as a > different value. > > dpll.rst describes the attribute as the granularity the pin handles, and > zl3073x advertises its real step (half the synth period). The grid here > is not uniform, so there may be no single exact value. Userspace could > still assume 1 ps resolution from this.
The delay grid is whole VCO cycles of the output's PLL plus 30 ps steps, so no single step fits every PLL. The driver programs the nearest grid point and the getter reports the value set, as the comment says. No change.