Article View: linux.kernel.netdev
Article #21084Re: [PATCH net v8 2/4] net: stmmac: track unfilled XSK RX descriptors explicitly
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 14:39
Date: Mon, 23 Nov 2026 14:39
180 lines
15467 bytes
15467 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 ยท High: 2 ยท Medium: 0 ยท Low: 1
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] Permanent RX stall on dwmac4/dwxgmac2 XSK queues after a full-
ring refill that ends at a non-zero index.
- [High] net: stmmac: pre-loop refill failure in stmmac_rx_zc() skips
later refills
- [Low] The comment added in stmmac_rx_refill_zc() describes a narrower
condition than the code under it.
--
net: stmmac: track unfilled XSK RX descriptors explicitly
This commit adds an xsk_rx_pending counter that tracks XSK RX descriptors
waiting for refill. It also adds a clear_rx_owner descriptor op so unfilled
descriptors stay CPU-owned. stmmac_rx_zc() and stmmac_rx_refill_zc() now
retry refills on every poll and write an end-of-ring tail address when a
refill ends at index zero.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 8bd2440461959..f9ac82d2e7266 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
[ ... ]
> @@ -5626,12 +5632,18 @@ static bool stmmac_rx_refill_zc(struct stmmac_priv *priv, u32 queue, u32 budget)
> dma_wmb();
> stmmac_set_rx_owner(priv, rx_desc, use_rx_wd);
>
> + rx_q->xsk_rx_pending--;
> entry = STMMAC_NEXT_ENTRY(entry, priv->dma_conf.dma_rx_size);
> }
>
> if (rx_desc) {
> rx_q->dirty_rx = entry;
> - stmmac_set_queue_rx_tail_ptr(priv, rx_q, queue, rx_q->dirty_rx);
> + /* Use the end-of-ring address when filling an initially empty
> + * ring completely, so the tail differs from its initial base.
> + */
[Severity: Low]
This isn't a bug, but the comment covers less than the code below it does.
The entry ?: dma_rx_size expression applies to every refill whose last
entry wraps to 0. That includes ordinary wrap-around on every lap of the
ring, not only a complete fill of an initially empty ring.
The commit message calls this "a refill ending at index zero", which
matches the code. Could the comment say the same?
It might also help to say why this differs from stmmac_rx_refill(), which
writes the base address for index 0:
stmmac_set_queue_rx_tail_ptr(priv, rx_q, queue, rx_q->dirty_rx);
The later patches in the series leave this comment unchanged.
> + stmmac_set_queue_rx_tail_ptr(priv, rx_q, queue,
> + entry ?: priv->dma_conf.dma_rx_size);
> + stmmac_enable_dma_reception(priv, priv->ioaddr, queue);
> }
[Severity: High]
Can RX DMA stay stalled after a full-ring refill that ends at a non-zero
index?
This patch removes the one-slot gap that stmmac_rx_zc() used to keep:
- if (unlikely(next_entry == rx_q->dirty_rx))
- break;
The consume loop now stops only on dma_own or on this check:
if (rx_q->xsk_rx_pending == priv->dma_conf.dma_rx_size)
break;
Suppose the XSK fill ring runs dry under traffic. The CPU can then consume
every descriptor, and the ring becomes completely empty with
cur_rx == dirty_rx == k for any k. The last successful refill wrote the
tail as base + k * desc, and DMA has stopped with its current pointer at k.
Now suppose userspace supplies at least dma_rx_size buffers before the next
poll. The refill at the top of stmmac_rx_zc() runs:
if (rx_q->xsk_rx_pending)
failure = !stmmac_rx_refill_zc(priv, queue, rx_q->xsk_rx_pending);
It fills all N slots and entry wraps back to k. The tail is then written as
entry ?: dma_rx_size, which is base + k * desc again. That equals both the
stalled DMA current pointer and the previous tail value. The ?: special
case only covers k == 0.
The comment above depends on a tail equal to the DMA position not
restarting DMA ("so the tail differs from its initial base"). Doesn't the
same reasoning apply when k != 0?
After this refill xsk_rx_pending is 0, so no later poll writes the tail
again. Every later poll finds descriptor cur_rx DMA-owned and breaks out.
stmmac_enable_dma_reception() seems to be implemented only for dwmac1000.
On dwmac4 the RBU interrupt only increments rx_buf_unav_irq, and on xgmac
it only schedules NAPI. On dwmac4 and dwxgmac2, would the queue stay dead
until it is reinitialized?
The later patches in the series don't seem to change this logic.
[ ... ]
> @@ -5661,6 +5672,9 @@ static int stmmac_rx_zc(struct stmmac_priv *priv, int limit, u32 queue)
> bool failure = false;
> int xdp_status = 0;
>
> + if (rx_q->xsk_rx_pending)
> + failure = !stmmac_rx_refill_zc(priv, queue, rx_q->xsk_rx_pending);
> +
> if (netif_msg_rx_status(priv)) {
> void *rx_head = stmmac_get_rx_desc(priv, rx_q, 0);
>
[Severity: High]
Can a refill failure at the top of stmmac_rx_zc() stop buffers that
are freed later in the same poll from being reposted?
The pre-loop call asks stmmac_rx_refill_zc() for all of
xsk_rx_pending. Whenever the pool holds fewer free buffers than that,
xsk_buff_alloc() returns NULL partway through and failure is latched
to true before the receive loop starts. A partially filled fill ring
is exactly the case this patch is meant to support.
Both the batch refill inside the loop and the new refill after
stmmac_finalize_xdp_rx() are gated on !failure. Neither one runs for
the rest of the poll.
Meanwhile several paths call xsk_buff_free() on the buffer:
- XDP_PASS
- STMMAC_XDP_CONSUMED (XDP_DROP, XDP_ABORTED, failed redirect)
- the discard_frame and rx_not_ls error paths
- XDP_TX, via xdp_convert_buff_to_frame()
Each of these puts the buffer back on the pool free_list, where
xsk_buff_alloc() could hand it straight back out. The old code started
every poll with failure set to false. It would have reposted those
buffers once dirty reached STMMAC_RX_FILL_BATCH.
With XDP_USE_NEED_WAKEUP, suppose those paths consume every descriptor
that was posted. The poll then ends with xsk_rx_pending equal to
dma_rx_size and no DMA-owned descriptor left in the ring.
stmmac_rx_zc() returns count < limit and NAPI completes, so no further
RX interrupt can arrive. None of these frames reach the XSK RX ring.
Doesn't recovery then depend entirely on userspace issuing a wakeup
without having received anything?
Without need_wakeup the problem goes the other way. Suppose the pool
has fewer than dma_rx_size buffers in total, for example a TX-only
socket that never populates the fill ring. Then xsk_rx_pending never
reaches zero and the pre-loop refill fails on every poll, so
stmmac_rx_zc() returns limit every time. Wouldn't NAPI then never
complete, even on an idle link? Before this patch the same setup left
failure false and returned count.
Should the later refills still be attempted after an earlier failure,
for example by OR-ing the result into failure instead of skipping the
call? And is busy polling intended when the fill ring is simply
smaller than the RX ring?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795096430.git.dinghui%40lixiang.com
Technical Details
Message-ID:
<179544477433.3135.15487793537442434685@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-369485-linux-kernel-netdev=dewy.ruReferences:
<31856c65c85293ac3955212a22653ca41a36ad2f.1795096430.git.dinghui@lixiang.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-369485-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v8 2/4] net: stmmac: track unfilled XSK RX descriptors explicitly Date: Mon, 23 Nov 2026 14:39:34 +0000 Organization: Usenet Network Message-ID: <179544477433.3135.15487793537442434685@kernel.org> References: <31856c65c85293ac3955212a22653ca41a36ad2f.1795096430.git.dinghui@lixiang.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3903438"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:I7GqD4NpiyKFpKRaeWtBXYTNgeY= sha256:qohQZzV/hg8IivYPuZEwtvnXSAoo3gLHYp9OwzsVMEk= sha1:j48a13CCOGGUpEa5eW6VxRjvCGY= sha256:oXJdBUR3cFXsWsPQQPgYIsdkPqDZ7MRnn1usW4twJcY= 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 7A3BE125DBD; Mon, 23 Nov 2026 17:39:57 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 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] 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 S3jYUWgcGxaW; Mon, 23 Nov 2026 17:39:50 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369485-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 9FC72125DBB; Mon, 23 Nov 2026 17:39:40 +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 360E43042C; Mon, 23 Nov 2026 14:39:38 +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=1795444777; b=T7h21n/GCeJH52O59lRxxykgzMA71ttPYU9JSuzjoXifpLbkAEzaIwo7UjT7PKLEEsz1 fyxmV09gzG8auZR5wBWLu5asUcd5NdSZymQm15Rm31yU9j2q/JbKmucYoS6rTxT7iQ2SI Tw0QcU90MOrSJs0/vbpm43rc/KjwYfFAYmXk1DSVd0/aHi/nRl4v43jg/Qs5kDP6Nkj1r WaoTF6RiaH74UZsWDATqIg7Y0BjBK7BVDY691/oYMC+j8RVB5ET44MJb+MCJEPrgnQI4j JAqX3YnflDI9B+GwU9MkK/Cz8zuqeFNe7DjaW0S/NdOEj2nfKpflUoOTP1/GOEiu3mw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795444777; 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=Xt4XcogETaPg/vLPHA+ZVa2mgH1C1Y+V+9gARYxKDCo=; b=Ydr4KgsDz2HdgF1hnmOxMXqgB8QZGeSaEBMm8MdCmdphBMAlMWJe9XBq/EImUaBGy87C jSaXBLllipzZe/W0R68nVCJ5iKo/p45SH/7YhGht3DJC1b9SWBObMONBidi43T/A4+3Ma uqz4viQnqQUQJ3IMlreGd2CgxCP25Jr9TLIaHyrd/h55puczYXl/+V0c/r61/T1LSN6o1 myCdt0T9HMSWWUE5g+KL3+7K80OPn7Jhr4JGhYJXxaSBXUhDWwrhYgDjgBQakm8/7zqXn jLMth3NlbrlwuOuIdkSRdtPjHSpWZpoWlXf/1+MDWx+VR4j5L0cyQXITXzqvksqVPIQ== 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=Nc3Cp1Yy; 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 5FA5E606A333; Mon, 23 Nov 2026 14:39:37 +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=Nc3Cp1Yy 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=1795444776; b=kQQ3ViCVVJV3TIV2sx+OXKJS66wT/ceJNJm3Csh5K7W17Jq8YME2gtFOUT85znq6wS2c qsbhAywmoSrX51cCakETGaqQKKgMnYgDJ9RB/5V6xhyJv5TfIZZscSQ4VEH6A+/+TAR2q Ha+wskQ3X3+6auHWisJCaAEzLWTFPuT0ug+/Ua62kR0NK01ZrB+aiwVVtFEc9fRx2SVfN ruyUYyUpXJR6nPLOCsslOZf1xp1ddA5c8r8hwcial2j2/DOqkcpJeoqEgPlTZpK5he11j qUX6Jz30aqL3sLD9RmhiFK0OAe2deWMrHSDt3PTmqYzSubfH4CSrKSRHl4xpbxoEdEg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795444776; 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=Xt4XcogETaPg/vLPHA+ZVa2mgH1C1Y+V+9gARYxKDCo=; b=AlJqjSYGcKHf8FDILLaBwtVqZSNcnf0BS4w97vzXgaeFzrXuLcpq1dM+M6MtXmpQHw1c ZGRbPvWw6/GdcdMoWQNk/jPvyN19Oez6RnEc8TAE9voThO7KXzfcUTuScReWMQkW/BZJC FuoFIzO586KgYaIf2IpL0mJpwn4QXqY/D9y8MBKv7vLJdRhqfw0ocG7HuMeZyUyMsRNqc MrpX4aPTLT0Oj9C8O4PcUDKvedvP04mpIq469X+pDLQEyQI1Q7F/5qUOS2KblMrMZpG6l URwOm7YS5LR5+MdF3cxhSA9xjw+Dx0A4J7K+pgmTWwhscAXs/tBpxlaV/GMc1CzAhyg== 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=Nc3Cp1Yy; 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 7E628606A31A; Mon, 23 Nov 2026 14:39:36 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C08AE1F000C6; Mon, 23 Nov 2026 14:39:34 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795444775; bh=Xt4XcogETaPg/vLPHA+ZVa2mgH1C1Y+V+9gARYxKDCo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Nc3Cp1YyqxS8+n1+wQNwrlyR/It0roSLBI26bH8bkouZdaqwqYuJYwYf+s3WJ80oT JbyrajvaMQD2SfQUoCgGMeklH7PEqhF3bJYzYdyhoydD2aibO2WY640cy2XR5FGD8i GfYl/sAG3oz3Mu2nUGsYnDUOpij8MvFIv+92qegDdRRVsA8oSt/zZpQFP8F9+61ELT WhaVx6cUIpdvBhYiQiTRXbs44844xRqOvA5NsxG6VBuCWbHrZBBl3Tb2iECVzAnj0J dXF0hVkLJQrW7tBYH6rkOUnJXLgmH7aCMV/JP/2O+Vmrzn1Mr9KtnYK1OLkTayC0wF CAvq9z015JQ8g== X-Cc: maxime.chevallier@bootlin.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dinghui@lixiang.com, xiasanbo@lixiang.com, yangchen11@lixiang.com, liuxuanjun@lixiang.com, fujiahui@lixiang.com, zhoujing3@lixiang.com X-In-Reply-To: <31856c65c85293ac3955212a22653ca41a36ad2f.1795096430.git.dinghui@lixiang.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