Skip to content

RFC net: macb: fix TX stalls, IRQ storms and a lost NCR update on link-up

Steffen Dirkwinkel linux-rt-devel lkml netdev stable 1 version In review

Get series with b4
b4 am [email protected] change-id 20261022-std-macb-v14-send-6c5fd939b4e1

Versions newest first

  1. v1 RFC Latest6 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6net: macb: take bp->lock around NCR read-modify-writesdrivers/net/ethernet/cadence/macb_main.c+12 -20 replies
2/6net: macb: reprogram TBQP after shuffling the TX ring on link-updrivers/net/ethernet/cadence/macb_main.c+8 -10 replies
3/6net: macb: mask TXUBR during TX NAPI poll to prevent IRQ stormsdrivers/net/ethernet/cadence/macb_main.c+3 -20 replies
4/6net: macb: rotate unreaped TX frames behind the ring base on link-updrivers/net/ethernet/cadence/macb_main.c+31 -120 replies
5/6net: macb: kick the transmitter on link-updrivers/net/ethernet/cadence/macb_main.c+6 -00 replies
6/6net: macb: keep best-effort traffic on TX queue 0drivers/net/ethernet/cadence/macb_main.c+11 -00 replies

Reviews trailers per patch

1 of 6 patches has a Reviewed-by or Acked-by.

PatchNicolai Buchwitz
1/6R-b
2/6
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH RFC net 0/6] net: macb: fix TX stalls, IRQ storms and a lost NCR update on link-up

Hello Théo, Christian, all,

I've been looking at RCU and TX stalls on macb devices (Xilinx ZynqMP on Beckhoff CX9240) for a while and have been carrying downstream patches similar to Christian's. A while ago I let Claude try to reproduce this on my devices, it was able to reproduce and found some fixes but I wasn't happy with the quality of the patches and my understanding of them. I briefly talked to Théo in Prague and he suggested I send what I have as either the patches or the reproducers may be useful for ideas.
I've finally gotten around to it and also ran some more testing and improved the patches in the meantime. The series includes Christian's patches in the original form (should also at least be reworded) and I also have Patch 1 in here since the bench seems to have reproduced the issue on hardware (see below).

If anyone has other ideas / patches for these issues I'm also happy to run tests on devices.

Claude output from here:

This series fixes the TX stalls, TXUBR interrupt storms and RCU stalls we reproduce on ZynqMP (GEM rev 0x50070106, two TX queues, PREEMPT_RT). Patch 1 is Théo's NCR locking patch [1], unchanged; patches 2 and 3 are Christian's v1 [2], unchanged; patches 4 to 6 are ours. Patch 6 is most likely what Théo reported in [3].

Reproducers (all on the same ZynqMP board, RT config, IRQs on CPU 0, rcu_cpu_stall_timeout=8, iperf3 -P10 against a host on the same link):

A. the link speed is toggled between 100 and 1000 Mbit/s every ~12 s
with "ethtool -s end0 speed {100,1000} duplex full autoneg on" while the load runs; after every link-up the transmit counter, the netdev watchdog counters and the interrupt rate are checked. A storm is left running so the RCU stall detector can report it.
B. a managed switch cycles the DUT's two ports (one port only, the other
port only at 10 Mbit/s, back at autoneg), ~140 s per cycle; a hit is an RCU stall on the serial console.

Results, vanilla net/main 78731b46967e, PREEMPT_RT:

  driver                       A: failures/toggles          B: hits/cycles
  net/main                     watchdog at link-up 2,       1 TX stall episode
                               RCU stall at link-up 3       in 74 cycles

(idle mode: stall at 3)
patches 2-6 0/300 (idle mode 0/50) 0/74 (with load)

Same on a v7.2.7-rt tree with the net/main driver files (same bench):

net/main 8/9 toggles failed, RCU stall after 9 link-ups
patches 2-6 1/300 (one dead transmitter), 0 stalls in ~1300

Per patch, one patch removed at a time from the series (method A):

patch 2 (TBQP) alone off 0/100; TBQP reads the stale pre-link-down
index in 176/295 link-ups without the write, 0/555 with it (trace)

  patch 3 (TXUBR mask) alone off  0/100
  patches 2+3 off                 RCU stall at toggle 85 (1/153)
  patches 2+3+4 off               RCU stall at toggle 42 (1/41, p = 0.03)
  patch 4 (rotate) alone off      1/97: TBQP stopped at index 0 on the used

descriptor of an unreaped frame, watchdog
patch 5 (kick) alone off 8/11 toggles: watchdogs, p = 7e-13
patch 6 (queue 0) alone off 1/100 watchdog; per-stream share at
100 Mbit/s 6.9 to 11.7 Mbit/s over both queues vs 9.3 Mbit/s x10 with it
patches 5+6 off (2-4 only) 8/16 toggles: watchdogs on queue 0

So patches 2, 3 and 4 together prevent the storm and the RCU stall, patch 5 fixes the TX stall after link-up, patch 6 fixes the strict-priority unfairness (no starvation-induced stall reproduced on this device).

Patch 1: once in ~300 toggles the transmitter stayed dead after a link-up with patches 2-6. Tracing every NCR writer showed the cause:
macb_mac_link_down() clears RE|TE with an unlocked read-modify-write, and macb_tx_restart() in the TX NAPI poll, which had read NCR with TE set just before, writes its image back with TSTART 40 us to 900 us later. TE is set again while the link is down, the next link-up starts with TE set, the TBQP write of patch 2 is dropped and the ring is rotated under a running transmitter. With the read-to-write gap of the TSTART path widened to 1 ms to amplify the race: without patch 1, 3 dead transmitters and an RCU stall in 792 toggles, 6 lost updates in 408 traced link-downs; with patch 1, 0 in 1196 toggles (p = 0.025) and 0 lost updates in 1206 link-downs. The
traces (link_down clear, the stale write from irq/22-eth%d, TE set at the next link-up) are available on request.

Answering the review of [2]: with the rest of the series in place, removing patch 2 or patch 3 alone gives 0/100 each, removing both brings the RCU stall back (1 in 153 toggles), removing 2, 3 and 4 gives 1 in 41; TBQP of queue 0 keeps its
value while TE is low in about half of the link-ups on this GEM, as in Christian's trace, while the fetch still starts at the base after TSTART. Both reproducers were run on vanilla net/main; only PREEMPT_RT was tested.

Théo's steady-state case ("iperf3 -P10" for 30 min without transitions) gave no watchdog on this device with or without the series.

[1] https://lore.kernel.org/netdev/[email protected]/
[2] https://lore.kernel.org/netdev/20260706-upstreaming-macb-irq-storm-v1-1-ab3115b5a13a@weidmueller.com/
[3] https://lore.kernel.org/netdev/[email protected]/

---
Christian Taedcke (2):
net: macb: reprogram TBQP after shuffling the TX ring on link-up
net: macb: mask TXUBR during TX NAPI poll to prevent IRQ storms

Steffen Dirkwinkel (3):
net: macb: rotate unreaped TX frames behind the ring base on link-up
net: macb: kick the transmitter on link-up
net: macb: keep best-effort traffic on TX queue 0

Théo Lebrun (1):

      net: macb: take bp->lock around NCR read-modify-writes
 drivers/net/ethernet/cadence/macb_main.c | 80 ++++++++++++++++++++++++++------
 1 file changed, 67 insertions(+), 13 deletions(-)

---
base-commit: 78731b46967e3e7102b5cd5062bef185f3404b5c
change-id: 20261022-std-macb-v14-send-6c5fd939b4e1

Best regards,

Signature · 1 line
Steffen Dirkwinkel <[email protected]>