mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v2 0/3] net: macb: fix close races (and RX refill error handling)
@ 2026-09-25 13:59 Théo Lebrun
  2026-09-25 13:59 ` [PATCH net v2 1/3] net: macb: never give hardware a NULL RX buffer Théo Lebrun
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Théo Lebrun @ 2026-09-25 13:59 UTC (permalink / raw)
  To: Conor Dooley, Andrew Lunn, David S. Miller, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Sean Anderson, Antoine Tenart,
	Eric Dumazet, Nicolas Ferre, Russell King
  Cc: netdev, linux-kernel, Nicolai Buchwitz, Vladimir Kondratiev,
	Gregory CLEMENT, Tawfik Bayouk, Thomas Petazzoni,
	Maxime Chevallier, Théo Lebrun, stable

The context-swapping series [0] has been ongoing for a while. The most
interesting part is a proper hardware shutdown sequence, which is truly
lacking in other parts of the MACB driver: at close, at suspend and in
the HRESP error task.

Instead of introducing that sequence for a new feature, apply it now to
fix the main offender, the close path. That fixes the races listed in
patch 3 and will allow the sequence to be reused later.

The first two patches are also fixes, but not related to the shutdown
sequence: they address allocation-failure codepaths. They are sent
alongside patch 3 because they touch the same code and would cause
merge conflicts if applied separately.

Now, let me list issues I'm aware of that we do *not* fix here, to make
the scope explicit:
 - HRESP task should sync with all other contexts. It frees buffers
   under the feet of the whole driver. The hardware shutdown sequence
   will help.
 - Suspend callback is also racy with BH primitives. We'll be able to
   reuse the hardware shutdown sequence.
 - Even if we assume tasks are frozen, the phylink ops aren't and might
   trigger between suspend and resume callbacks. Here we need to
   (1) early return in phylink ops and (2) at resume put the HW in its
   proper state according to phylink ops that occured.
 - Alloc failure codepaths aren't perfect outside open. Hardware and
   ring buffers are left in a sad state. We can probably do better.

[0]: https://lore.kernel.org/all/20260812-macb-context-v9-0-7ddbf5f715e0@bootlin.com/

---
Changes in v2:
- P1: ensure gem_rx() and macb_rx_pending() don't consume the
  descriptors where alloc failed.
- P2: gem_rx_refill() now only propagates an error if zero descriptors
  are ready. We tolerate partial refill hoping the next one will help.
- P2: we do *NOT* fix the set_ringparam codepath reported by Sashiko.
  Proper implementation will come with context swapping which will
  reuse the infra put in place in P3.
- P3: the hresp_err_bh_work/tx_lpi_work Sashiko-reported race has been
  fixed in a standalone, *NOT* here.
  https://lore.kernel.org/netdev/20260925-macb-netdev-register-race-v1-1-752f90ce1c39@bootlin.com/
- Take 2x Reviewed-by: Nicolai.
- Rebase onto latest net/main (11536ee3d3e0), nothing to report.
- Link to v1: https://patch.msgid.link/20260918-macb-close-v1-0-05e32ce98813@bootlin.com
- Nicolai's v1 reviews (duplicate thread):
  https://patch.msgid.link/20260918-macb-close-v1-0-221d916b7961@bootlin.com

To: Conor Dooley <conor.dooley@microchip.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>
To: "David S. Miller" <davem@davemloft.net>
To: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
To: Simon Horman <horms@kernel.org>
To: Sean Anderson <sean.anderson@linux.dev>
To: Antoine Tenart <atenart@kernel.org>
To: Eric Dumazet <edumazet@kernel.org>
To: Nicolas Ferre <nicolas.ferre@microchip.com>
To: Russell King <linux@armlinux.org.uk>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Nicolai Buchwitz <nb@tipi-net.de>
Cc: Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Cc: Gregory CLEMENT <gregory.clement@bootlin.com>
Cc: Tawfik Bayouk <tawfik.bayouk@mobileye.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: Théo Lebrun <theo.lebrun@bootlin.com>

---
Théo Lebrun (3):
      net: macb: never give hardware a NULL RX buffer
      net: macb: propagate RX ring refill errors
      net: macb: quiesce IRQs and drain BH on interface close

 drivers/net/ethernet/cadence/macb.h      |   7 +-
 drivers/net/ethernet/cadence/macb_main.c | 133 ++++++++++++++++++++++++-------
 2 files changed, 112 insertions(+), 28 deletions(-)
---
base-commit: 7c416e8f8423e6fe9b48e0b9c174bd902789f8db
change-id: 20260918-macb-close-dbbd23b4b8f2

Best regards,
--  
Théo Lebrun <theo.lebrun@bootlin.com>


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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 13:59 [PATCH net v2 0/3] net: macb: fix close races (and RX refill error handling) Théo Lebrun
2026-09-25 13:59 ` [PATCH net v2 1/3] net: macb: never give hardware a NULL RX buffer Théo Lebrun
2026-09-25 13:59 ` [PATCH net v2 2/3] net: macb: propagate RX ring refill errors Théo Lebrun
2026-09-25 14:20   ` Nicolai Buchwitz
2026-09-25 13:59 ` [PATCH net v2 3/3] net: macb: quiesce IRQs and drain BH on interface close Théo Lebrun

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®