From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E7501F000C1; Sun, 29 Nov 2026 06:34:36 +0000 (UTC) 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== Subject: Re: [PATCH net v2] net: stmmac: retry a failed RX refill from a timer From: netdev-bot+sashiko@kernel.org To: Anandu.Padinhare@electrifex.com 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 Date: Sun, 29 Nov 2026 06:34:35 +0000 Message-ID: <179593407568.3146.3078773695061553580@kernel.org> In-Reply-To: References: X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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