๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21085

Re: [PATCH net v8 3/4] net: stmmac: restore RX descriptor buffer addresses on resume

#21085
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 14:39
167 lines
15017 bytes
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
Technical Details
Message-ID: <179544477624.3135.5494306095846250622@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-369486-linux-kernel-netdev=dewy.ru
References: <52672e4d879760b1434a92e12f3c7d5b2287e086.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-369486-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
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
Organization: Usenet Network
Message-ID: <179544477624.3135.5494306095846250622@kernel.org>
References: <52672e4d879760b1434a92e12f3c7d5b2287e086.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="3903486"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:K3ssk3bx8jZ5jLu8r1pswXCg+mg= sha256:28u8nsz85wQ5f87UfK54b6KS2mJWuwyLqUzDCp1wS34=
	sha1:6OdKkr2t4nfIWHDqtECLY6aRN2w= sha256:7DUKhlrKIBJ9T9++BXbln+fLqk21HqlpZMsC2WQDAsQ=
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 F1285125DBB; 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 BIUVkl-GVznQ;
	Mon, 23 Nov 2026 17:39:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369486-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 AA10E125DB9; Mon, 23 Nov 2026 17:39:44 +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 24B97317FB; Mon, 23 Nov 2026 14:39:39 +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=1795444778;
	b=VHrAg0tpVHpII/sFQ8dnPVbFtv3JdW2leY95gluBAWOBoMXICPGQZGAozG689qCJgovB
	 fzPoBKSpzhY71D3E3jjVO/eVhOtqnXMV7K+2RWSz8o+wW4MwimG5knIZPgNtBshjhi6YP
	 LNdblIPiZ4xRu6/ait8wuGCyo9+ww/zdoOQ4/+FM7s4iLlw9LeCeWAAR0NFi1I35Yfe7Q
	 pYiHZTtr0/qPT5hjxkkHItl/3JSjjUQANfKMPCZx2TC6Fkx8PhUZHGHB66cC+cnxU2gWq
	 iif6XnL4oMoS1VVwZMUbhKnNKSzl7J/Nl5NdVcljcuaAYfdiYrMb/7Td38gUbKV2PYA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795444778;
	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=T6qSvEjZyD41I87wlBj9dRMtlhR3Lhe1Gpro/JPPIOw=;
	b=0KVJHtnm0Is66zSsYslhAoXyzFYGydcXQivbeA68QhDqElfAaeortMznrJSyWbH1ZLu0
	 zuTV7fvjGHCqaSsWK+4yN1joBctSTIYgnWx28+WsblhBGQhPAfTmOFvkqfKmuOi+AUKDf
	 FnnwkvcqDqkb2z98XUFw+ANjRMgOJ/ny2jgrbUezAtguwjDdrtl32E4l8fqwTMzQKFsxV
	 6n2OcqtylIFz9RfJMBAbKYJ1nRIjxEkB5cDZmXMl9enLL5w9XPu67lzJNr8u13OuuZ6w9
	 6zhfiSlnY8/1kKfAt+qalHnd317n8lc2d/pmP7t7AMD98wup0/wFUXvyMj+fktzaVJg==
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=d2pLYXdw;
	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 D9054606A32D;
	Mon, 23 Nov 2026 14:39:38 +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=d2pLYXdw
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=1795444778;
	b=Ou3VJW7B3SNKfj9QqNkC23fjFfIrVGI6BUFbPSJjVn7A2f4hlPQN+jgbf9m8reZn+SF2
	 g/fwlpY31yNMvG5ELEh0fljBJRtbpc7gdIGMAAUHjaCTzQFyTX6zfAkLW4CcPSBp+LLGE
	 m6jJ+9fHkg8OJMqLEtggZ75bvoZAe+93o950e2AyLsuU7EmD48GeJnxgx4x5pqQbuh8dm
	 6Y8glVxdjisdMLcKhRNvQQlzHP78i3Exh0uCA1JmPb1tY0iumB/ZScH/nFL9Dx0tXgNsP
	 Ql37UZnX6BeNWT15/yklLm9pMY8oeI0di9srTjAsG4QqFcE5kvVsdsYZuEIxdKXKRZQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795444778;
	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=T6qSvEjZyD41I87wlBj9dRMtlhR3Lhe1Gpro/JPPIOw=;
	b=OMMefkVXaG/DvTVkC/BMXoL7bvuF1wNAN8mD+/D3HxEtJLZd6yCjyzp6QD+aN7jCT1YG
	 5YRdnSbvyzELXDsRz8iH/JAqcMiwWLhXqicxKmzO9pwM5h3clohZzObhnEgHYTYaPIU5b
	 lidbRAkJCWBInvbePcd+OO9D7avmh/JACkyY7uyJVZyXWfPgfqEi4137aXGXDJOIRpyqW
	 G2BwGTQ9TXr6pn7Svuw7Fd52p+31nEEZheAEFJKStCuRKO7XwCoY2uQ0dzy8B+qgoQnVV
	 JbEn6Uz/5mrIzhqGft5D2AmXBhClpw92+WzzW9uJUTA8n9IM9uwtCbGOqLR9BmJbl5w==
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=d2pLYXdw;
	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 05FD5606A33B;
	Mon, 23 Nov 2026 14:39:37 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A073E1F000C0;
	Mon, 23 Nov 2026 14:39:36 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795444777;
	bh=T6qSvEjZyD41I87wlBj9dRMtlhR3Lhe1Gpro/JPPIOw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=d2pLYXdwb8Uu/UC8PAUm7O6721joxh6PjGnTSg2poM9FgumP76d9CiuKwpxfRdWuP
	 BAv4UZejLB4E0suNJ2cmLmHczG9XwiPJYRExlk4e3jtz4elbAMG5UhFKGNsDq8l3rs
	 aBocclsNgdUoIRqaZaijgFIRnCFp3lC7K3N+3Sxd7axFht9rSRY8nb6BQEBWrQYzbW
	 InLRSD/zSu1o24my0gOwC27rq9azN/cKQr5laV2Dj1Lnu8MHULW3kCEF5gpZLXsL0D
	 kgr9UONXRfUQqw8vRzA9rLCZwEIpsPHp4HeqQyU3X6GFpq7Vx1zw2EgAInHaoVu/Jo
	 fv3oTR9JtQY2w==
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: <52672e4d879760b1434a92e12f3c7d5b2287e086.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