[PATCH net-next v7 0/3] net: stmmac: dwxgmac2: timestamp interrupt support + Agilex5 fix
flat view
WARM1d
From: Zxyan Zhu <hidden>
Date: 2026-10-04 12:06:09
Also in:
linux-arm-kernel, lkml
Revision v7 of 3 in this series.
Revisions (3)
- v5 [diff vs current]
- v6 [diff vs current]
- v7 current
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(), which redoes the EXTTS programming
under aux_ts_lock before re-arming, when a channel was left enabled
across suspend.
v1: https://lore.kernel.org/netdev/20260806-dwxgmac2-timestamp-irq-v1-1-c051c79c9d90@gmail.com/ (local)
v2: https://lore.kernel.org/netdev/20260810100221.9166-1-zxyan0222@gmail.com/ (local)
v3: https://lore.kernel.org/netdev/20260818132722.1852876-1-zxyan0222@gmail.com/ (local)
v4: https://lore.kernel.org/netdev/20260902131441.322167-1-zxyan0222@gmail.com/ (local)
v5: https://lore.kernel.org/netdev/20260910081020.86227-1-zxyan0222@gmail.com/ (local)
v6: https://lore.kernel.org/netdev/20260929073553.4136336-1-zxyan0222@gmail.com/ (local)
v7:
- Rebase onto the current net-next/main: stmmac_resume() now only
re-initialises timestamping under priv->ptp_enabled (8181678a92f0),
so stmmac_rearm_timestamp_irq() moved inside that block.
- Raise and drop STMMAC_FLAG_INT_SNAPSHOT_EN under aux_ts_lock in
smtg_crosststamp(), so concurrent cross-timestamp requests cannot
lose the flag.
- Restore the enabled auxiliary snapshot trigger on resume: the
platform init resets the MAC, so stmmac_rearm_timestamp_irq() now
flushes the FIFO and re-programs the PTP_ACR ATSEN bit (channel
recorded by stmmac_enable()) before re-arming the interrupt.
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 | 59 +++++++++++++++++++
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 | 51 ++++++++++++++++
.../net/ethernet/stmicro/stmmac/stmmac_ptp.c | 23 +++++++-
.../net/ethernet/stmicro/stmmac/stmmac_ptp.h | 2 +
include/linux/stmmac.h | 1 +
9 files changed, 187 insertions(+), 11 deletions(-)
base-commit: 62d7b9186cad08324d6b9d262631104bb215e67d
--
2.34.1