[PATCH net v3] r8169: clear RxOverflow before unmasking interrupts
From: Jure Rebernik
Date: Thu Nov 26 2026 - 03:38:25 EST
When the RTL8125B runs out of RX descriptors it sets RxOverflow
(RxDescUnavail in the vendor driver) and stops receiving until
RxOverflow is cleared in IntrStatus, even after the driver has returned
the descriptors. Since commit 6994520a3328 ("r8169: disable interrupt
source RxOverflow") nothing may clear it:
1. The ring fills. The chip completes the last frames (RxOK), then
sets RxOverflow and stops receiving.
2. rtl8169_interrupt() read IntrStatus before RxOverflow was set, so it
clears only RxOK.
3. NAPI empties the ring and unmasks the interrupts.
4. The stopped receiver raises no new RxOK, and RxOverflow is not an
interrupt source, so reception stays stopped until another event,
such as TxOK, makes the handler clear all status bits.
This was observed on an RTL8125B (XID 641) on an arm64 Qualcomm QCS8550
with a 2.5 Gbit/s link, running v7.2.6 and receiving UDP at
1500 Mbit/s: reception stopped for seconds in most 30 s runs. During
stops in earlier runs, RxOverflow was set with all RX descriptors owned
by the NIC, and clearing only RxOverflow from user space restarted
reception. The order of steps 1 and 2 is inferred from that state.
Reproducing the stall needs no kernel change.
Clear RxOverflow in rtl8169_poll() whenever rtl_rx() stops at a
descriptor owned by the NIC, before napi_complete_done(). Clearing it
only when NAPI completes is not enough: with threaded busy polling NAPI
never completes and reception would stay stopped.
The clear runs on all chips that use rtl8169_poll(), that is all except
RTL8127 with more than one interrupt vector, but was tested only on
RTL8125B. Where RxOverflow is not set, the write has no effect.
Testing on v7.2.6 with two RTL8125B boards; a stall means reception
stopped for at least 1 s:
- Inbound UDP at 1500 Mbit/s, switching between the old and the new
behaviour on the same boot, 40 runs of 30 s each: old, 30 runs
stalled and 11% of the datagrams were lost; new, no run stalled and
0.012% were lost, almost all counted in rx_missed while the default
256-entry ring was briefly full.
- Threaded busy polling with the NAPI thread starved for 20 ms of every
200 ms, inbound UDP at 800 and 1500 Mbit/s, 12 runs of 40 s each:
old, no frame was received in any run; new, frames were received
throughout.
On this tree the patch was only built. rtl8169_poll() and
rtl_ack_events() changed since v7.2 for multiple RX queues
(36af5aac9545, 5df447aee076), but the changed lines behave the same on
single-vector chips.
The investigation was done with an AI coding assistant (Claude Code):
it wrote the HIL test scripts, the debugfs instrumentation and the
register tools used above, proposed this change and drafted this
changelog. I reviewed the change and the evidence, and the test
results above come from runs on our hardware.
Fixes: 6994520a3328 ("r8169: disable interrupt source RxOverflow")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jure Rebernik <jure.rebernik@xxxxxxxxxxx>
---
Notes:
v3:
- Clear RxOverflow whenever rtl_rx() has returned all descriptors, not
only when napi_complete_done() returns true, so that busy polling
cannot keep reception stopped (Sashiko)
- Say in the comment and the changelog that the clear runs on all
single-vector chips but was tested only on RTL8125B (Sashiko)
- Say how this tree differs from the tested v7.2 code (Sashiko)
- Test both paths at 1500 Mbit/s, where the stall reproduces reliably,
and busy polling with a starved NAPI thread
- Dropped Jacob's Reviewed-by, as the code changed
A build of this patch that counts the clears where RxOverflow was
actually set: in 20 runs at 1500 Mbit/s without a stall, 269 were
followed by NAPI completing and interrupts being re-enabled, and 320 by
NAPI not completing yet because of deferred hard interrupts.
With the RX ring raised to 1024 entries, which this patch does not do,
no run stalled with this patch: at 800 Mbit/s the NIC dropped no frames
in 60 runs on three boards, and at 1500 Mbit/s only 157 datagrams were
lost in 20 runs on two boards. With busy polling and the starved thread
it received about 69200 and 125100 frames/s at 800 and 1500 Mbit/s.
Stable trees do not have the multi-queue rework, so backports need
their context adapted; I can send those.
v2: https://lore.kernel.org/netdev/20261121073652.410916-1-jure.rebernik@xxxxxxxxxxx/
v1: https://lore.kernel.org/netdev/20261101102720.702600-1-jure.rebernik@xxxxxxxxxxx/
drivers/net/ethernet/realtek/r8169_main.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index f151ab681393..1da64c6e39e2 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5670,8 +5670,17 @@ static int rtl8169_poll(struct napi_struct *napi, int budget)
/* rtl8169_poll() is used only when there is a single RX ring. */
work_done = rtl_rx(dev, tp, &tp->rx_ring[0], budget, napi);
- if (work_done < budget && napi_complete_done(napi, work_done))
- rtl_irq_enable(tp);
+ if (work_done < budget) {
+ /* At least the RTL8125B stops receiving after running out of
+ * RX descriptors until RxOverflow is cleared. All descriptors
+ * are back with the chip now, so clear it, also when busy
+ * polling keeps NAPI from completing.
+ */
+ rtl_ack_events(tp, RxOverflow);
+
+ if (napi_complete_done(napi, work_done))
+ rtl_irq_enable(tp);
+ }
return work_done;
}
--
2.56.0