🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9251

Re: [PATCH net v4 4/5] net: phy: stop postponing PHY interrupts when a PHY PM callback fails

#9251
From: netdev-bot+sashiko
Date: Sun, 01 Nov 2026 08:36
167 lines
14085 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 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).

- [Medium] Interrupt storm and WARN flood when a PHY PM callback fails
  because MDIO access is broken, which can then disable the shared IRQ…
- [Low] Comments that say interrupt handling is postponed 'until the PHY
  has resumed' are now wrong on the failure paths.

--

net: phy: stop postponing PHY interrupts when a PHY PM callback fails

This patch changes mdio_bus_phy_suspend() so that a failed phy_suspend()
undoes the interrupt postponement and restarts the state machine. It also
changes mdio_bus_phy_resume() so that a failed phy_init_hw() or
phy_resume() reruns the postponed PHY interrupt. Before this, the function
returned with the line still disabled.

> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index ef5e1cd3a8319..390069ec13cac 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c

[ ... ]

> @@ -383,9 +384,20 @@ static __maybe_unused int mdio_bus_phy_suspend(struct device *dev)
>  	if (!mdio_bus_phy_may_suspend(phydev))
>  		return 0;
>  
> +	ret = phy_suspend(phydev);
> +	if (ret) {
> +		/* The PM core skips the resume callback of a device whose
> +		 * suspend callback failed.
> +		 */
> +		mdio_bus_phy_resume_irq(phydev);
> +		if (phy_uses_state_machine(phydev))
> +			phy_start_machine(phydev);
> +		return ret;
> +	}
> +
>  	phydev->suspended_by_mdio_bus = 1;
>  
> -	return phy_suspend(phydev);
> +	return 0;
>  }

[ ... ]

> @@ -411,11 +423,11 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
>  
>  	ret = phy_init_hw(phydev);
>  	if (ret < 0)
> -		return ret;
> +		goto err_resume_irq;
>  
>  	ret = phy_resume(phydev);
>  	if (ret < 0)
> -		return ret;
> +		goto err_resume_irq;
>  no_resume:
>  	mdio_bus_phy_resume_irq(phydev);
>  
> @@ -423,6 +435,10 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev)
>  		phy_start_machine(phydev);
>  
>  	return 0;
> +
> +err_resume_irq:
> +	mdio_bus_phy_resume_irq(phydev);
> +	return ret;

[Severity: Medium]
Can this cause an interrupt storm when phy_init_hw() or phy_resume() fails
because the PHY can't be reached over MDIO?

Suppose a postponed interrupt set irq_rerun during the sleep transition.
mdio_bus_phy_resume_irq() then re-enables the line and wakes the thread. It
does not check whether the PHY can be accessed:

drivers/net/phy/phy_device.c:mdio_bus_phy_resume_irq() {
    ...
	if (atomic_xchg(&phydev->irq_rerun, 0)) {
		enable_irq(phydev->irq);
		irq_wake_thread(phydev->irq, phydev);
	}
    ...
}

irq_suspended is now clear, so phy_interrupt() calls
drv->handle_interrupt(). If the MDIO read fails, a typical handler can't
acknowledge the source:

drivers/net/phy/micrel.c:kszphy_handle_interrupt() {
	irq_status = phy_read(phydev, MII_KSZPHY_INTCS);
	if (irq_status < 0) {
		phy_error(phydev);
		return IRQ_NONE;
	}
    ...
}

dp83848_handle_interrupt() does the same thing. phy_error() is an
unconditional WARN_ON(1) followed by phy_process_error(). That only sets
PHY_ERROR and triggers the state machine. It does not mask the interrupt in
the PHY and does not free the IRQ.

The line is requested with IRQF_ONESHOT | IRQF_SHARED. If the PHY is still
powered and keeps its level INT_N asserted, the line fires again as soon as
the thread finishes.

Would each pass then cost a failed MDIO transaction and a full WARN
backtrace? That would repeat until the spurious IRQ detector disables the
line for every sharer. With panic_on_warn set, the first rerun would panic.

The rollback in mdio_bus_phy_suspend() above takes the same path when
drv->suspend() fails on an MDIO error.

Before this patch, the line just stayed disabled in this case. The commit
message says:

    ... which gives the line back to the other users of a
    shared line. A handler that then cannot read the PHY reports it through
    phy_error(), as most PHY drivers do on any MDIO error.

Can other users of a shared line actually get it back if the PHY's own
interrupt source can't be acknowledged? Whether INT_N stays asserted while
MDIO fails depends on the hardware. Nothing on this path guards against it,
though.

[Severity: Low]
This isn't a bug, but several comments still say the postponed interrupt is
handled only once the PHY has resumed. On the new failure paths, the
postponement ends even though the PHY never resumed:

drivers/net/phy/phy.c:phy_interrupt():
	/* Wakeup interrupts may occur during a system sleep transition.
	 * Postpone handling until the PHY has resumed.
	 */

drivers/net/phy/phy_device.c, above mdio_bus_phy_suspend_irq():
/* Wakeup interrupts may occur during the system sleep transition when
 * the PHY is inaccessible. Set flag to postpone handling until the PHY
 * has resumed. Wait for concurrent interrupt handler to complete.
 */

include/linux/phy.h, struct phy_device kernel-doc:
 * @irq_suspended: Flag indicating PHY is suspended and therefore interrupt
 *                 handling shall be postponed until PHY has resumed

A later patch in the series, "net: phy: postpone PHY interrupts during
sleep with MAC-managed PM", changes the phy.h kernel-doc to "postponed
until mdio_bus_phy_resume()". The comments in phy.c and phy_device.c are
still unchanged at the end of the series.

Should those two comments be updated as well?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261031-b4-phylib-mac-pm-irq-v3-v4-0-5ba23b3ff9a4%40iav.lv
Technical Details
Message-ID: <179352219604.3131.6703522094615416778@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354207-linux-kernel-netdev=dewy.ru
References: <20261031-b4-phylib-mac-pm-irq-v3-v4-4-5ba23b3ff9a4@iav.lv>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354207-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v4 4/5] net: phy: stop postponing PHY interrupts when
 a PHY PM callback fails
Date: Sun, 01 Nov 2026 08:36:36 +0000
Organization: Usenet Network
Message-ID: <179352219604.3131.6703522094615416778@kernel.org>
References: <20261031-b4-phylib-mac-pm-irq-v3-v4-4-5ba23b3ff9a4@iav.lv>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2654021"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:busajK3z8wQWpedbKQCqkbPbUiA= sha256:VnN2KSBXF1735hPiij3d3JP7RYwlE+3Hx8PXFVNvsvM=
	sha1:sCQBrton6CS7FBRj6aVv21EYsUc= sha256:cF9K9fPPSbhbqKjs9qcRSMdoaoQcW8p9sMussG7HLIo=
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 3A492112306; Sun,  1 Nov 2026 11:38:22 +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 ljTY7rb6xdeK;
	Sun,  1 Nov 2026 11:38:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354207-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 686801122EE; Sun,  1 Nov 2026 11:38:10 +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 9B7F32B947; Sun,  1 Nov 2026 08:36:52 +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=1793522212;
	b=ugPDEVZ1wgerAhI+E/IHA47N9d+nyc9OFaR4dDZ4qGGpPUE3nOlE2Y/4rFL4eSwQRe/l
	 xCdNu/bR6xbN34cSB5lH07LmxoWSzAVNftbQDjJiRR6r+x3KZZtzZ8J5RnaBSf5oiCXBX
	 KobebNw2AuPIMIZZnQtud1jeZMYtwcQHbh+3Himj6FCz6uaUtcwN2iVox07A6AkG5BJlL
	 ST6vxKi+TOe189l2NnDdURzUIHXRwn5YBz9pSbgPlEFCktwsizZWbMHC5ITr5R1j725OK
	 VmxWY93+lqIbq32WH5l45idqXggn+g1tUGSY+BYi6+m1MXfsZXxGkFwo6bLTXO+lylA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793522212;
	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=MT/gtzRgjYEkyY6o8rD+a9NlNn+Ql+jmRXlXyRDFw3c=;
	b=guLKUR9F9fJIXebZokwqGl2MTUjC5hUud2I0Ys7SCUdZnIghFRdBp50TuIYhB/+heQ5i
	 42OhDR45/tDVGykmSsTbkKQBB606tUnZ6e+DenSIDyog506f8e19V70VKmmDhKZAy4GEP
	 6h/6lpcUVaMoRo6WT+FSwnMItG85fQcvwbFzqeBSAh2OF1PzpgE2hackLZeBaDgP+jkRz
	 M20ozcwtiM9DfaRyVbGjPpIxEe7aoL5UualpkLf014VlK15T2xNB8faYvKZfI4/wGViSG
	 rDJP5T3X6oGWhyHJL5cHu4pDRrcO3doJz848qGHoILRKCJpEnk2nmg99Q+oK1We/sSg==
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=ixL6rJwo;
	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 5BE53606A330;
	Sun,  1 Nov 2026 08:36:52 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ixL6rJwo
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=1793522198;
	b=TBRYMAqWeMkULLhiuBeZPM2/v9A8ryM9snvSGM10/wUuQKlQeT29/WNAydUfvvEwbv52
	 EtZynCuix5UHnUU9K/MGw0fUI2+FxLQOyZHTabiUSgPQPWaWUuQwcbrk3GP/t60XDlco2
	 CZ0ITZ6ch/foKXaRhO+sRIJIoBYqbn36HdyAVXxpnIQtvq1tUPnkxwIh//wJPBlGCxCiD
	 mJ9PRGAceTFiySD3TLqmi700j0VO28oTsHc8X74LTsQUMiZFVhpn33V541NIamVZc/Eq9
	 dpnQxbBSUL2qBkspZb8c0ttNPWzJpqlhiEGS6fThzq7flwaXv29f5rTJxerH3pS2JuQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793522198;
	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=MT/gtzRgjYEkyY6o8rD+a9NlNn+Ql+jmRXlXyRDFw3c=;
	b=eXej2f+AIiXmpor6+43pIzvlCPeXHfKQX2mQLXBdCSVhM0lQN8Sx07NTrvepTGJDdEIf
	 QV02ikCfwd6Jt9DPxkDeJZUPCZV97hLmrwlz9Mu0/yDAj4HnKW+uWrlS8mzxwGaNTENo+
	 RlpL0uh0JrMuVvtQ1N+q8twhS6zoromD7PEpSCWWA8KrXGxQnE4xd9QPaHlbTsPQSycyP
	 EENJQShNYPkHUIl2PVmI5wXsHcoYeYqX9fkzcsr5wcE8GY9Q4ChfU5NQ4XdoI/MCAd8ge
	 6LxpZkr+W8D38pIE484NHDmD0UgyE4XcNfNW6frSD9M7yIIU+ZuNtvUYKw1KujRVb2g==
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=ixL6rJwo;
	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 F30B9606A332;
	Sun,  1 Nov 2026 08:36:37 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A5BC1F000C1;
	Sun,  1 Nov 2026 08:36:36 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793522197;
	bh=MT/gtzRgjYEkyY6o8rD+a9NlNn+Ql+jmRXlXyRDFw3c=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ixL6rJwoLi1sArTn5kZcpt3DMW9Lk+ki5C3O9dEAIRUQDZJxL0VxJSAusN+4bZ/sT
	 84j4GjZ3bKs6XQf54grlolngo8bNrjE8R3dpdDql6h6bDkVA9D5EJW5S4v5U3OVQyX
	 3ypGJIitutZ/YGDVUti9I3PkdlcaS3VZOg30PrG1DClSzUY0MC9Y2gmxyNlhtdQHoG
	 bEXGzQNcpcAUEglf1o3I8VhF2nPnRrpSGsZ2vaspNkyrO1QaeYGlH5fDu4nKjnkPk3
	 dCLGiFnT16+oRDxUK5cwuRpBRkJDN3AmwQCdJdIUSid5KZjR0D4XlliKQvl6rlhcO0
	 w+XW3eAV9HfLg==
X-Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 maxime.chevallier@bootlin.com, lukas@wunner.de, rafael.j.wysocki@intel.com,
 wei.fang@nxp.com, niklas.soderlund@ragnatech.se, paul@pbarker.dev,
 florian.fainelli@broadcom.com, opendmb@gmail.com, Thangaraj.S@microchip.com,
 shenwei.wang@nxp.com, netdev@vger.kernel.org,
 linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261031-b4-phylib-mac-pm-irq-v3-v4-4-5ba23b3ff9a4@iav.lv>
X-sashiko-severity: Medium
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