Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: ahmadexp@gmail.com
Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch,
	arkadiusz.kubalewski@intel.com, davem@davemloft.net,
	edumazet@kernel.org, jiri@resnulli.us, kuba@kernel.org,
	pabeni@redhat.com, richardcochran@gmail.com,
	rmk+kernel@armlinux.org.uk, vadim.fedorenko@linux.dev,
	vladimir.oltean@nxp.com
Subject: Re: [PATCH net v3 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL
Date: Tue, 24 Nov 2026 22:10:27 +0000	[thread overview]
Message-ID: <179555822748.3135.10487682659847621386@kernel.org> (raw)
In-Reply-To: <20261120-timecard-common-v3-33316bf475-3-ahmadexp@gmail.com>

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

Critical: 0 · High: 0 · Medium: 1 · 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 fix keys only on the software flag `sma->disabled`, and
  nothing rebuilds that flag from hardware at probe.
- [Low] The testing and provenance paragraphs of the changelog are the
  same text used in the other patches of the series.

--

ptp: ocp: report disabled SMA inputs consistently over DPLL

This commit changes ptp_ocp_dpll_frequency_get() so that a disabled SMA
input uses SMA_DISABLE before the selector table lookup, which is what
the sysfs show path already does. Before this, a disabled input read
back as 10 MHz, and the DPLL core skipped a later 10 MHz set as
unchanged.

Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org

> Reported by the netdev Sashiko AI review and confirmed by code
> inspection. Source-derived C regression tests pass with ASan/UBSan;
> restoring the faulty selector, mask, disabled-state or DCF value makes
> the corresponding regression fail. Tests use stubbed MMIO, not hardware.

[ ... ]

> Codex prepared the fix, tests and changelog from the review and upstream
> source, at the request to separate common-driver fixes from WiWi support
> and validate removal ordering.

[Severity: Low]
Do these paragraphs describe this commit? They look like the same
testing and provenance text used in the other patches of the series.

This patch only adds the disabled-state substitution in
ptp_ocp_dpll_frequency_get().

It doesn't change the selector handling or SMA_SELECT_MASK. That work
is in the earlier patch "ptp: ocp: use hardware selectors in DPLL
frequency operations".

It also has nothing to do with removal ordering. That is in "ptp:
disable all timestamp channels after removing the user interfaces".

At this commit the DCF output entry still has the old value:

drivers/ptp/ptp_ocp.c:ptp_ocp_sma_out[] {
    ...
	{ .name = "DCF",	.value = 0x0020,  .frequency = 77000 },
    ...
}

The following patch, "ptp: ocp: correct the DCF output frequency",
fixes that value. So a DCF regression test would fail on this tree by
itself.

Could the changelog describe only the testing that applies to this
change?

> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 95a4df468e793..653c3b1ca0668 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -5889,6 +5889,8 @@ static int ptp_ocp_dpll_frequency_get(const struct dpll_pin *pin,
>  
>  	val = bp->sma_op->get(bp, sma_nr + 1);
>  	val &= SMA_SELECT_MASK;
> +	if (sma->mode == SMA_MODE_IN && sma->disabled)
> +		val = SMA_DISABLE;

[Severity: Medium]
Can a disabled input still be reported as 10 MHz after the driver is
unbound and rebound?

The new check looks only at the software flag sma->disabled. Disabling
an input in ptp_ocp_sma_store_val() writes 0 to the whole input field,
and that also clears SMA_ENABLE:

drivers/ptp/ptp_ocp.c:ptp_ocp_sma_store_val() {
    ...
	if (!sma->fixed_dir)
		val |= SMA_ENABLE;		/* add enable bit */

	if (sma->disabled)
		val = 0;
    ...
}

On rebind, bp is allocated zeroed, so disabled starts out false.
ptp_ocp_sma_fb_init() uses bit 15 of the gpio registers only to pick
the direction:

drivers/ptp/ptp_ocp.c:ptp_ocp_sma_fb_init() {
    ...
		reg = ioread32(&bp->sma_map1->gpio2);
		bp->sma[2].mode = reg & BIT(15) ? SMA_MODE_OUT : SMA_MODE_IN;
		bp->sma[3].mode = reg & BIT(31) ? SMA_MODE_OUT : SMA_MODE_IN;
    ...
}

Take SMA3 or SMA4 on a board where the direction can be changed.
Switch it to input, disable it, then rebind the driver. The pin comes
back as SMA_MODE_IN with disabled == false.

In ptp_ocp_dpll_frequency_get(), the line "val &= SMA_SELECT_MASK"
drops bit 15. In hardware, that bit is the only thing that tells
disabled (0x0000) apart from enabled 10 MHz (0x8000).

The new check doesn't fire, and the lookup matches the "10Mhz" entry.
A DPLL request for 10 MHz then returns early here:

drivers/dpll/dpll_netlink.c:dpll_pin_freq_set() {
    ...
	if (freq == old_freq)
		return 0;
    ...
}

The input stays disabled, which is the failure the changelog says this
patch fixes.

This assumes the FPGA mux registers keep their value across
unbind/rebind. Probe doesn't seem to reset them, but this hasn't been
confirmed on hardware.

Would it work to check the raw SMA_ENABLE bit for !sma->fixed_dir pins
before masking? Another option is to set sma->disabled from that bit in
ptp_ocp_sma_fb_init().

>  	tbl = bp->sma_op->tbl[sma->mode];
>  	for (i = 0; tbl[i].name; i++)
>  		if (val == tbl[i].value) {

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-timecard-common-v3-33316bf475-0-ahmadexp%40gmail.com

  reply	other threads:[~2026-11-24 22:10 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 21:21 [PATCH net v3 0/4] ptp: fix timestamp teardown and OCP DPLL routing Ahmad Byagowi
2026-11-20 21:21 ` [PATCH net v3 1/4] ptp: disable all timestamp channels after removing the user interfaces Ahmad Byagowi
2026-11-22 20:10   ` Vadim Fedorenko
2026-11-23  1:57     ` Ahmad Byagowi
2026-11-24 22:10   ` netdev-bot+sashiko
2026-11-20 21:21 ` [PATCH net v3 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations Ahmad Byagowi
2026-11-24 22:10   ` netdev-bot+sashiko
2026-11-20 21:21 ` [PATCH net v3 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL Ahmad Byagowi
2026-11-24 22:10   ` netdev-bot+sashiko [this message]
2026-11-20 21:21 ` [PATCH net v3 4/4] ptp: ocp: correct the DCF output frequency Ahmad Byagowi

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=179555822748.3135.10487682659847621386@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=ahmadexp@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=vadim.fedorenko@linux.dev \
    --cc=vladimir.oltean@nxp.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox