🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18090

[PATCH net-next v7 1/3] net: ethernet: mtk_eth_soc: fix the RX

#18090
From: Sandeep Haemoon
Date: Fri, 13 Nov 2026 22:34
68 lines
11669 bytes
mtk_poll_rx() keeps one dma_addr_t across the whole poll loop and only
refreshes it when a replacement buffer was mapped for the descriptor
being processed.  The paths that jump straight to release_desc (no
netdev for the source port, MTK_RESETTING set, or a refill allocation
failure) re-arm the descriptor with the buffer it still holds.  The
address written back must therefore come from the descriptor's own
rxd2, and the release path relies on dma_addr being DMA_MAPPING_ERROR
to select those bits.

The declaration was moved to function scope and initialised to
DMA_MAPPING_ERROR by commit e10a35abb3da ("net: ethernet: mtk_eth_soc:
fix uninitialized variable"), which also added the first check for
that sentinel on the release path.  The check was later replaced with
the FIELD_GET(rxd2) fallback below by commit 6e0490fc36cd ("net:
ethernet: mtk_eth_soc: fix SER panic with 4GB+ RAM").  Because the
sentinel is only still true before the first mapping, that fallback
has only ever been taken for the first descriptor of a poll.  From the
second iteration on, the previous descriptor's high address bits are
combined with the current descriptor's low bits in rxd1.  With
MTK_36BIT_DMA and DRAM above 4 GiB the hardware then DMAs the next
frame to an address that is neither buffer, and the driver passes the
stale contents of the untouched buffer up the stack.  mtk_rx_clean()
unmaps the same mismatched address during a SER, which is the panic
that commit was fixing.

Reset dma_addr to DMA_MAPPING_ERROR at the start of every iteration,
so a descriptor that is released without a new mapping keeps its own
address bits.

This change depends on the FIELD_GET(rxd2) fallback, so that commit or
its stable backport has to be present: on a tree without it the
release path would clear the high bits instead of preserving them.

Fixes: 2d75891ebc09 ("net: ethernet: mtk_eth_soc: support 36-bit DMA addressing on MT7988")
Signed-off-by: Sandeep Haemoon <sandeeph@loljews.com>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 21abeccfe0..6c8b039fad 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2210,7 +2210,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
 	u8 *data, *new_data;
 	struct mtk_rx_dma_v2 *rxd, trxd;
 	int done = 0, bytes = 0;
-	dma_addr_t dma_addr = DMA_MAPPING_ERROR;
+	dma_addr_t dma_addr;
 	int ppe_idx = 0;
 
 	while (done < budget) {
@@ -2219,6 +2219,12 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
 		u32 hash, reason;
 		int mac = 0;
 
+		/* The release paths below hand the descriptor back with the
+		 * buffer it still holds, so only overwrite its address when
+		 * a new buffer was actually mapped for it.
+		 */
+		dma_addr = DMA_MAPPING_ERROR;
+
 		ring = mtk_get_rx_ring(eth);
 		if (unlikely(!ring))
 			goto rx_done;
-- 
2.53.0
Technical Details
Message-ID: <patch-295a65477d87017ff5b65482ffae46fb@loljews.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365586-linux-kernel-netdev=dewy.ru
References: <patch-7d2c457e68de6b53b7348d1bdbeadcec@loljews.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365586-linux-kernel-netdev=dewy.ru
From: sandeeph@loljews.com (Sandeep Haemoon)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v7 1/3] net: ethernet: mtk_eth_soc: fix the RX
Date: Sat, 14 Nov 2026 00:34:14 +0200
Organization: Usenet Network
Message-ID: <patch-295a65477d87017ff5b65482ffae46fb@loljews.com>
References: <patch-7d2c457e68de6b53b7348d1bdbeadcec@loljews.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2415445"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:/ZJkHmHLSpU33tegRvMQ549J9Sc= sha256:YqRrr7g+tI9UV9eTrQrZE1f0wEdC0hjmf5fdC4k0KhU=
	sha1:mQDufg7UTFQB4KS+9q7LpLbu0QE= sha256:pNLbe+r8S4Booq3oBms2fi82yDB7zUylYKMn89UhOEM=
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 1925611507E; Tue, 17 Nov 2026 22:57:01 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.051
X-Spam-Status: No, score=-2.051 tagged_above=-9999 required=6.31
	tests=[DATE_IN_PAST_48_96=1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=loljews.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 pniO1yDOnJaU;
	Tue, 17 Nov 2026 22:56:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365586-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=loljews.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 0C0E9115073; Tue, 17 Nov 2026 22:56:49 +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 3D45763C84; Tue, 17 Nov 2026 19:56:16 +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=1794945376;
	b=uE8n5qVtazPxxiuSl1/3ZGDEKc5UcNprXUUlxLR7SxDeCsreo4bWn1B2H4UNB1RrC97G
	 2NpL7qlzatcMmA45V6nJrWJ59vAMwH4jscnKfICYp8q8S9KpEv788LWXenHWJMgFGdpV1
	 jRWR2yzOjQkRsw3F+CX4Wi6Jat+nWthvFVMe+LVzeaFYROEP7mS5VLpI9FcRIum3x2ugL
	 rNXyQ6ro0riYm5Oxm9Z7jzSUsPXg0j7LCH05BQruPu27N2+qceJT+p0SldNiU/Bsk2g86
	 dNYHHBKXqodBi4sEQBCwVIWjFnHcFbTLfEFV/c0wHVzyP4WvbxU5yafUveXFZgHbGog==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794945376;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To:
	 Cc:Subject:Date:Message-Id:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=atmLLf/NrghE7vi1E0C0B1jlNi40I3lfJXEpESPi88w=;
	b=4THmmmP1zjnurRhc+uYaD4KgGU/M+HEN5Egsl8tD5RSM/pfckVfO6noS7ZcnDHEJFu+3
	 zJfCJoODFpT6F4D3ZsrnjGiZF2zlsZxV/ldfnMjedzj5Jj+Mrf61qyGerhJSkZIKF96Qt
	 i9CohQBUcX6COsPgTzEh+JnjCQTUy1gToJZEzrteYKG5KzPxTEdeXRZ8o4AAOLZ7kQ4ul
	 R6ySJwsN4fhbzJT6COCjvxJQSAAz9pN3h9hgFs72yT0MEZjl2gqfJH632QERe0tHhfG0J
	 YSDPiWxly7VRLPkC9NlNoil3N6XAmEZWFhcNtgSka/36fSFPAoWJgHJ2e9sjmJWCaNg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=loljews.com header.i=@loljews.com header.a=rsa-sha256 header.s=mail header.b="aSx/lh+L";
	dmarc=pass header.from=loljews.com;
	spf=pass smtp.mailfrom=loljews.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 E25F1606A880;
	Tue, 17 Nov 2026 19:56:15 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=loljews.com header.i=@loljews.com header.a=rsa-sha256 header.s=mail header.b=aSx/lh+L
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=54.38.221.178
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794945370;
	b=eL13l+gLXgfLkTcsqQBgAkf1yG9c5IRAt/2GiZHJUEK06yczjEHtsAyPdjPISNoKzAMa
	 Y2juO+8mOb0r5NbPduOLddcEkIHUhnP/3bT9OLFP3iYA8eZYUUme8O+7bjyiVAG5fl3l7
	 p9r6SMfob4bux928AYD1hhVYrb1gWQd7x6p46z70+XbotOH4YJeFEm+By5AjxAOEmHDRX
	 O0ZM3J4Trwti6AjvSMC8d72rCJTTyp/QUHsdZcc1u8vGYWwgwQYX39vaTBffRI+qPD6pM
	 OZzwxn954F8dxtbpedOh6Vz3C1uACUGDQ0lgB69j2curheVjqq1Q8Z6+ln2i6YDor6Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794945370;
	h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date:
	 Message-Id:In-Reply-To:References:MIME-Version:Content-Type:
	 Content-Transfer-Encoding;
	bh=atmLLf/NrghE7vi1E0C0B1jlNi40I3lfJXEpESPi88w=;
	b=o1Y2Mhhs+TXOBpRHrC4mu3VxwiHKRFlaXuBWPU2Rxc1VDVOACyD/gjaFeFl1VxYv2oIj
	 /GfZc+k6i/iuiYwqo12ntakDysuJnfStO6ef6llWBWsM3lR1DsvTZ2xQFapJgzatzEglp
	 N3wfoghzKJEaOPef5MEov8hXRFmkMca5KtmOdimR4tQCwEW3+uhzeWT7SQ6MEpRznfweI
	 Kxpu9hqCRilzn1NZDjXTIysxY8LFSB7vOT/YRYBcEGxLNBGAuRhJbkGf5T7hTQ9oTg6jt
	 2Q/a/zvNB0RoC+t26sq/GTZjd8xMPU+nr1ejceXlmHmYrjkhNN6S4o2OvCl63J/YNRQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=loljews.com;
	spf=pass smtp.mailfrom=loljews.com;
	dkim=pass header.d=loljews.com header.i=@loljews.com header.a=rsa-sha256 header.s=mail header.b="aSx/lh+L";
	arc=none smtp.remote-ip=54.38.221.178
X-Received: from mnc015mcc432.ss7-reroute.local (unknown [54.38.221.178])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A1C3606A32C;
	Tue, 17 Nov 2026 19:56:08 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5A1C3606A32C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=loljews.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loljews.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=loljews.com; s=mail;
	t=1794945359; bh=atmLLf/NrghE7vi1E0C0B1jlNi40I3lfJXEpESPi88w=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=aSx/lh+L3pKE96uXgp/sMxSO+2Zcz36mZCaBI4ghv5rqtml9bZj7poMkG8tbyMmpz
	 fmOxuyPK2EewB1V0kF+7EPLX5qbDyWbYnCZgTfEOi9yHSuvpe/Sg+/vwaXHB882L14
	 uolzVyELNgvprXt1+8pANbV9qPtPlZ4bBIqOXYc+kLt9v1Vr5vgkELxFQZwlvCPZFc
	 V9f/fqCcjGDlGt1GmQmRLQsgm327Zblz2NQZsmeibEXj06s625eQz0uCsa3Xrh9Ghf
	 OKD4PvL1a8jqsaAVQAVFpCHSmKHrf9d1HFB9lxwEGTvBICZrteqpqNRf/xxHBF29g6
	 DD/uSvoGzw+TQ==
X-Received: from loljews.com (localhost [127.0.0.1])
	by postfix (Postfix) with ESMTP id 762FB27A6BB2;
	Tue, 17 Nov 2026 21:55:59 +0200 (EET)
X-Cc: Felix Fietkau <nbd@nbd.name>, Lorenzo Bianconi <lorenzo@kernel.org>, 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>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Russell King <linux@armlinux.org.uk>, Daniel Golle <daniel@makrotopia.org>, Mason Chang <mason-cw.chang@mediatek.com>, Frank Wunderlich <frank-w@public-files.de>, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
X-In-Reply-To: <patch-7d2c457e68de6b53b7348d1bdbeadcec@loljews.com>
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