From: Ahmad Byagowi <ahmadexp@gmail.com>
To: netdev@vger.kernel.org
Cc: 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: [PATCH net v4 3/5] ptp: ocp: preserve disabled SMA inputs across driver rebind
Date: Sun, 22 Nov 2026 17:57:41 -0800 [thread overview]
Message-ID: <20261122-timecard-common-v4-e0db4ab1aa-3-ahmadexp@gmail.com> (raw)
In-Reply-To: <20261122-timecard-common-v4-e0db4ab1aa-0-ahmadexp@gmail.com>
Disabling an SMA input clears its mux field. Zero is also the selector
for 10 MHz on FB and ADVA, so a DPLL read reports 10 MHz while sysfs
reports None. The DPLL core then skips a 10 MHz request as unchanged,
leaving the input disabled. ADVA X1 has no zero selector; its disabled
input instead fails the frequency lookup, blocking DPLL reads and later
frequency changes.
Substitute SMA_DISABLE for disabled inputs before the frequency lookup,
as the sysfs path already does, so the None entry reports zero Hz.
The software flag alone is insufficient after a rebind. Recover it from
the mux enable bits when initializing direction-configurable FB-style
connectors. The existing direction selection picks an enabled side if
either side is enabled. If the selected side is also disabled, neither
buffer is enabled: represent this as an input with the None function.
The mux does not preserve a direction for that disconnected state.
Do not write the mux or change the interpretation of fixed-direction
firmware, which does not provide these enable bits.
Source-derived tests reproduce the lost disabled state using retained
mux values and a fresh driver instance with stubbed MMIO. The corrected
rebind and DPLL re-enable cases pass under ASan/UBSan. No physical rebind
or card test was performed.
The issues were reported by the Sashiko review. Codex assisted with the
code, tests and changelog using the report and public SMA-selector RTL.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Link: https://lore.kernel.org/r/179538006912.3135.16971430532149423594@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v4:
- Recover the disconnected state from mux enable bits at initialization.
- Explain the original ADVA X1 error, not only the false 10 MHz case.
- Drop the earlier review tag because initialization behavior changed.
Testing: 243 configurations across FB/ADVA/ADVA X1, covering all four
connectors, enabled inputs, outputs and disconnected states. Initialization
performs zero writes; fixed-direction behavior remains unchanged. Re-enable
uses the actual DPLL core get-before-set function. The old source fails
the rebind case. Three disabled-state negative variants fail at runtime.
These are source-derived tests with stubbed MMIO, not a physical rebind.
drivers/ptp/ptp_ocp.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index df1a428eb2fe..e27abe2c24c7 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;
+ }
}
}
@@ -5889,6 +5897,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;
tbl = bp->sma_op->tbl[sma->mode];
for (i = 0; tbl[i].name; i++)
if (val == tbl[i].value) {
next prev parent reply other threads:[~2026-11-23 1:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 1:57 [PATCH net v4 0/5] Fix PTP teardown and Time Card DPLL operations Ahmad Byagowi
2026-11-23 1:57 ` [PATCH net v4 1/5] ptp: disable all timestamp channels after removing the user interfaces Ahmad Byagowi
2026-11-23 1:57 ` [PATCH net v4 2/5] ptp: ocp: handle hardware selectors and combined DPLL input routes Ahmad Byagowi
2026-11-23 1:57 ` Ahmad Byagowi [this message]
2026-11-23 1:57 ` [PATCH net v4 4/5] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-23 1:57 ` [PATCH net v4 5/5] ptp: ocp: correct the ART 10 MHz input 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=20261122-timecard-common-v4-e0db4ab1aa-3-ahmadexp@gmail.com \
--to=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