[PATCH net v6 8/8] ptp: ocp: defer timestamp shutdown to clock unregister

From: Ahmad Byagowi

Date: Thu Nov 26 2026 - 11:43:09 EST


From: ahmadexp <ahmadexp@xxxxxxxxx>

ptp_ocp_detach() disables timestamp sources before ptp_clock_unregister() removes the user interfaces. An in-flight request can rearm a source after that early disable.

Rely on the PTP core unregister cleanup to disable timestamp channels after userspace operations have been removed and drained. Keep the shared PPS subscription-map shortcut unchanged. This driver patch depends on the separate PTP core teardown series.

A coding assistant helped trace the detach race, prepare this driver-side change and develop the combined teardown regression test. The test uses the actual callback and cleanup functions with register and IRQ operations stubbed.

Fixes: 627366c51145 ("ptp: ocp: fix resource freeing order")

Link: https://lore.kernel.org/r/179548551283.3135.17206659598806657887@xxxxxxxxxx
Signed-off-by: Ahmad Byagowi <ahmadexp@xxxxxxxxx>
---
drivers/ptp/ptp_ocp.c | 13 -------------
1 file changed, 13 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 040518895176..27cf3ab3327c 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -5768,19 +5768,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);
--
2.54.0 (Apple Git-157)