🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24065

Re: [PATCH net v2] net: stmmac: retry a failed RX refill from a timer

#24065
From: netdev-bot+sashiko
Date: Sun, 29 Nov 2026 06:34
160 lines
14412 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 (1) · Medium: 0 · Low: 0

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).

- [High] The new full-budget return in stmmac_rx() can leave RX dead in
  the tc block offload path, which is the failure this patch is meant to…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but resume hands
  RX descriptors without valid buffer addresses back to the DMA, and the…

--

net: stmmac: retry a failed RX refill from a timer

The patch adds a per-channel timer to stmmac. The timer schedules RX NAPI
when a page_pool refill failure leaves too few RX descriptors with the DMA.
stmmac_rx() now also returns the full budget when it stopped at the
descriptor before dirty_rx and the refill then succeeded. That way NAPI
polls again instead of waiting for an RX interrupt.

Link: https://lore.kernel.org/netdev/20260331195927.3353cc6d@kernel.org/
Link: https://lore.kernel.org/netdev/20260402174049.0ac088cc@kernel.org/

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index a685ce4638f61..bd0badb90bc8a 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

[ ... ]

> @@ -328,8 +361,17 @@ static void stmmac_enable_all_queues(struct stmmac_priv *priv)
>  			continue;
>  		}
>  
> -		if (queue < rx_queues_cnt)
> +		if (queue < rx_queues_cnt) {
> +			/* Disabling the queues cancelled any pending refill
> +			 * retry, but the ring may have been kept as it was.
> +			 * Check it while no poll can run.
> +			 */
> +			bool refill = stmmac_rx_refill_needed(priv, queue);
> +
>  			napi_enable(&ch->rx_napi);
> +			if (refill)
> +				stmmac_rx_refill_timer_arm(ch);
> +		}
>  		if (queue < tx_queues_cnt)
>  			napi_enable(&ch->tx_napi);
>  	}

[Severity: High]
This isn't a bug introduced by this patch, but the new check here can't
catch it. On resume, can the RX DMA get descriptors that have no valid
buffer address?

stmmac_resume() calls stmmac_reset_queues_param(), and
stmmac_reset_rx_queue() does:

	rx_q->cur_rx = 0;
	rx_q->dirty_rx = 0;

It then calls stmmac_clear_descriptors(). stmmac_clear_rx_descriptors()
runs stmmac_init_rx_desc() on every slot without checking
buf_pool[i].page.

On dwmac4, dwmac4_rd_init_rx_desc() only calls dwmac4_set_rx_owner(). That
ORs OWN and BUFFER1_VALID into des3 and leaves des0/des1 unchanged.

Suppose an earlier stmmac_rx_refill() stopped on a page_pool allocation
failure. The slots after it were already consumed: buf->page is NULL, and
des0/des1 still hold write-back data (for example the VLAN tag that
dwmac4_wrback_get_rx_vlan_tci() reads from des0).

After resume the DMA owns those descriptors. Could it write received
frames to an address built from those stale write-back words?

Resume reset the indices, so stmmac_rx_refill_needed() sees
CIRC_SPACE(0, 0, size) = size - 1 here and never arms the refill timer.

The notes below the --- line list "resume after a failed refill" as not
changed. Is a separate fix planned for it?

[ ... ]

> @@ -6146,6 +6195,13 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue)
>  	priv->xstats.rx_dropped += rx_dropped;
>  	priv->xstats.rx_errors += rx_errors;
>  
> +	/* A frame may be waiting in the descriptor we stopped at. If the
> +	 * refill freed it, poll again rather than wait for an interrupt
> +	 * that already fired. If not, the refill timer polls again.
> +	 */
> +	if (unlikely(at_dirty) && !stmmac_rx_refill_needed(priv, queue))
> +		return limit;
> +
>  	return count;
>  }

[Severity: High]
Can this full-budget return leave the RX DMA interrupt masked for good
on the tc block offload path?

stmmac_napi_check() masks the channel's RX DMA interrupt before it
schedules rx_napi:

	if (napi_schedule_prep(rx_napi)) {
		spin_lock_irqsave(&ch->lock, flags);
		stmmac_disable_dma_irq(priv, priv->ioaddr, chan, 1, 0);
		spin_unlock_irqrestore(&ch->lock, flags);
		__napi_schedule(rx_napi);
	}

Only stmmac_napi_poll_rx() unmasks it, and only when work_done < budget
and napi_complete_done() succeeds.

With this change, stmmac_rx() returns limit even when count < limit. If a
napi_disable() is pending at that point, __napi_poll() completes NAPI
itself:

	if (unlikely(napi_disable_pending(n))) {
		napi_complete(n);
		return work;
	}

so the driver's unmask never runs.

stmmac_setup_tc_block_cb() (cls_u32 / flower offload) calls
__stmmac_disable_all_queues() and then stmmac_enable_all_queues(). Neither
unmasks the DMA interrupt or reinitialises the ring.

The new check in stmmac_enable_all_queues() arms the timer only when
stmmac_rx_refill_needed() is true. This full-budget return only happens
when it is false, and the ring indices don't change in between. After
napi_enable() there is no pending timer and no scheduled poll, and the RX
interrupt is still masked.

Before this patch, a 64-entry ring (DMA_MIN_RX_SIZE) with the default NAPI
weight of 64 could return at most 63, so every poll completed and
unmasked the interrupt. The notes below the --- line report 400 of 851
polls returning the full budget with a 64-entry ring. With larger rings
the same thing now also happens after an allocation failure followed by a
successful refill, which is the case this patch is meant to fix.

The notes say a separate fix will follow, but that text won't reach git,
and the patch is tagged for stable. Could the fix be part of this patch?
For example, always call napi_schedule(&ch->rx_napi), or arm the refill
timer, after napi_enable() in stmmac_enable_all_queues() or
stmmac_setup_tc_block_cb().

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/MA0PR01MB92174ED1110DC61766D591C4FD432%40MA0PR01MB9217.INDPRD01.PROD.OUTLOOK.COM
Technical Details
Message-ID: <179593407568.3146.3078773695061553580@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.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-373388-linux-kernel-netdev=dewy.ru
References: <MA0PR01MB92174ED1110DC61766D591C4FD432@MA0PR01MB9217.INDPRD01.PROD.OUTLOOK.COM>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.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-373388-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2] net: stmmac: retry a failed RX refill from a timer
Date: Sun, 29 Nov 2026 06:34:35 +0000
Organization: Usenet Network
Message-ID: <179593407568.3146.3078773695061553580@kernel.org>
References: <MA0PR01MB92174ED1110DC61766D591C4FD432@MA0PR01MB9217.INDPRD01.PROD.OUTLOOK.COM>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1119030"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:cGjI8xXm01CyzkcOo1pSoorks74= sha256:Cgki+kiQdU4SN3VRA0T/E8VF4bNCCMrOZ4kY3ykQ9vg=
	sha1:NlKkDoQqc00/JN1Q9TzrwRbj4o4= sha256:Dz7Anq0yFXQrt5WLmgeaa4ySOqJy9JtROY+b7WBGM/M=
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 AB9F7125F95; Sun, 29 Nov 2026 09:35:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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 (2048-bit key)
	header.d=kernel.org
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 njW_1UdEyr0P;
	Sun, 29 Nov 2026 09:34:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373388-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 6A15E125F96; Sun, 29 Nov 2026 09:34:47 +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 EDC61266D1; Sun, 29 Nov 2026 06:34:43 +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=1795934083;
	b=xpc/+eb/iIpcV/9ttZUSPNcx3aw2h6mA5Ki0DNq9AJyfwXcL/Dpp8tBKtkywdmM5CoIw
	 kEDQgeI4hhhMP39MJdigPrm7nSphpxHI+tONoMUILxt+l1/OkoVFCTM5yMzzHrX5idKXu
	 vGTHVhUA/tuPGDwkT4P5trz2mno8LduFqXhQjNVhN7WaSbo4JJiM6B3/gaWNT7+5PSYig
	 gpPsT6J5KJU1ngQ5wr/K4y9GXnejP4LdzEKYfbWVtfQZ/GPOREyVCmd9oVZiLV6ld8khO
	 8f7lfaT70RVKKAkK8lnaqvTmWknIY+g/cwFuUnuBUGSS2LBj6j4oEyH2LyeGDjhbvyg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795934083;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=1XYOwiO7TcrrD4LYgk9hns6j5+6lZYu1NRvKXPgbvGg=;
	b=QB0Gn/qS0ft39Qvn4hxq+49zziPfk97K2Fbj/X+Y9vLJjticCDuuzmNGbJ9qkJTkxHpL
	 tFr4dB3eVqajIJ2PgZVeUMIfkuAZK58+pqhcgYzt+AUEz/ChDAuqPEIgLMGtY8X1DvjRA
	 eDXijt76W1OwZbxyN3pfXett8/O+nuifqglV9RSjb4+JKLC8Aa6JVet39j9Fb+4GcHAqh
	 y0rXqWu+APJMnK2j3PAAQPFeU5to4ZN90ZK1pYwMBitu/XLTgmkajzLjt4dg/asnZBMVK
	 N46uVfrXl1cuV6xLAy1cG6DOWLqE9vcfSQbDtcgh2OFkthmhocWySp6dXa5HeLYOIWw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="BX8/+x7q";
	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 C42C0606A325;
	Sun, 29 Nov 2026 06:34:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BX8/+x7q
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795934078;
	b=dycfErUNEx68iCQQnukE7wp65ZrRcj9eS60z63zknD45RcUbiPSW+a36Zku5Y5cVckNx
	 CTB0EpmlkDlzg4mCd/qvAOmKbS/6cU9FpIgZuEfEMQZF1sa8lxcWjIhcvLpyS2Vh7wjcZ
	 Yb6oGwQmP56nuvkNklrrr0CP4UVtrzb8B9W2pGzTrJ7KvlausmX7hkMgz+gLqUkistHe+
	 jKC65GM5LucSfSzyTJAOmDU3s9gWkdqzhnnVJ1+tjd++QJgi8HRnX64NEvxCXb31lwbD8
	 vfnhPha4MwXW6qUqmKPk+3Me/NPamxzyoW5nhryOKRb8P+j9q0Hg0bwqVfknmd/egNw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795934078;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=1XYOwiO7TcrrD4LYgk9hns6j5+6lZYu1NRvKXPgbvGg=;
	b=IEkmruzZoK22/2GQmzfCLLZRUcy9kVb4JYiHqY2cUlWkJY0H7HFl8ir5Z7TjDk4aVOFS
	 /muVDZQcMgVqMy6tK+AoduhoFGNCFNJbw9JTmMLTp3po5xGyHXSf1EEXmspvOpvvwLrqm
	 YWOT0sMN7ezpfxlijvagd2sEYHYmlyKtaBkO+d2XdHAtiUTigtUT7d4piYw57ZHh6Evu4
	 0EwftoRKdSNNAqO2bM+RZYcRKkbTLfatA2TE14JNxZ+/0JbwMeUWdwfM8L3l7POxGUA30
	 0ZbskcymV4N4TOnQKXpDPcOoz4heSrVZg8G/AyGWMTpvLc3H6Z74ZFADp+BuBgOPLLg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="BX8/+x7q";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(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 E0EED606A326;
	Sun, 29 Nov 2026 06:34:37 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E7501F000C1;
	Sun, 29 Nov 2026 06:34:36 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795934077;
	bh=1XYOwiO7TcrrD4LYgk9hns6j5+6lZYu1NRvKXPgbvGg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=BX8/+x7qXwnBvDSOsltdmFnpTStbLsgehfJQtABkeN7Xby6cEqJyntWqwNt7kV4iP
	 yMebdEn3JLzZ74DMeT2kCFa9PP4U/b8uocOZeUOjkp19JHFnYaJlbU+71MfQEg/NQH
	 lnfDekorcuilvaGVID9L588AYdKe81JqITFnyBDqElgrj7Rb01DSintsFpvKDp+owA
	 BXklXhNk7FcAEmMDorZyWbayiz2gpIu8gb3Demf/KkBtiuYqIREHLgR2aapGc6Dw19
	 P3oz69HVabNYJF4qsgT5ueiH6RP59KTMy6miiYr3dGZc8B/PaALj3Q7TJREacRM11V
	 0zVEdivbcAahQ==
X-Cc: maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 netdev@vger.kernel.org, mcoquelin.stm32@gmail.com,
 alexandre.torgue@foss.st.com, ast@kernel.org, daniel@iogearbox.net,
 hawk@kernel.org, john.fastabend@gmail.com, sdf@fomichev.me,
 linux-stm32@st-md-mailman.stormreply.com,
 linux-arm-kernel@lists.infradead.org, bpf@vger.kernel.org,
 rmk+kernel@armlinux.org.uk, cfsworks@gmail.com, nb@tipi-net.de,
 david.wu@rock-chips.com, stable@vger.kernel.org
X-In-Reply-To: <MA0PR01MB92174ED1110DC61766D591C4FD432@MA0PR01MB9217.INDPRD01.PROD.OUTLOOK.COM>
X-sashiko-severity: High
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