* [PATCH net v2 1/4] ptp: ocp: prevent timestamp rearming during detach
2026-11-19 21:19 [PATCH net v2 0/4] ptp: ocp: fix timestamp teardown and DPLL routing Ahmad Byagowi
@ 2026-11-19 21:19 ` Ahmad Byagowi
2026-11-19 22:23 ` Vadim Fedorenko
2026-11-19 21:19 ` [PATCH net v2 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations Ahmad Byagowi
` (3 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-19 21:19 UTC (permalink / raw)
To: netdev, vadim.fedorenko, richardcochran
Cc: andrew+netdev, davem, edumazet, kuba, pabeni
Detach disables timestamp interrupts before unregistering the PTP clock.
Until the POSIX clock is unregistered, an ioctl can rearm a channel
after that disable. The clock can then be released while the timestamp
IRQ is still registered. The core cleanup does not necessarily disable
the channel: EXTTS requests do not require a PTP_PF_EXTTS pin assignment.
Use the existing device spinlock to serialize the stopping check, PPS
subscription updates and timestamp MMIO. Set ts_stopping under that lock
before detach disables the channels, so an enable already in progress
finishes first and later enables fail with -ENODEV. Keep disables
available for PTP core cleanup.
Flush the interrupt mask writes under the lock, then drop the lock and
restore IRQ flags before pci_irq_vector(), which takes the MSI descriptor
mutex, and synchronize_irq(), which may sleep. During teardown, bypass
the PPS no-state-change shortcut: a concurrent disable
may have cleared pps_req_map and dropped the lock without yet draining
its IRQ. Detach must still disable and drain that channel before
ptp_clock_unregister().
Reported by the netdev Sashiko AI review, then checked against the PTP
and POSIX-clock paths. The source-derived userspace harness reproduces
rearming with the old source. With this fix it rejects late enables,
serializes in-flight enables, drains a mocked active IRQ and covers a
disable paused after unlock but before IRQ synchronization. It checks
that MMIO is locked and vector lookup and IRQ synchronization run unlocked
with IRQ flags restored. Shared PPS/EXTTS subscriptions and all six
channels pass with ASan/UBSan. This is not an in-kernel UAF, lockdep or
physical-card test.
Codex revised the code, tests and changelog from Vadim's review, at the
request to check the spinlock approach and rerun the removal-race tests.
Fixes: 627366c51145 ("ptp: ocp: fix resource freeing order")
Suggested-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Link: https://lore.kernel.org/r/ad6883e5-c103-4f82-8040-e5463477ca10@linux.dev
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
drivers/ptp/ptp_ocp.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 625a85b2dc..4c98558e96 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -367,6 +367,8 @@ struct ptp_ocp {
struct pci_dev *pdev;
struct device dev;
spinlock_t lock;
+ /* Protected by lock; blocks timestamp arming during teardown. */
+ bool ts_stopping;
struct ocp_reg __iomem *reg;
struct tod_reg __iomem *tod;
struct pps_reg __iomem *pps_to_ext;
@@ -2550,6 +2552,15 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
struct ptp_ocp_ext_src *ext = priv;
struct ts_reg __iomem *reg = ext->mem;
struct ptp_ocp *bp = ext->bp;
+ unsigned long flags;
+ bool need_sync = false;
+ int err = 0;
+
+ spin_lock_irqsave(&bp->lock, flags);
+ if (enable && bp->ts_stopping) {
+ err = -ENODEV;
+ goto out;
+ }
if (ext == bp->pps) {
u32 old_map = bp->pps_req_map;
@@ -2559,9 +2570,9 @@ 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)
- return 0;
+ /* Teardown must drain IRQs even if another disable cleared the map. */
+ if ((!!old_map ^ !!bp->pps_req_map) == 0 && !bp->ts_stopping)
+ goto out;
}
if (enable) {
@@ -2569,16 +2580,21 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
iowrite32(1, ®->intr_mask);
iowrite32(1, ®->intr);
} else {
- int irq_vec = pci_irq_vector(bp->pdev, ext->irq_vec);
-
iowrite32(0, ®->intr_mask);
iowrite32(0, ®->enable);
ioread32(®->intr_mask);
+ need_sync = true;
+ }
+
+out:
+ spin_unlock_irqrestore(&bp->lock, flags);
+ if (need_sync) {
+ int irq_vec = pci_irq_vector(bp->pdev, ext->irq_vec);
+
if (irq_vec > 0)
synchronize_irq(irq_vec);
}
-
- return 0;
+ return err;
}
static void
@@ -5749,12 +5765,17 @@ ptp_ocp_detach_sysfs(struct ptp_ocp *bp)
static void
ptp_ocp_detach(struct ptp_ocp *bp)
{
+ unsigned long flags;
int i;
ptp_ocp_debugfs_remove_device(bp);
ptp_ocp_detach_sysfs(bp);
ptp_ocp_attr_group_del(bp);
timer_delete_sync(&bp->watchdog);
+ /* Drain in-flight enables and prevent rearming before unregister. */
+ spin_lock_irqsave(&bp->lock, flags);
+ bp->ts_stopping = true;
+ spin_unlock_irqrestore(&bp->lock, flags);
/* Disable interrupts on all timestampers */
if (bp->ts0)
ptp_ocp_ts_enable(bp->ts0, 0, false);
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH net v2 1/4] ptp: ocp: prevent timestamp rearming during detach
2026-11-19 21:19 ` [PATCH net v2 1/4] ptp: ocp: prevent timestamp rearming during detach Ahmad Byagowi
@ 2026-11-19 22:23 ` Vadim Fedorenko
2026-11-19 23:46 ` Ahmad Byagowi
0 siblings, 1 reply; 17+ messages in thread
From: Vadim Fedorenko @ 2026-11-19 22:23 UTC (permalink / raw)
To: Ahmad Byagowi, netdev, richardcochran
Cc: andrew+netdev, davem, edumazet, kuba, pabeni
On 19/11/2026 21:19, Ahmad Byagowi wrote:
> Detach disables timestamp interrupts before unregistering the PTP clock.
> Until the POSIX clock is unregistered, an ioctl can rearm a channel
> after that disable. The clock can then be released while the timestamp
> IRQ is still registered. The core cleanup does not necessarily disable
> the channel: EXTTS requests do not require a PTP_PF_EXTTS pin assignment.
I think we have to fix it other way. Basically, there are several ways
to enable EXTTS in ptp_ocp:
1. Via sma* attributes in ptp_ocp sysfs entry
2. Via pin name sysfs entry under ptp device
3. Via PTP_PIN_SETFUNC ioctl
4. Via PTP_EXTTS_REQUEST ioctl
On teardown, sma* attributes (1) are removed before disabling
interrupts. Options 2 and 3 set PTP_PF_EXTTS function and reverted
during ptp_clock_unregister(). Only option 4 does not set PTP_PF_EXTTS
function to pin, because it calls ops->enable() callback directly.
To fix it properly enable() callback has to set PTP_PF_EXTTS function
if it's requested. That will make ptp_disable_all_events() do exactly
what is has to do - clear all events generators of ptp device after
removing ioctl interface.
>
> Use the existing device spinlock to serialize the stopping check, PPS
> subscription updates and timestamp MMIO. Set ts_stopping under that lock
> before detach disables the channels, so an enable already in progress
> finishes first and later enables fail with -ENODEV. Keep disables
> available for PTP core cleanup.
>
> Flush the interrupt mask writes under the lock, then drop the lock and
> restore IRQ flags before pci_irq_vector(), which takes the MSI descriptor
> mutex, and synchronize_irq(), which may sleep. During teardown, bypass
> the PPS no-state-change shortcut: a concurrent disable
> may have cleared pps_req_map and dropped the lock without yet draining
> its IRQ. Detach must still disable and drain that channel before
> ptp_clock_unregister().
>
> Reported by the netdev Sashiko AI review, then checked against the PTP
> and POSIX-clock paths. The source-derived userspace harness reproduces
> rearming with the old source. With this fix it rejects late enables,
> serializes in-flight enables, drains a mocked active IRQ and covers a
> disable paused after unlock but before IRQ synchronization. It checks
> that MMIO is locked and vector lookup and IRQ synchronization run unlocked
> with IRQ flags restored. Shared PPS/EXTTS subscriptions and all six
> channels pass with ASan/UBSan. This is not an in-kernel UAF, lockdep or
> physical-card test.
>
> Codex revised the code, tests and changelog from Vadim's review, at the
> request to check the spinlock approach and rerun the removal-race tests.
>
> Fixes: 627366c51145 ("ptp: ocp: fix resource freeing order")
> Suggested-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
> Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
> Link: https://lore.kernel.org/r/ad6883e5-c103-4f82-8040-e5463477ca10@linux.dev
> Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
> ---
> drivers/ptp/ptp_ocp.c | 35 ++++++++++++++++++++++++++++-------
> 1 file changed, 28 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 625a85b2dc..4c98558e96 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -367,6 +367,8 @@ struct ptp_ocp {
> struct pci_dev *pdev;
> struct device dev;
> spinlock_t lock;
> + /* Protected by lock; blocks timestamp arming during teardown. */
> + bool ts_stopping;
> struct ocp_reg __iomem *reg;
> struct tod_reg __iomem *tod;
> struct pps_reg __iomem *pps_to_ext;
> @@ -2550,6 +2552,15 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
> struct ptp_ocp_ext_src *ext = priv;
> struct ts_reg __iomem *reg = ext->mem;
> struct ptp_ocp *bp = ext->bp;
> + unsigned long flags;
> + bool need_sync = false;
> + int err = 0;
> +
> + spin_lock_irqsave(&bp->lock, flags);
> + if (enable && bp->ts_stopping) {
> + err = -ENODEV;
> + goto out;
> + }
>
> if (ext == bp->pps) {
> u32 old_map = bp->pps_req_map;
> @@ -2559,9 +2570,9 @@ 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)
> - return 0;
> + /* Teardown must drain IRQs even if another disable cleared the map. */
there was no need of this in the previous patch, why do we need it now?
> + if ((!!old_map ^ !!bp->pps_req_map) == 0 && !bp->ts_stopping)
> + goto out;
> }
>
> if (enable) {
> @@ -2569,16 +2580,21 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
> iowrite32(1, ®->intr_mask);
> iowrite32(1, ®->intr);
> } else {
> - int irq_vec = pci_irq_vector(bp->pdev, ext->irq_vec);
> -
> iowrite32(0, ®->intr_mask);
> iowrite32(0, ®->enable);
> ioread32(®->intr_mask);
> + need_sync = true;
> + }
> +
> +out:
> + spin_unlock_irqrestore(&bp->lock, flags);
> + if (need_sync) {
> + int irq_vec = pci_irq_vector(bp->pdev, ext->irq_vec);
> +
> if (irq_vec > 0)
> synchronize_irq(irq_vec);
> }
> -
> - return 0;
> + return err;
> }
>
> static void
> @@ -5749,12 +5765,17 @@ ptp_ocp_detach_sysfs(struct ptp_ocp *bp)
> static void
> ptp_ocp_detach(struct ptp_ocp *bp)
> {
> + unsigned long flags;
> int i;
>
> ptp_ocp_debugfs_remove_device(bp);
> ptp_ocp_detach_sysfs(bp);
> ptp_ocp_attr_group_del(bp);
> timer_delete_sync(&bp->watchdog);
> + /* Drain in-flight enables and prevent rearming before unregister. */
> + spin_lock_irqsave(&bp->lock, flags);
> + bp->ts_stopping = true;
> + spin_unlock_irqrestore(&bp->lock, flags);
> /* Disable interrupts on all timestampers */
> if (bp->ts0)
> ptp_ocp_ts_enable(bp->ts0, 0, false);
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH net v2 1/4] ptp: ocp: prevent timestamp rearming during detach
2026-11-19 22:23 ` Vadim Fedorenko
@ 2026-11-19 23:46 ` Ahmad Byagowi
2026-11-20 19:31 ` Vadim Fedorenko
0 siblings, 1 reply; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-19 23:46 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: netdev, Richard Cochran, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On Thu, 19 Nov 2026 at 22:23 UTC, Vadim Fedorenko wrote:
> enable() callback has to set PTP_PF_EXTTS function
Thanks. I tested the cleanup path. Recording an assignment makes the core
disable that channel, but ptp_ocp exposes six timestamp channels and only
four SMA descriptors. TS0 is the internal GNSS source and TS5 is the PHC
source. All six can be enabled without pin assignments. Four descriptors
cannot record that state without rejecting requests or changing the pin
interface. extts_enable sysfs also reaches enable() without an assignment.
Would you and Richard prefer disabling all n_ext_ts channels in
ptp_disable_all_events(), followed by the existing PPS disable? That keeps
cleanup after posix_clock_unregister(), without inventing pin assignments.
I have prepared and tested that alternative locally, not posted it yet.
I also removed ptp_ocp's preliminary disable loop. Otherwise it can clear
pps_req_map while an in-flight enable subsequently rearms the hardware.
An overlapping sysfs/ioctl request can likewise leave an empty map with
the source enabled, so the final disable now always masks and drains an
empty PPS map. The shortcut remains while another subscription is active.
> why do we need it now?
The v2 teardown exception covered a disable that had cleared the map and
dropped the spinlock but had not yet completed synchronize_irq(). The
previous mutex version held its lock through the IRQ drain. This local
revision removes the stopping flag and its special-case condition: core
cleanup runs after active requests finish, and an empty map is disabled
and drained regardless of its prior value.
The source-derived ASan/UBSan removal/shared-PPS tests pass 100 runs, and
seven deliberate regressions fail assertions. Five KUnit cases using real
PTP register/unregister pass in QEMU with KASAN and lockdep; the old core
fails all five. The KUnit callback models events, and the source-derived
tests model MMIO/IRQs. Neither is a physical Time Card removal test.
I have preserved your Reviewed-by tags on the other three unchanged fixes.
Thank you for reviewing them.
Ahmad
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net v2 1/4] ptp: ocp: prevent timestamp rearming during detach
2026-11-19 23:46 ` Ahmad Byagowi
@ 2026-11-20 19:31 ` Vadim Fedorenko
2026-11-20 21:21 ` Ahmad Byagowi
0 siblings, 1 reply; 17+ messages in thread
From: Vadim Fedorenko @ 2026-11-20 19:31 UTC (permalink / raw)
To: Ahmad Byagowi
Cc: netdev, Richard Cochran, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On 19/11/2026 23:46, Ahmad Byagowi wrote:
> On Thu, 19 Nov 2026 at 22:23 UTC, Vadim Fedorenko wrote:
>> enable() callback has to set PTP_PF_EXTTS function
>
> Thanks. I tested the cleanup path. Recording an assignment makes the core
> disable that channel, but ptp_ocp exposes six timestamp channels and only
> four SMA descriptors. TS0 is the internal GNSS source and TS5 is the PHC
> source. All six can be enabled without pin assignments. Four descriptors
> cannot record that state without rejecting requests or changing the pin
> interface. extts_enable sysfs also reaches enable() without an assignment.
Fair point. Pins are pins, time stampers are time stampers. We have to
disable things which may trigger interrupts, the time stampers.
> Would you and Richard prefer disabling all n_ext_ts channels in
> ptp_disable_all_events(), followed by the existing PPS disable? That keeps
> cleanup after posix_clock_unregister(), without inventing pin assignments.
> I have prepared and tested that alternative locally, not posted it yet.
Yes, it's better to make correct core PTP cleanup function.
>
> I also removed ptp_ocp's preliminary disable loop. Otherwise it can clear
> pps_req_map while an in-flight enable subsequently rearms the hardware.
> An overlapping sysfs/ioctl request can likewise leave an empty map with
> the source enabled, so the final disable now always masks and drains an
> empty PPS map. The shortcut remains while another subscription is active.
>
>> why do we need it now?
>
> The v2 teardown exception covered a disable that had cleared the map and
> dropped the spinlock but had not yet completed synchronize_irq(). The
> previous mutex version held its lock through the IRQ drain. This local
> revision removes the stopping flag and its special-case condition: core
> cleanup runs after active requests finish, and an empty map is disabled
> and drained regardless of its prior value.
Could you please keep more context while quoting? It's really hard to
follow the conversation otherwise
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net v2 1/4] ptp: ocp: prevent timestamp rearming during detach
2026-11-20 19:31 ` Vadim Fedorenko
@ 2026-11-20 21:21 ` Ahmad Byagowi
0 siblings, 0 replies; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-20 21:21 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: netdev, Richard Cochran, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On Fri, 20 Nov 2026 at 19:31 UTC, Vadim Fedorenko wrote:
> On 19/11/2026 23:46, Ahmad Byagowi wrote:
>> On Thu, 19 Nov 2026 at 22:23 UTC, Vadim Fedorenko wrote:
>>> enable() callback has to set PTP_PF_EXTTS function
>>
>> Thanks. I tested the cleanup path. Recording an assignment makes the core
>> disable that channel, but ptp_ocp exposes six timestamp channels and only
>> four SMA descriptors. TS0 is the internal GNSS source and TS5 is the PHC
>> source. All six can be enabled without pin assignments. Four descriptors
>> cannot record that state without rejecting requests or changing the pin
>> interface. extts_enable sysfs also reaches enable() without an assignment.
>
> Fair point. Pins are pins, time stampers are time stampers. We have to
> disable things which may trigger interrupts, the time stampers.
>
>> Would you and Richard prefer disabling all n_ext_ts channels in
>> ptp_disable_all_events(), followed by the existing PPS disable? That keeps
>> cleanup after posix_clock_unregister(), without inventing pin assignments.
>> I have prepared and tested that alternative locally, not posted it yet.
>
> Yes, it's better to make correct core PTP cleanup function.
Thanks. V3 follows that direction: disable all n_ext_ts channels in
ptp_disable_all_events(), followed by the existing PPS disable. Pin
descriptors and SMA routing stay unchanged. The driver's preliminary
timestamp-disable loop is removed, so final shutdown runs after sysfs
callbacks and active ioctls have finished, while the clock is still alive.
You also wrote:
>> I also removed ptp_ocp's preliminary disable loop. Otherwise it can clear
>> pps_req_map while an in-flight enable subsequently rearms the hardware.
>> An overlapping sysfs/ioctl request can likewise leave an empty map with
>> the source enabled, so the final disable now always masks and drains an
>> empty PPS map. The shortcut remains while another subscription is active.
>>
>>> why do we need it now?
>>
>> The v2 teardown exception covered a disable that had cleared the map and
>> dropped the spinlock but had not yet completed synchronize_irq(). The
>> previous mutex version held its lock through the IRQ drain. This local
>> revision removes the stopping flag and its special-case condition: core
>> cleanup runs after active requests finish, and an empty map is disabled
>> and drained regardless of its prior value.
>
> Could you please keep more context while quoting? It's really hard to
> follow the conversation otherwise
Sorry, I trimmed the original question too far. Here is the code and the
full question from your 19 November review:
>> - /* if no state change, just return */
>> - if ((!!old_map ^ !!bp->pps_req_map) == 0)
>> - return 0;
>> + /* Teardown must drain IRQs even if another disable cleared the map. */
>
> there was no need of this in the previous patch, why do we need it now?
>
>> + if ((!!old_map ^ !!bp->pps_req_map) == 0 && !bp->ts_stopping)
>> + goto out;
In v1, the mutex stayed held through synchronize_irq(). In v2, the
spinlock had to be released before that sleeping operation. Another
disable could therefore observe an empty subscription map while the first
disable still had an IRQ to drain. The ts_stopping exception made detach
drain it too, instead of returning solely because the map was unchanged.
V3 removes that flag and the added spinlock section. After user interfaces
are removed and their active operations have drained, core cleanup disables
each channel. In ptp_ocp_ts_enable(), the shortcut becomes:
if (old_map && bp->pps_req_map)
return 0;
This retains the shared source while a PPS or EXTTS subscriber remains.
An empty map always takes the mask/disable/readback/synchronize_irq path.
That also handles an earlier overlapping sysfs enable and ioctl disable
which left the map empty but the hardware enabled. This final shutdown
change is not a claim to serialize every normal-operation sysfs/ioctl race.
The refreshed source-derived removal/shared-PPS tests pass 100 runs and
reject all seven deliberate regressions. The routing fixes are unchanged
and retain your Reviewed-by tags. I have posted the signed four-patch
v3 series to net in a separate thread:
https://lore.kernel.org/r/20261120-timecard-common-v3-33316bf475-0-ahmadexp@gmail.com
The cover links this discussion and explains replacement of the older
pending series. Thank you for reviewing the changes.
Ahmad
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net v2 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations
2026-11-19 21:19 [PATCH net v2 0/4] ptp: ocp: fix timestamp teardown and DPLL routing Ahmad Byagowi
2026-11-19 21:19 ` [PATCH net v2 1/4] ptp: ocp: prevent timestamp rearming during detach Ahmad Byagowi
@ 2026-11-19 21:19 ` Ahmad Byagowi
2026-11-19 22:23 ` Vadim Fedorenko
2026-11-23 21:49 ` netdev-bot+sashiko
2026-11-19 21:19 ` [PATCH net v2 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL Ahmad Byagowi
` (2 subsequent siblings)
4 siblings, 2 replies; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-19 21:19 UTC (permalink / raw)
To: netdev, vadim.fedorenko, richardcochran
Cc: andrew+netdev, arkadiusz.kubalewski, davem, edumazet, jiri, kuba,
pabeni
The selector table index is not the hardware selector value. Passing the
index to the SMA setter can select unrelated signals, or fail on ART.
Use the table value, as the sysfs path already does.
Mask the direction enable bit before the frequency lookup. Otherwise an
enabled, direction-configurable pin has no matching table entry and its
DPLL get or dump fails. Apply both corrections to all board variants.
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.
The driver object builds on current net with W=1 and KCFLAGS=-Werror. No
physical card was tested.
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.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
drivers/ptp/ptp_ocp.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 4c98558e96..f1f97c1fa0 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -5903,7 +5903,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;
}
@@ -5921,6 +5922,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) {
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH net v2 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations
2026-11-19 21:19 ` [PATCH net v2 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations Ahmad Byagowi
@ 2026-11-19 22:23 ` Vadim Fedorenko
2026-11-23 21:49 ` netdev-bot+sashiko
1 sibling, 0 replies; 17+ messages in thread
From: Vadim Fedorenko @ 2026-11-19 22:23 UTC (permalink / raw)
To: Ahmad Byagowi, netdev, richardcochran
Cc: andrew+netdev, arkadiusz.kubalewski, davem, edumazet, jiri, kuba,
pabeni
On 19/11/2026 21:19, Ahmad Byagowi wrote:
> The selector table index is not the hardware selector value. Passing the
> index to the SMA setter can select unrelated signals, or fail on ART.
> Use the table value, as the sysfs path already does.
>
> Mask the direction enable bit before the frequency lookup. Otherwise an
> enabled, direction-configurable pin has no matching table entry and its
> DPLL get or dump fails. Apply both corrections to all board variants.
>
> 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.
> The driver object builds on current net with W=1 and KCFLAGS=-Werror. No
> physical card was tested.
>
> 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.
>
> Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
> Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
> Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
> ---
> drivers/ptp/ptp_ocp.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 4c98558e96..f1f97c1fa0 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -5903,7 +5903,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;
> }
>
> @@ -5921,6 +5922,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) {
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH net v2 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations
2026-11-19 21:19 ` [PATCH net v2 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations Ahmad Byagowi
2026-11-19 22:23 ` Vadim Fedorenko
@ 2026-11-23 21:49 ` netdev-bot+sashiko
2026-11-23 21:58 ` Ahmad Byagowi
1 sibling, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 21:49 UTC (permalink / raw)
To: ahmadexp
Cc: netdev, vadim.fedorenko, richardcochran, andrew+netdev,
arkadiusz.kubalewski, davem, edumazet, jiri, kuba, pabeni
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 0 · Low: 0
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).
- [High] On ADVA TimeCard X1 boards (PCI_DEVICE_DATA(ADVA, TIMECARD_X1)
-> ocp_adva_x1_sma_op), DPLL get and dump can still fail for an…
--
ptp: ocp: use hardware selectors in DPLL frequency operations
The DPLL frequency_set op now passes the selector table value to
ptp_ocp_sma_store_val() instead of the table index. The frequency_get op
now masks the readback with SMA_SELECT_MASK before the table lookup, so
the direction enable bit does not prevent a match.
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 4c98558e96b9c..f1f97c1fa0978 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
[ ... ]
> @@ -5921,6 +5922,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) {
[Severity: High]
Does this fully fix the get/dump failure on ADVA TimeCard X1 boards? The
commit message says:
Mask the direction enable bit before the frequency lookup. Otherwise an
enabled, direction-configurable pin has no matching table entry and its
DPLL get or dump fails. Apply both corrections to all board variants.
ptp_ocp_dpll_direction_set() switches a pin to input with selector 0:
return ptp_ocp_sma_store_val(bp, 0, mode, sma_nr + 1);
When the direction is not fixed, ptp_ocp_sma_store_val() adds the enable
bit:
if (!sma->fixed_dir)
val |= SMA_ENABLE;
The hardware therefore holds 0x8000. With the new mask, the readback in
ptp_ocp_dpll_frequency_get() becomes 0. However, ptp_ocp_adva_x1_sma_in[]
has no 0x0000 entry:
static const struct ocp_selector ptp_ocp_adva_x1_sma_in[] = {
{ .name = "PPS1", .value = 0x0001, .frequency = 1 },
...
{ .name = "None", .value = SMA_DISABLE, .frequency = 0 },
The "None" entry is BIT(16), and SMA_SELECT_MASK clears that bit. The
lookup finds no entry and returns -EINVAL.
On X1 the direction is configurable (sma_map2->gpio2 != 0xffffffff in
ptp_ocp_sma_fb_init()). In that case, does a direction change to input
through DPLL leave the pin in a state that frequency_get cannot decode?
If so, the error has three effects:
dpll_msg_add_pin_freq() passes the error up, so DPLL_CMD_PIN_GET fails
for that pin.
dpll_nl_pin_get_dumpit() only skips -ENODEV, so a system-wide pin dump
also stops with -EINVAL.
dpll_pin_freq_set() calls frequency_get() before frequency_set(). It
fails with "unable to get old frequency value", so the pin cannot be
moved to a valid frequency through DPLL either. The only way to recover
is through sysfs.
A later commit in the series, "ptp: ocp: report disabled SMA inputs
consistently over DPLL", maps disabled inputs to SMA_DISABLE ("None").
That handles the disabled-input case. The override only applies when
sma->disabled is set, though, and direction_set leaves disabled false.
So the direction_set case still appears to fail at the end of the series
(d6d7d7a64ee6).
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-timecard-common-v2-078fe69f33-0-ahmadexp%40gmail.com
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH net v2 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations
2026-11-23 21:49 ` netdev-bot+sashiko
@ 2026-11-23 21:58 ` Ahmad Byagowi
0 siblings, 0 replies; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-23 21:58 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: netdev, vadim.fedorenko, richardcochran, andrew+netdev,
arkadiusz.kubalewski, davem, edumazet, jiri, kuba, pabeni
On Mon, 23 Nov 2026 at 21:49:50 +0000, netdev-bot+sashiko@kernel.org wrote:
> ptp_ocp_dpll_direction_set() switches a pin to input with selector 0:
>
> return ptp_ocp_sma_store_val(bp, 0, mode, sma_nr + 1);
>
> When the direction is not fixed, ptp_ocp_sma_store_val() adds the enable
> bit:
>
> if (!sma->fixed_dir)
> val |= SMA_ENABLE;
>
> The hardware therefore holds 0x8000. With the new mask, the readback in
> ptp_ocp_dpll_frequency_get() becomes 0. However, ptp_ocp_adva_x1_sma_in[]
> has no 0x0000 entry:
Thank you. This is a valid failure in v2, and I reproduced the exact
direction-change case. It is already addressed by the posted v4 patch 2:
https://lore.kernel.org/r/20261122-timecard-common-v4-e0db4ab1aa-2-ahmadexp@gmail.com
After the exact-match lookup, v4 handles unmatched input selectors
without returning -EINVAL. For this X1 zero selector, no destination
establishes a frequency, so the getter returns success with frequency
zero (unknown), not a claim that the signal is absent or measured at
zero Hz. The DPLL core can then perform a subsequent frequency update.
Output selectors still require an exact match.
> A later commit in the series, "ptp: ocp: report disabled SMA inputs
> consistently over DPLL", maps disabled inputs to SMA_DISABLE ("None").
> That handles the disabled-input case. The override only applies when
> sma->disabled is set, though, and direction_set leaves disabled false.
> So the direction_set case still appears to fail at the end of the series
> (d6d7d7a64ee6).
Agreed. This case is distinct from a disabled input. The v4 result does
not depend on the disabled-input override: the test asserts that the
input is enabled, sma->disabled is false, and readback is exactly 0x8000.
I reran a focused source-derived ASan/UBSan test using the actual driver
direction callback, SMA accessors and DPLL core get-before-set function.
The v2 getter returns -EINVAL. With the unchanged submitted v4 code,
all four X1 connectors pass this sequence:
output -> direction_set(INPUT) -> raw 0x8000, disabled=false
frequency_get -> success, frequency=0
DPLL core frequency_set(1) -> success, raw 0x8001, frequency_get=1
This is software validation with stubbed MMIO, not a physical X1 test or
an end-to-end netlink dump. No new driver change or respin was needed.
Ahmad
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net v2 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL
2026-11-19 21:19 [PATCH net v2 0/4] ptp: ocp: fix timestamp teardown and DPLL routing Ahmad Byagowi
2026-11-19 21:19 ` [PATCH net v2 1/4] ptp: ocp: prevent timestamp rearming during detach Ahmad Byagowi
2026-11-19 21:19 ` [PATCH net v2 2/4] ptp: ocp: use hardware selectors in DPLL frequency operations Ahmad Byagowi
@ 2026-11-19 21:19 ` Ahmad Byagowi
2026-11-19 22:24 ` Vadim Fedorenko
2026-11-19 21:19 ` [PATCH net v2 4/4] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-23 22:07 ` [PATCH net v2 0/4] ptp: ocp: fix timestamp teardown and DPLL routing Ahmad Byagowi
4 siblings, 1 reply; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-19 21:19 UTC (permalink / raw)
To: netdev, vadim.fedorenko, richardcochran
Cc: andrew+netdev, arkadiusz.kubalewski, davem, edumazet, jiri, kuba,
pabeni
Disabling an SMA input clears its mux field. Zero is also the selector
for 10 MHz, so a DPLL read reports 10 MHz while sysfs reports None. The
DPLL core then treats a request to enable 10 MHz as unchanged and skips
the setter, leaving the input disabled.
Substitute SMA_DISABLE for disabled inputs before looking up the
frequency, as the sysfs path already does. The None entry reports zero
Hz and a subsequent 10 MHz request reaches the setter.
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.
The driver object builds on current net with W=1 and KCFLAGS=-Werror. No
physical card was tested.
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.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
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 f1f97c1fa0..06d05fac6e 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -5923,6 +5923,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] 17+ messages in thread* Re: [PATCH net v2 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL
2026-11-19 21:19 ` [PATCH net v2 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL Ahmad Byagowi
@ 2026-11-19 22:24 ` Vadim Fedorenko
0 siblings, 0 replies; 17+ messages in thread
From: Vadim Fedorenko @ 2026-11-19 22:24 UTC (permalink / raw)
To: Ahmad Byagowi, netdev, richardcochran
Cc: andrew+netdev, arkadiusz.kubalewski, davem, edumazet, jiri, kuba,
pabeni
On 19/11/2026 21:19, Ahmad Byagowi wrote:
> Disabling an SMA input clears its mux field. Zero is also the selector
> for 10 MHz, so a DPLL read reports 10 MHz while sysfs reports None. The
> DPLL core then treats a request to enable 10 MHz as unchanged and skips
> the setter, leaving the input disabled.
>
> Substitute SMA_DISABLE for disabled inputs before looking up the
> frequency, as the sysfs path already does. The None entry reports zero
> Hz and a subsequent 10 MHz request reaches the setter.
>
> 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.
> The driver object builds on current net with W=1 and KCFLAGS=-Werror. No
> physical card was tested.
>
> 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.
>
> Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
> Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
> Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
> ---
> 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 f1f97c1fa0..06d05fac6e 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -5923,6 +5923,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) {
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH net v2 4/4] ptp: ocp: correct the DCF output frequency
2026-11-19 21:19 [PATCH net v2 0/4] ptp: ocp: fix timestamp teardown and DPLL routing Ahmad Byagowi
` (2 preceding siblings ...)
2026-11-19 21:19 ` [PATCH net v2 3/4] ptp: ocp: report disabled SMA inputs consistently over DPLL Ahmad Byagowi
@ 2026-11-19 21:19 ` Ahmad Byagowi
2026-11-19 22:24 ` Vadim Fedorenko
2026-11-23 21:49 ` netdev-bot+sashiko
2026-11-23 22:07 ` [PATCH net v2 0/4] ptp: ocp: fix timestamp teardown and DPLL routing Ahmad Byagowi
4 siblings, 2 replies; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-19 21:19 UTC (permalink / raw)
To: netdev, vadim.fedorenko, richardcochran
Cc: andrew+netdev, arkadiusz.kubalewski, davem, edumazet, jiri, kuba,
pabeni
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.
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.
The driver object builds on current net with W=1 and KCFLAGS=-Werror. No
physical card was tested.
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.
Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
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 06d05fac6e..0d3d9ffd1f 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1375,7 +1375,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] 17+ messages in thread* Re: [PATCH net v2 4/4] ptp: ocp: correct the DCF output frequency
2026-11-19 21:19 ` [PATCH net v2 4/4] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
@ 2026-11-19 22:24 ` Vadim Fedorenko
2026-11-23 21:49 ` netdev-bot+sashiko
1 sibling, 0 replies; 17+ messages in thread
From: Vadim Fedorenko @ 2026-11-19 22:24 UTC (permalink / raw)
To: Ahmad Byagowi, netdev, richardcochran
Cc: andrew+netdev, arkadiusz.kubalewski, davem, edumazet, jiri, kuba,
pabeni
On 19/11/2026 21:19, Ahmad Byagowi wrote:
> 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.
>
> 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.
> The driver object builds on current net with W=1 and KCFLAGS=-Werror. No
> physical card was tested.
>
> 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.
>
> Fixes: 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
> Link: https://lore.kernel.org/r/179502617840.3136.12704245716223038161@kernel.org
> Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
> ---
> 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 06d05fac6e..0d3d9ffd1f 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -1375,7 +1375,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 },
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH net v2 4/4] ptp: ocp: correct the DCF output frequency
2026-11-19 21:19 ` [PATCH net v2 4/4] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
2026-11-19 22:24 ` Vadim Fedorenko
@ 2026-11-23 21:49 ` netdev-bot+sashiko
2026-11-23 21:58 ` Ahmad Byagowi
1 sibling, 1 reply; 17+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 21:49 UTC (permalink / raw)
To: ahmadexp
Cc: netdev, vadim.fedorenko, richardcochran, andrew+netdev,
arkadiusz.kubalewski, davem, edumazet, jiri, kuba, pabeni
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] This patch fixes one bad frequency in a selector table, but an
identical bug from the same Fixes commit (09eeb3aecc6c) is left in…
- [Low] The commit message describes testing and process for changes this
patch does not contain.
--
ptp: ocp: correct the DCF output frequency
This commit changes the DCF entry in the ptp_ocp_sma_out selector table
from 77000 Hz to 77500 Hz. That makes it match the input table and the
advertised DPLL_PIN_FREQUENCY_DCF77 value.
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.
> The driver object builds on current net with W=1 and KCFLAGS=-Werror. No
> physical card was tested.
>
> 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]
This isn't a bug, but do these paragraphs describe this commit?
The diff only changes the DCF .frequency value in ptp_ocp_sma_out. The
selector, mask, disabled-state and removal ordering work mentioned here
is not part of this patch. Someone reading this commit by itself, such
as a stable backporter, will see validation claims for code it does not
touch.
Could the series-level testing notes and the description of tool
assistance go in the cover letter or below the '---' separator instead?
The "Reported by the netdev Sashiko AI review" sentence could also become
a proper tag, or be dropped since the Link: tag is already there.
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 06d05fac6e1c2..0d3d9ffd1f9b9 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -1375,7 +1375,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 },
[Severity: Medium]
Should the "10Mhz" entry in ptp_ocp_art_sma_in be fixed the same way?
It comes from the same commit, 09eeb3aecc6c, and looks like the same
kind of typo:
drivers/ptp/ptp_ocp.c:
static const struct ocp_selector ptp_ocp_art_sma_in[] = {
{ .name = "PPS1", .value = 0x0001, .frequency = 1 },
{ .name = "10Mhz", .value = 0x0008, .frequency = 1000000 },
{ }
};
That value is 1 MHz. The matching "10Mhz" entry in ptp_ocp_art_sma_out
uses 10000000, and ptp_ocp_art_sma_init() labels 0x08 as the 10 MHz
input:
bp->sma[0].default_fcn = 0x08; /* IN: 10Mhz */
The ART pins advertise ptp_ocp_sma_freq. That list has
DPLL_PIN_FREQUENCY_10MHZ and no 1 MHz entry.
This produces the same two symptoms the commit message describes for
DCF.
On read, ptp_ocp_dpll_frequency_get()->ptp_ocp_art_sma_get() returns
0x08 for sma[0] in its default mode. The driver then reports 1000000 Hz,
which is outside the advertised set.
On write, take a non-fixed ART pin. A request for the advertised
10000000 Hz passes dpll_pin_is_freq_supported() in the DPLL core. The
exact match in ptp_ocp_dpll_frequency_set() then finds no entry:
if (tbl[i].frequency == frequency)
so the request fails with -EINVAL. The core rejects a 1 MHz request, so
the ART 10 MHz input cannot be selected through the DPLL frequency
interface at all.
Could this be fixed in this patch, or in a companion patch with the
same Fixes: tag?
> { .name = "GEN1", .value = 0x0040 },
> { .name = "GEN2", .value = 0x0080 },
> { .name = "GEN3", .value = 0x0100 },
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-timecard-common-v2-078fe69f33-0-ahmadexp%40gmail.com
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH net v2 4/4] ptp: ocp: correct the DCF output frequency
2026-11-23 21:49 ` netdev-bot+sashiko
@ 2026-11-23 21:58 ` Ahmad Byagowi
0 siblings, 0 replies; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-23 21:58 UTC (permalink / raw)
To: netdev-bot+sashiko
Cc: netdev, vadim.fedorenko, richardcochran, andrew+netdev,
arkadiusz.kubalewski, davem, edumazet, jiri, kuba, pabeni
On Mon, 23 Nov 2026 at 21:49:51 +0000, netdev-bot+sashiko@kernel.org wrote:
> Should the "10Mhz" entry in ptp_ocp_art_sma_in be fixed the same way?
> It comes from the same commit, 09eeb3aecc6c, and looks like the same
> kind of typo:
>
> drivers/ptp/ptp_ocp.c:
> static const struct ocp_selector ptp_ocp_art_sma_in[] = {
> { .name = "PPS1", .value = 0x0001, .frequency = 1 },
> { .name = "10Mhz", .value = 0x0008, .frequency = 1000000 },
> { }
> };
>
> That value is 1 MHz. The matching "10Mhz" entry in ptp_ocp_art_sma_out
> uses 10000000, and ptp_ocp_art_sma_init() labels 0x08 as the 10 MHz
> input:
>
> bp->sma[0].default_fcn = 0x08; /* IN: 10Mhz */
Yes, thank you. This is a real defect in v2. The posted v4 series already
includes the separate companion patch 5, with the same Fixes commit:
https://lore.kernel.org/r/20261122-timecard-common-v4-e0db4ab1aa-5-ahmadexp@gmail.com
It changes the ART input entry to 10000000 Hz. Keeping this separate
leaves the DCF correction narrowly scoped and preserves its review tag.
I reran the source-derived ASan/UBSan regression on the unchanged
submitted v4 source. It uses the actual ART init/set/get functions and
the DPLL core supported-frequency and get-before-set functions:
- A literal 10000000 Hz request succeeds and selects 0x08.
- A 1000000 Hz request is rejected by core validation.
- The fixed-pin default 0x08 reads back as 10000000 Hz.
The pre-fix source failed the ART regression during v4 preparation;
the submitted v4 code passes. These tests use stubbed registers, not a
physical ART card or an end-to-end netlink session.
> The diff only changes the DCF .frequency value in ptp_ocp_sma_out. The
> selector, mask, disabled-state and removal ordering work mentioned here
> is not part of this patch. Someone reading this commit by itself, such
> as a stable backporter, will see validation claims for code it does not
> touch.
>
> Could the series-level testing notes and the description of tool
> assistance go in the cover letter or below the '---' separator instead?
Agreed about the cross-patch claims. The posted v4 DCF patch now describes
only the DCF set/readback regression and its software-only validation:
https://lore.kernel.org/r/20261122-timecard-common-v4-e0db4ab1aa-4-ahmadexp@gmail.com
Detailed test and revision notes are below the separator. Brief discovery,
validation and provenance statements remain in the commit message as
required by maintainer-netdev.rst and generated-content.rst. The repeated
selector, disabled-state and teardown testing claims are removed, and
the original report link is retained. No new revision is needed for
either of these v2 findings.
Ahmad
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH net v2 0/4] ptp: ocp: fix timestamp teardown and DPLL routing
2026-11-19 21:19 [PATCH net v2 0/4] ptp: ocp: fix timestamp teardown and DPLL routing Ahmad Byagowi
` (3 preceding siblings ...)
2026-11-19 21:19 ` [PATCH net v2 4/4] ptp: ocp: correct the DCF output frequency Ahmad Byagowi
@ 2026-11-23 22:07 ` Ahmad Byagowi
4 siblings, 0 replies; 17+ messages in thread
From: Ahmad Byagowi @ 2026-11-23 22:07 UTC (permalink / raw)
To: netdev, vadim.fedorenko, richardcochran
Cc: andrew+netdev, arkadiusz.kubalewski, davem, edumazet, jiri, kuba,
pabeni
On Thu, 19 Nov 2026, Ahmad Byagowi wrote:
> These fixes address existing Time Card teardown and routing issues and
> are independent of the WiWi board support series.
Please treat this four-patch v2 series as withdrawn in favor of the
five-patch v4 series posted on November 22. V2 still has all four patches
marked New in Patchwork and its implementation remains in the CI pending
tree, where it conflicts with the replacement v4 teardown patch.
The replacement series is:
https://lore.kernel.org/r/20261122-timecard-common-v4-e0db4ab1aa-0-ahmadexp@gmail.com
https://patchwork.kernel.org/series/1219090/
V4 follows Vadim's requested teardown approach: the PTP core disables all
timestamp channels after removing the user interfaces, rather than adding
the v2 stopping flag and driver locking. It also addresses the selector,
combined-route and disabled-input review points, and includes a separate
ART 10 MHz frequency correction. Thank you for the review and for pointing
out the shortcomings in the earlier revisions.
Current validation:
- All five signed v4 patches apply cleanly to net/main 639a75a3539f and
net-next/main 57f165ff2f30. The resulting affected files match their
previously tested common-v4 integrations on those respective trees.
- The ptp_ocp.c blob in the reported CI branch,
net-next-2026-11-23--03-00, is the same blob used in the local conflict
reproduction. Reversing only the four posted v2 patches from that file
and applying v4 succeeds and reproduces the tested v4 dependency file.
This is an affected-file application check, not a full pending-tree
build or a claim that public CI has already passed.
- V4's public 32-bit, allmodconfig-warning, Clang and checkpatch checks
report success. The contest check fails on the pending-tree conflict
at ptp_ocp.c:2559; contest-hw is blocked by that check.
- The focused source-derived X1 test reproduces v2's -EINVAL after an
input-direction change. V4 passes for all four connectors, including
the DPLL get-before-set path. The ART tests accept 10 MHz, reject 1 MHz
and read back 10 MHz for the fixed default. These use stubbed registers,
not physical X1 or ART hardware.
The focused results and relevant v4 patch links are also in these replies:
https://lore.kernel.org/r/20261123-timecard-common-v4-followup-x1-ahmadexp@gmail.com
https://lore.kernel.org/r/20261123-timecard-common-v4-followup-art-ahmadexp@gmail.com
Please remove v2 from the active queue so CI can test v4 without stacking
it on this obsolete revision. This status request applies only to v2;
v4 remains the series for review. WiWi board support remains separate.
pw-bot: changes-requested
Thanks,
Ahmad
^ permalink raw reply [flat|nested] 17+ messages in thread