🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26681

[RFC PATCH net] r8169: order TX completion reads after observing cur_tx

#26681
From: "swing.chen"
Date: Fri, 04 Dec 2026 02:36
86 lines
13441 bytes
A UGREEN DH4300 Plus (RK3588C, arm64) repeatedly panicked while its
RTL8125B (XID 641) was transmitting. The link was up at 2.5 Gbit/s.
Pstore captured six distinct panics on this machine, all on vendor
kernel 6.1.84 (build d64bed19bdfd), with the same failure:

  kernel BUG at lib/dynamic_queue_limits.c:27!
  pc : dql_completed+0x13c/0x14c
  lr : rtl8169_poll+0x3a0/0x54c [r8169]

In each crash, the completion count exceeded the number of bytes BQL
had outstanding by exactly 60. In one case the driver reported 254
bytes complete with only 194 outstanding.

rtl8169_start_xmit() orders its stores before publishing cur_tx, but
rtl_tx() uses READ_ONCE() to read that index. This does not order the
subsequent reads of the descriptor and BQL state against the index
load on the completion CPU.

Publish cur_tx with smp_store_release() and pair it with an acquire
load in rtl_tx(). Also move BQL enqueue accounting before dma_wmb(),
ahead of the handoff of the first descriptor to the device. The device
still signals completion by clearing DescOwn.

With both changes applied to the vendor kernel, the same machine
continued transmitting without another DQL panic during the field
test. This result does not distinguish the two changes or establish
which one prevented the panic. On the net tree, r8169.o was cross-built
for arm64 with W=1 and BQL enabled. There is no mainline reproduction
or kernel selftest result to report.

Link: https://lore.kernel.org/netdev/20261118141130.2694997-1-hanson.wang@ugreen.com/
Signed-off-by: swing.chen <swing.chen@ugreen.com>
---
RFC question: would you keep the release/acquire pairing and leave BQL
accounting where it is? In the original code the accounting is already
before cur_tx is published. The field run tested the two changes together.
The vendor baseline also lacks c71e3a5cffd5 ("r8169: Fix possible ring
buffer corruption on fragmented Tx packets."); its contribution to the
field failures has not been ruled out.

Only the vendor build was run on hardware. The net tree was not booted
on the board; allyesconfig and allmodconfig builds were not run either.
CodeBuddy assisted with the port, the log analysis and the write-up.

 drivers/net/ethernet/realtek/r8169_main.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 1da64c6e39e2..c09d0d8734fa 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -5118,17 +5118,15 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
 
 	skb_tx_timestamp(skb);
 
+	door_bell = __netdev_sent_queue(dev, skb->len, netdev_xmit_more());
+
 	/* Force memory writes to complete before releasing descriptor */
 	dma_wmb();
 
-	door_bell = __netdev_sent_queue(dev, skb->len, netdev_xmit_more());
-
 	txd_first->opts1 |= cpu_to_le32(DescOwn | FirstFrag);
 
-	/* rtl_tx needs to see descriptor changes before updated tp->cur_tx */
-	smp_wmb();
-
-	WRITE_ONCE(tp->cur_tx, tp->cur_tx + frags + 1);
+	/* Publish descriptor, skb and BQL state to rtl_tx's acquire load. */
+	smp_store_release(&tp->cur_tx, tp->cur_tx + frags + 1);
 
 	stop_queue = !netif_subqueue_maybe_stop(dev, 0, rtl_tx_slots_avail(tp),
 						R8169_TX_STOP_THRS,
@@ -5232,7 +5230,8 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp,
 
 	dirty_tx = tp->dirty_tx;
 
-	while (READ_ONCE(tp->cur_tx) != dirty_tx) {
+	/* Pairs with the release in rtl8169_start_xmit() before reclaim. */
+	while (smp_load_acquire(&tp->cur_tx) != dirty_tx) {
 		unsigned int entry = dirty_tx % NUM_TX_DESC;
 		u32 status;
 
-- 
2.34.1
Technical Details
Message-ID: <20261204023642.2933576-1-swing.chen@ugreen.com>
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376996-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376996-linux-kernel-netdev=dewy.ru
From: swing.chen@ugreen.com ("swing.chen")
Newsgroups: linux.kernel.netdev
Subject: [RFC PATCH net] r8169: order TX completion reads after observing cur_tx
Date: Fri,  4 Dec 2026 10:36:42 +0800
Organization: Usenet Network
Message-ID: <20261204023642.2933576-1-swing.chen@ugreen.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2657909"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:utG+v/4zn5X5VvJqmium2Ip+sww= sha256:IuVlWnn6cnJOcUBmItTh4kFhZud2tv2Ez2gOoNI6vqQ=
	sha1:JqCStGzws7wHL9IVbSua8i5B0jE= sha256:E8aZ8yfB995CMi7GRW2UozCogoI3wyoPlc2VMcBkLaM=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 2D606117AC9; Fri,  4 Dec 2026 05:40:38 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.298
X-Spam-Status: No, score=-3.298 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=ugreen.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id R5a3IMEUAPDk;
	Fri,  4 Dec 2026 05:40:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376996-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=ugreen.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 08CA1117AC3; Fri,  4 Dec 2026 05:40:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 96D452A2C5; Fri,  4 Dec 2026 02:40:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796352014;
	b=YsYD9DIdmMVaZ3QYUbWZi7cNovZL/60J1Xxi6kS6DzKkWawzYOp7Q33cYa9H9kgk8zKV
	 HRQ84XX1sK3ZLukLhXwTbPtRXlKkxvPM2A0DoRxe8k4+qqEBBYgHvQ2CSm8UI3mP1J9sg
	 eIW89B294TTVNu48lqXNb57Y/RZ7LOGv9Fh3ilFzGjeF/VHMV2bG4auB0iIhgmaEQpxyt
	 V2rk79GS2DrovDYvwdMih9f+uuqxEib3vM5tm6RCj6w1Vj5VjMNLlDODpCo4X9rLPxm8B
	 cPTGUAknhuwpt/KAUf+KlIXXiCFQLDHE8IUb4Y+08jOA9xcXleyi/kPkP0Cj6SmjHvA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796352014;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-QQ-mid:
	 X-QQ-Originating-IP:Received:X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:
	 EX-QQ-RecipientCnt:From:To:Cc:Subject:Date:Message-Id:X-Mailer:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO:
	 X-QQ-XMRINFO:X-QQ-RECHKSPAM;
	bh=VFxsW1ios6D4kotlRkFu9wj/UnWpHu2nNTFkusTj0IA=;
	b=EbvOFt8bK8Mjb1I53hphQk+jqgLERSo493q0z8UnSlQhUe8I83iXgXJJJoShXFhnaa7y
	 H1bxGtytm0g5huTemyz4tlmL2oE0GEjpnarItGS7e2WA7wkMBR0/qetGj0QMdEAXoBsn7
	 AFhgrfK4WW+LnZToCrxwxtXrnAfeleKZfP8f7RA8rjXs5pyLhxUJogP4+Kka9XCT631Rb
	 3CK3hvg/Xjb+qvdqblhYcx9e0tMxZy0rcvYZE0xR87sJd7tsll1gZniqqlVY9E2l7ZXSC
	 4wviOwY8rHaBteG875irc84wjlsUZvxzqx2O1iXmLvEhFTo2zNqAiWE9vgPupqSL9Uw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=ugreen.com header.i=@ugreen.com header.a=rsa-sha256 header.s=pkvm2402 header.b=qfQgqUVV;
	dmarc=pass header.from=ugreen.com;
	spf=pass smtp.mailfrom=ugreen.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 5590F606A33C;
	Fri,  4 Dec 2026 02:40:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=ugreen.com header.i=@ugreen.com header.a=rsa-sha256 header.s=pkvm2402 header.b=qfQgqUVV
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.243.244.52
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796352013;
	b=F/+gtoIFHWVIdRw5bANk+WSqFtSW84rCOTI1wkzmJiKcrODR9XzBT1ARdVNUu5AEBe8u
	 T8FMRnWIgkewqhWRPMJfIbLe/SKQ6CjQfJ55k4IJ/yw+w4/7T+fFJPAs5nmqCpi/SqZ3U
	 PY9yj56qXfR5mRNJ82uMIaMt2GldNT3koTQorftYtKU+8Flqnfrw14ytRHDktqSRRPIUv
	 oC3IDxGQfcrfWHBEC+vKsULHGzaGiWFaHrhAScLwUvzC9QBeHY+N5i8s6zEQ9Tpf4K5b7
	 lT6AUQfBm1tPJBlhVQNZLdw7NgmxJB+HNHGcFiBy9bdE6lHnnoEudEAO/41tb3Uecog==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796352013;
	h=DMARC-Filter:DKIM-Signature:X-QQ-mid:X-QQ-Originating-IP:Received:
	 X-QQ-SSF:X-QQ-GoodBg:X-BIZMAIL-ID:EX-QQ-RecipientCnt:From:To:Cc:
	 Subject:Date:Message-Id:X-Mailer:MIME-Version:
	 Content-Transfer-Encoding:X-QQ-SENDSIZE:Feedback-ID:X-QQ-XMAILINFO:
	 X-QQ-XMRINFO:X-QQ-RECHKSPAM;
	bh=VFxsW1ios6D4kotlRkFu9wj/UnWpHu2nNTFkusTj0IA=;
	b=fuViAyUdqwwtLTtWMExmFYQQ+JCmG9irM/IFRLeGQo8twFFsf9yoPy1uaOWh+piqJZMH
	 perJrZo3nd5CbXxVgVHxEbAJCRX4We6dM5fzoxemhdz8f8VWwtbgoUHN97QKAYh7B5kJB
	 AS0my9lkUDic6qudG5wjCuafbh6vwZ1kBwTFfDBbaIHDMO0lJEvUG6XXutALD3VHWGIue
	 0FuZKTpXkpinxwy2vx9tSymvNeI3tyKyxp2MUKyLN46kOb4wGhLz/ZiEr7tkXWYMC3IuD
	 HeIEchj4zdJdWY4rvKtlgiJTMkURK7BrXaVW6X/jjnL1toN06BuIWMfED9tywLBZ93w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=ugreen.com;
	spf=pass smtp.mailfrom=ugreen.com;
	dkim=pass header.d=ugreen.com header.i=@ugreen.com header.a=rsa-sha256 header.s=pkvm2402 header.b=qfQgqUVV;
	arc=none smtp.remote-ip=54.243.244.52
X-Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AB09606A339
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 02:40:10 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8AB09606A339
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ugreen.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ugreen.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ugreen.com;
	s=pkvm2402; t=1796351825;
	bh=VFxsW1ios6D4kotlRkFu9wj/UnWpHu2nNTFkusTj0IA=;
	h=From:To:Subject:Date:Message-Id:MIME-Version;
	b=qfQgqUVVOuD8MiMNCXJQkX5bpl/lXq2NvbQs7INs3xg2UtEnMgQkRftVEM2s4davu
	 a7VHfwqoLlYEs6lz/lhhWoPEnh6ESnzexp3euILgTTo+TaSCDbNnQ2pCsJESOpS836
	 OjtPIxImAf+ctgtn57zhtzWE4zkeauduEwcC5i0U=
X-QQ-mid: zesmtpgz9t1796351811t6c91a9ea
X-QQ-Originating-IP: vvFPkFg66DJhxFeIJYNLJBJvq4cmHfDpHoVob3tPdvo=
X-Received: from localhost.localdomain ( [121.34.63.119])
	by bizesmtp.qq.com (ESMTP) with 
	id ; Fri, 04 Dec 2026 10:36:45 +0800 (CST)
X-QQ-SSF: 0000000000000000000000000000000
X-QQ-GoodBg: 1
X-BIZMAIL-ID: 2069383893636607505
X-EX-QQ-RecipientCnt: 9
X-Cc: hanson.wang@ugreen.com,
	Heiner Kallweit <hkallweit1@gmail.com>,
	nic_swsd@realtek.com,
	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>
X-Mailer: git-send-email 2.34.1
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-QQ-SENDSIZE: 520
X-Feedback-ID: zesmtpgz:ugreen.com:qybglogicsvrgz:qybglogicsvrgz5b-1
X-QQ-XMAILINFO: NYaClDVrQHFLaJidhD4rF3moUUUUk4qtDewfZ1nal+ZXk7k2MqDWZQnC
	sd0FCskXXY6tQ4hItJR3ztmgfg7LV/YUTh2Ywes55MOwTmPKXtOIgQwdrk0lIVBFZh6ON4B
	4naYg3UAuDscCCY2+q54lu7HArEsDGgVLivoWhtG9bSZqZG3PoS4Vkuz60YGtkT1wXJUWxf
	xKQw0oe3m8CqgaImrDsiCHM2jKRm1W58TRi5cbJl++Umr1AlmtXam7EMoFUZv+MjL7u7R8z
	d4tM01Av9FzBEvFLsAc0MIZkWHqPpG0r0pG3u9osozyOaANemjJG86ho8nQhKyW9zu5f51A
	T3atG6MTr3zO4cc/IhmHfXz0iGdx0tWYkAkOhjrIRCd5qseqyk8uGA7AEQq7BJD8/22tFRu
	1xkBEaFy7jPRn4dB/fMdJJRkbDBGOYyMhE4H8AlDLU7NIOInlcgb0/4kJMXSkZNYE+T24Y0
	kFXMpBeCOW0F2EEq/6EeXDw7kBGPWebRvrJBznwbZnUNe7kw//SD6ztL5/vYUyGT+mUDLDg
	O9mc/dST8FBCpcsrd52ZGjl8AoNA4CY3koqCLc7TRd2cpIfKXkaj923N1gFlVKgDX40ip+X
	OPhwZUcOKCzR+Qn/YOA13zB3y67l5gWLubhdvq7WNbckUnqwKYyGF4Ra6zCQjc1P9p5hPRU
	if9DbUHvGDl0usHCuckOXZvS4fV56lXWisaG9BpOPvnf3XH1hUwVPCKmR3B4/iW6U3d1/PY
	iefAAmTFslNY6hRbL9v7OXc5ZZJh6lTB508adA37rvrY52y0i1QVxPwbmS4GWzNazRMzjFu
	8ywEMS8AXTt8+fD4dYzfxZ1AtQDcY+1e4tJi2fn/FlSUb7x7plwXvsodj+SrBOs9WEPrIkm
	uGT4Lu2weZzDSCkxdLdehmcy4AUj38w6VBizMtTZFuOnmrRxb1dGq5ICokNcPnXQROMtjVm
	nrdQoON4xoj8sQonRw8sFYqVpYpdSAUHDF20xb1EgPw1P+4NledYZhjkYNUgWRwStrlh0PK
	9aj7B/jMEvbu3/wUlwq6MJ9dIx2qg=
X-QQ-XMRINFO: Nq+8W0+stu50tPAe92KXseR0ZZmBTk3gLg==
X-QQ-RECHKSPAM: 0