From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796258351; b=5SyyeDfYFRLkHtxE/Py++p91vVhyJnRid5OotUSddkKlapJ1qNMI8bzD+h+alNoc71EM 0YBJX9tXWrZVWGr0Wfqghf0++JnEYaSTFz8ngocUMEtKky0JXtut/9DLFrAlL04u5iGKZ JNQCEZlM0KwLAESESOJufMcfw5mqhpYFEEjz/ZnInfFx4y6pQEPb9fpw2OlzI23EKEqHd op7C1QuVeHtB7XnXPy/z5q/SYBqlZlHBGuSjlzrCpKzvJU/lg/BMlf+oNxT8uj1YtnZvo F0jJfZqNGtwxC2Vizg5W6KTHFkIKdDaqdvbYNm0uZw0yAIhlO1g8C3vD6CfPxVTChlg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796258351; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=+2e/2cKuRYk12tLHxVneMASyas7dOP4NkX9ukJGLg0M=; b=j7XlkTF2gPLatVlx0Ypxvakyny1nm63UsmSXTmg3nHmm3vB75l3DO93nttUTq5Df1NYs 8uZDCkISitQgNYgnuzNRVbrjqvD4z3Ur91kDO4Mfy90UZVdvJ2VPJY30YUii8q59gZMmT VKaElkCri5X1gGkg+DqtbOxqYcLteMlNT1PxVGMzzlrocbMuBAgDav/FuvticwsFiToKS WU6fzJoLcidhkM0sA/4TL0/aI9wcjMeUDpGZgFkm3pRlXLXgJOJoOaGbyO7DSV+9rnGO9 egsnKSxucwpYVEjt/CBfdsjWxJ3OrxtD8KrzVXMdVHfSlF0LTsQgZAoIiPoPP9ZU/9g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PIUZ1Mwp; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B590606A68D; Thu, 3 Dec 2026 00:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PIUZ1Mwp Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A5FE1F00923; Thu, 3 Dec 2026 00:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796258351; bh=+2e/2cKuRYk12tLHxVneMASyas7dOP4NkX9ukJGLg0M=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=PIUZ1Mwpd7aZvDequ2w5pJmWSNk0559Ld3LYiMsAWbWj4SqahpmSLXtJqvOzavpAj hULKThv21v4/9MRUelHjWXGJrJlPMB6dBhfcaASv5+hjqr5NHdlXwnEhX6cwFMomPI 7c3VSADlFNWWoIw4inTbkXL1mN0Lz5auxZbLWTeDYV8ZGeJwzj6zkosaHtDAL/nbuJ dj9n+UhAGjwHq/wsqPFEIR2sUTb9iXpRd8phHNCcg/RJviZRCBna55GyCzw+O86Xoj FKYWWIAt2C2/bg0lcTWjH11Z+WbkBLpI+iq/g0GXG+F/i4jyJ26otpjgdBy7tzAHzi fziOXbKgtiT9w== Subject: Re: [PATCH net-next v17 08/13] dpll: sit9531x: add support to get and set priority on input pins From: netdev-bot+sashiko@kernel.org To: arouhi@sitime.com Cc: jiri@resnulli.us, ivecera@redhat.com, vadim.fedorenko@linux.dev, arkadiusz.kubalewski@intel.com, kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, prabhakar.mahadev-lad.rj@bp.renesas.com, cjubran@nvidia.com, Oleg.Zadorozhnyi@devoxsoftware.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 03 Dec 2026 00:39:09 +0000 Message-ID: <179625834984.3146.5434082265561517682@kernel.org> In-Reply-To: <20261201235202.97645-9-arouhi@sitime.com> References: <20261201235202.97645-9-arouhi@sitime.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 3 · Low: 4 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] Changing the priority of a standby input that the PLL does not track still runs the whole table-commit sequence in… - [Medium] Pin ops are chosen once, at registration, in sit9531x_dpll_pin_ops_get() ('As read at probe'). - [Medium] The commit message says a table 'rewritten outside the driver, by a profile reload or an I2C tool, becomes the new configuration'. - [Low] The subject says this patch adds priority get/set, but it also changes behaviour that the previous patch in the same unmerged series… - [Low] sit9531x_dpll_input_pin_prio_set() updates only dpin->prio on success. - [Low] Comments added by this patch state the wrong locking invariant for sitdpll->pins. - [Low] sit9531x_prio_table_commit() now calls sit9531x_chan_lock_fetch() before forcing holdover whenever the new table is non-empty, and… -- dpll: sit9531x: add support to get and set priority on input pins This commit adds prio_get and prio_set pin callbacks to the sit9531x DPLL driver. It keeps a configured priority for each input and PLL, and rebuilds the Page 1 priority table when a priority is set. It also makes table writes prefer the routed source as the active selection, reports the XO priority read-only, and reworks the poll so it notifies changes against a baseline taken at registration and after state requests. > A table rewritten outside the driver, by a profile reload or an I2C > tool, becomes the new configuration. [Severity: Medium] How does the driver stay in step with the device's page select register when an I2C tool rewrites the table? sit9531x_page_select() caches the selected page and skips the PAGE_SEL write when the cache matches: drivers/dpll/sit9531x/core.c:sit9531x_page_select() { ... if (sitdev->page == page) return 0; ... } The cache is only dropped on a regmap error or on resume. An external tool has to write PAGE_SEL to rewrite the Page 1 table. If it leaves PAGE_SEL on a page other than the cached one, the next driver access to the cached page goes to the same offset on the wrong page. The poll would then read OUTER_LOL, HO_FREEZE, CLKMON and the priority table from another page. sit9531x_chan_state_fetch() could then adopt a "table" read from the wrong page as the new configuration through sit9531x_prio_cfg_seed(). Writes such as HO_CTRL, the debug keys, the input FORCE/STATE bits and the priority slots could also land on unrelated registers. Can the I2C tool case be supported while the page is cached, or should the commit message leave it out? > diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c > index d0305cbf12d5a..6e06e99e5ff82 100644 > --- a/drivers/dpll/sit9531x/core.c > +++ b/drivers/dpll/sit9531x/core.c [ ... ] > @@ -780,6 +808,13 @@ static u8 sit9531x_prio_activesel_pick(struct sit9531x_dev *sitdev, > (idle || top != sit9531x_prio_top_live(sitdev, old))) > return sit9531x_prio_table_code(sitdev, srcs, top); > > + if (sit9531x_prio_src_usable(routed) && > + sit9531x_prio_src_live(sitdev, routed)) { > + code = sit9531x_prio_table_code(sitdev, srcs, routed); > + if (code != SIT9531X_PRIO_SRC_NONE) > + return code; > + } > + [Severity: Low] This isn't a bug at the head of the series, but this patch also changes behaviour added by the previous patch, "dpll: sit9531x: implement input pin state on a DPLL": - The pick now prefers the routed source over the selection nibble. At the earlier commit, the device could fall back from A to B while the nibble still named A. An unrelated state request that rewrote the table then latched A again. - Every table commit, including SELECTABLE and DISCONNECTED requests, now runs sit9531x_chan_lock_fetch() first. - The pin->seen baseline is replaced, because the earlier poll re-notified changes that the core had already notified for a state request. These look like fixes to the earlier patch. Could they be folded into it, so that bisecting to that commit doesn't hit the old behaviour? [ ... ] > @@ -818,6 +853,16 @@ static int sit9531x_prio_table_commit(struct sit9531x_dev *sitdev, u8 pll_idx, > memcpy(back, chan->table_pending ? chan->table_back : chan->prio_srcs, > sizeof(back)); > > + /* > + * Sample the lock state and the routed source for the pick before the > + * forced holdover changes them. > + */ > + if (!empty) { > + rc = sit9531x_chan_lock_fetch(sitdev, pll_idx); > + if (rc) > + return rc; > + } [Severity: Low] Should a failure here abort the whole priority or state request? On a tracking PLL, sit9531x_chan_lock_fetch() calls sit9531x_chan_routed_ref_read(). That function opens the PLL debug window and ends with: return rc ? rc : lock_rc; So the request fails even when only the final re-lock fails and the routed source was read correctly. The routed source is only a hint for the selection nibble, and sit9531x_prio_activesel_pick() already handles SIT9531X_PRIO_SRC_NONE. A failed re-lock also leaves the debug key open (key_pending). Before this patch, this path only touched HO_CTRL and the priority registers. Could a failed sample fall back to no routed source instead of failing the request? [ ... ] > @@ -1043,6 +1096,59 @@ static int sit9531x_prio_table_apply(struct sit9531x_dev *sitdev, u8 pll_idx, [ ... ] > + chan = &sitdev->chan[pll_idx]; > + old_prio = chan->cfg_prio[input_idx]; > + old_known = chan->cfg_known; > + chan->cfg_prio[input_idx] = prio; > + chan->cfg_known |= BIT(input_idx); > + > + if (!(chan->prio_mask & BIT(input_idx))) > + return 0; > + > + rc = sit9531x_prio_table_apply(sitdev, pll_idx, chan->prio_mask); [Severity: Medium] The commit message says: A table write that leaves the best live source unchanged keeps as the active selection the source the PLL tracks, read at the write, or the selected one it acquires, so the PLL does not restart acquisition for it. Is that accurate for this path? A priority change that only reorders standby sources still goes through sit9531x_prio_table_apply()->sit9531x_prio_table_commit(). That sequence: - sets HO_FORCE on the locked PLL - rewrites the table - latches through sit9531x_prio_prg_commit() - releases holdover Right after the latch, the driver records: /* A latch starts a new acquisition; see sit9531x_reselect(). */ if (!prg_rc) { chan->tracked = false; chan->stall_polls = 0; } sit9531x_reselect() also says that a latch restarts acquisition. The routed-source preference in sit9531x_prio_activesel_pick() stops the latch from naming a different source. It doesn't avoid the forced holdover or the re-latch. So would swapping the priorities of two backup inputs, while a higher-priority source stays active, still disturb the active reference? Before this patch, only state requests and the poll's re-select reached this sequence. If the forced holdover and latch are part of the hardware table-write procedure, could the commit message say so? [ ... ] > @@ -2387,13 +2511,24 @@ static int sit9531x_dpll_pins_register(struct sit9531x_dpll *sitdpll) [ ... ] > - /* List changes are made under multiop_lock */ > + /* > + * Earlier pins are already reachable from netlink, and the > + * walks over this list run under multiop_lock. > + */ > mutex_lock(&sitdpll->dev->multiop_lock); > list_add(&pin->list, &sitdpll->pins); > mutex_unlock(&sitdpll->dev->multiop_lock); [Severity: Low] Is this comment accurate? The same applies to the one added in sit9531x_dpll_pins_unregister() ("Detached under multiop_lock, which callbacks walking the list hold"). sit9531x_dpll_pins_unregister() walks sitdpll->pins without the lock. The new second loop in sit9531x_dpll_changes_check() walks the list after dropping multiop_lock: mutex_unlock(&sitdev->multiop_lock); list_for_each_entry(pin, &sitdpll->pins, list) { if (!pin->ntf_pending) continue; No dpll_pin_ops callback seems to walk this list. The walks look safe because the poll is queued after registration and cancelled with kthread_cancel_delayed_work_sync() before unregister. multiop_lock is not what protects them. Could the comments describe that instead? > diff --git a/drivers/dpll/sit9531x/dpll.c b/drivers/dpll/sit9531x/dpll.c > index 5d16183aa1aeb..3a31d0707127a 100644 > --- a/drivers/dpll/sit9531x/dpll.c > +++ b/drivers/dpll/sit9531x/dpll.c [ ... ] > @@ -414,11 +426,82 @@ sit9531x_dpll_input_pin_state_on_dpll_set(const struct dpll_pin *pin, [ ... ] > + mutex_lock(&sitdev->multiop_lock); > + if (sit9531x_chan_state_get(sitdev, sitdpll->id)->manual_input) { > + mutex_unlock(&sitdev->multiop_lock); > + return sit9531x_dpll_manual_select_refuse(extack); > + } > + rc = sit9531x_input_prio_set(sitdev, sitdpll->id, > + sit9531x_input_hw_src(dpin->id), > + (u8)prio); > + if (!rc) > + dpin->prio = prio; > + mutex_unlock(&sitdev->multiop_lock); [Severity: Low] Should this re-baseline the pin, the way sit9531x_dpll_input_pin_state_on_dpll_set() does? The core also notifies a successful prio_set: dpll_pin_prio_set() ops->prio_set() __dpll_pin_change_ntf(pin) The table rewrite can change this pin's operstate, and the core's notification already carries the new value. pin->pin_state and pin->operstate still hold the values from before the request. The next sit9531x_dpll_changes_check() would then send a second notification for the same change. Would calling sit9531x_dpll_pin_baseline(dpin) here avoid that? [ ... ] > @@ -482,19 +575,82 @@ const struct dpll_pin_ops * [ ... ] > +/* Caller must hold sitdev->multiop_lock. */ > +static void sit9531x_dpll_pin_snapshot(struct sit9531x_dpll *sitdpll, > + const struct sit9531x_dpll_pin *pin, > + enum dpll_pin_state *state, > + enum dpll_pin_operstate *operstate, > + u8 *prio) > +{ > + struct sit9531x_dev *sitdev = sitdpll->dev; > + u8 id = pin->id; > + > + sit9531x_dpll_selection_state_get(sitdev, sitdpll, id, state); > + sit9531x_dpll_selection_operstate_get(sitdev, sitdpll, id, operstate); > + /* A PLL on manual input select reports no priority */ > + if (sit9531x_chan_state_get(sitdev, sitdpll->id)->manual_input || > + sit9531x_input_prio_get(sitdev, sitdpll->id, > + sit9531x_input_hw_src(id), prio)) > + *prio = pin->prio; > +} [Severity: Medium] Can this disagree with what sit9531x_dpll_input_pin_prio_get() reports? The ops are chosen once, at registration, in sit9531x_dpll_pin_ops_get(). sit9531x_resume() can still find a PLL on manual input select. It updates chan->manual_input and only warns that the pins keep the callbacks they were registered with. In that state, the automatic-mode .prio_get still returns chan->cfg_prio[]. It is also installed in sit9531x_dpll_xo_pin_ops. sit9531x_chan_state_fetch() still reseeds cfg_prio[] through sit9531x_prio_cfg_seed() when the hardware table changes. For a manual PLL, this function and sit9531x_dpll_xo_prio_update() both keep the old pin->prio. If the table is then rewritten outside the driver, the PRIO attribute that userspace reads changes. The poll never sees a difference, so it never calls dpll_pin_change_ntf(). Should prio_get and the snapshot apply the same manual_input check? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201235202.97645-1-arouhi%40sitime.com