Netdev List
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Jure Rebernik <jure.rebernik@luxonis.com>,
	Heiner Kallweit <hkallweit1@gmail.com>, <nic_swsd@realtek.com>,
	<netdev@vger.kernel.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Sunil Goutham <sgoutham@marvell.com>,
	<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH net v2] r8169: clear RxOverflow before unmasking interrupts
Date: Mon, 23 Nov 2026 11:20:14 -0800	[thread overview]
Message-ID: <e5f2fb8e-1129-41d0-b627-6d96b81899f8@intel.com> (raw)
In-Reply-To: <20261121073652.410916-1-jure.rebernik@luxonis.com>

On 11/20/2026 11:36 PM, Jure Rebernik wrote:
> When the RTL8125B runs out of RX descriptors it sets RxOverflow
> (RxDescUnavail in the vendor driver) and stops receiving. It does not
> start again when the driver returns descriptors to it, only when
> RxOverflow is cleared in IntrStatus. 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. Reception stays stopped, and every frame is
>     counted in rx_missed, until another event such as TxOK makes the
>     handler clear all status bits.
> 
> This was observed on a machine in real use: an RTL8125B (XID 641) on the
> PCIe bus of an arm64 Qualcomm QCS8550, running v7.2.6 and receiving UDP
> at 800 Mbit/s while sending nothing. Reception stopped for seconds and
> a single transmitted packet restarted it. During each stop, a debugfs
> dump added to a test build of the driver showed IntrMask 0x2f,
> IntrStatus 0x50, NAPI idle and all 256 RX descriptors owned by the NIC,
> and writing only RxOverflow to IntrStatus from user space, through the
> sysfs PCI resource mapping and with nothing transmitted, restarted
> reception in 17 of 17 stops. The order of steps 1 and 2 is inferred
> from that state, not traced. Reproducing the stall itself needs no
> kernel modification.
> 
> Clear RxOverflow in rtl8169_poll() once NAPI has emptied the ring, right
> before unmasking. This restarts reception without making the "ring
> empty" condition an interrupt source again.
> 
> Testing, on v7.2.6 with an RTL8125B and inbound UDP at 800 Mbit/s in
> 30 s runs:
> 
>  - A test build with a module parameter that switches between the old
>    and the new behaviour on the same boot, 75 runs each:
> 
>      old: 9 runs lost more than 1000 datagrams, 1041366 lost in total
>      new: no run lost more than 1000 datagrams, 846 lost in total and
>           at most 184 in one run
> 
>    The 846 equal the NIC's rx_missed count over those runs. The NIC
>    dropped them while the default 256-entry RX ring was briefly full;
>    reception did not stop.
> 
>  - This patch as written, without the module parameter: no run of 20
>    lost more than 1000 datagrams (166 lost in total due to the default
>    256-entry RX ring). With the unchanged driver on the same day, 3 of
>    10 runs did (237264 lost in total).
> 
> On this tree the patch was only built, not run; rtl8169_poll() is the
> same here as in v7.2.
> 
> 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@vger.kernel.org
> Signed-off-by: Jure Rebernik <jure.rebernik@luxonis.com>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

> 
> Notes:
>     v2:
>     - Clear RxOverflow in rtl8169_poll() instead of making it an interrupt
>       source again, as there should be no "ring empty" interrupt (Jakub)
>     - Describe the race step by step
>     - Same-boot A/B test results
>     
>     Keeping the v1 approach also fixes the stall: with RxOverflow in the
>     unconditional init of tp->irq_mask, as Jakub suggested for v1, 0 of 76
>     runs lost more than 1000 datagrams against 5 of 76 with the old mask.
>     I can send that version instead if it is preferred.
>     
>     With the RX ring raised to 1024 entries, which this patch does not do,
>     and v1 or v2 of this fix, 20 runs on two boards lost no datagrams at
>     all.
>     
>     The patch changes only rtl8169_poll(), the single-vector path that
>     RTL8125B uses. The multi-vector path added for RTL8127 after v7.3 has
>     its own poll handlers and is not changed.
>     
>     v1: https://lore.kernel.org/netdev/20261101102720.702600-1-jure.rebernik@luxonis.com/
> 
>  drivers/net/ethernet/realtek/r8169_main.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index f151ab681393..99b0a410f58e 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -5670,8 +5670,14 @@ 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))
> +	if (work_done < budget && napi_complete_done(napi, work_done)) {
> +		/* After running out of RX descriptors the chip does not
> +		 * receive again until RxOverflow is cleared. The ring is
> +		 * empty now, so clear it before unmasking.
> +		 */
> +		rtl_ack_events(tp, RxOverflow);
>  		rtl_irq_enable(tp);
> +	}
>  
>  	return work_done;
>  }


      reply	other threads:[~2026-11-23 19:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  7:36 [PATCH net v2] r8169: clear RxOverflow before unmasking interrupts Jure Rebernik
2026-11-23 19:20 ` Jacob Keller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e5f2fb8e-1129-41d0-b627-6d96b81899f8@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=hkallweit1@gmail.com \
    --cc=jure.rebernik@luxonis.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    --cc=pabeni@redhat.com \
    --cc=sgoutham@marvell.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox