From: netdev-bot+sashiko@kernel.org
To: tommaso.merciai.xr@bp.renesas.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, peppe.cavallaro@st.com,
netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
biju.das.jz@bp.renesas.com, tomm.merciai@gmail.com,
dinghui@lixiang.com, dinghui1111@163.com
Subject: Re: [PATCH net] net: stmmac: stop Tx NAPI before disabling the queues
Date: Thu, 19 Nov 2026 21:52:38 +0000 [thread overview]
Message-ID: <179512515855.3136.15162646874622512762@kernel.org> (raw)
In-Reply-To: <20261116-tm-stmmac-eth-s2idle-v1-1-bbe165b743b5@bp.renesas.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 2 (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 only fences the ndo_start_xmit producer.
- [High] The patch assumes NAPI is the last thing that can wake a TX
queue once stmmac_disable_all_queues() returns.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
stmmac_xdp_release() quiesces TX in the order the patch's new comment…
--
net: stmmac: stop Tx NAPI before disabling the queues
This commit adds a netif_tx_disable() call to stmmac_suspend(), right
after stmmac_disable_all_queues(). A TX queue woken by stmmac_tx_clean()
between netif_device_detach() and napi_disable() is then stopped again
before the platform suspend callback gates the clocks. It follows an
earlier bcmgenet fix.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 25894771e9e9f..41d62f3b7ce51 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -8412,6 +8412,9 @@ int stmmac_suspend(struct device *dev)
>
> stmmac_disable_all_queues(priv);
>
> + /* NAPI may have woken a TX queue after netif_device_detach() */
> + netif_tx_disable(ndev);
> +
[Severity: High]
Does this also cover the XDP transmit path? stmmac_xdp_xmit() is the
ndo_xdp_xmit callback, and its only gate is the STMMAC_DOWN bit:
stmmac_xdp_xmit() {
if (unlikely(test_bit(STMMAC_DOWN, &priv->state)))
return -ENETDOWN;
...
__netif_tx_lock(nq, cpu);
...
if (flags & XDP_XMIT_FLUSH) {
stmmac_flush_tx_descriptors(priv, queue);
stmmac_tx_timer_arm(priv, queue);
}
__netif_tx_unlock(nq);
...
}
stmmac_suspend() never sets STMMAC_DOWN. stmmac_xdp_xmit() also doesn't
check netif_xmit_stopped() or netif_device_present().
So netif_tx_disable() only waits for an XDP transmit that already holds
the txq lock. It doesn't stop new ones from starting.
The core redirect path doesn't block this either. xdp_ok_fwd_dev() only
checks IFF_UP and the MTU, and netif_device_detach() leaves IFF_UP set.
Once an XDP program is attached, stmmac_xdp_set_prog() advertises the
device as a redirect target through xdp_features_set_redirect_target().
Suppose another interface redirects into this one through a devmap, for
example a NIC that suspends later in dpm order, or a veth. Could this
sequence then run after stmmac_stop_all_dma() and priv->plat->suspend()?
bq_xmit_all()
stmmac_xdp_xmit()
stmmac_xdp_xmit_xdpf()
stmmac_enable_dma_transmission() <- MMIO
stmmac_flush_tx_descriptors()
stmmac_set_queue_tx_tail_ptr() <- MMIO
stmmac_tx_timer_arm() <- re-arms cancelled txtimer
That looks like the same SError the commit message describes: a tail
pointer write after the clocks are gated.
Is a driver-level state needed here that every TX entry point checks?
One option is to set STMMAC_DOWN (or a dedicated suspended bit) before
stmmac_stop_all_dma() and clear it on resume. Another is to check
netif_device_present() in stmmac_xdp_xmit().
[Severity: High]
The new comment assumes that once stmmac_disable_all_queues() returns,
nothing but NAPI can wake a TX queue. Is that true? stmmac_tx_err() also
wakes the queue, from hardirq context:
stmmac_tx_err() {
netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, chan));
stmmac_stop_tx_dma(priv, chan);
...
stmmac_start_tx_dma(priv, chan);
priv->xstats.tx_errors++;
netif_tx_wake_queue(netdev_get_tx_queue(priv->dev, chan));
}
It is called through stmmac_interrupt()->stmmac_dma_interrupt() and
through stmmac_msi_intr_tx(). Both handlers return early only on
STMMAC_DOWN, which stmmac_suspend() never sets.
The channel IRQs also stay enabled until
stmmac_stop_all_dma()->stmmac_deinit_chan() masks them.
Say a tx_hard_error status is handled after this netif_tx_disable().
TX DMA is restarted and the txq is woken. Can the qdisc then call
stmmac_xmit() after priv->plat->suspend() has gated the clocks?
On dwmac4, stmmac_stop_all_dma() may open this window by itself.
DMA_CHAN_INTR_ABNORMAL enables RPS, so stopping RX DMA can raise AIS.
dwmac4_dma_interrupt() then decodes TPS, which is set when
stmmac_stop_tx_dma() clears ST, as tx_hard_error:
dwmac4_dma_interrupt() {
...
if (unlikely(intr_status & DMA_CHAN_STATUS_TPS)) {
x->tx_process_stopped_irq++;
ret = tx_hard_error;
}
...
}
A fatal bus error during the suspend window would take the same path.
Should the DMA interrupts be masked, or a down state set, before the
queues are disabled here?
> for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
> hrtimer_cancel(&priv->dma_conf.tx_queue[chan].txtimer);
>
[Severity: High]
This isn't a bug introduced by this patch, but stmmac_xdp_release() in
the same file still uses the ordering this patch fixes in
stmmac_suspend():
stmmac_xdp_release() {
/* Ensure tx function is not running */
netif_tx_disable(dev);
/* Disable NAPI process */
stmmac_disable_all_queues(priv);
...
stmmac_free_irq(dev, REQ_IRQ_ERR_ALL, 0);
...
stmmac_stop_all_dma(priv);
...
free_dma_desc_resources(priv, &priv->dma_conf);
...
}
A tx NAPI poll that runs before napi_disable() completes can reach
stmmac_tx_clean(). There it finds the queue stopped and
stmmac_tx_avail() > STMMAC_TX_THRESH, so it calls netif_tx_wake_queue(),
which also reschedules the qdisc.
stmmac_xmit() can then run, holding only the txq lock, while
stmmac_xdp_release() carries on into free_dma_desc_resources(). Could
stmmac_xmit() write descriptors and tx_skbuff entries into ring memory
that is being freed?
This can be hit by attaching or detaching an XDP program on a running
interface while TX traffic is flowing, through
stmmac_xdp_set_prog()->stmmac_xdp_release().
__stmmac_release(), and stmmac_suspend() after this patch, both disable
NAPI before calling netif_tx_disable(). Should stmmac_xdp_release() use
the same order?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-tm-stmmac-eth-s2idle-v1-1-bbe165b743b5%40bp.renesas.com
prev parent reply other threads:[~2026-11-19 21:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 9:51 Tommaso Merciai
2026-11-16 9:57 ` netdev-bot+sinfo
2026-11-19 21:52 ` 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=179512515855.3136.15162646874622512762@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andrew+netdev@lunn.ch \
--cc=biju.das.jz@bp.renesas.com \
--cc=davem@davemloft.net \
--cc=dinghui1111@163.com \
--cc=dinghui@lixiang.com \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=maxime.chevallier@bootlin.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peppe.cavallaro@st.com \
--cc=tomm.merciai@gmail.com \
--cc=tommaso.merciai.xr@bp.renesas.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
all inboxes | Powered by JetHome®