All of lore.kernel.org
 help / color / mirror / Atom feed
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 v17 07/13] dpll: sit9531x: implement input pin state on a DPLL
Date: Wed, 02 Dec 2026 23:52:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-246773@kernel.org> (raw)
In-Reply-To: <20261201235202.97645-8-arouhi@sitime.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] dpll: sit9531x: indirect manual input decoded in
  sit9531x_chan_select_fetch()
- [Medium] dpll: sit9531x: stale priorities on re-seed in
  sit9531x_prio_cfg_seed()
--

commit e145fff66daa4f2e791c772fadb59ceb2f603c99
Author: Oleg Zadorozhnyi <Oleg.Zadorozhnyi@devoxsoftware.com>

dpll: sit9531x: implement input pin state on a DPLL

This commit implements getting and setting DPLL input pin states and
operational states by managing each PLL's hardware priority table, input
receiver gating, and reference re-selection during polling.

> diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c
> index 4ff9e251eb776..d0305cbf12d5a 100644
> --- a/drivers/dpll/sit9531x/core.c
> +++ b/drivers/dpll/sit9531x/core.c

[ ... ]

> @@ -340,39 +490,607 @@ static u8 sit9531x_prio_slot_get(u8 val, u8 slot)

[ ... ]

> +/*
> + * Take the configured priorities from the hardware table: a listed source gets
> + * the first slot it occupies.
> + */
> +static void sit9531x_prio_cfg_seed(struct sit9531x_dev *sitdev, u8 pll_idx,
> +				   const u8 *srcs)
> +{
> +	struct sit9531x_chan *chan = &sitdev->chan[pll_idx];
> +	u16 seeded = 0;
> +	u8 slot, src;
> +
> +	for (slot = 0; slot < SIT9531X_PRIO_MAX_SLOTS; slot++) {
> +		src = srcs[slot] & SIT9531X_PRIO_NIBBLE_MASK;
> +		if (!sit9531x_prio_src_usable(src))
> +			continue;
> +		src = sit9531x_prio_src_canon(sitdev, src);
> +		if (seeded & BIT(src))
> +			continue;
> +		seeded |= BIT(src);
> +		chan->cfg_prio[src] = slot;
> +		chan->cfg_known |= BIT(src);
> +	}
> +
> +	for (src = 0; src < SIT9531X_PRIO_NUM_SRC; src++) {
> +		if (chan->cfg_known & BIT(src))
> +			continue;
> +		chan->cfg_prio[src] = SIT9531X_PRIO_MAX_SLOTS - 1;
> +		chan->cfg_known |= BIT(src);
> +	}
> +
> +	memcpy(chan->seen_srcs, srcs, sizeof(chan->seen_srcs));
> +	chan->seen_valid = true;
> +}

[Severity: Medium]
Does sit9531x_prio_cfg_seed() leave stale entries in chan->cfg_prio[] when
a modified hardware table is reloaded?

The initial call at probe sets every bit in chan->cfg_known.  If
sit9531x_chan_state_fetch() later calls sit9531x_prio_cfg_seed() because
the hardware priority table changed over suspend/resume or outside the
driver, the second loop checks chan->cfg_known instead of seeded and skips
every source absent from the new table.  Setting such a pin to
DPLL_PIN_STATE_SELECTABLE will then insert it at its old chan->cfg_prio[src]
slot rather than SIT9531X_PRIO_MAX_SLOTS - 1.

[ ... ]

> @@ -508,7 +1226,8 @@ static int sit9531x_pll_is_active(struct sit9531x_dev *sitdev, u8 pll_idx,
>  static int sit9531x_chan_select_fetch(struct sit9531x_dev *sitdev, u8 pll_idx)
>  {
>  	struct sit9531x_chan *chan = &sitdev->chan[pll_idx];
> -	bool manual_input = false;
> +	bool manual_input = false, manual_any = false;
> +	u8 manual_ref = SIT9531X_REF_INVALID;
>  	u8 cfg, misc, sel;
>  	int rc;
>  
> @@ -534,8 +1253,13 @@ static int sit9531x_chan_select_fetch(struct sit9531x_dev *sitdev, u8 pll_idx)
>  	if (rc)
>  		return rc;
>  	manual_input = true;
> +	manual_any = !(sel & SIT9531X_MAN_IN_SEL_FROM_REG) ||
> +		     (sel & SIT9531X_MAN_IN_SEL_INDIRECT);
>  	if (sel & SIT9531X_MAN_IN_SEL_FROM_REG) {
>  		sel = FIELD_GET(SIT9531X_MAN_IN_SEL_MASK, sel);
> +		manual_ref =
> +			sit9531x_hw_src_input(sit9531x_prio_src_canon(sitdev,
> +								      sel));
>  		dev_dbg(sitdev->dev,
>  			"PLL%c: the profile selects its reference from the register, input code %u; reported as manual\n",
>  			'A' + pll_idx, sel);
> @@ -544,24 +1268,81 @@ static int sit9531x_chan_select_fetch(struct sit9531x_dev *sitdev, u8 pll_idx)
>  			"PLL%c: the profile selects its reference from the input-select pins; reported as manual\n",
>  			'A' + pll_idx);
>  	}
> +	/*
> +	 * The select pins and the indirect choice are not read here: a PLL
> +	 * found on them again keeps the input it last tracked.
> +	 */
> +	if (manual_any && chan->manual_input && chan->manual_any)
> +		manual_ref = chan->manual_ref;
>  
>  record:
>  	chan->manual_input = manual_input;
> +	chan->manual_any = manual_any;
> +	chan->manual_ref = manual_ref;

[Severity: Medium]
When both SIT9531X_MAN_IN_SEL_FROM_REG and SIT9531X_MAN_IN_SEL_INDIRECT are
set, does sit9531x_chan_select_fetch() populate manual_ref from the low
nibble instead of leaving it as SIT9531X_REF_INVALID?

At probe, chan->manual_input and chan->manual_any are false, so the
fallback to chan->manual_ref does not overwrite the decoded value.  If the
PLL is unlocked or in holdover, sit9531x_dpll_selection_state_get() will
report that pin as DPLL_PIN_STATE_CONNECTED even though indirect selection
is active and the selected input is unknown.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201235202.97645-1-arouhi@sitime.com?part=7

  reply	other threads:[~2026-12-02 23:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 23:52 [PATCH net-next v17 00/13] dpll: add SiTime SiT9531x DPLL clock driver Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 02/13] dt-bindings: vendor-prefixes: add SiTime Corporation Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 01/13] dpll: omit pin phase attributes the driver has no value for Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 03/13] dt-bindings: dpll: add SiTime SiT95316 clock generator Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 04/13] dpll: add basic SiTime SiT9531x support Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 06/13] dpll: sit9531x: register DPLL devices and pins Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 05/13] dpll: sit9531x: read DPLL types and pin properties from system firmware Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 07/13] dpll: sit9531x: implement input pin state on a DPLL Ali Rouhi
2026-12-02 23:52   ` sashiko-bot [this message]
2026-12-01 23:52 ` [PATCH net-next v17 08/13] dpll: sit9531x: add support to get and set priority on input pins Ali Rouhi
2026-12-02 23:52   ` sashiko-bot
2026-12-01 23:52 ` [PATCH net-next v17 10/13] dpll: sit9531x: implement output pin state on a DPLL Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 09/13] dpll: sit9531x: add support to get and set frequency on pins Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 12/13] dpll: sit9531x: add support to get phase offset on the connected input Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 11/13] dpll: sit9531x: add support to adjust output phase Ali Rouhi
2026-12-02 23:52   ` sashiko-bot
2026-12-01 23:52 ` [PATCH net-next v17 13/13] dpll: sit9531x: model the inter-PLL sync line as a pair of pins Ali Rouhi
2026-12-02 23:53   ` sashiko-bot

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-246773@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.