mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 3/4] net: stmmac: restore RX descriptor buffer addresses on resume
Date: Mon, 23 Nov 2026 14:39:36 +0000	[thread overview]
Message-ID: <179544477624.3135.5494306095846250622@kernel.org> (raw)
In-Reply-To: <52672e4d879760b1434a92e12f3c7d5b2287e086.1795096430.git.dinghui@lixiang.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 2

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] This patch adds a failure point to stmmac_resume(): `ret =
  stmmac_resume_descriptors(priv); if (ret) goto error_unlock;`.
- [Medium] The new early failure in stmmac_resume()
  (stmmac_resume_descriptors() returning -ENOMEM) jumps to error_unlock.
- [Low] Part of the commit message describes code that is not in the
  tree.
- [Low] The commit message frames the bug only as GMAC4/XGMAC writeback
  overwriting buffer addresses, which leads to a 'fatal bus error'.

--

net: stmmac: restore RX descriptor buffer addresses on resume

The patch restores RX descriptor buffer addresses on resume. On GMAC4 and
XGMAC, hardware writeback during suspend can overwrite them. Buffer
preparation is factored into stmmac_prepare_rx_buffer() and
stmmac_prepare_rx_buffer_zc(). A new stmmac_reinit_rx_descriptors()
allocates any missing pages with GFP_KERNEL, and the per-ring resume work
is gathered in stmmac_resume_descriptors().

> Rebuild chain pointers and use stmmac_reset_rx_queue() to discard partial
> receive state from before the DMA reset. Initialize RX descriptors after
> restoring their addresses,
> using the existing per-queue initializer to preserve the watchdog policy
> and legacy control fields. Keep the unpopulated XSK suffix CPU-owned when
> DMA restarts. This replaces the separate final ownership-setting loop.

[ ... ]

> The RX rings no longer undergo initialization before address restoration.

[Severity: Low]
Which ownership-setting loop does this replace? Before this patch,
stmmac_resume() only called stmmac_reset_queues_param(),
stmmac_free_tx_skbufs() and stmmac_clear_descriptors().
stmmac_set_rx_owner() is only used in stmmac_rx_refill() and
stmmac_rx_refill_zc().

The second sentence has the same problem. The old resume path never
restored RX addresses, so nothing was ever initialized "before address
restoration".

Both sentences read like notes against an earlier, unposted version. Could
they be reworded to describe what changes relative to the current tree?

> Share buffer preparation with the refill paths and restore addresses
> from attached buffers. Allocate missing primary and secondary pages
> independently with GFP_KERNEL. If allocation fails, return the error
> without restarting DMA and leave the device detached.

[Severity: Low]
The commit message doesn't say why pages can be missing at resume time.

stmmac_rx() hands buf->page to the stack or page_pool and sets
buf->page = NULL. If the GFP_ATOMIC refill in stmmac_rx_refill() then
fails, that entry is left with no page attached.

The old resume path set OWN on every RX descriptor through
stmmac_clear_descriptors() whether a page was attached or not. On cores
whose writeback leaves the address word intact, the re-armed descriptor
still pointed at a page the driver no longer owned. DMA could then write
into recycled memory.

The new stmmac_reinit_rx_descriptors() fixes this too. Could the commit
message describe this case, so stable backporters know the patch also
fixes it?

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f9ac82d2e7266..1508cf08f03b0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

[ ... ]

> @@ -8563,10 +8659,9 @@ int stmmac_resume(struct device *dev)
>  
>  	mutex_lock(&priv->lock);
>  
> -	stmmac_reset_queues_param(priv);
> -
> -	stmmac_free_tx_skbufs(priv);
> -	stmmac_clear_descriptors(priv, &priv->dma_conf);
> +	ret = stmmac_resume_descriptors(priv);
> +	if (ret)
> +		goto error_unlock;

[Severity: High]
If stmmac_resume_descriptors() fails here, does NAPI stay disabled while
netif_running() is still true?

stmmac_suspend() already called stmmac_disable_all_queues(), and
error_unlock skips stmmac_enable_all_queues(). Any later stmmac_suspend()
or stmmac_release() would then call napi_disable() a second time on the
same instances:

stmmac_release()
  __stmmac_release()
    stmmac_disable_all_queues()
      __stmmac_disable_all_queues()
        napi_disable(&ch->rx_napi)
          napi_disable_locked()

net/core/dev.c:napi_disable_locked() {
    ...
		while (val & (NAPIF_STATE_SCHED | NAPIF_STATE_NPSVC)) {
			usleep_range(20, 200);
			val = READ_ONCE(n->state);
		}
    ...
}

SCHED is still set from the first disable. Wouldn't this loop spin forever?
In the close path (ip link set down, MTU change, XDP setup, ring resize) it
would hold rtnl_lock. On the next system suspend it would hold priv->lock.

The -ENOMEM comes from the GFP_KERNEL page_pool allocations in
stmmac_reinit_rx_descriptors() -> stmmac_init_rx_buffers(). These run
during resume with the PM gfp restriction in place, so failure looks
reachable under memory pressure.

The commit message says "If allocation fails, return the error without
restarting DMA and leave the device detached". Is that detached state safe
to leave the device in? The stmmac_hw_setup() failure path already behaves
this way, but this patch adds a new way to reach it.

[Severity: Medium]
On the same failure path, is the MAC receiver left enabled?

error_unlock only powers down the legacy SerDes and drops the locks. Only
error_stop_dma calls stmmac_mac_set(priv, priv->ioaddr, false). With
Wake-on-LAN enabled, stmmac_suspend() never disables the MAC:

	if (priv->wolopts) {
		stmmac_pmt(priv, priv->hw, priv->wolopts);
		priv->irq_wake = 1;
	} else {
		stmmac_mac_set(priv, priv->ioaddr, false);

dwmac4_pmt() sets GMAC_CONFIG_RE when it arms wake-up. The
stmmac_pmt(priv, priv->hw, 0) call earlier in stmmac_resume() only writes
PMT=0 and leaves RE set. Because stmmac_hw_setup() is skipped, no DMA soft
reset clears the configuration either.

After the failure, the MAC keeps receiving with the link still up, while
RX DMA is stopped. The failing queue's descriptors have already been made
CPU-owned by the OWN-clearing loop at the top of
stmmac_reinit_rx_descriptors(). Incoming frames fill the MTL FIFO with
nothing to drain it. STMMAC_DOWN is not set, so the pre-suspend interrupt
enables can still reach stmmac_interrupt().

Should this path disable the MAC (and the DMA interrupts) before
returning? Otherwise the device is neither armed for wake-up nor quiesced.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795096430.git.dinghui%40lixiang.com

  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 " 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 [this message]
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=179544477624.3135.5494306095846250622@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

all inboxes | Powered by JetHome®