🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21718

Re: [PATCH net-next v4 3/5] net: stmmac: Balance runtime PM when the probe fails

#21718
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 11:16
156 lines
13872 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 (1) · 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] In __stmmac_dvr_probe()
  (drivers/net/ethernet/stmicro/stmmac/stmmac_main.c), the patch adds an…
- [Low] The patch fixes a real, user-visible runtime-PM bug in
  __stmmac_dvr_probe() but has no Fixes: tag.

Pre-existing issues:
- [Medium] Before stmmac_hw_init(), __stmmac_dvr_probe() asserts and then
  deasserts priv->plat->stmmac_rst, and deasserts the shared…

--

net: stmmac: Balance runtime PM when the probe fails

This adds pm_runtime_disable() and pm_runtime_put_noidle() at the
error_mdio_register label in __stmmac_dvr_probe(). A failed or deferred
probe then undoes the runtime PM enable and the usage count taken before
stmmac_mdio_register(), the same way stmmac_dvr_remove() does.

> Undo both, as stmmac_dvr_remove() does.
>
> Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>

[Severity: Low]
Should this have a Fixes: tag?

Commit 5ec55823438e ("net: stmmac: add clocks management for gmac
driver") added the pm_runtime_get_noresume(), pm_runtime_set_active()
and pm_runtime_enable() sequence to __stmmac_dvr_probe(). The only
matching pm_runtime_put() is on the success path, and the error labels
were never updated.

Something like:

Fixes: 5ec55823438e ("net: stmmac: add clocks management for gmac driver")

would let stable tell which kernels need this. It would usually be
targeted at the net tree as well.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index f256244ce0d11..4ebf4b6253743 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -8407,6 +8407,8 @@ static int __stmmac_dvr_probe(struct device *device,
>  error_pcs_setup:
>  	stmmac_mdio_unregister(ndev);
>  error_mdio_register:
> +	pm_runtime_disable(device);
> +	pm_runtime_put_noidle(device);

[Severity: High]
Is this pm_runtime_disable() balanced on PCI based stmmac devices?

The probe path only enables runtime PM when it is not already enabled:

	pm_runtime_get_noresume(device);
	pm_runtime_set_active(device);
	if (!pm_runtime_enabled(device))
		pm_runtime_enable(device);

Commit d90d0c175cf2 ("net: stmmac: Fix "Unbalanced pm_runtime_enable!"
warning") made that check conditional. The PCI core has already enabled
runtime PM before any driver binds:

drivers/pci/bus.c:pci_bus_add_device() {
    ...
	pm_runtime_enable(&dev->dev);
    ...
}

So for the PCI glue drivers (stmmac_pci.c, dwmac-intel.c,
dwmac-loongson.c, dwmac-motorcomm.c), probe skips the enable. This
error path still disables, though. That removes the PCI core's enable
and leaves disable_depth at 1.

Every failure from stmmac_mdio_register() onward ends up here. That
includes -EPROBE_DEFER, and also failures from stmmac_pcs_setup(),
stmmac_phylink_setup(), stmmac_register_devlink() and
register_netdev(). After that:

local_pci_probe()
    pm_runtime_put_sync(dev);      <- no effect, runtime PM disabled
really_probe()
    device_unbind_cleanup()
        pm_runtime_reinit()
            pm_runtime_set_suspended(dev);

pm_runtime_reinit() finds runtime PM disabled and the status
RPM_ACTIVE. The function is still in D0, but it is recorded as
RPM_SUSPENDED, and the parent bridge's child_count is decremented.

When stmmac itself retries a deferred probe, it re-enables runtime PM.
If the failure is permanent, or a different driver binds next (for
example vfio-pci through driver_override), runtime PM stays disabled
and the device still never runtime-suspends. The PCI callers'
error paths, such as intel_eth_pci_probe(), do not restore it.

Isn't that the same symptom the commit message says this fixes?

Could a local bool record whether this probe actually called
pm_runtime_enable(), so pm_runtime_disable() is only called in that
case?

stmmac_dvr_remove(), which the commit message names as the model,
already has the same unconditional pm_runtime_disable(). It looks like
it has the same mismatch on PCI. Later patches in the series do not
appear to change this error path.

>  	stmmac_napi_del(ndev);
>  error_hw_init:
>  	destroy_workqueue(priv->wq);

[Severity: Medium]
This issue is pre-existing and was not introduced by this patch, and it
is separate from the runtime PM problem. Since this error path is being
matched against stmmac_dvr_remove(), should it also put the resets
back?

Before stmmac_hw_init(), __stmmac_dvr_probe() does:

	if (priv->plat->stmmac_rst) {
		ret = reset_control_assert(priv->plat->stmmac_rst);
		reset_control_deassert(priv->plat->stmmac_rst);
		...
	}

	ret = reset_control_deassert(priv->plat->stmmac_ahb_rst);

stmmac_dvr_remove() asserts both again:

	if (priv->plat->stmmac_rst)
		reset_control_assert(priv->plat->stmmac_rst);
	reset_control_assert(priv->plat->stmmac_ahb_rst);

None of the probe error labels do this. After a failed or deferred
probe, the MAC is left out of reset.

stmmac_ahb_rst comes from devm_reset_control_get_optional_shared() in
stmmac_probe_config_dt(), and devres releases the handle without
asserting it. Could that leave the shared deassert_count raised? If
so, another consumer sharing the AHB reset could no longer really
assert it.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-sun8i-emac-mux-uaf-v4-0-57eba8915f25%40gmail.com
Technical Details
Message-ID: <179551897911.3135.10060956110819643456@kernel.org>
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370273-linux-kernel-netdev=dewy.ru
References: <20261120-sun8i-emac-mux-uaf-v4-3-57eba8915f25@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370273-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v4 3/5] net: stmmac: Balance runtime PM when the
 probe fails
Date: Tue, 24 Nov 2026 11:16:19 +0000
Organization: Usenet Network
Message-ID: <179551897911.3135.10060956110819643456@kernel.org>
References: <20261120-sun8i-emac-mux-uaf-v4-3-57eba8915f25@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4121574"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+3tYH9JrSX6+e/0vd9j6W6AjCZQ= sha256:P+R0AbWUFXRp6OhkMTmZG7A5Hskm3UqKnpvnYHhPc6M=
	sha1:lTXZwuUbY3zxWL8t2+IUthzF45Q= sha256:dwMBIrDn2l40rdG9v0+XEkBJMs15clOEKSmjqyuKfkI=
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 B6817125E00; Tue, 24 Nov 2026 14:16:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[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 sQR86L3jrUCq;
	Tue, 24 Nov 2026 14:16:32 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-370273-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id A579B125DFC; Tue, 24 Nov 2026 14:16:23 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id D28826030E1; Tue, 24 Nov 2026 11:16:22 +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=1795518982;
	b=5qI3iCZ3WQ1mkWoCii/wqJ2wIJlw1BUwcdOFmG8QVSTuaaxYaEgNXZRXC4DW9lv30BHn
	 524F6aAI/SuZGD/aSCyurBRHpjtKexFUvihxYIRdPtAwOrlIrLcCpIYXEeI32xj+AVx3r
	 ygGXLE5yYDgXUC/qYz7xw4f2hc9krtMR6ee3CBwuFwu1oFc+LlcgKyQ6NuPCR9cA9SEg1
	 8RsgDX2fJvL+MpRG3XKnvCc0hGrtKMp/kORu1f1smlOCemwPOLZt9CZjM0JXdQt1+mUYr
	 qcy8Ziaa2tVmkU5jUDyMwwBdENxUQgQQovZWoCZkQ0VRBYwEdL2gUtgvCZI70H9A6TA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795518982;
	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=muxY4t+JASM5puVdEtPnoVoZ9a0aIbs760H+tQNuqfA=;
	b=m7HcMvyb+iT1qOzrtqAbbBb8REDegIPt7WCu9mw9n0MsMyFBnkjJH2UjSRpBVae2hJ9C
	 F301wIz0N/gUyLFZotq73CNjz17XZjpE+W/40MYc0ceejyOnF4C06fccBV7I4OsfmRAWU
	 uMPb4GByBcJdnZTr6Fd+7WJGCmIqOGjC7pwey8V5fLbv9WVtj811oF/h90M50XhziCuaO
	 ByObU/JJXyM9jSx0ejK1JT8ivvaz50YABH/7mhdBnBTz2fIr7ZUwtVhjnob2oWAMiHUsG
	 wsElBi+f3Teeaii6EG4JZ7GA8taTWQMjI/KTXAU8lS+hvbYWXfkxf15VzKcXRqDpQcg==
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=hKos+bSh;
	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 3A0E5606A33B;
	Tue, 24 Nov 2026 11:16:22 +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=hKos+bSh
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=1795518981;
	b=FnAnjomy9wARcgLN2yKnsWEay4rjAG74yOvzS3by/qWghAM+a7ScxKPqlNttJq8txf90
	 yT+nlZvbwBpMpjDmNaZv8rRw9afueG1JcpzJGTJL3738C9HvxiZp5t7vUQHWdrbE3TzYj
	 5Lab5hxApmKlsql7NTkvcXHJ/CRuPzp1CcPi1A8zRiXUdlkx/tbA35tBcysZux4bkIGwA
	 8BgWctXSWoWOkZlBSWXN34WUXzuG1m1QvVhtkz4yFCdUsT9+wChYaxijPGsoo7FXQpm6e
	 n9lACHtQjtG6XgIk16jGF9UQOaQQ/oY3widXqcqa2T9YLK9EQjfZ6a0TptptVnAJrNg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795518981;
	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=muxY4t+JASM5puVdEtPnoVoZ9a0aIbs760H+tQNuqfA=;
	b=TY/Rm81QGIkPALMA0luAaNhPIrg047YkyIUB28yElmaG+SObG5D/rYvCz7avrLzIVG+d
	 Gjhd3p2UUCmnzkOVCRu++WjARj1nA7srHRMJTGPT7X4z8HmUQ+kPVVO1GukhAg/1YyhRL
	 8A25Xdi/AZUFhDXiAr+WzVCFtYk3EMGyd3me2ROejb4lQTL/kfml54XUOoD8hkiLoSJqx
	 zcfrWJGKzDAonbXh/9cxPvDoVteGmTyOsb4KpSJL9Tz/E48FEfJl6FcvxB9pDvT5m1uHb
	 O+5ssur2vdLEx5lYqciHuqgy6NGj9lLjNyseHLyc6lzlLrQXIG6LEkfUmnWoNjBiFRw==
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=hKos+bSh;
	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 591F4606A321;
	Tue, 24 Nov 2026 11:16:21 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C2A71F000CF;
	Tue, 24 Nov 2026 11:16:19 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795518980;
	bh=muxY4t+JASM5puVdEtPnoVoZ9a0aIbs760H+tQNuqfA=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=hKos+bShwfIe7Dgym62Fg+t4JI0I36+nzK/h0qFQk4b7Z6URMMBHY1zt+E13ieAdb
	 o4p7TxQrRW9leNas20xjn5LKANfaw0i9iRzoUDtF7Edi/L1nkm6UvJyMRspiXKB4dc
	 tjw17G9ue+Pj1TCRWQ1iEL2fKWHF+cM1HvxKZkRY0H1EWUyIp6vy7fNpJEBg/49Fsy
	 9+LBSi3aDFraQq/k6cW6MBBbpOmzoin1FaiXo2KDTP+vrkHg5PRGJmzhUeuGZ7MKeN
	 s4nKZE9z+U2ptz5w4hznAmFo59w5k7S8AMA0of6tPxeIYzCDzq+YA8O0NwzLUnhqTK
	 +ADOQQYAfHNLQ==
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, wens@kernel.org,
 jernej.skrabec@gmail.com, samuel@sholland.org, p.zabel@pengutronix.de,
 linux@armlinux.org.uk, netdev@vger.kernel.org,
 linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev,
 linux-stm32@st-md-mailman.stormreply.com, linux-kernel@vger.kernel.org
X-In-Reply-To: <20261120-sun8i-emac-mux-uaf-v4-3-57eba8915f25@gmail.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