mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable
@ 2026-11-17  4:27 David Wu
  2026-11-19  8:11 ` Maxime Chevallier
  2026-11-19 19:27 ` netdev-bot+sashiko
  0 siblings, 2 replies; 5+ messages in thread
From: David Wu @ 2026-11-17  4:27 UTC (permalink / raw)
  To: netdev
  Cc: andrew+netdev, Jose.Abreu, davem, rmk+kernel, maxime.chevallier,
	lorenzo.bianconi, luis.la, linux-stm32, linux-kernel, David Wu

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.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index a0249715fafa..929aa77ce247 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
@@ -153,8 +153,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))
-- 
2.25.1


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

* Re: [PATCH net-next] net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable
  2026-11-17  4:27 [PATCH net-next] net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable David Wu
@ 2026-11-19  8:11 ` Maxime Chevallier
  2026-11-19 19:27 ` netdev-bot+sashiko
  1 sibling, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2026-11-19  8:11 UTC (permalink / raw)
  To: David Wu, netdev
  Cc: andrew+netdev, Jose.Abreu, davem, rmk+kernel, lorenzo.bianconi,
	luis.la, linux-stm32, linux-kernel

Hi,

You're missing some people in CC, including the network maintainers...

On 11/17/26 05:27, David Wu wrote:
> 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.
> 
> Signed-off-by: David Wu <david.wu@rock-chips.com>

In essence this looks correct to me. This fixes some real hangs, so
I'm wondering if this shouldn't actually go to net.

Please re-send to net and with everyone in CC, you can add:

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>

Maxime


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

* Re: [PATCH net-next] net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable
  2026-11-17  4:27 [PATCH net-next] net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable David Wu
  2026-11-19  8:11 ` Maxime Chevallier
@ 2026-11-19 19:27 ` netdev-bot+sashiko
  1 sibling, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 19:27 UTC (permalink / raw)
  To: david.wu
  Cc: netdev, andrew+netdev, Jose.Abreu, davem, rmk+kernel,
	maxime.chevallier, lorenzo.bianconi, luis.la, linux-stm32,
	linux-kernel, kuba

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

Critical: 0 · High: 0 · Medium: 3 · 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).

- [Medium] The commit message says that because the RBU handler only
  counted the event, "the RX NAPI is therefore never invoked,…
- [Medium] In dwmac4_dma_interrupt()
  (drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c), the new `ret |=…
- [Medium] In dwmac4_dma_interrupt(), the new RBU handling only runs
  inside `if (intr_status & DMA_CHAN_STATUS_AIS)`.
- [Low] The commit fixes a user-visible problem: it says RX "hangs
  forever" once the ring is exhausted, and it blames the gap on commit…

--

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

The patch makes dwmac4_dma_interrupt() return handle_rx when the RBU
(Receive Buffer Unavailable) status bit is set, so the RX NAPI is
scheduled and the ring gets refilled. Before this, RBU only bumped a
counter. The goal is to match the XGMAC handler and recover from RX
hangs once the RX ring is exhausted.

> 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: Medium]
Is this description accurate? stmmac_rx() calls stmmac_rx_refill() at
the end of every NAPI poll, and stmmac_rx_refill() always ends with:

	rx_q->dirty_rx = entry;
	stmmac_set_queue_rx_tail_ptr(priv, rx_q, queue, rx_q->dirty_rx);
	/* Wake up Rx DMA from the suspend state if required */
	stmmac_enable_dma_reception(priv, priv->ioaddr, queue);

If the ring ran dry only because refill was slow, the next poll
triggered by an RI would restart it.

A permanent hang seems to need a poll that completes while descriptors
are still unrefilled. In the non-ZC path, that happens when
page_pool_alloc_pages() fails for buf->page, or for buf->sec_page with
SPH:

		if (stmmac_rx_check_buf2_cap(priv) && !buf->sec_page) {
			buf->sec_page = page_pool_alloc_pages(rx_q->page_pool, gfp);
			if (!buf->sec_page)
				break;

stmmac_rx_refill() returns void, so stmmac_rx() returns count < budget
and stmmac_napi_poll_rx() calls napi_complete_done(). No RI follows
after that, because the DMA is suspended on CPU-owned descriptors.

The XSK path already handles this case. stmmac_rx_zc() ends with:

	return failure ? limit : (int)count;

so NAPI keeps polling.

If refill failure is the real trigger, the hang would predate
1b9707e6f1a9. Before that commit RBU was not enabled at all, and the
same exhaustion plus refill failure would hang the same way. Could the
commit message describe the refill failure case instead?

There is a related concern. Suppose the poll triggered by RBU also
fails to allocate, and the hardware raises RBU only once per
suspension. NAPI would complete again and RX would stay hung. Would it
be more robust to keep polling on refill failure, the way
stmmac_rx_zc() does? Whether RBU is raised again while the DMA stays
suspended can't be determined from the driver code alone.

[ ... ]

> Signed-off-by: David Wu <david.wu@rock-chips.com>

[Severity: Low]
Should this have a Fixes: tag? The commit message names 1b9707e6f1a9
as the commit that left the gap, and this change depends on it.
1b9707e6f1a9 is what added DMA_CHAN_INTR_ENA_RBU to both
DMA_CHAN_INTR_ABNORMAL and DMA_CHAN_INTR_ABNORMAL_4_10.

On a tree without that commit, RBU raises no interrupt. A backport of
the new ret |= handle_rx would build but do nothing. For example:

Fixes: 1b9707e6f1a9 ("net: stmmac: enable RPS and RBU interrupts")

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> index a0249715fafaf..929aa77ce247d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> @@ -153,8 +153,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: Medium]
Can handle_rx get lost here? Later in the same AIS block of
dwmac4_dma_interrupt(), the TPS and FBE branches 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;
		}

Say RBU and TPS (or FBE) are set in the same status read and RI is
not. The handle_rx bit set above is then overwritten. The final
writel(intr_status & intr_en, ...) still acknowledges RBU because RBUE
is enabled. The RX NAPI is not scheduled and the RX DMA stays
suspended.

The callers then see status == tx_hard_error in stmmac_dma_interrupt()
and stmmac_msi_intr_tx(), so only stmmac_tx_err() runs.

The XGMAC handler that the commit message refers to uses
ret |= tx_hard_error in dwxgmac2_dma_interrupt(), so handle_rx is kept
there.

TPS can occur together with RBU in the shared IRQ path, because
stmmac_dma_interrupt() passes DMA_DIR_RXTX. TPS is also never
acknowledged. DMA_CHAN_INTR_DEFAULT_MASK and
DMA_CHAN_INTR_DEFAULT_MASK_4_10 have no TPS enable bit, and the
writeback is masked with intr_en.

TX DMA can be stopped at runtime without a full DMA reset, for example
in stmmac_tx_err() and in stmmac_disable_tx_queue() during XSK pool
setup. If the hardware latches TPS regardless of its enable bit, every
later RBU on that channel would lose handle_rx.

FBE is in DMA_CHAN_STATUS_MSK_COMMON, so it can clobber handle_rx on
the per-channel RX MSI path too, although FBE is fatal anyway.

Switching TPS and FBE to |= would also mean the status ==
tx_hard_error checks in stmmac_dma_interrupt() and stmmac_msi_intr_tx()
have to become bit tests.

[Severity: Medium]
Does checking RBU only under AIS leave a gap in multi-MSI mode (INTM
mode 1, set in dwmac4_dma_init() when multi_msi_en is set)? AIS is
part of DMA_CHAN_STATUS_MSK_COMMON, so DMA_CHAN_STATUS_MSK_TX also
includes it. The per-channel TX vector reads and writes back the same
channel status register:

stmmac_msi_intr_tx()
  stmmac_napi_check(priv, chan, DMA_DIR_TX)
    dwmac4_dma_interrupt()
      writel(intr_status & intr_en, ...)

RBU is masked out on that path, but AIS is not. On 4.10+ cores,
DMA_CHAN_INTR_ENA_AIE_4_10 is BIT(14), the same bit as
DMA_CHAN_STATUS_AIS. The TX side can therefore write-1-clear AIS while
RBU stays set.

When stmmac_msi_intr_rx() runs next with DMA_DIR_RX, it would see RBU
with AIS clear and skip the new ret |= handle_rx. Its writeback still
clears RBU, because RBU is in DMA_CHAN_STATUS_MSK_RX and RBUE is
enabled. The RBU event is used up without scheduling the RX NAPI, so
RX stays suspended until something else schedules it.

TBU, RWT and ERI are already checked outside the AIS block. Would it
make sense to check RBU outside it as well? This depends on whether
AIS re-asserts while RBU stays set, which the driver code doesn't
show.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117042754.96177-1-david.wu%40rock-chips.com

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

* Re: [PATCH net-next] net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable
  2026-11-17  3:43 David Wu
@ 2026-11-19 19:43 ` netdev-bot+sashiko
  0 siblings, 0 replies; 5+ messages in thread
From: netdev-bot+sashiko @ 2026-11-19 19:43 UTC (permalink / raw)
  To: david.wu
  Cc: rmk+kernel, maxime.chevallier, lorenzo.bianconi, luis.la, netdev,
	linux-stm32, linux-kernel, kuba

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

Critical: 0 · High: 0 · Medium: 3 · 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).

- [Medium] In dwmac4_dma_interrupt()
  (drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c), the new `ret |=…
- [Medium] The fix depends on a single RBU edge to restart a suspended RX
  DMA, but the non-ZC RX poll does not handle a refill failure.
- [Medium] The new RBU → handle_rx scheduling in dwmac4_dma_interrupt()
  runs only when the handler sees DMA_CHAN_STATUS_AIS (line 155).
- [Low] The patch fixes a permanent, user-visible RX hang but has no
  Fixes: tag and no stable Cc.

--

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

This patch makes dwmac4_dma_interrupt() return handle_rx when it sees the
Receive Buffer Unavailable (RBU) abnormal interrupt. The RX NAPI then gets
scheduled, so stmmac_rx_refill() can restart a suspended RX DMA. This
matches what the XGMAC handler already does for RBU.

> 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: tag for 1b9707e6f1a9, and maybe a stable Cc?
Without one, kernels that already have 1b9707e6f1a9 won't get this hang
fix automatically.

The wording also suggests that 1b9707e6f1a9 caused the hang. As far as I
can tell, 1b9707e6f1a9 only added DMA_CHAN_INTR_ENA_RPS/RBU to
DMA_CHAN_INTR_ABNORMAL(_4_10) so the counters would update. A drained ring
stalled before that commit too. 1b9707e6f1a9 is what makes this approach
possible.

Would a sentence saying this change has no effect without 1b9707e6f1a9
help backporters?

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> index a0249715fafaf..929aa77ce247d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
> @@ -153,8 +153,10 @@ int dwmac4_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
>  
>  	/* ABNORMAL interrupts */
>  	if (unlikely(intr_status & DMA_CHAN_STATUS_AIS)) {

[Severity: Medium]
Is gating on AIS safe in multi-MSI mode? stmmac_msi_intr_tx() and
stmmac_msi_intr_rx() both call dwmac4_dma_interrupt() on the same
DMA_CHAN_STATUS register, and no lock serializes them. AIS is in
DMA_CHAN_STATUS_MSK_COMMON, which is part of both MSK_RX and MSK_TX. AIE is
in intr_en, so the TX vector handler also acks AIS.

Consider this sequence on one channel:

TX vector (CPU1)
  dwmac4_dma_interrupt(..., DMA_DIR_TX)
    reads AIS | TI | RBU, masks to MSK_TX
    writel(AIS | TI)   /* clears AIS */

RX vector (CPU2)
  dwmac4_dma_interrupt(..., DMA_DIR_RX)
    reads RBU without AIS
    skips the RBU branch
    writel(RBU)        /* clears RBU */

Could RBU get acked here without rx_napi being scheduled? Two things
decide this, and I couldn't confirm either from the code:

  - whether RBU can reach the RX vector without RI in the same read
  - whether AIS re-asserts while RBU stays set

The dir mask already limits RBU to the RX side. Would testing RBU outside
the AIS block close this window?

This doesn't apply in shared IRQ (DMA_DIR_RXTX) mode.

> -		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: Medium]
Can handle_rx be lost when RBU shows up in the same status read as TPS or
FBE? Later in the same AIS block, ret is assigned, not ORed:

drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c:dwmac4_dma_interrupt() {
    ...
		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;
		}
    ...
	writel(intr_status & intr_en,
	       ioaddr + DMA_CHAN_STATUS(dwmac4_addrs, chan));
}

DMA_CHAN_INTR_ENA_RBU is in DMA_CHAN_INTR_ABNORMAL, so the final writel()
still clears RBU. stmmac_napi_check() then doesn't schedule rx_napi. When
status == tx_hard_error, stmmac_dma_interrupt() only calls stmmac_tx_err().
Would the RX DMA stay suspended in that case?

TPS may make this easier to hit. Its enable bit isn't in
DMA_CHAN_INTR_ABNORMAL(_4_10), so the W1C write never clears it. TX DMA
can be stopped without a DMA soft reset, for example:

  - stmmac_tx_err()->stmmac_stop_tx_dma()
  - stmmac_disable_tx_queue() during XSK pool setup

TPS could then stay latched. In shared IRQ (DMA_DIR_RXTX) mode, every
later RBU on that channel would take the ret = tx_hard_error path, and
stmmac_tx_err() would stop TX DMA again.

dwxgmac2_dma_interrupt(), which the commit message cites, uses
ret |= tx_hard_error and so keeps handle_rx. Switching to |= alone isn't
enough here, because stmmac_dma_interrupt() and stmmac_msi_intr_tx() test
for equality:

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

Would it work to OR handle_rx back in after the TPS/FBE checks, or to
switch both sides to bit tests?

[Severity: Medium]
Is a single RBU edge enough to recover if the refill fails? This RBU is
W1C cleared before anyone knows whether stmmac_rx_refill() worked.

stmmac_rx_refill() allocates with GFP_ATOMIC | __GFP_NOWARN:

		if (!buf->page) {
			buf->page = page_pool_alloc_pages(rx_q->page_pool, gfp);
			if (!buf->page)
				break;
		}

		if (stmmac_rx_check_buf2_cap(priv) && !buf->sec_page) {
			buf->sec_page = page_pool_alloc_pages(rx_q->page_pool, gfp);
			if (!buf->sec_page)
				break;

If the allocation fails on the first dirty descriptor, dirty_rx and the
tail pointer are written back unchanged. dwmac4 has no
enable_dma_reception callback to kick the DMA.

stmmac_rx_refill() returns void, and stmmac_rx() returns only the packet
count. So stmmac_napi_poll_rx() calls napi_complete_done() and re-enables
only RIE. A suspended DMA can't raise RI. RBU is set only when the DMA
moves from a DMA-owned descriptor to a host-owned one, so it shouldn't
re-assert.

Would RX on that queue then hang, which is the same state this patch is
meant to fix?

stmmac_rx_zc() handles the same case by returning limit on failure, so
NAPI keeps polling:

	return failure ? limit : (int)count;

The SPH setup in the commit message needs two page allocations per
descriptor, so it is the setup most likely to hit this.

> +		}
>  		if (unlikely(intr_status & DMA_CHAN_STATUS_RPS))
>  			x->rx_process_stopped_irq++;
>  		if (unlikely(intr_status & DMA_CHAN_STATUS_ETI))

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117034332.88443-1-david.wu%40rock-chips.com

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

* [PATCH net-next] net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable
@ 2026-11-17  3:43 David Wu
  2026-11-19 19:43 ` netdev-bot+sashiko
  0 siblings, 1 reply; 5+ messages in thread
From: David Wu @ 2026-11-17  3:43 UTC (permalink / raw)
  To: david.wu
  Cc: rmk+kernel, maxime.chevallier, lorenzo.bianconi, luis.la, netdev,
	linux-stm32, linux-kernel

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.

Signed-off-by: David Wu <david.wu@rock-chips.com>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index a0249715fafa..929aa77ce247 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
@@ -153,8 +153,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))
-- 
2.25.1


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

end of thread, other threads:[~2026-11-19 19:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17  4:27 [PATCH net-next] net: stmmac: dwmac4: schedule RX NAPI on Receive Buffer Unavailable David Wu
2026-11-19  8:11 ` Maxime Chevallier
2026-11-19 19:27 ` netdev-bot+sashiko
  -- strict thread matches above, loose matches on Subject: below --
2026-11-17  3:43 David Wu
2026-11-19 19:43 ` 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®