mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v3 00/10] net: stmmac: preserve datapath state across MTU and resume failures
@ 2026-09-24 17:44 James Hilliard
  2026-09-24 17:44 ` [PATCH net v3 01/10] net: stmmac: unwind the WoL IRQ after a safety IRQ request failure James Hilliard
                   ` (9 more replies)
  0 siblings, 10 replies; 18+ messages in thread
From: James Hilliard @ 2026-09-24 17:44 UTC (permalink / raw)
  To: Russell King, Andrew Lunn, Heiner Kallweit, David S. Miller,
	Eric Dumazet, 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
  Cc: Richard Genoud, Alastair D'Silva, Maxime Ripard, netdev,
	linux-kernel, linux-stm32, linux-arm-kernel, bpf, ZhaoJinming,
	Lorenzo Bianconi, Ding Hui, James Hilliard

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@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>
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

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


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

end of thread, other threads:[~2026-09-25 19:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-24 17:44 [PATCH net v3 00/10] net: stmmac: preserve datapath state across MTU and resume failures James Hilliard
2026-09-24 17:44 ` [PATCH net v3 01/10] net: stmmac: unwind the WoL IRQ after a safety IRQ request failure James Hilliard
2026-09-24 17:44 ` [PATCH net v3 02/10] net: phylink: allow stopping a suspended instance James Hilliard
2026-09-24 17:44 ` [PATCH net v3 03/10] net: stmmac: keep datapath state coherent after reinitialization failure James Hilliard
2026-09-25 19:11   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 04/10] net: stmmac: leave the datapath running for normal-size MTU changes James Hilliard
2026-09-24 17:44 ` [PATCH net v3 05/10] net: stmmac: unwind partially allocated DMA configurations James Hilliard
2026-09-25 19:11   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 06/10] net: stmmac: keep DMA configurations at stable addresses James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 07/10] net: stmmac: account for failed live XDP reopening James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 08/10] net: stmmac: use the tracked datapath restart for XSK pool changes James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 09/10] net: stmmac: retain PHY and PM ownership during ethtool reopening James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 10/10] net: stmmac: retain DMA resources across MTU changes James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko

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®