Skip to content

net: stmmac: fix DMA allocation and IRQ failure cleanup

Karl Mehltretter bpf linux-arm-kernel lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3net: stmmac: handle partially allocated DMA queuesdrivers/net/ethernet/stmicro/stmmac/stmmac_main.c+17 -51 reply
2/3net: stmmac: free RX resources when TX allocation failsdrivers/net/ethernet/stmicro/stmmac/stmmac_main.c+2 -01 reply
3/3net: stmmac: stop DMA when IRQ registration failsdrivers/net/ethernet/stmicro/stmmac/stmmac_main.c+2 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH net 0/3] net: stmmac: fix DMA allocation and IRQ failure cleanup

A DMA error-path review for the BeagleV Ahead found three bugs in the common STMMAC code. Partial allocation can call buffer cleanup without the metadata it indexes. A later TX allocation failure leaks the RX resources allocated first. IRQ registration failure can release descriptors and packet buffers while DMA remains active.

Patches 1 and 2 fix allocation cleanup. Patch 3 fixes the IRQ failure unwind independently.

Testing:

- BeagleV Ahead, TH1520 DWMAC 3.70a: guarded baseline/fixed boots for RX and TX allocation failures and normal-open IRQ failure. Baseline runs reached the guarded unsafe boundaries. Fixed runs cleared the tracked resources and stopped DMA before cleanup.
- A matched follow-up applied the same RTL8211F-VD resume repair to all baseline and fixed kernels. At both 100 and 1000 Mbit/s, each variant passed eight close/open cycles (32 total), delay-register checks, pings and bidirectional 1 MiB SHA-256 transfers with no RX CRC or DMA-API errors.
- Native-XDP IRQ failure was exercised on the same board. The baseline reached IRQ unwind with DMA active and required a test-only rescue; the fixed kernel stopped DMA before unwind. Both reached descriptor cleanup with DMA inactive and no DMA-API errors.
- The physical native-XDP pair used CONFIG_BPF_JIT=n in both variants to bypass an independent RISC-V execmem Oops after the STMMAC unwind. The default configuration's XDP-open path remains covered by the QEMU fault-injection matrix.
- The exact combined code passed 24 of 24 checked 64 MiB transfers on fresh BeagleV Ahead boots with no DMA-API errors.
- QEMU orangepi-pc/dwmac-sun8i: 36 of 36 cold boots passed across the allocation and IRQ matrices, including XDP-open IRQ failure.
- The exact combined code cross-built the STMMAC objects and BeagleV Ahead DTB with a RISC-V defconfig and DWMAC_THEAD enabled.

The guards and fault-injection hooks are test-only and are not in this series. The RTL8211F-VD repair is being submitted separately.

Based on 24a19b953e2a (Linux 7.3-rc7).

Karl Mehltretter (3):
net: stmmac: handle partially allocated DMA queues
net: stmmac: free RX resources when TX allocation fails
net: stmmac: stop DMA when IRQ registration fails

 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 26 +++++++++++++++----
 1 file changed, 21 insertions(+), 5 deletions(-)

base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907

Signature · 1 line
2.39.5 (Apple Git-154)