From: netdev-bot+sashiko@kernel.org
To: dinghui1111@163.com
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
Subject: Re: [PATCH net v8 2/4] net: stmmac: track unfilled XSK RX descriptors explicitly
Date: Mon, 23 Nov 2026 14:39:34 +0000 [thread overview]
Message-ID: <179544477433.3135.15487793537442434685@kernel.org> (raw)
In-Reply-To: <31856c65c85293ac3955212a22653ca41a36ad2f.1795096430.git.dinghui@lixiang.com>
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
next prev parent reply other threads:[~2026-11-23 14:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 14:08 [PATCH net v8 0/4] net: stmmac: fix RX descriptors and XSK TX on resume Ding Hui
2026-11-19 14:08 ` [PATCH net v8 1/4] net: stmmac: honor allocation flags when initializing RX buffers Ding Hui
2026-11-19 14:08 ` [PATCH net v8 2/4] net: stmmac: track unfilled XSK RX descriptors explicitly Ding Hui
2026-11-23 14:39 ` netdev-bot+sashiko [this message]
2026-11-19 14:08 ` [PATCH net v8 3/4] net: stmmac: restore RX descriptor buffer addresses on resume Ding Hui
2026-11-23 14:39 ` netdev-bot+sashiko
2026-11-19 14:09 ` [PATCH net v8 4/4] net: stmmac: restore the XSK TX pool " Ding Hui
2026-11-23 14:39 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179544477433.3135.15487793537442434685@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dinghui1111@163.com \
--cc=dinghui@lixiang.com \
--cc=edumazet@kernel.org \
--cc=fujiahui@lixiang.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=liuxuanjun@lixiang.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=xiasanbo@lixiang.com \
--cc=yangchen11@lixiang.com \
--cc=zhoujing3@lixiang.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox