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 v16 07/13] dpll: sit9531x: implement input pin state on a DPLL
Date: Fri, 20 Nov 2026 22:58:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-226323@kernel.org> (raw)
In-Reply-To: <20261119225752.41846-8-arouhi@sitime.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] dpll: sit9531x: sit9531x_prio_activesel_pick() latches
lower-priority source
- [Medium] dpll: sit9531x: sit9531x_prio_table_commit() releases
unforced holdover on error
- [Medium] dpll: sit9531x: sit9531x_reselect() leaves PLL stuck in
holdover
- [Medium] dpll: sit9531x: manual PLL priority table entries prevent
disabling inputs
--
commit 2d816e6713729c64ab6242d9d6911d753a230377
Author: Oleg Zadorozhnyi <Oleg.Zadorozhnyi@devoxsoftware.com>
dpll: sit9531x: implement input pin state on a DPLL
This commit implements DPLL input pin state and operstate reporting and
configuration by managing per-PLL priority tables, input receiver gating,
and holdover reference re-selection.
> diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c
> index 8a63b92fb7d62..d61c2a8e24f39 100644
> --- a/drivers/dpll/sit9531x/core.c
> +++ b/drivers/dpll/sit9531x/core.c
[ ... ]
> @@ -382,20 +487,462 @@ static u8 sit9531x_prio_slot_get(u8 val, u8 slot)
[ ... ]
> +/*
> + * Pick the active selection to latch; after a latch the PLL uses that source
> + * until it loses signal.
> + */
> +static u8 sit9531x_prio_activesel_pick(struct sit9531x_dev *sitdev,
> + const u8 *old, const u8 *srcs, u8 cur)
> +{
> + u8 top, i;
> +
> + top = sit9531x_prio_top_live(sitdev, srcs);
> + if (top != SIT9531X_PRIO_SRC_NONE &&
> + top != sit9531x_prio_top_live(sitdev, old))
> + return top;
> +
> + cur = sit9531x_prio_src_canon(sitdev, cur & SIT9531X_PRIO_NIBBLE_MASK);
> +
> + if (sit9531x_prio_src_usable(cur) &&
> + sit9531x_prio_src_live(sitdev, cur))
> + for (i = 0; i < SIT9531X_PRIO_MAX_SLOTS; i++)
> + if (srcs[i] == cur)
> + return cur;
> +
> + if (top != SIT9531X_PRIO_SRC_NONE)
> + return top;
> +
> + for (i = 0; i < SIT9531X_PRIO_MAX_SLOTS; i++)
> + if (sit9531x_prio_src_usable(srcs[i]))
> + return srcs[i];
> +
> + return srcs[0];
> +}
[Severity: Medium]
Can sit9531x_prio_activesel_pick() re-latch a lower-priority cur source
instead of top when sit9531x_reselect() runs?
sit9531x_reselect() calls sit9531x_prio_table_commit() with
srcs == chan->prio_srcs, so old and srcs point to the same array and
top != sit9531x_prio_top_live(sitdev, old) is always false (and during
sit9531x_prio_table_apply(), sit9531x_prio_top_live(sitdev, old) also
evaluates old against the newly fetched sitdev->ref[].los state rather than
chan->live_top). If the previous active-selection nibble cur names a
lower-priority source in srcs[] whose loss-of-signal bit is clear (such as
OCXO or an input with qual_fail), sit9531x_prio_activesel_pick() returns cur
without checking whether the PLL is tracking it, and
sit9531x_prio_table_commit() updates chan->live_top to top so subsequent
polls never re-select top.
In addition, cur is canonicalized with sit9531x_prio_src_canon(), whereas
chan->prio_srcs[] holds uncanonicalized hardware nibbles from
sit9531x_prio_mask_build(), so srcs[i] == cur and the fallback return of
srcs[i] do not match or canonicalize differential N-lane codes.
> +
> +static int sit9531x_prio_table_commit(struct sit9531x_dev *sitdev, u8 pll_idx,
> + const u8 *srcs)
> +{
> + u8 val, last_old, slot, attempt, written = 0, restored = 0;
> + u8 now[SIT9531X_PRIO_MAX_SLOTS], back[SIT9531X_PRIO_MAX_SLOTS];
> + struct sit9531x_chan *chan = &sitdev->chan[pll_idx];
> + int rc = 0, prg_rc, ho_rc = 0;
> + bool empty, ho_foreign, pending = false;
> + bool pending_before = chan->table_pending;
> + u16 reg;
> +
> + empty = true;
> + for (slot = 0; slot < SIT9531X_PRIO_MAX_SLOTS; slot++)
> + if (sit9531x_prio_src_usable(srcs[slot]))
> + empty = false;
> +
> + memcpy(back, chan->table_pending ? chan->table_back : chan->prio_srcs,
> + sizeof(back));
> +
> + /*
> + * Treat a forced holdover as set by this driver only when the table is
> + * empty or a release is pending; leave any other in place.
> + */
> + rc = sit9531x_read_pll_u8(sitdev, pll_idx, SIT9531X_PLL_REG_HO_CTRL,
> + &val);
> + if (rc)
> + return rc;
> +
> + ho_foreign = (val & BIT(SIT9531X_PLL_HO_FORCE_BIT)) &&
> + chan->prio_mask && !chan->ho_release_pending;
> +
> + rc = sit9531x_write_pll_u8(sitdev, pll_idx, SIT9531X_PLL_REG_HO_CTRL,
> + val | BIT(SIT9531X_PLL_HO_FORCE_BIT));
> + if (rc)
> + goto release;
[Severity: Medium]
Should this return rc directly instead of jumping to release when forcing
holdover fails?
When sit9531x_write_pll_u8() fails here, holdover was never forced by this
call, yet jumping to release tries to clear SIT9531X_PLL_HO_FORCE_BIT and
sets chan->ho_release_pending = true if that update also fails (which causes
later calls to treat an externally forced holdover bit as driver-owned and
clear it).
[ ... ]
> @@ -852,34 +1565,211 @@ static int sit9531x_dev_state_fetch(struct sit9531x_dev *sitdev)
[ ... ]
> +/*
> + * Rebuild pll_mask from the cached priority tables and the manual-select
> + * inputs. Caller must hold sitdev->multiop_lock.
> + */
> +static void sit9531x_ref_pll_mask_rebuild(struct sit9531x_dev *sitdev)
> +{
> + u8 pll_idx, src, index;
> +
> + for (index = 0; index < sitdev->info->num_inputs; index++)
> + sitdev->ref[index].pll_mask = 0;
> +
> + for (pll_idx = 0; pll_idx < SIT9531X_NUM_PLLS; pll_idx++) {
> + u16 mask = sitdev->chan[pll_idx].prio_mask;
> +
> + for (src = 0; src < SIT9531X_PRIO_NUM_SRC; src++) {
> + if (!(mask & BIT(src)))
> + continue;
> +
> + index = sit9531x_hw_src_input(src);
> + if (index < sitdev->info->num_inputs)
> + sitdev->ref[index].pll_mask |= BIT(pll_idx);
> + }
> + }
> +
> + sit9531x_manual_claims_add(sitdev);
> +}
[Severity: Medium]
Should sit9531x_ref_pll_mask_rebuild() and sit9531x_ref_pll_mask_fetch()
skip PLLs with chan->manual_input set?
A manual-select PLL ignores its priority table and exposes no
state_on_dpll_set callback to remove entries from it, so folding its
prio_mask into ref->pll_mask keeps those inputs claimed forever and prevents
sit9531x_input_disable() from powering down their receivers when they are
disconnected from all automatic PLLs. Note that sit9531x_dev_state_fetch()
also calls sit9531x_ref_pll_mask_fetch() before sit9531x_chan_select_fetch()
has populated chan->manual_input.
[ ... ]
> +static void sit9531x_reselect(struct sit9531x_dev *sitdev, u8 pll_idx)
> +{
> + struct sit9531x_chan *chan = &sitdev->chan[pll_idx];
> + u8 top;
> + int rc;
> +
> + /* A PLL on manual input select uses no priority table */
> + if (chan->manual_input || !chan->prio_mask || chan->mode ||
> + chan->ho_release_pending || chan->table_pending)
> + return;
> +
> + top = sit9531x_prio_top_live(sitdev, chan->prio_srcs);
> + if (chan->reselect_armed) {
> + if (top == SIT9531X_PRIO_SRC_NONE || !chan->ho_freeze) {
> + chan->reselect_armed = false;
> + chan->live_top = top;
> + return;
> + }
> + } else {
> + if (top == chan->live_top)
> + return;
> + /*
> + * Tracking is locked and not frozen; the two bits are read
> + * independently.
> + */
> + if (top == SIT9531X_PRIO_SRC_NONE ||
> + (chan->locked && !chan->ho_freeze)) {
> + chan->live_top = top;
> + return;
> + }
> + }
> +
> + rc = sit9531x_prio_table_commit(sitdev, pll_idx, chan->prio_srcs);
[Severity: Medium]
Can returning whenever top == chan->live_top leave the PLL stuck in holdover
when a live source is available?
If a higher-priority source IN0 recovers while the PLL is locked to a
fallback source IN1, sit9531x_reselect() sees chan->locked && !chan->ho_freeze,
updates chan->live_top to IN0, and returns. If IN1 later fails and puts the
PLL into holdover while IN0 is still live, top == chan->live_top is true, so
sit9531x_reselect() returns early and never re-latches the table to acquire
IN0 (the same happens if the active top source drops into holdover and
recovers between two polls).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119225752.41846-1-arouhi@sitime.com?part=7
next prev parent reply other threads:[~2026-11-20 22:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 22:57 [PATCH net-next v16 00/13] dpll: add SiTime SiT9531x DPLL clock driver Ali Rouhi
2026-11-19 22:57 ` [PATCH net-next v16 02/13] dt-bindings: vendor-prefixes: add SiTime Corporation Ali Rouhi
2026-11-19 22:57 ` [PATCH net-next v16 01/13] dpll: omit pin phase attributes the driver has no value for Ali Rouhi
2026-11-19 22:57 ` [PATCH net-next v16 04/13] dpll: add basic SiTime SiT9531x support Ali Rouhi
2026-11-20 22:58 ` sashiko-bot
2026-11-19 22:57 ` [PATCH net-next v16 03/13] dt-bindings: dpll: add SiTime SiT95316 clock generator Ali Rouhi
2026-11-19 22:57 ` [PATCH net-next v16 05/13] dpll: sit9531x: read DPLL types and pin properties from system firmware Ali Rouhi
2026-11-19 22:57 ` [PATCH net-next v16 06/13] dpll: sit9531x: register DPLL devices and pins Ali Rouhi
2026-11-20 22:58 ` sashiko-bot
2026-11-19 22:57 ` [PATCH net-next v16 07/13] dpll: sit9531x: implement input pin state on a DPLL Ali Rouhi
2026-11-20 22:58 ` sashiko-bot [this message]
2026-11-19 22:57 ` [PATCH net-next v16 08/13] dpll: sit9531x: add support to get and set priority on input pins Ali Rouhi
2026-11-19 22:57 ` [PATCH net-next v16 09/13] dpll: sit9531x: add support to get and set frequency on pins Ali Rouhi
2026-11-20 22:58 ` sashiko-bot
2026-11-19 22:57 ` [PATCH net-next v16 10/13] dpll: sit9531x: implement output pin state on a DPLL Ali Rouhi
2026-11-20 22:58 ` sashiko-bot
2026-11-19 22:58 ` [PATCH net-next v16 11/13] dpll: sit9531x: add support to adjust output phase Ali Rouhi
2026-11-20 22:58 ` sashiko-bot
2026-11-19 22:58 ` [PATCH net-next v16 13/13] dpll: sit9531x: model the inter-PLL sync line as a pair of pins Ali Rouhi
2026-11-20 22:58 ` sashiko-bot
2026-11-19 22:58 ` [PATCH net-next v16 12/13] dpll: sit9531x: add support to get phase offset on the connected input Ali Rouhi
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-226323@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.