[PATCH net-next v6 0/3] net: stmmac: dwxgmac2: timestamp interrupt support + Agilex5 fix
From: Zxyan Zhu
Date: Tue Sep 29 2026 - 03:39:16 EST
This series adds auxiliary snapshot (EXTTS) interrupt support to
DWXGMAC2/DWXLGMAC2, fixes a stale TSIS race on the Agilex5
cross-timestamp path that the new handler would otherwise expose, and
guards the shared aux snapshot handler against a zero channel mask.
Patch 1 makes smtg_crosststamp() complete on the persistent ATSNS
count instead of the transient TSIS bit, waits for the ATSFC FIFO
clear to complete, and holds aux_ts_lock across the whole
trigger/poll/drain sequence so a concurrent PTP_CLK_REQ_EXTTS
request cannot flush the snapshot FIFO mid-flight.
Patch 2 guards the shared aux snapshot handler against a zero
PTP_ACR channel mask: ilog2() is applied to the mask without
checking for zero, and ilog2(0) yields an out-of-range event index
that ptp_clock_event() feeds to test_bit() unchecked from hard IRQ
context.
Patch 3 wires up a dedicated DWXGMAC2 timestamp interrupt handler,
following the guarded pattern of the shared one. Before this change
the XGMAC hwif entries used the generic stmmac_ptp ops, whose
timestamp_interrupt callback read the dwmac4 offset
GMAC_TIMESTAMP_STATUS (0xb20) instead of the XGMAC register at 0xd20.
The PTP clock advertised the aux snapshot channels, so
PTP_EXTTS_REQUEST succeeded but no event was ever delivered.
Following 30300d9f9150 ("net: stmmac: xgmac: Disable the Timestamp
interrupt by default"), XGMAC_TSIE is not added back to
XGMAC_INT_DEFAULT_EN. Instead it is armed on demand from the
PTP_CLK_REQ_EXTTS enable/disable path via a new optional
timestamp_interrupt_cfg mac callback (mirroring dwmac1000). The
interrupt is only touched after the ATSFC FIFO clear has completed,
and the handler refuses to drain entries while that clear is still
in flight; it also leaves the snapshot FIFO alone while an internal
cross-timestamp owns it (STMMAC_FLAG_INT_SNAPSHOT_EN), is disarmed
when the PTP clock is unregistered, and is re-armed on resume by
stmmac_rearm_timestamp_irq() when a channel was left enabled across
suspend.
v1: https://lore.kernel.org/netdev/20260806-dwxgmac2-timestamp-irq-v1-1-c051c79c9d90@xxxxxxxxx/
v2: https://lore.kernel.org/netdev/20260810100221.9166-1-zxyan0222@xxxxxxxxx/
v3: https://lore.kernel.org/netdev/20260818132722.1852876-1-zxyan0222@xxxxxxxxx/
v4: https://lore.kernel.org/netdev/20260902131441.322167-1-zxyan0222@xxxxxxxxx/
v5: https://lore.kernel.org/netdev/20260910081020.86227-1-zxyan0222@xxxxxxxxx/
v6:
- Hold aux_ts_lock across the whole crosststamp sequence instead of
dropping it after arming, so a concurrent EXTTS request cannot flush
the FIFO between the poll and the drain loop.
- Arm XGMAC_TSIE on demand from the PTP_CLK_REQ_EXTTS path instead of
adding it to XGMAC_INT_DEFAULT_EN, addressing the review comments on
reverting 30300d9f9150 and on the missing disable counterpart.
- Reword the ATSNS comments: ATSNS is the aux snapshot FIFO level; it
is not cleared by reading XGMAC_TIMESTAMP_STATUS, which is the
property the poll relies on.
- Add Fixes: to the EXTTS support patch and guard the shared handler
against a zero PTP_ACR channel mask, placed before the new handler
so every intermediate tree leaves the shared path hardened.
Zxyan Zhu (3):
net: stmmac: dwmac-socfpga: complete cross-timestamp on ATSNS
net: stmmac: guard against a zero channel in the aux snapshot handler
net: stmmac: dwxgmac2: add XGMAC timestamp interrupt support
.../ethernet/stmicro/stmmac/dwmac-socfpga.c | 36 ++++++++++---
.../ethernet/stmicro/stmmac/dwxgmac2_core.c | 54 +++++++++++++++++++
drivers/net/ethernet/stmicro/stmmac/hwif.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/hwif.h | 5 ++
.../ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 17 +++++-
.../net/ethernet/stmicro/stmmac/stmmac_main.c | 14 +++++
.../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 9 ++++
.../net/ethernet/stmicro/stmmac/stmmac_ptp.h | 1 +
8 files changed, 130 insertions(+), 10 deletions(-)
base-commit: d0ec95a8a4e79f2fd6063fc8932415db8c227689
--
2.34.1