[PATCH net v3 00/10] net: stmmac: preserve datapath state across MTU and resume failures
From: James Hilliard
Date: Thu Sep 24 2026 - 14:09:51 EST
Keep the stmmac datapath coherent after failed MTU changes or hardware
resume without changing the interface's administrative state. Retain the
working MTU configuration for rollback, and allow ordinary down/up recovery
when hardware cannot be restored.
The ten patches separate ownership and recovery fixes from the MTU
transaction:
1. Correct the WoL/safety IRQ unwind order after failed IRQ registration.
2. Allow phylink_stop() to finish a suspended instance, restoring PHY
advertisement reduced by suspend without restarting the failed MAC.
3. Track datapath ownership separately from administrative and hardware
sleep state. Close and PM perform only the work still outstanding.
4. Leave normal-size MTU changes running, including supported AF_XDP MTUs.
5. Make partial DMA allocation unwind complete and leave freed queues empty.
6. Keep DMA configurations at stable addresses, use persistent IRQ
contexts, and drain timer producers before the final cancellation.
7. Track live XDP release/reopen and propagate program-attach failures.
8. Use that tracked restart for AF_XDP pool changes, handling failures
without leaving NAPI active over missing buffers or unmapping live pools.
9. Retain PHY and runtime-PM ownership during ethtool ring/channel reopening.
10. Retain rings and IRQ registrations across jumbo MTU replacement,
restoring the old MTU and rings if hardware setup fails.
The ownership states remain distinct: DOWN has no datapath allocations;
RUNNING has active queues; SUSPENDED retains rings and IRQs; HALTED retains
rings but has released IRQs after failed MTU rollback. Collapsing the last
two states would make close free IRQs which it no longer owns.
Jumbo rollback allocates no new buffers or IRQ registrations. RX holes are
filled before reset without changing the old descriptors; descriptors are
rebuilt or retired only after reset succeeds. If rollback also fails, the
interface remains detached until down/up recovery. This cannot guarantee
recovery from indefinitely failing hardware.
Failed interfaces still receive hardware/PHY sleep handling. A failed
datapath with MAC WoL configured rejects suspend with -EBUSY because its
wake path is unusable; PHY-only WoL is not rejected. Timestamp filters and
PHC registration survive an MTU change, but continuous PHC time across the
hardware reset is not preserved.
Live XDP and ethtool failures leave the administratively-up interface
detached for ordinary down/up recovery. Program attachment failures return
an error without consuming the proposed program. BPF-link and XSK-pool
removal still complete if their datapath restart fails, so teardown can
release the program or pool safely. AF_XDP pool reconfiguration now pauses
all queues and link resolution while rebuilding the rings; this trades
reconfiguration latency for one consistent ownership and failure path.
Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
---
Changes in v3:
- Snapshot debugfs queue counts under RTNL with the descriptor ownership
check, so a reader blocked behind channel shrink uses the new topology.
- Complete pending core sleep state during close and retry restoration on
open after runtime-PM acquisition. Use the installed wake state rather
than mutable WoL settings, and retain the pending marker if restoration
fails.
- Put the independent IRQ unwind fix first, ahead of the ownership changes.
- Correct the WoL/safety IRQ unwind order, fixing a repeated safety IRQ
free and a leaked WoL handler.
- Account for live XDP release/reopen in datapath ownership. Stop DMA on
late IRQ failure, propagate program-attach errors without losing program
references, and allow BPF-link removal to complete after restart failure.
- Replace the void AF_XDP queue-enable helpers with the tracked XDP restart.
Unmap a removed pool only after freeing its rings, undo failed pool
attachment, and preserve TBS configuration while rebuilding the channels.
- Keep PHY/PM ownership across ethtool ring/channel changes, restoring the
old configuration after failed reopening and leaving the interface
detached for down/up recovery without a second runtime-PM put.
Explicitly disable the MAC during release even when link resolution has
not reached mac_link_up().
- Split the MTU work into normal-size MTU handling, allocation unwind,
stable DMA/IRQ ownership (including timer lifetime), and the retained-ring
transaction. Keep the ownership change and its open/error-path adaptations
in the same patch.
- Restore the PHY advertisement reduced by phylink_suspend() when stopping
a suspended instance, without restarting or reconfiguring the MAC, in
response to Andrew Lunn.
- Keep suspend-owned PHY speed control separate from explicit driver
speed-down requests, so close-time power saving does not overwrite the
original advertisement and remains effective until the matching speed-up.
- Suspend a stopped PHY powered back up by phylink_prepare_resume() when
stopping after a failed MAC resume, without repeating phy_stop().
- Add a separate MTU transaction patch retaining old DMA resources and IRQ
registrations until replacement succeeds, following Andrew Lunn's request
to keep the old setup for failure recovery.
- Keep DMA configuration objects at stable addresses and use persistent
channel objects for per-queue interrupt contexts.
- Drain transmitters and post-completion NAPI poll tails before cancelling
TX timers.
- Avoid resetting normal-size MTU changes, including all supported AF_XDP
MTUs, and stop rebinding live pools through temporary RXQ objects.
- Program the new MAC receive limit before activation and restore the old
MTU on failure; refill old RX buffer holes before reset so rollback does
not require allocation.
- Preserve coalescing, TBS state, PHC registration and timestamp filters;
leave a failed rollback detached with old rings retained for close.
- Harden partial-allocation unwind.
- Separate core sleep completion from datapath ownership so failed MTU and
resume paths still receive hardware PM handling, without disabling NAPI
twice or restarting released queues. Address the skipped-suspend issue
reported by Sashiko; reject an unusable MAC WoL path with -EBUSY.
- Balance platform noirq PTP clock handling against resources still owned
after detached XDP cleanup.
- Link to v2: https://patch.msgid.link/20260922-submit-stmmac-reset-fixes-v1-v2-0-d92e609be996@xxxxxxxxx
Changes in v2:
- Drop forced netif_close() and retain the interface's administrative state,
as requested by Maxime Chevallier.
- Separate queue quiescence from resource release and use explicit datapath
state instead of a napi_disabled argument to the release helper.
- Handle repeated suspend/resume after failure, preserve PHY/PM ownership
until ordinary close, and allow a fresh down/up recovery.
- Check XDP/AF_XDP cleanup, descriptor readback and asynchronous reset work
while the netdev is administratively up but unavailable.
- Explain the generic phylink suspend-to-stop transition and why restarting
phylink after a failed MAC resume is not a valid substitute, in response
to Andrew Lunn.
- Combine the two stmmac error-path fixes so every user of the new state
has consistent resource and NAPI lifetime handling in one patch.
- Link to v1: https://patch.msgid.link/20260921-submit-stmmac-reset-fixes-v1-v1-0-87a4e431ee00@xxxxxxxxx
To: Maxime Chevallier <maxime.chevallier@xxxxxxxxxxx>
To: Andrew Lunn <andrew+netdev@xxxxxxx>
To: "David S. Miller" <davem@xxxxxxxxxxxxx>
To: Eric Dumazet <edumazet@xxxxxxxxxx>
To: Jakub Kicinski <kuba@xxxxxxxxxx>
To: Paolo Abeni <pabeni@xxxxxxxxxx>
To: Maxime Coquelin <mcoquelin.stm32@xxxxxxxxx>
To: Alexandre Torgue <alexandre.torgue@xxxxxxxxxxx>
To: Serge Semin <fancer.lancer@xxxxxxxxx>
To: Suraj Jaiswal <quic_jsuraj@xxxxxxxxxxx>
To: Russell King <linux@xxxxxxxxxxxxxxx>
To: Andrew Lunn <andrew@xxxxxxx>
To: Heiner Kallweit <hkallweit1@xxxxxxxxx>
To: Joakim Zhang <qiangqing.zhang@xxxxxxx>
To: "Russell King (Oracle)" <rmk+kernel@xxxxxxxxxxxxxxx>
To: Alexei Starovoitov <ast@xxxxxxxxxx>
To: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
To: Jesper Dangaard Brouer <hawk@xxxxxxxxxx>
To: John Fastabend <john.fastabend@xxxxxxxxx>
To: Stanislav Fomichev <sdf@xxxxxxxxxxx>
To: Richard Cochran <richardcochran@xxxxxxxxx>
To: Christian Marangi <ansuelsmth@xxxxxxxxx>
To: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
To: Huacai Chen <chenhuacai@xxxxxxxxxx>
To: Joao Pinto <Joao.Pinto@xxxxxxxxxxxx>
To: Vladimir Oltean <vladimir.oltean@xxxxxxx>
To: Ong Boon Leong <boon.leong.ong@xxxxxxxxx>
To: Voon Weifeng <weifeng.voon@xxxxxxxxx>
To: "Song, Yoong Siang" <yoong.siang.song@xxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Cc: linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: bpf@xxxxxxxxxxxxxxx
---
James Hilliard (10):
net: stmmac: unwind the WoL IRQ after a safety IRQ request failure
net: phylink: allow stopping a suspended instance
net: stmmac: keep datapath state coherent after reinitialization failure
net: stmmac: leave the datapath running for normal-size MTU changes
net: stmmac: unwind partially allocated DMA configurations
net: stmmac: keep DMA configurations at stable addresses
net: stmmac: account for failed live XDP reopening
net: stmmac: use the tracked datapath restart for XSK pool changes
net: stmmac: retain PHY and PM ownership during ethtool reopening
net: stmmac: retain DMA resources across MTU changes
drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 6 +-
drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/stmmac.h | 21 +-
.../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 4 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1036 +++++++++++++-------
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 19 +-
.../net/ethernet/stmicro/stmmac/stmmac_selftests.c | 8 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 6 +-
drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c | 83 +-
drivers/net/phy/phylink.c | 51 +-
10 files changed, 815 insertions(+), 423 deletions(-)
---
base-commit: 8e1937fed6738460554ec123c64839e2445e7d53
change-id: 20260921-submit-stmmac-reset-fixes-v1-7c98b92d29a9
Best regards,
--
James Hilliard <james.hilliard1@xxxxxxxxx>