mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v4 00/15] net: stmmac: preserve datapath state across MTU and resume failures
@ 2026-09-26 15:48 James Hilliard
  2026-09-26 15:48 ` [PATCH net v4 01/15] net: stmmac: unwind the WoL IRQ after a safety IRQ request failure James Hilliard
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: James Hilliard @ 2026-09-26 15:48 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Jakub Kicinski, Paolo Abeni, Joakim Zhang, Russell King (Oracle),
	Maxime Chevallier, Andrew Lunn, Maxime Coquelin,
	Alexandre Torgue, Christian Marangi, Tiezhu Yang, Huacai Chen,
	Alexei Starovoitov, Daniel Borkmann, Jesper Dangaard Brouer,
	John Fastabend, Stanislav Fomichev, Serge Semin, Suraj Jaiswal,
	Richard Cochran, Joao Pinto, Vladimir Oltean, Ong Boon Leong,
	Voon Weifeng, Song, Yoong Siang, Linus Walleij,
	Martin Blumenstingl, Magnus Karlsson, Maciej Fijalkowski,
	Simon Horman, Björn Töpel, Thierry Reding,
	Jonathan Hunter, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland,
	Eric Dumazet
  Cc: Richard Genoud, Alastair D'Silva, Maxime Ripard, netdev,
	linux-kernel, linux-stm32, linux-arm-kernel, bpf, ZhaoJinming,
	Lorenzo Bianconi, Ding Hui, James Hilliard, linux-tegra,
	linux-sunxi

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 fifteen patches put independent fixes and lifetime prerequisites ahead
of the retained-ring MTU transaction:

  1. Correct the WoL/safety IRQ unwind order.
  2. Reuse the MDIO reset GPIO across repeated resets.
  3. Allow phylink_stop() to finish a suspended instance.
  4. Freeze deferred AF_XDP pool teardown before device system suspend.
  5. Serialize PHC changes and cache reset-sensitive timestamp settings.
  6. Keep normal-size MTU changes running, including supported AF_XDP MTUs.
  7. Unwind partial DMA allocations and fix saved RX skb ownership.
  8. Keep DMA configurations and IRQ contexts at stable addresses, and
     drain timer producers before cancelling their timers.
  9. Track datapath and power ownership across MTU, XDP and ethtool reopen
     failures, including noirq clock handling and unpowered-access guards.
 10. Use the tracked restart for XSK pool changes.
 11. Restore TC filters, steering, preemption mapping and EST before DMA.
 12. Allow independent references to AF_XDP DMA mappings and UMEM pages.
 13. Retain DMA memory until hardware confirms shutdown or reset.
 14. Prepare device-local interrupt masking and DMA-handler quiescence.
 15. Retain rings and IRQ registrations across jumbo MTU replacement.

The ownership transition and its XDP, ethtool and PM consumers land
together, so resource cleanup does not precede the power-access guards it
requires. The larger DMA shutdown change precedes MTU rollback, rather
than leaving early retained-ring commits with unsafe teardown paths.

The ownership states remain distinct: DOWN owns no IRQs or enabled NAPI;
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. DMA memory
ownership is tracked separately: a failed shutdown can retain allocations
even in DOWN until hardware acknowledges a successful reset.

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. Replay the platform PTP clock selector,
frequency correction, PEROUT and EXTTS settings after reset; continuous PHC
time across the 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 replays the MAC link while rebuilding the rings. Successful
reconfiguration leaves the PHY running rather than powering it down and
restarting autonegotiation. All queues and other sockets are still paused
while their rings are rebuilt. A failed restart stops phylink without
reconfiguring the failed MAC, then permits ordinary down/up recovery.

Close and live XDP/XSK release now require stopped DMA process states
or a completed global reset before releasing DMA memory. Unsupported
idle-register layouts, including XGMAC and GMAC4 with more than three
channels, use the reset fallback. Replay cached L3/L4 filters, EtherType
steering, VLAN priority, preemption/TC mapping, PTP settings and EST before
starting DMA. Replay failure enters the existing rollback or detached
recovery path. Reset does not preserve continuous PHC time.

If shutdown and reset both fail, retain rings, mappings and backing memory.
AF_XDP pool teardown still completes, with independent references keeping
its DMA mapping and UMEM pages alive. A later successful down/up reset
reclaims them. There is no generic isolation guarantee for permanently
unresponsive hardware: removal reports and retains unsafe DMA allocations,
which may therefore remain pinned until reboot.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Changes in v4:
- Reorder prerequisites ahead of their consumers. Separate the independent
  MDIO GPIO fix and PHC/IRQ preparation, and combine datapath ownership with
  the XDP, ethtool and PM paths which must observe it. Keep MTU rollback last.
- Replay cached TC filters, steering, preemption mapping and EST after reset,
  with DMA held stopped until replay succeeds. Preserve the previous cached
  rule on installation failure and advance EST base time by whole cycles.
- Validate TAPRIO replacements without modifying the installed schedule;
  reject failed PHC reads and retain a valid cache after setup failure.
- Keep control operations from accessing unpowered registers after close
  reattaches the netdev. Permit software-only VLAN, qdisc and TC filter
  removal, and preserve open-time power recovery. Remove cached flower,
  steering and u32 rules while down or detached so reset cannot replay
  filters which TC has already deleted.
- Use phylink link replay for live XDP/XSK updates, leaving the PHY running
  on success and balancing replay with phylink_stop() on failed restart.
- Require a hardware idle acknowledgement or completed reset before DMA
  memory retirement on close, XDP/XSK replacement and failed open. Retain
  failed configurations for recovery, and defer IRQ TX recovery and resume
  descriptor rebuilding until shutdown/reset is confirmed.
- Add independent AF_XDP mapping/UMEM references so pool teardown can
  complete without unmapping DMA-visible memory after a shutdown failure.
  Document reset fallback and permanent-failure memory retention.
- Keep shared IRQ controller lines enabled during MTU replacement. Mask DMA
  sources at the device, protect DMA-handler quiescence with the channel
  lock, and drain registered handlers with synchronize_irq().
- Preserve pending DMA status while quiesced, including when hardware setup
  restores interrupt enables. Restore saved masks on restart and leave DMA
  sources masked when failed rollback releases the driver's IRQ handlers.
- Reuse the final TX queue and timer drain after synchronizing IRQ handlers.
- Restore saved RX skb ownership immediately when taking partial receive
  state, including a budget-one completion and a DMA-owned next descriptor.
- Cancel the EEE software timer after draining NAPI, and make GSO feature
  checks use stable platform TBS capabilities rather than replaceable rings.
- Reuse the MDIO reset GPIO acquired at probe and reject TC queue work when
  the datapath is not running, except for software-only filter deletion.
- Let carrier-down XSK TX polls complete instead of continuously repolling,
  and remove the unused external XSK wakeup declaration.
- Stop a PHY powered by prepare_resume() after failed ethtool setup. Publish
  core queue counts transactionally only after the fallible open work.
- Initialize rollback RX addresses before publishing descriptor ownership.
  Restore the platform PTP clock selection, frequency adjustment, PEROUT and
  EXTTS settings; serialize PHC/devlink access across reset and reject access
  to a failed retained clock.
- Freeze deferred XSK pool teardown before device PM. Track platform power,
  pending clock restoration and actual PTP clock ownership separately from
  the datapath. Avoid unpowered MAC/MDIO accesses on failed close-time
  recovery and balance clocks even after a noirq resume failure.
- Check unusable MAC WoL before the pending-sleep shortcut, and update
  comments for HALTED ownership and the ethtool reopen path.
- Link to v3: https://patch.msgid.link/20260924-submit-stmmac-reset-fixes-v1-v3-0-c031e3f3a282@gmail.com

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@gmail.com

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@gmail.com

To: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>
To: "David S. Miller" <davem@davemloft.net>
To: Eric Dumazet <edumazet@google.com>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
To: Maxime Coquelin <mcoquelin.stm32@gmail.com>
To: Alexandre Torgue <alexandre.torgue@foss.st.com>
To: Serge Semin <fancer.lancer@gmail.com>
To: Suraj Jaiswal <quic_jsuraj@quicinc.com>
To: Russell King <linux@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>
To: Heiner Kallweit <hkallweit1@gmail.com>
To: Joakim Zhang <qiangqing.zhang@nxp.com>
To: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
To: Alexei Starovoitov <ast@kernel.org>
To: Daniel Borkmann <daniel@iogearbox.net>
To: Jesper Dangaard Brouer <hawk@kernel.org>
To: John Fastabend <john.fastabend@gmail.com>
To: Stanislav Fomichev <sdf@fomichev.me>
To: Richard Cochran <richardcochran@gmail.com>
To: Christian Marangi <ansuelsmth@gmail.com>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
To: Huacai Chen <chenhuacai@kernel.org>
To: Joao Pinto <Joao.Pinto@synopsys.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Ong Boon Leong <boon.leong.ong@intel.com>
To: Voon Weifeng <weifeng.voon@intel.com>
To: "Song, Yoong Siang" <yoong.siang.song@intel.com>
To: Linus Walleij <linusw@kernel.org>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
To: Magnus Karlsson <magnus.karlsson@intel.com>
To: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Simon Horman <horms@kernel.org>
To: Björn Töpel <bjorn@kernel.org>
To: Thierry Reding <thierry.reding@kernel.org>
To: Jonathan Hunter <jonathanh@nvidia.com>
To: Chen-Yu Tsai <wens@kernel.org>
To: Jernej Skrabec <jernej.skrabec@gmail.com>
To: Samuel Holland <samuel@sholland.org>
Cc: netdev@vger.kernel.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Cc: bpf@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: linux-sunxi@lists.linux.dev

---
James Hilliard (15):
      net: stmmac: unwind the WoL IRQ after a safety IRQ request failure
      net: stmmac: reuse the MDIO reset GPIO on resume
      net: phylink: allow stopping a suspended instance
      xsk: freeze deferred pool teardown during system sleep
      net: stmmac: serialize and retain PHC configuration across reset
      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: track datapath and power ownership across failed reopening
      net: stmmac: use the tracked datapath restart for XSK pool changes
      net: stmmac: restore TC offloads before restarting DMA
      xsk: allow drivers to retain DMA mappings independently of pools
      net: stmmac: retain DMA memory until hardware shutdown completes
      net: stmmac: prepare device-local DMA interrupt quiescence
      net: stmmac: retain DMA resources across MTU changes

 drivers/net/ethernet/stmicro/stmmac/chain_mode.c   |    6 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c  |   28 +
 drivers/net/ethernet/stmicro/stmmac/dwmac-tegra.c  |    5 +-
 .../net/ethernet/stmicro/stmmac/dwmac1000_dma.c    |    2 +
 drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c |    2 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c   |    4 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h   |    8 +
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c   |   29 +
 drivers/net/ethernet/stmicro/stmmac/dwmac_dma.h    |    4 +
 drivers/net/ethernet/stmicro/stmmac/dwmac_lib.c    |   30 +
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c |   11 +
 drivers/net/ethernet/stmicro/stmmac/hwif.h         |    9 +
 drivers/net/ethernet/stmicro/stmmac/ring_mode.c    |    4 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |   64 +-
 .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c   |   15 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_fpe.c   |    1 +
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 1720 ++++++++++++++------
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c  |   33 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_pcs.c   |    3 +-
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  |   38 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c   |  131 +-
 .../net/ethernet/stmicro/stmmac/stmmac_selftests.c |    8 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c    |  376 +++--
 drivers/net/ethernet/stmicro/stmmac/stmmac_vlan.c  |    6 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_xdp.c   |   83 +-
 drivers/net/phy/phylink.c                          |   51 +-
 include/net/xdp_sock_drv.h                         |   23 +
 include/net/xsk_buff_pool.h                        |    4 +
 net/xdp/xsk_buff_pool.c                            |   53 +-
 29 files changed, 2049 insertions(+), 702 deletions(-)
---
base-commit: a7bfaba4823e3c165bb2004c74eff7c096672bc7
change-id: 20260921-submit-stmmac-reset-fixes-v1-7c98b92d29a9

Best regards,
--  
James Hilliard <james.hilliard1@gmail.com>


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-09-26 16:00 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-26 15:48 [PATCH net v4 00/15] net: stmmac: preserve datapath state across MTU and resume failures James Hilliard
2026-09-26 15:48 ` [PATCH net v4 01/15] net: stmmac: unwind the WoL IRQ after a safety IRQ request failure James Hilliard
2026-09-26 15:48 ` [PATCH net v4 02/15] net: stmmac: reuse the MDIO reset GPIO on resume James Hilliard
2026-09-26 15:48 ` [PATCH net v4 03/15] net: phylink: allow stopping a suspended instance James Hilliard
2026-09-26 15:48 ` [PATCH net v4 04/15] xsk: freeze deferred pool teardown during system sleep James Hilliard
2026-09-26 15:49 ` [PATCH net v4 05/15] net: stmmac: serialize and retain PHC configuration across reset James Hilliard
2026-09-26 15:49 ` [PATCH net v4 06/15] net: stmmac: leave the datapath running for normal-size MTU changes James Hilliard
2026-09-26 15:49 ` [PATCH net v4 07/15] net: stmmac: unwind partially allocated DMA configurations James Hilliard
2026-09-26 15:49 ` [PATCH net v4 08/15] net: stmmac: keep DMA configurations at stable addresses James Hilliard
2026-09-26 15:49 ` [PATCH net v4 09/15] net: stmmac: track datapath and power ownership across failed reopening James Hilliard
2026-09-26 15:49 ` [PATCH net v4 10/15] net: stmmac: use the tracked datapath restart for XSK pool changes James Hilliard
2026-09-26 15:49 ` [PATCH net v4 11/15] net: stmmac: restore TC offloads before restarting DMA James Hilliard
2026-09-26 15:49 ` [PATCH net v4 12/15] xsk: allow drivers to retain DMA mappings independently of pools James Hilliard
2026-09-26 15:49 ` [PATCH net v4 13/15] net: stmmac: retain DMA memory until hardware shutdown completes James Hilliard
2026-09-26 15:49 ` [PATCH net v4 14/15] net: stmmac: prepare device-local DMA interrupt quiescence James Hilliard
2026-09-26 15:49 ` [PATCH net v4 15/15] net: stmmac: retain DMA resources across MTU changes James Hilliard
2026-09-26 16:00 ` [PATCH net v4 00/15] net: stmmac: preserve datapath state across MTU and resume failures Maxime Chevallier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®