Re: [PATCH net v6 4/8] ptp: ocp: restore disabled SMA inputs when binding
From: netdev-bot+sashiko
Date: Fri Nov 27 2026 - 11:48:29 EST
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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 commit message describes a hardware bug that does not
exist.
- [Medium] The code that disables an SMA input and the new restore code
in ptp_ocp_sma_fb_init() read the hardware state differently for…
- [Low] There are three submission metadata problems.
--
ptp: ocp: restore disabled SMA inputs when binding
This commit adds a loop to ptp_ocp_sma_fb_init(). At probe time the loop
reads each SMA selector through ptp_ocp_sma_fb_get() and sets
bp->sma[i].disabled when SMA_ENABLE is clear. It also forces disabled
pins to SMA_MODE_IN, so they show as "IN: None" after a rebind.
> The SMA disable state is stored in software and is lost when the driver is unbound. The hardware selector may therefore route an input after a rebind even though userspace had disabled it.
>
> Apply the disabled state during SMA initialization so the hardware mux and software state agree after binding. This fix is independent of DPLL reporting.
[Severity: Medium]
Is this description accurate? The disable path already writes the
disabled state into the hardware input selector:
drivers/ptp/ptp_ocp.c:ptp_ocp_sma_store_val() {
...
if (sma->disabled)
val = 0;
if (mode == SMA_MODE_IN)
val = ptp_ocp_sma_set_inputs(bp, sma_nr, val);
...
}
Neither ptp_ocp_detach() nor the probe path writes sma_map1 or
sma_map2. The probe path goes through
ptp_ocp_sma_init()->ptp_ocp_sma_fb_init(). So the cleared input selector
should survive an unbind and rebind. The new loop also only reads
hardware, through ptp_ocp_sma_fb_get(). It updates bp->sma[i].disabled
and bp->sma[i].mode but writes nothing to the mux.
Before the patch, the user-visible problem looks like a reporting one. A
disabled SMA1/SMA2 has its input field cleared, so BIT(15)/BIT(31) of
sma_map1->gpio1 is clear and the pin is detected as an output:
bp->sma[0].mode = reg & BIT(15) ? SMA_MODE_IN : SMA_MODE_OUT;
bp->sma[1].mode = reg & BIT(31) ? SMA_MODE_IN : SMA_MODE_OUT;
sysfs then reports it as an output. A disabled SMA3/SMA4 is reported as
an input without "None".
On "independent of DPLL reporting": ptp_ocp_dpll_direction_get() takes
the direction from sma->mode:
*direction = sma->mode == SMA_MODE_IN ?
DPLL_PIN_DIRECTION_INPUT :
DPLL_PIN_DIRECTION_OUTPUT;
The patch forces SMA_MODE_IN for disabled pins. After a rebind, the DPLL
netlink direction for a disabled SMA1/SMA2 therefore changes from OUTPUT
to INPUT.
Could the commit message describe the reporting fix and this change to
the DPLL-reported direction instead?
> A coding assistant helped validate the rebind behavior and prepare the source-derived regression test and changelog.
[Severity: Low]
The patch only touches drivers/ptp/ptp_ocp.c, so the regression test
mentioned here isn't included. Can it be posted for reviewers?
This isn't a bug, but the From: name (ahmadexp) doesn't match the
Signed-off-by: name (Ahmad Byagowi), and checkpatch will flag that. The
body paragraphs are also not wrapped at 75 columns.
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 284908c6abc22..aa18c5e5eba45 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -2932,6 +2932,14 @@ ptp_ocp_sma_fb_init(struct ptp_ocp *bp)
> 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;
> +
> + for (i = 0; i < OCP_SMA_NUM; i++) {
> + reg = ptp_ocp_sma_fb_get(bp, i + 1);
> + bp->sma[i].disabled = !(reg & SMA_ENABLE);
[Severity: Medium]
For SMA1/SMA2, can this miss a pin that was disabled while it was
already in input mode?
If the pin is already SMA_MODE_IN, ptp_ocp_sma_store_val() skips the
direction switch, so only the input selector is cleared:
if (mode != sma->mode) {
if (mode == SMA_MODE_IN)
ptp_ocp_sma_set_output(bp, sma_nr, 0);
...
}
...
if (sma->disabled)
val = 0;
On rebind, the SMA1/SMA2 direction comes only from the input-enable bit
in sma_map1->gpio1, so the disabled pin is first classified as
SMA_MODE_OUT. Because of that mode, ptp_ocp_sma_fb_get() then reads the
output register:
else
gpio = sma_nr > 2 ? &bp->sma_map1->gpio2 : &bp->sma_map2->gpio2;
disabled is set only if SMA_ENABLE is also clear in sma_map2->gpio2.
Suppose the output half has SMA_ENABLE set while the pin is in input
mode. Then the "IN: None" setting is not restored, and the pin comes
back as an enabled output, the same as before the patch.
Every direction switch in the driver clears the other half, so this
state would have to come from the firmware power-on defaults for
sma_map2->gpio2. I couldn't verify those defaults. SMA3/SMA4 don't seem
affected, because their direction comes from the output-enable bit.
Should the restore check the input selector for these pins? Or should
the disable path also clear the output half?
> + /* Both buffers disabled: report None. */
> + if (bp->sma[i].disabled)
> + bp->sma[i].mode = SMA_MODE_IN;
> + }
> }
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-timecard-driver-v6-0-ahmadexp%40gmail.com