Skip to contentSkip to conversation

net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable

PATCH RESEND New David Wu 2 participants 2 messages Nov 20 – Nov 24

Subsystems (4)
lore
Share & tools
lore

David Wu

author
#0 lore raw

PATCH RESEND 1/1 net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable

Once the RX ring is exhausted, the RX DMA enters the suspend state and no more Receive Interrupts can be generated: incoming frames are kept in the MTL RX FIFO and are dropped once it overflows. The RX DMA only resumes after software refills the ring and updates the RX tail pointer, which is done by the RX NAPI poll (stmmac_rx_refill()).

Commit 1b9707e6f1a9 ("net: stmmac: enable RPS and RBU interrupts") enabled the RBU interrupt for dwmac4, but the interrupt handler only updates the statistics counter without scheduling the RX NAPI. The RX NAPI is therefore never invoked, stmmac_rx_refill() never runs, and the RX path hangs forever once the ring has been exhausted.

Schedule the RX NAPI when the RBU interrupt is received, aligning the dwmac4 behaviour with XGMAC (commit 6338488356d2 ("net: stmmac: xgmac:
Add RBU handling in DMA interrupt")).

This can be observed on a GMAC4 based platform with Split Header (SPH) enabled under high TCP RX pressure, where the slower RX refill path lets the RX ring run dry.

Tested with Split Header (SPH) enabled, running a large file download over TCP:

- Without this change, the RX path hangs permanently once the RX ring is exhausted: the RX tail pointer is never updated again and the DMA channel status register latches the RBU bit, while the TX path keeps running.

- With this change, each RBU interrupt is handled and the RX path recovers by itself. e.g. 3 RBU events within 6 ms during a download peak, each one self-recovered (the RX tail pointer resumes advancing right after), with no further RBU events afterwards.

---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +3 -1
index 02aa1a3dd1e2..de6bd6f8a7d5 100644
@@ -155,8 +155,10 @@ int dwmac4_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
 
 	/* ABNORMAL interrupts */
 	if (unlikely(intr_status & DMA_CHAN_STATUS_AIS)) {
-		if (unlikely(intr_status & DMA_CHAN_STATUS_RBU))
+		if (unlikely(intr_status & DMA_CHAN_STATUS_RBU)) {
 			x->rx_buf_unav_irq++;
+			ret |= handle_rx;
+		}
 		if (unlikely(intr_status & DMA_CHAN_STATUS_RPS))
 			x->rx_process_stopped_irq++;
 		if (unlikely(intr_status & DMA_CHAN_STATUS_ETI))
Signature · 1 line
2.25.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).

- [High] The fix only works when RBU is handled through stmmac_napi_check().
- [Medium] In dwmac4_dma_interrupt(), the new ret |= handle_rx for RBU (line 160) is followed by the TPS and FBE branches, which still use…
- [Low] The commit fixes a user-visible permanent RX hang and names commit 1b9707e6f1a9 ('net: stmmac: enable RPS and RBU interrupts') as…

--

net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable

When dwmac4_dma_interrupt() sees the Receive Buffer Unavailable (RBU) abnormal interrupt, this patch makes it return handle_rx so that the RX NAPI is scheduled. That NAPI poll refills the ring and lets the suspended RX DMA resume. The goal is to match the existing XGMAC RBU handling.

Quoted 5 lines

Commit 1b9707e6f1a9 ("net: stmmac: enable RPS and RBU interrupts") enabled the RBU interrupt for dwmac4, but the interrupt handler only updates the statistics counter without scheduling the RX NAPI. The RX NAPI is therefore never invoked, stmmac_rx_refill() never runs, and the RX path hangs forever once the ring has been exhausted.

[Severity: Low]
Should this have a Fixes: 1b9707e6f1a9 ("net: stmmac: enable RPS and RBU interrupts") tag, and perhaps a Cc: stable? The trailers only include Signed-off-by and Reviewed-by. Commit 686b5f47f8cc ("net: stmmac: Clear DMA errors for multi-channel interrupts") does carry a Fixes: tag for the same commit.

drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c int dwmac4_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr, · line 161

Quoted 13 lines
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +3 -1
index 02aa1a3dd1e25..de6bd6f8a7d58 100644
@@ -155,8 +155,10 @@ int dwmac4_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
 
 	/* ABNORMAL interrupts */
 	if (unlikely(intr_status & DMA_CHAN_STATUS_AIS)) {
-		if (unlikely(intr_status & DMA_CHAN_STATUS_RBU))
+		if (unlikely(intr_status & DMA_CHAN_STATUS_RBU)) {
 			x->rx_buf_unav_irq++;
+			ret |= handle_rx;
+		}

[Severity: High]
Does this also cover GMAC4 platforms in multi-MSI mode (STMMAC_FLAG_MULTI_MSI_EN, e.g. dwmac-intel mGbE, dwmac-motorcomm YT6801, dwmac-s32, dwmac-loongson)?

On those platforms RBU is part of the error mask:

#define DMA_CHAN_STATUS_MSK_ERR (DMA_CHAN_STATUS_AIS | DMA_CHAN_STATUS_FBE | DMA_CHAN_STATUS_RPS | DMA_CHAN_STATUS_RBU)

The common IRQ handler gets here with DMA_DIR_ERR:

stmmac_mac_interrupt()
stmmac_dma_err_interrupt()
stmmac_dma_interrupt_status(..., DMA_DIR_ERR)
dwmac4_dma_interrupt()

stmmac_dma_err_interrupt() only checks for tx_hard_error, so the handle_rx bit returned here is dropped:

	status = stmmac_dma_interrupt_status(priv, priv->ioaddr,
					     &priv->xstats, chan,
					     DMA_DIR_ERR);
	if (unlikely(status & tx_hard_error))
		stmmac_global_err(priv);

The write-back at the end of dwmac4_dma_interrupt() still acknowledges RBU and AIS:

	writel(intr_status & intr_en,
	       ioaddr + DMA_CHAN_STATUS(dwmac4_addrs, chan));

That consumes the RBU event, and the RX NAPI is never scheduled. Wouldn't the RX DMA then stay suspended, with stmmac_rx_refill() never running? That is the same RX hang the commit message describes.

RBU is in both DMA_CHAN_STATUS_MSK_RX and DMA_CHAN_STATUS_MSK_ERR, and nothing serializes the read/ack sequence across vectors. So the common IRQ handler could also beat the per-channel RX vector and swallow the event even when the RX vector saw it too.

Commit 686b5f47f8cc ("net: stmmac: Clear DMA errors for multi-channel interrupts") is what sends RBU to this error path in multi-MSI mode.

Could stmmac_dma_err_interrupt() honour handle_rx for chan < rx_queues_to_use the same way stmmac_napi_check() does? That would mean disabling the RX DMA irq under ch->lock and calling __napi_schedule() on rx_napi.

[Severity: Medium]
A few lines further down, the TPS and FBE branches still use plain assignment:

		if (unlikely(intr_status & DMA_CHAN_STATUS_TPS)) {
			x->tx_process_stopped_irq++;
			ret = tx_hard_error;
		}
		if (unlikely(intr_status & DMA_CHAN_STATUS_FBE)) {
			x->fatal_bus_error_irq++;
			ret = tx_hard_error;
		}

If RBU appears in the same status read as TPS or FBE, is the handle_rx bit set here overwritten?

In single IRQ mode (DMA_DIR_RXTX), stmmac_napi_check() would then skip rx_napi, and stmmac_dma_interrupt() would only run TX recovery:

		} else if (unlikely(status[chan] == tx_hard_error)) {
			stmmac_tx_err(priv, chan);
		}

By then the write-back has already acknowledged RBU, so the RX ring would stay exhausted. In multi-MSI RX mode, FBE is also in the RX mask, so RBU together with FBE loses handle_rx in the same way.

TPS isn't in DMA_CHAN_INTR_ABNORMAL, so the writel(intr_status & intr_en, ...) write-back never acknowledges it. If the hardware keeps TPS latched after a runtime TX DMA stop (stmmac_tx_err() and stmmac_disable_tx_queue() both call stmmac_stop_tx_dma()), every later RBU in RXTX mode could hit this overwrite. That part depends on how the IP latches TPS, and I couldn't confirm it from the code.

The XGMAC handler named in the commit message, dwxgmac2_dma_interrupt(), uses ret |= tx_hard_error, so handle_rx is kept there. Just changing dwmac4 to |= wouldn't be enough, though, because stmmac_dma_interrupt() tests status[chan] == tx_hard_error.

Could handle_rx be ORed in after the TPS/FBE assignments? The other option would be to change both the assignments and the callers' equality tests.

Quoted 3 lines
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +0 -0
 		if (unlikely(intr_status & DMA_CHAN_STATUS_RPS))
 			x->rx_process_stopped_irq++;
 		if (unlikely(intr_status & DMA_CHAN_STATUS_ETI))
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120150805.763415-1-david.wu%40rock-chips.com