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 4/4] net: stmmac: restore the XSK TX pool on resume
Date: Mon, 23 Nov 2026 14:39:38 +0000 [thread overview]
Message-ID: <179544477829.3135.13778479191723150995@kernel.org> (raw)
In-Reply-To: <5874b73b815d2385bbbf5f6988d50b3772fa0ce0.1795096430.git.dinghui@lixiang.com>
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 fix is incomplete because it is applied to one caller
instead of the shared helper.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the same
resume path leaves corrupted TX next-descriptor pointers in chain mode.
--
net: stmmac: restore the XSK TX pool on resume
When dma_free_tx_skbufs() completes outstanding XSK TX frames, it also
clears tx_q->xsk_pool. This commit restores that pointer in
stmmac_resume_descriptors() after the call. Without the restore,
stmmac_tx_clean() skips zero-copy transmission after resume, even though
the AF_XDP socket is still bound.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 1508cf08f03b0..550a0bd647e13 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -2277,6 +2277,9 @@ static int stmmac_resume_descriptors(struct stmmac_priv *priv)
> for (queue = 0; queue < priv->plat->tx_queues_to_use; queue++) {
> stmmac_reset_tx_queue(priv, queue);
> dma_free_tx_skbufs(priv, dma_conf, queue);
> + /* Buffer cleanup may clear the pool; the socket remains bound. */
> + dma_conf->tx_queue[queue].xsk_pool =
> + stmmac_get_xsk_pool(priv, queue);
[Severity: High]
Does stmmac_tx_err() run into the same problem? It is not a teardown
path, but it also calls dma_free_tx_skbufs() and then restarts the queue:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_tx_err() {
...
stmmac_stop_tx_dma(priv, chan);
dma_free_tx_skbufs(priv, &priv->dma_conf, chan);
stmmac_clear_tx_descriptors(priv, &priv->dma_conf, chan);
stmmac_reset_tx_queue(priv, chan);
stmmac_init_tx_chan(priv, priv->ioaddr, priv->plat->dma_cfg,
tx_q->dma_tx_phy, chan);
stmmac_start_tx_dma(priv, chan);
...
}
stmmac_dma_interrupt() and stmmac_msi_intr_tx() call it on a TX hard
error. If xsk_frames_done is non-zero, dma_free_tx_skbufs() does:
if (tx_q->xsk_pool && tx_q->xsk_frames_done) {
xsk_tx_completed(tx_q->xsk_pool, tx_q->xsk_frames_done);
tx_q->xsk_frames_done = 0;
tx_q->xsk_pool = NULL;
}
Nothing in stmmac_tx_err() sets the pointer again, even though
af_xdp_zc_qps still has the bit set for this queue.
After that, stmmac_tx_clean() skips its if (tx_q->xsk_pool) block, so
stmmac_xdp_xmit_zc() never runs. stmmac_napi_check() also starts sending
TX interrupts to ch->tx_napi:
tx_napi = tx_q->xsk_pool ? &ch->rxtx_napi : &ch->tx_napi;
For ZC queues, stmmac_enable_all_queues() enabled rxtx_napi, not tx_napi.
Wouldn't this stall zero-copy TX in the same way as the resume case?
The commit message says:
Keep the buffer cleanup helper's behavior for teardown unchanged.
This suggests the other callers of dma_free_tx_skbufs() are all teardown
paths, but stmmac_tx_err() is not one of them.
Would it be better to fix this in the shared helper instead? For example,
xsk_pool could be cleared only in __free_dma_tx_desc_resources(), or
dma_free_tx_skbufs() could stop clearing it altogether. Either would
cover both paths and remove the need for a restore in each caller.
> stmmac_clear_tx_descriptors(priv, dma_conf, queue);
> }
[Severity: High]
This isn't a bug introduced by this patch, but does the TX loop here
need the same chain-pointer rebuild as the RX loop?
In chain mode with non-extended descriptors and hwts_tx_en set, the MAC
writes the timestamp seconds into des3 of the last-segment descriptor.
In chain mode, des3 also holds the address of the next descriptor.
clean_desc3() in chain_mode.c repairs this:
if (tx_q->tx_skbuff_dma[entry].last_segment && !priv->extend_desc &&
priv->hwts_tx_en)
/* NOTE: Device will overwrite des3 with timestamp value if
* 1588-2002 time stamping is enabled, hence reinitialize it
* to keep explicit chaining in the descriptor.
*/
However, clean_desc3() only runs from stmmac_tx_clean(). stmmac_suspend()
disables NAPI before it stops DMA. A frame that completes in between is
never cleaned, so its des3 still holds the timestamp.
On resume, stmmac_clear_tx_descriptors()->ndesc_init_tx_desc() only
clears TDES0_OWN and sets the chain bit. It does not touch des3, and
nothing on this path calls stmmac_mode_init() for TX again.
The RX side of this function already handles the same hazard in
stmmac_reinit_rx_descriptors():
/* Hardware timestamp writeback may have overwritten chain pointers. */
if (priv->descriptor_mode == STMMAC_CHAIN_MODE) {
...
stmmac_mode_init(priv, des, rx_q->dma_rx_phy,
dma_conf->dma_rx_size, priv->extend_desc);
}
Could TX DMA then fetch its next descriptor from an address equal to the
PTP seconds value? stmmac_tx_err() seems to have the same gap.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795096430.git.dinghui%40lixiang.com
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
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 [this message]
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=179544477829.3135.13778479191723150995@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