๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #9249

Re: [PATCH net v4 5/5] net: phy: postpone PHY interrupts during sleep with MAC-managed PM

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

Critical: 0 ยท High: 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] net: phy: false wakeup in phy_interrupt() during mac_managed_pm
  suspend

--

> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -332,16 +332,55 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
>  	return !phydev->suspended;
>  }
>  
> +static __maybe_unused enum phy_irq_wake
> +phy_irq_wake_source(struct phy_device *phydev)
> +{
> +	struct net_device *netdev = phydev->attached_dev;
> +	bool phy_wol;
> +
> +	if (!netdev)
> +		return PHY_IRQ_WAKE_NONE;
> +
> +	/* phy_suspend() cached the answer of a suspended PHY, which may
> +	 * not be reachable over MDIO.
> +	 */
> +	if (phydev->suspended && !phy_can_wakeup(phydev))
> +		phy_wol = phydev->wol_enabled;
> +	else
> +		phy_wol = phy_may_wakeup(phydev);
> +
> +	if (netdev->ethtool->wol_enabled || phy_wol)
> +		return PHY_IRQ_WAKE_SYSTEM;
> +
> +	/* A MAC that manages PHY PM stops the PHY itself: the link
> +	 * interrupt that follows is not a wakeup.
> +	 */
> +	if (phydev->mac_managed_pm)
> +		return PHY_IRQ_WAKE_NONE;
> +
> +	if (device_may_wakeup(&netdev->dev))
> +		return PHY_IRQ_WAKE_NETDEV;
> +
> +	if (netdev->dev.parent && device_may_wakeup(netdev->dev.parent))
> +		return PHY_IRQ_WAKE_PARENT;
> +
> +	return PHY_IRQ_WAKE_NONE;
> +}
> +
>  /* 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.
> + * Decide which wakeup event a postponed interrupt reports now, while
> + * the PHY can still be read.
>   */
>  static __maybe_unused void mdio_bus_phy_suspend_irq(struct phy_device *phydev)
>  {
>  	if (!phy_interrupt_is_valid(phydev))
>  		return;
>  
> -	WRITE_ONCE(phydev->irq_suspended, true);
> +	phydev->irq_wake = phy_irq_wake_source(phydev);
> +	/* Pairs with smp_load_acquire() in phy_interrupt() */
> +	smp_store_release(&phydev->irq_suspended, true);
>  	synchronize_irq(phydev->irq);
>  }
>  

[Severity: High]
phy_irq_wake_source() runs from mdio_bus_phy_suspend(), before the
MAC's suspend callback. For a mac_managed_pm PHY, that callback still
changes the link afterwards. The mac_managed_pm check below only
covers the case without Wake-on-LAN. With Wake-on-LAN enabled we
return PHY_IRQ_WAKE_SYSTEM, so any link interrupt the MAC causes
itself makes phy_interrupt() call pm_system_wakeup() and abort the
suspend.

I can see two ways to get there.

WoL in the PHY on stmmac: stmmac_suspend() calls phylink_suspend(),
which goes through phylink_stop() -> phy_stop() -> phy_suspend(). With
wol_enabled set and no PHY_ALWAYS_CALL_SUSPEND, phy_suspend() returns
-EBUSY without calling the driver's suspend, so the link interrupt
stays unmasked. phylink_suspend() then calls phylink_speed_down(),
since stmmac sets wol_phy_speed_ctrl, and phy_speed_down() restarts
autonegotiation to drop to 10Mbps. The link goes down while
irq_suspended is set and irq_wake is PHY_IRQ_WAKE_SYSTEM.

WoL in the MAC only, fec for example: netdev->ethtool->wol_enabled is
set while phy_wol is false, and fec_suspend() calls phy_stop() and
gates its clocks. phy_suspend() again leaves the link interrupt of the
PHY enabled. rtl8211f_suspend(), for one, neither calls
genphy_suspend() nor masks the link status interrupt when wol_enabled
is set without driver-model wakeup. So the link-down interrupt is
reported as a system wakeup, although the PHY interrupt is not a
wakeup source here at all; the MAC is.

Before this patch these PHYs did not have irq_suspended set during the
MAC's suspend callback, so neither case could abort suspend. This
looks like a regression for anyone using WoL behind a MAC that manages
PHY PM. Did the Helios64 Wake-on-LAN test go through the speed
downshift in phylink_suspend()?

I'm not sure what the right fix is, so two questions. Should the
mac_managed_pm case count only phy_wol, and not the ethtool flag that
may describe MAC WoL? And for PHY WoL, can the wakeup be armed only
after the MAC has finished suspending, for example from a later
suspend phase, so that link changes the MAC makes itself are not
reported?

-- 
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: <179352219781.3131.16504721138901563596@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-354208-linux-kernel-netdev=dewy.ru
References: <20261031-b4-phylib-mac-pm-irq-v3-v4-5-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-354208-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v4 5/5] net: phy: postpone PHY interrupts during sleep
 with MAC-managed PM
Date: Sun, 01 Nov 2026 08:36:37 +0000
Organization: Usenet Network
Message-ID: <179352219781.3131.16504721138901563596@kernel.org>
References: <20261031-b4-phylib-mac-pm-irq-v3-v4-5-5ba23b3ff9a4@iav.lv>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2653822"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jRUQCm9qrerWFdhLbrj3mI2uxfg= sha256:/AF/whk0uD5iQbqB9G8d6use36NXrb1xMjb39yTjAS4=
	sha1:+sGQWjR+cSePK+PBU/qFSbDvxbI= sha256:JT3x2g4S6gc4fwgdjaWca0Jz9ZTodFA/uTnAL84YK5A=
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 CB845112304; Sun,  1 Nov 2026 11:37:01 +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 yHbPi2hXl8SX;
	Sun,  1 Nov 2026 11:36:54 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-354208-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 1BE5F1122FF; Sun,  1 Nov 2026 11:36:43 +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 E62FE602127; Sun,  1 Nov 2026 08:36:41 +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=1793522201;
	b=C76GMOljgrZcaYNPbbtWyFnxGNtcdNfnfhBkzJzzduf5Z0GkYHtKjbjOoNL2IqXTZ++h
	 4Zes4n0DlcT6snWtfT3KurfPr3u/Q3Tly1jsbYt/JLz13CtN7fCpgiZHqWAiubdGp86Re
	 2KYrLCouDYqK0/kzCHgqyAFSh/7ONSMg1B/9F12LpIDHP3CXln2+guzOPOHLQOsRAzklO
	 nf6ULz2Kl2JV1Grk2XWDzm2jIjX/JLMQbp1Z7N2wDFL91Lo9KwNqswyHhVWmSZdT6QI/e
	 kBH6d9zc4YpdXw0PMwagGn6SU121ftbyuEfMhOmaSJXw6tybJHnD5Klba8PnZxSynGw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793522201;
	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=LXCicZxC3YM8+qlDZ22L2zoCpC7gbAYtbkXJ6Bwzeew=;
	b=I+g4bDupPIDxl92GrmMk4iIE77yMhYKchhXeYPNdxA5WHTKwHmB3alVUyBCnbVP4tIKW
	 Nlw4hyvAZv0Ekn1SFE2/7xYh41YGk1mClJzD22dDn3UVbZ12IBJ8YMl8P09N1eklfgf2E
	 p2elynatGm3+zFdp8szbSwVl2c49l5QfhSiaCO1J2PH2c2plfpBOW1q1M2Y/6FZIv5BYa
	 GZKIvdlRrCvNVor6QQWOKHQ0yvI2aaiTIPcz+YzIp8HvpeQia2+ZR4evKi1aZVrOsqtA4
	 HMEBZv02KzJlE3fUtcVNImOVSkPHWgwevFGOVtQXkWDgut1W8G3Ubzp6AepZWFUTi+Q==
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="Tes5Dti/";
	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 E691D60A2601;
	Sun,  1 Nov 2026 08:36:40 +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=Tes5Dti/
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=1793522200;
	b=21OSitH5C+GwGUBzWftrfFXU8t2i0BSlP2m52xUDNfod/CA+h8+lmLDcX4T2zTQik/zs
	 3pYCyBhXVls1mLkTfhKS2w6z72pz1onfCutp//JxkCnP/sg0D+dEfXcGj+jvHEaqnmr7P
	 5in+FrbqRQkaUpGbHd5GjIiPFaVrjGnxcNHmAWmMK3ssKQvkGrRmbZ85cLTrNVsIY5AL4
	 4slFOsw9EXOuO8JxfLdTdyQ46DqjHHzFMsB5taHhIzAJu6meHnOx0ieQA86SRFd1eRRD/
	 DN8YzKhl1xFZk7LclUab3jtSKDPicvb943KrVmQkAdd5MRgcEblX8Sh2OCt6jFCM3Zg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793522200;
	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=LXCicZxC3YM8+qlDZ22L2zoCpC7gbAYtbkXJ6Bwzeew=;
	b=eeRJw89iTkKcUxYQT0cZnQXFoGTGHoDlRr73NuuXkS6kGjjF7VIM5c40k0Q7UlMM9eS9
	 /AvJDsYJBIUtu2WApibkCxfPVJb7TtV1UzeqtDeNCpvVb75gJyxRZ/52djKbSyQcUi96I
	 uM7VndQJpRm/3OAj+fIxSOchDQ8k1b7CJPPl8+uR4pP5vWDz9O5uPDsGFkuDgM01j7g5m
	 0A9k4BlPYbNZ5T8tgZuBI88n6WDn/Gaaka2jhs50X05aBQRYWcQDbL5/CIv/VRVbD2pSM
	 kSnMNtiAvYyD/jQF4h/Moy0Odpvv5B1OChaHN750Gv7jUEluPZLIpC0F5n74cKmWQGg==
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="Tes5Dti/";
	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 C474A606A326;
	Sun,  1 Nov 2026 08:36:39 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 420441F00A15;
	Sun,  1 Nov 2026 08:36:38 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793522199;
	bh=LXCicZxC3YM8+qlDZ22L2zoCpC7gbAYtbkXJ6Bwzeew=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Tes5Dti/hG/1AhQHhdTiEkH62QiB64z9bqwJPK6OFBMM83BHIUFcSNzY2CLX3rIcR
	 lLJ3dOUnndz38pX+F1FM9UoKEFTavddL+vK9Q/P1dEkaEqisVrPF4REyRh00JXn2if
	 LdTJshZ7prnDXXN17DS+ts6H0YTM8XU5uduc2p0DbfdxZBzNMpFy1TDxLM2gUsAEM1
	 LFF13ZS7cQc+xCyfWj8tG1PMxuFuci9QUebs+hwwQ80sKlfGhGtFTeL5xgepnok/r+
	 dupu7dyO6IRLe5VZW2roR1iFRwrPZIJRS0QlHyZUm1Bfyppl/vC1tXLo4ho4fy9Ysf
	 XeT1UuCyoTEIA==
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-5-5ba23b3ff9a4@iav.lv>
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