[PATCH net v6 4/8] ptp: ocp: restore disabled SMA inputs when binding

From: Ahmad Byagowi

Date: Thu Nov 26 2026 - 11:42:40 EST


From: ahmadexp <ahmadexp@xxxxxxxxx>

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.

A coding assistant helped validate the rebind behavior and prepare the source-derived regression test and changelog.

Fixes: b2c4f0ac53f3 ("ptp: ocp: Add ability to disable input selectors.")
Signed-off-by: Ahmad Byagowi <ahmadexp@xxxxxxxxx>
---
drivers/ptp/ptp_ocp.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 284908c6abc2..aa18c5e5eba4 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);
+ /* Both buffers disabled: report None. */
+ if (bp->sma[i].disabled)
+ bp->sma[i].mode = SMA_MODE_IN;
+ }
}
}

--
2.54.0 (Apple Git-157)