* [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting
@ 2026-11-24 4:42 Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 1/8] ptp: serialize sysfs requests with the ioctl paths Ahmad Byagowi
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
This series fixes PTP request serialization and timestamp shutdown, and
corrects OCP SMA/DPLL reporting. It is based on net at 4392bb809812.
It contains no WiWi board support or LED driver changes.
The first two patches address prerequisites identified in v4 review:
serialize all three sysfs enable callbacks with the ioctl paths, and
prevent SJA1105 EXTTS disable from switching its shared pin to input.
Patch 3 preserves Vadim's requested teardown design: after removing the
user interfaces, send direct disable requests for each advertised EXTTS
channel, followed by PPS. Do not use a pin-function helper for channel
indices, alter pin assignments, or add a driver stopping flag or spinlock.
The remaining patches handle hardware selector values and combined input
routes, recover disabled SMA state on bind, report disabled inputs as
zero Hz, and correct the DCF77 and ART 10 MHz frequencies. Rebind recovery
is now separate from DPLL reporting, with the earlier b2c4f0ac53f3 Fixes
tag, so kernels without DPLL support can receive that correction.
Changes since v4:
- New patch 1 takes pincfg_mux in extts_enable, pps_enable and period.
All callback errors and existing permission checks are preserved.
- New patch 2 changes the SJA1105 pin function only on EXTTS enable.
- Patch 3 has unchanged code. Its message no longer presents the runtime
sysfs/ioctl race as remaining after patch 1. It explains why an empty
software subscription map is not proof of initially idle hardware.
- Old patch 3 becomes patches 5 and 6, with separate Fixes tags. Correct
the incremental ADVA X1 description: patch 4 already makes its zero
input selector return zero Hz rather than -EINVAL.
- Patches 4, 7 and 8 retain their v4 code and messages. Preserve Vadim's
Reviewed-by on the unchanged DCF correction only.
Validation of this revision:
- Reproduced v4's shared-PPS runtime race and SJA1105 pin side effect with
actual extracted functions, controlled scheduling and stubbed hardware.
- 100 removal/shared-PPS model runs; 100 runtime serialization runs, each
with four controlled interleavings; 100 SJA1105 runs, each with 14
chip/direction cases. All passed under ASan/UBSan.
- Eight local KUnit cases passed in x86_64 QEMU with KASAN, lockdep and
DEBUG_ATOMIC_SLEEP. These exercise real PTP register/unregister and
real sysfs stores with a test clock, not physical OCP/SJA1105 hardware.
- x86_64 and i386 allmodconfig and allyesconfig builds passed for the PTP
subtree and SJA1105 PTP object with W=1 and KCFLAGS=-Werror.
- SMA/DPLL tests cover 4,669 input combinations, 243 retained-mux rebind
states, ART accessors, disabled-input re-enable and X1 direction change.
- Twenty deliberately broken variants were rejected by runtime assertions.
The review fixtures are local validation material, not new upstream test
interfaces. No physical card or switch was tested for this revision.
The reports came from the public review thread. Codex assisted with the
code, regression tests and submission text; the commit messages identify
the reports and distinguish modeled tests from hardware observations.
Previous revision:
https://lore.kernel.org/r/20261122-timecard-common-v4-e0db4ab1aa-0-ahmadexp@gmail.com
Latest review reports:
https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org
https://lore.kernel.org/r/179548551472.3135.11972018356692852897@kernel.org
Ahmad Byagowi (8):
ptp: serialize sysfs requests with the ioctl paths
net: dsa: sja1105: leave the pin function unchanged on EXTTS disable
ptp: disable all timestamp channels after removing the user interfaces
ptp: ocp: handle hardware selectors and combined DPLL input routes
ptp: ocp: recover disabled SMA inputs when binding the driver
ptp: ocp: report zero frequency for disabled SMA inputs
ptp: ocp: correct the DCF output frequency
ptp: ocp: correct the ART 10 MHz input frequency
drivers/net/dsa/sja1105/sja1105_ptp.c | 8 ++--
drivers/ptp/ptp_chardev.c | 14 ++++---
drivers/ptp/ptp_ocp.c | 58 ++++++++++++++++++---------
drivers/ptp/ptp_sysfs.c | 9 +++++
4 files changed, 62 insertions(+), 27 deletions(-)
base-commit: 4392bb809812ac79449cd0cf1f5e00469ee102d1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH net v5 1/8] ptp: serialize sysfs requests with the ioctl paths
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
@ 2026-11-24 4:42 ` Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 2/8] net: dsa: sja1105: leave the pin function unchanged on EXTTS disable Ahmad Byagowi
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
The extts_enable, pps_enable and period sysfs stores call the driver's
enable callback without taking pincfg_mux. The corresponding ioctls and
pin configuration changes take that mutex, so sysfs requests can race
with them and with requests through the other sysfs attributes.
On ptp_ocp, PPS and EXTTS channel 5 share pps_req_map and a hardware
source. Concurrent read-modify-write updates can lose a subscription,
and an enable can overlap the register writes and IRQ drain of a
disable. The software subscription state can then disagree with the
hardware state even though both requests succeeded.
Take pincfg_mux around all three sysfs enable callbacks, just as the
ioctl paths do. Keep permission checks and request validation outside
the critical section, propagate callback errors, and return -ERESTARTSYS
if acquiring the mutex is interrupted. A mutex permits callbacks that
sleep, including ptp_ocp's synchronize_irq() on disable.
The Sashiko review identified the EXTTS/sysfs race while reviewing the
timestamp teardown fix. Inspection found the same missing serialization
in pps_enable and period. Codex assisted with the correction, tests and
changelog. Source-derived tests with controlled scheduling reproduce the
reported shared-PPS failure on the previous series and pass with this
fix. Local KUnit tests call the real sysfs stores under mutex contention
in QEMU with KASAN and lockdep. No physical hardware was tested.
Fixes: d94ba80ebbea ("ptp: Added a brand new class driver for ptp clocks.")
Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
- New prerequisite from the runtime-race review of v4 patch 1.
- Serialize EXTTS, PPS and PEROUT sysfs stores, not only EXTTS.
Testing: 100 controlled runtime suites with four interleavings each;
real-store mutex-contention KUnit cases under QEMU KASAN/lockdep; permission,
error and interrupted-lock model cases. Removing each lock independently
causes a runtime assertion failure. No physical hardware was used.
drivers/ptp/ptp_sysfs.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index 8e0e0aa09981..90fdddc1e6a7 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -60,7 +60,10 @@ static ssize_t extts_enable_store(struct device *dev,
if (req.extts.index >= ops->n_ext_ts)
goto out;
+ if (mutex_lock_interruptible(&ptp->pincfg_mux))
+ return -ERESTARTSYS;
err = ops->enable(ops, &req, enable ? 1 : 0);
+ mutex_unlock(&ptp->pincfg_mux);
if (err)
goto out;
@@ -130,7 +133,10 @@ static ssize_t period_store(struct device *dev,
goto out;
enable = req.perout.period.sec || req.perout.period.nsec;
+ if (mutex_lock_interruptible(&ptp->pincfg_mux))
+ return -ERESTARTSYS;
err = ops->enable(ops, &req, enable);
+ mutex_unlock(&ptp->pincfg_mux);
if (err)
goto out;
@@ -157,7 +163,10 @@ static ssize_t pps_enable_store(struct device *dev,
if (cnt != 1)
goto out;
+ if (mutex_lock_interruptible(&ptp->pincfg_mux))
+ return -ERESTARTSYS;
err = ops->enable(ops, &req, enable ? 1 : 0);
+ mutex_unlock(&ptp->pincfg_mux);
if (err)
goto out;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v5 2/8] net: dsa: sja1105: leave the pin function unchanged on EXTTS disable
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 1/8] ptp: serialize sysfs requests with the ioctl paths Ahmad Byagowi
@ 2026-11-24 4:42 ` Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 3/8] ptp: disable all timestamp channels after removing the user interfaces Ahmad Byagowi
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
sja1105_extts_enable() selects the EXTTS pin function even when disabling
timestamp capture. EXTTS and PEROUT share PTP_CLK, so disabling EXTTS
while the pin is an output changes it to an input and stops the periodic
output. This also makes the hardware function disagree with a retained
PTP_PF_PEROUT pin assignment.
Only select the EXTTS function when enabling timestamp capture. On
disable, clear extts_enabled and synchronously delete the polling timer
without reprogramming the pin. This also avoids attempting the
unsupported AVB_PARAMS dynamic configuration on SJA1105E/T when disabling
an already inactive EXTTS channel.
The Sashiko review found this side effect when reviewing a PTP core
change to disable every advertised timestamp channel during teardown.
Codex assisted with the correction, tests and changelog. Tests executing
the actual functions with stubbed configuration writes reproduce the
output-to-input change and pass with this fix, including repeated
disable, enable and error paths. No physical switch was tested.
Fixes: 747e5eb31d59 ("net: dsa: sja1105: configure the PTP_CLK pin as EXT_TS or PER_OUT")
Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
- New prerequisite from the SJA1105 side-effect review of v4 patch 1.
Testing: 100 actual-function suites with 14 chip/direction cases each,
repeated disable, enable and error paths; four x86_64/i386 PTP/SJA1105
build configurations with W=1 KCFLAGS=-Werror. Configuration writes are
stubbed. Restoring unconditional pin selection fails at runtime.
drivers/net/dsa/sja1105/sja1105_ptp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c
index 350f958dcb2a..da35805152e0 100644
--- a/drivers/net/dsa/sja1105/sja1105_ptp.c
+++ b/drivers/net/dsa/sja1105/sja1105_ptp.c
@@ -816,9 +816,11 @@ static int sja1105_extts_enable(struct sja1105_private *priv,
(extts->flags & PTP_EXTTS_EDGES) != PTP_EXTTS_EDGES)
return -EOPNOTSUPP;
- rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_EXTTS);
- if (rc)
- return rc;
+ if (on) {
+ rc = sja1105_change_ptp_clk_pin_func(priv, PTP_PF_EXTTS);
+ if (rc)
+ return rc;
+ }
priv->ptp_data.extts_enabled = on;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v5 3/8] ptp: disable all timestamp channels after removing the user interfaces
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 1/8] ptp: serialize sysfs requests with the ioctl paths Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 2/8] net: dsa: sja1105: leave the pin function unchanged on EXTTS disable Ahmad Byagowi
@ 2026-11-24 4:42 ` Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes Ahmad Byagowi
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
PTP_EXTTS_REQUEST and extts_enable can enable channels without assigning
a PTP_PF_EXTTS pin. ptp_disable_all_events() only visits assigned pins,
so those channels can still generate events after the clock is released.
ptp_ocp exposes six timestamp channels but only four SMA pin descriptors;
the internal GNSS and PHC timestamp sources do not need an SMA assignment.
Disable each advertised external timestamp channel, followed by the
existing PPS disable, after posix_clock_unregister() has removed sysfs
and drained active ioctls. Issue PTP_CLK_REQ_EXTTS requests directly for
timestamp channel indices. Do not use the pin-function helper or require
a pin assignment. Keep that helper for changes to actual pin configuration.
Remove ptp_ocp's preliminary timestamp-disable loop. It runs before the
user interfaces are removed and can race with an enable: the enable sets
pps_req_map, detach clears it and disables the source, then the enable
rearms the source. With shutdown delegated to the core, requests finish
before the final disables and IRQ drains. Keep the existing resource
cleanup for probe failures without a clock.
Do not skip the shared PPS source's register disable when the final
subscription map is empty. The map tracks software subscriptions, not
the hardware's initial state: ptp_ocp_register_ext() requests the IRQ
without resetting the source. An already active source must also be
masked and drained before releasing the clock. Preserve the shortcut
while another PPS or EXTTS subscription remains. The preceding sysfs
serialization fix prevents runtime enables from overlapping disables;
the SJA1105 prerequisite prevents an EXTTS disable from changing its pin.
Source-derived tests with stubbed MMIO and IRQ operations reproduce the
early-disable/map race and exercise an empty-map prearmed source. Core
unregister tests pass in QEMU with KASAN and lockdep. These are software
tests, not observations of a prearmed physical card.
The issue was reported by the Sashiko review. Codex assisted with the
code, tests and changelog in response to that report and Vadim's review.
Fixes: a60fc3294a37 ("ptp: rework ptp_clock_unregister() to disable events")
Fixes: 627366c51145 ("ptp: ocp: fix resource freeing order")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Link: https://lore.kernel.org/r/4e42134b-b017-4836-9772-9c1915b16e77@linux.dev
Link: https://lore.kernel.org/r/08537eb6-3f85-4a46-b3be-46796998eda4@linux.dev
Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
- Keep the v4 code and Vadim's direct channel-disable approach unchanged.
- Add sysfs serialization and SJA1105 prerequisites before this patch.
- Explain the empty-map shutdown independently of the now-fixed runtime
race, and distinguish modeled prearmed hardware from a physical test.
Testing: 100 removal/shared-PPS suite runs and all eight local PTP KUnit
cases passed. Seven cleanup mutations fail at runtime. No physical card
was used; the review-only fixture is not part of this patch.
drivers/ptp/ptp_chardev.c | 14 +++++++++-----
drivers/ptp/ptp_ocp.c | 17 ++---------------
2 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index f63b45f5ee6a..5835c01cddb4 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -53,11 +53,15 @@ void ptp_disable_all_events(struct ptp_clock *ptp)
unsigned int i;
mutex_lock(&ptp->pincfg_mux);
- /* Disable any pins that may raise EXTTS events */
- for (i = 0; i < info->n_pins; i++)
- if (info->pin_config[i].func == PTP_PF_EXTTS)
- ptp_disable_pinfunc(info, info->pin_config[i].func,
- info->pin_config[i].chan);
+ /* EXTTS requests do not require a pin assignment. */
+ for (i = 0; i < info->n_ext_ts; i++) {
+ struct ptp_clock_request req = {
+ .type = PTP_CLK_REQ_EXTTS,
+ .extts.index = i,
+ };
+
+ info->enable(info, &req, 0);
+ }
/* Disable the PPS event if the driver has PPS support */
if (info->pps) {
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 625a85b2dc7e..b16d36c3305f 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -2559,8 +2559,8 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
else
bp->pps_req_map &= ~req;
- /* if no state change, just return */
- if ((!!old_map ^ !!bp->pps_req_map) == 0)
+ /* Skip the register update while a subscription remains. */
+ if (old_map && bp->pps_req_map)
return 0;
}
@@ -5755,19 +5755,6 @@ ptp_ocp_detach(struct ptp_ocp *bp)
ptp_ocp_detach_sysfs(bp);
ptp_ocp_attr_group_del(bp);
timer_delete_sync(&bp->watchdog);
- /* Disable interrupts on all timestampers */
- if (bp->ts0)
- ptp_ocp_ts_enable(bp->ts0, 0, false);
- if (bp->ts1)
- ptp_ocp_ts_enable(bp->ts1, 0, false);
- if (bp->ts2)
- ptp_ocp_ts_enable(bp->ts2, 0, false);
- if (bp->ts3)
- ptp_ocp_ts_enable(bp->ts3, 0, false);
- if (bp->ts4)
- ptp_ocp_ts_enable(bp->ts4, 0, false);
- if (bp->pps)
- ptp_ocp_ts_enable(bp->pps, ~0, false);
if (bp->ptp)
ptp_clock_unregister(bp->ptp);
kfree(bp->ptp_info.pin_config);
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
` (2 preceding siblings ...)
2026-11-24 4:42 ` [PATCH net v5 3/8] ptp: disable all timestamp channels after removing the user interfaces Ahmad Byagowi
@ 2026-11-24 4:42 ` Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 5/8] ptp: ocp: recover disabled SMA inputs when binding the driver Ahmad Byagowi
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
The selector table index is not the hardware selector value. Passing the
index to the SMA setter can select unrelated signals. Use the table
value, as the sysfs path already does, and mask the direction enable bit
before looking up the frequency.
Inputs can feed several destinations. For example, IN: TS1 TS2 produces
selector 0x000c, which is not an individual table entry. An exact-match
frequency lookup fails with -EINVAL, preventing the DPLL core from
reading the old frequency before a later frequency change. The error
also propagates through the DPLL pin dump.
For input combinations, report a known frequency only when the selected
frequency-bearing destinations agree. Timestamp and counter destinations
do not constrain it. Report zero when there is no known frequency, when
destinations disagree, or when unknown selector bits remain. This uses
the same zero-frequency representation as individual timestamp routes.
Keep the exact-match requirement for output selectors.
Source-derived tests reproduce the selector and combined-input failures
using stubbed MMIO and the DPLL core get-before-set function. They pass
with the fix under ASan/UBSan. No physical card was tested.
The issues were reported by the Sashiko review. Codex assisted with the
code, tests and changelog in response to those reports.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Link: https://lore.kernel.org/r/179538006772.3135.15875996486888374193@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
- Renumbered from v4 patch 2; code and commit message unchanged.
Testing: 4,669 input-route combinations and X1 direction-change recovery.
The boundary test also confirms disabled X1 reads zero Hz and re-enables
PPS at this point in the series, before patches 5 and 6.
drivers/ptp/ptp_ocp.c | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index b16d36c3305f..df1a428eb2fe 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -5869,7 +5869,8 @@ static int ptp_ocp_dpll_frequency_set(const struct dpll_pin *pin,
tbl = bp->sma_op->tbl[sma->mode];
for (i = 0; tbl[i].name; i++)
if (tbl[i].frequency == frequency)
- return ptp_ocp_sma_store_val(bp, i, sma->mode, sma_nr + 1);
+ return ptp_ocp_sma_store_val(bp, tbl[i].value,
+ sma->mode, sma_nr + 1);
return -EINVAL;
}
@@ -5887,6 +5888,7 @@ static int ptp_ocp_dpll_frequency_get(const struct dpll_pin *pin,
int i;
val = bp->sma_op->get(bp, sma_nr + 1);
+ val &= SMA_SELECT_MASK;
tbl = bp->sma_op->tbl[sma->mode];
for (i = 0; tbl[i].name; i++)
if (val == tbl[i].value) {
@@ -5894,7 +5896,28 @@ static int ptp_ocp_dpll_frequency_get(const struct dpll_pin *pin,
return 0;
}
- return -EINVAL;
+ if (sma->mode == SMA_MODE_OUT)
+ return -EINVAL;
+
+ /* Inputs can feed several destinations, including timestampers. */
+ *frequency = 0;
+ for (i = 0; tbl[i].name; i++) {
+ if (!(val & tbl[i].value))
+ continue;
+ val &= ~tbl[i].value;
+ if (!tbl[i].frequency)
+ continue;
+ if (*frequency && *frequency != tbl[i].frequency) {
+ *frequency = 0;
+ return 0;
+ }
+ *frequency = tbl[i].frequency;
+ }
+ /* Unknown destinations do not establish a frequency either. */
+ if (val)
+ *frequency = 0;
+
+ return 0;
}
static const struct dpll_device_ops dpll_ops = {
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v5 5/8] ptp: ocp: recover disabled SMA inputs when binding the driver
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
` (3 preceding siblings ...)
2026-11-24 4:42 ` [PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes Ahmad Byagowi
@ 2026-11-24 4:42 ` Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 6/8] ptp: ocp: report zero frequency for disabled SMA inputs Ahmad Byagowi
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
Disabling an SMA input clears its mux field and sets the software-only
disabled flag. After unbind and rebind, the hardware retains the cleared
field but the newly allocated driver state loses the flag. Direction
initialization can then report an output function for a connector with
neither buffer enabled. This happens independently of DPLL support.
Recover the disabled state from the mux enable bits when initializing
direction-configurable FB-style connectors, including ADVA and ADVA X1.
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 fixed-direction firmware's interpretation,
since it does not provide these enable bits. Keep this initialization
fix separate from the DPLL frequency-reporting correction so it can be
backported to kernels predating DPLL support.
Source-derived tests reproduce the lost state with retained mux values
and fresh driver state. The corrected initialization passes 243 modeled
FB/ADVA/X1 rebind states with stubbed MMIO under ASan/UBSan, without mux
writes. No physical rebind was performed.
The issue and missing earlier Fixes tag were reported by Sashiko review.
Codex assisted with the tests, correction and changelog.
Fixes: b2c4f0ac53f3 ("ptp: ocp: Add ability to disable input selectors.")
Link: https://lore.kernel.org/r/179538006912.3135.16971430532149423594@kernel.org
Link: https://lore.kernel.org/r/179548551472.3135.11972018356692852897@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
- Split initialization from v4 patch 3's DPLL frequency substitution.
- Use b2c4f0ac53f3 as the earlier Fixes tag for the lost rebind state.
- Describe the DPLL-independent behavior and backport scope.
Testing: this patch alone applies to the net base and passes 243 modeled
initialization states, without DPLL calls or mux writes. The unmodified
base reproduces the lost state. Older trees may need context adjustments.
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 df1a428eb2fe..c4c9d3501edf 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;
+ }
}
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v5 6/8] ptp: ocp: report zero frequency for disabled SMA inputs
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
` (4 preceding siblings ...)
2026-11-24 4:42 ` [PATCH net v5 5/8] ptp: ocp: recover disabled SMA inputs when binding the driver Ahmad Byagowi
@ 2026-11-24 4:42 ` Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 7/8] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 8/8] ptp: ocp: correct the ART 10 MHz input frequency Ahmad Byagowi
7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
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.
Substitute SMA_DISABLE for disabled inputs before the frequency lookup,
as the sysfs path already does, so the None entry reports zero Hz.
The preceding initialization fix also recovers this state on rebind.
For ADVA X1, the earlier combined-input fix already returns zero Hz for
a zero input selector and permits later frequency changes. This patch
does not fix another X1 -EINVAL failure; it uses the explicit None entry
without changing that result. X1's lost state across rebind is addressed
separately by the initialization fix.
Source-derived tests with stubbed MMIO and the DPLL core get-before-set
function reproduce the FB/ADVA disabled-input error and pass under
ASan/UBSan. No physical card was tested.
The issue and inaccurate incremental description were reported by
Sashiko review. Codex assisted with the correction, tests and changelog.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Link: https://lore.kernel.org/r/179548551472.3135.11972018356692852897@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
- Split the DPLL substitution from v4 patch 3's initialization fix.
- Retain the DPLL introduction Fixes tag for this part only.
- Correct the incremental X1 description: patch 4 already handles its
zero selector; the additional zero-as-10-MHz correction is for FB/ADVA.
Testing: disabled-input get/compare/set and re-enable, including the X1
series boundary. Stubbed MMIO only, no physical card test.
drivers/ptp/ptp_ocp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index c4c9d3501edf..e27abe2c24c7 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -5897,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) {
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v5 7/8] ptp: ocp: correct the DCF output frequency
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
` (5 preceding siblings ...)
2026-11-24 4:42 ` [PATCH net v5 6/8] ptp: ocp: report zero frequency for disabled SMA inputs Ahmad Byagowi
@ 2026-11-24 4:42 ` Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 8/8] ptp: ocp: correct the ART 10 MHz input frequency Ahmad Byagowi
7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
The output selector table uses 77000 Hz for DCF, whereas the input table
and the DPLL supported frequency list use 77500 Hz. A request for the
advertised DCF77 frequency consequently fails on an output, and reading
that output reports a frequency outside its advertised set.
Use 77500 Hz for the DCF output selector as well.
Source-derived set/readback tests with stubbed MMIO fail at 77500 Hz
with the old entry and pass with the correction under ASan/UBSan.
No physical card was tested.
The issue was reported by the Sashiko review. Codex assisted with this
table correction, its regression test and the changelog.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
- Renumbered from v4 patch 4; code and commit message unchanged.
- Preserve Vadim's Reviewed-by on this unchanged correction.
Testing: actual DPLL set/readback for 77500 Hz passes with stubbed MMIO;
restoring 77000 Hz fails at runtime.
drivers/ptp/ptp_ocp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index e27abe2c24c7..821ecd1a13c8 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1373,7 +1373,7 @@ static const struct ocp_selector ptp_ocp_sma_out[] = {
{ .name = "GNSS1", .value = 0x0004, .frequency = 1 },
{ .name = "GNSS2", .value = 0x0008, .frequency = 1 },
{ .name = "IRIG", .value = 0x0010, .frequency = 10000 },
- { .name = "DCF", .value = 0x0020, .frequency = 77000 },
+ { .name = "DCF", .value = 0x0020, .frequency = 77500 },
{ .name = "GEN1", .value = 0x0040 },
{ .name = "GEN2", .value = 0x0080 },
{ .name = "GEN3", .value = 0x0100 },
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH net v5 8/8] ptp: ocp: correct the ART 10 MHz input frequency
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
` (6 preceding siblings ...)
2026-11-24 4:42 ` [PATCH net v5 7/8] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
@ 2026-11-24 4:42 ` Ahmad Byagowi
7 siblings, 0 replies; 9+ messages in thread
From: Ahmad Byagowi @ 2026-11-24 4:42 UTC (permalink / raw)
To: netdev
Cc: andrew, arkadiusz.kubalewski, arnd, davem, edumazet, jiri,
john.stultz, jonathan.lemon, kuba, linux-kernel, olteanv, pabeni,
richardcochran, rmk+kernel, vadim.fedorenko
The ART input selector named 10Mhz has a frequency of 1000000 Hz instead
of 10000000 Hz. ART pins advertise 10 MHz, not 1 MHz. A request for the
advertised value passes the DPLL core's supported-frequency check but
matches no input selector, so frequency_set returns -EINVAL. Reading
the default ART input selector 0x08 reports the unadvertised 1 MHz value.
Use 10000000 Hz for the ART input selector, matching the advertised
frequency and the corresponding ART output entry.
Tests using the actual ART accessors, stubbed registers and DPLL core
frequency validation reproduce both failures and pass with the fix
under ASan/UBSan. No physical ART card was tested.
The issue was reported by the Sashiko review. Codex assisted with the
table correction, actual-accessor regression tests and the changelog.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179538006772.3135.15875996486888374193@kernel.org
Link: https://lore.kernel.org/r/179538007070.3135.8275620503580456948@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
Changes in v5:
- Renumbered from v4 patch 5; code and commit message unchanged.
Testing: actual ART accessors and DPLL get-before-set validate 10000000 Hz,
reject 1000000 Hz, and check the fixed-pin default. Restoring the old
frequency fails at runtime. No physical ART card was used.
drivers/ptp/ptp_ocp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 821ecd1a13c8..93923d5a2992 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1385,7 +1385,7 @@ static const struct ocp_selector ptp_ocp_sma_out[] = {
static const struct ocp_selector ptp_ocp_art_sma_in[] = {
{ .name = "PPS1", .value = 0x0001, .frequency = 1 },
- { .name = "10Mhz", .value = 0x0008, .frequency = 1000000 },
+ { .name = "10Mhz", .value = 0x0008, .frequency = 10000000 },
{ }
};
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-11-24 4:42 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 4:42 [PATCH net v5 0/8] ptp: fix request serialization, teardown and SMA reporting Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 1/8] ptp: serialize sysfs requests with the ioctl paths Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 2/8] net: dsa: sja1105: leave the pin function unchanged on EXTTS disable Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 3/8] ptp: disable all timestamp channels after removing the user interfaces Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 4/8] ptp: ocp: handle hardware selectors and combined DPLL input routes Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 5/8] ptp: ocp: recover disabled SMA inputs when binding the driver Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 6/8] ptp: ocp: report zero frequency for disabled SMA inputs Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 7/8] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-24 4:42 ` [PATCH net v5 8/8] ptp: ocp: correct the ART 10 MHz input frequency Ahmad Byagowi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox