Skip to content

igb: PTP Tx timestamp state fixes

Shivani Gupta intel-wired-lan lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2igb: Fix race condition in PTP tx codedrivers/net/ethernet/intel/igb/igb.h drivers/net/ethernet/intel/igb/igb_main.c drivers/net/ethernet/intel/igb/igb_ptp.c+83 -491 reply
2/2igb: Clear pending Tx timestamp requests when disabling Tx timestampingdrivers/net/ethernet/intel/igb/igb_main.c drivers/net/ethernet/intel/igb/igb_ptp.c+33 -130 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH iwl-net 0/2] igb: PTP Tx timestamp state fixes

The igb driver keeps a single outstanding Tx hardware timestamp request in adapter->ptp_tx_skb, guarded only by the atomic __IGB_PTP_TX_IN_PROGRESS bit. The fields around it (ptp_tx_skb, ptp_tx_start) are accessed from the transmit path, the retrieval worker, the watchdog and the teardown paths without any common synchronization.

Patch 1 ports the fix igc received in commit 9c50e2b150c8 ("igc: Fix race condition in PTP tx code") - which the igc series cover letter already announced as intended for igb - to igb's single-timestamp
model: a new ptp_tx_lock protects the timestamp request state and is initialized during software setup, before register_netdev() exposes any consumer. The state bit is removed, and the unsafe cancel_work_sync() calls in the watchdog path (deadlock with the new lock) and the atomic-context transmit error path (sleeping while atomic) are dropped in favor of the worker checking the request state under the lock. igb-specific paths that do not exist in igc (the 82576 polling worker with its timeout branch, and transmit error cleanup that verifies slot ownership) are covered as well.

Patch 2 fixes a related lifecycle bug: disabling Tx timestamping with a request outstanding strands the request. On re-enable, all new requests are dropped until the stale one is flagged as a bogus "Tx timestamp hang" by the watchdog up to 15 seconds later. Pending requests are now dropped at disable time. The disabled mode and empty slot are published atomically under the lock introduced by patch 1, so the transmit path cannot admit a replacement request during cleanup (which is why the two patches form one series).

Both issues were validated on QEMU's igb (82576) model. The unpatched disable/re-enable blackout reproduces deterministically (recovery only via the 15 s watchdog timeout); the final patches complete 100 cycles without a blackout. A 60-second timestamp stress test with link flaps delivered 6445 of 6469 requests and completed without a KASAN, lockdep, DEBUG_ATOMIC_SLEEP, warning, or panic report. The race window itself is nanoseconds wide and was not directly reproduced; it is identical in structure to the igc bug fixed by 9c50e2b150c8.

Note: this series touches the same schedule_work() call sites as Kurt Kanzenbach's pending "[PATCH iwl-next v5] igb: Retrieve Tx timestamp from BH workqueue" ([email protected]). The overlap is textual only - that patch changes which workqueue runs ptp_tx_work, this series changes the locking around the request state - and either rebases trivially on the other.

Shivani Gupta (2):
igb: Fix race condition in PTP tx code
igb: Clear pending Tx timestamp requests when disabling Tx
timestamping

 drivers/net/ethernet/intel/igb/igb.h      |   3 +-
 drivers/net/ethernet/intel/igb/igb_main.c |  49 +++++++-----
 drivers/net/ethernet/intel/igb/igb_ptp.c  | 120 ++++++++++++++++++++----------
 3 files changed, 113 insertions(+), 59 deletions(-)

base-commit: 24ef02f934eeb48830cff6b739abc3c62b1d107b