From nobody Wed Oct 1 21:27:16 2025 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC4A8213236; Sun, 28 Sep 2025 08:59:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049945; cv=none; b=K7fdOUZ7jSdT68o/xt8jusBxKtzAxVDY9nEJCY5bXjcOjuv1cz9lrge0t1lUeYMY4kFJcdv3EblnGiABzXAt0AfXgZdKPQovRM0gUxEc16bnFk7QyuRabg8HCuW+SwJJJU0blO/+vLWmnrwsXhR+cDQvbdMCrmEkLavTE9Un7CE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049945; c=relaxed/simple; bh=nvJfGrP7+h4Lfh67grIr5YrHb/pqusJhkLoty64/T78=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=p3T75A6fRt9yKLNizp0rIBfRYNBplyka9Clh9QZKZwFFs/nQgYSxhYv8o3ORzAnD5hT7+FemsyZI1NO4RfhRhFAd8xkssMDqBIE1XtjgGH0fI8lcYGsDUuF8yT/4bB+/SIbJMLWVyowfgZZADdmmF41C65Y9ECOAwMmNZ7CPdWs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=VzPMhNEx; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="VzPMhNEx" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gu5CfNLtZRXzS+mClkrGSXL7Px/goHLl4BLV18Mh0Lw=; b=VzPMhNExNUWP+FCng16dWadnLb rCCms0cjwIpnVk0fA2RHBml+ZbMaUREyrvU/mXsA7thyGkWIhYw2/YcWsWUxoJJAftljeAtEeN1Fq zcC/IUiubpcp3Flrm6jBrv9Qws+eO61JuzavWg6CVRHExbQsSDEQcF+y4WH09JWixdbZ5pBTqlH1F Ft2pjM22N1aXSic6KUSVI035S5goKprqqhEJtwjdMXxPCgwOBMaJWpin46Dny7lJa+0cRDCKgOJqC wMiwffI1ueh5dMsHcdJ2py/S0Av1ZTL32I/XLJCcJe9/2ljuwdZKr06bmb4nlkwDjA2vzmefFsh8M O4PUJV6w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:53250 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1v2nF8-000000005Ab-426O; Sun, 28 Sep 2025 09:58:55 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1v2nF8-00000007jXJ-0BUZ; Sun, 28 Sep 2025 09:58:54 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit , Florian Fainelli , Gatien Chevallier Cc: Alexandre Torgue , Andrew Lunn , Andrew Lunn , Christophe Roullier , Conor Dooley , "David S. Miller" , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Jakub Kicinski , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Rob Herring , Simon Horman , Tristram Ha Subject: [PATCH RFC net-next 1/6] net: phy: add phy_can_wakeup() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sun, 28 Sep 2025 09:58:54 +0100 Add phy_can_wakeup() to report whether the PHY driver has marked the PHY device as being wake-up capable as far as the driver model is concerned. Signed-off-by: Russell King (Oracle) --- include/linux/phy.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index b377dfaa6801..7f6758198948 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1379,6 +1379,18 @@ static inline void phy_disable_eee_mode(struct phy_d= evice *phydev, u32 link_mode linkmode_clear_bit(link_mode, phydev->advertising_eee); } =20 +/** + * phy_can_wakeup() - indicate whether PHY has driver model wakeup capabil= ities + * @phydev: The phy_device struct + * + * Returns: true/false depending on the PHY driver's device_set_wakeup_cap= able() + * setting. + */ +static inline bool phy_can_wakeup(struct phy_device *phydev) +{ + return device_can_wakeup(&phydev->mdio.dev); +} + void phy_resolve_aneg_pause(struct phy_device *phydev); void phy_resolve_aneg_linkmode(struct phy_device *phydev); =20 --=20 2.47.3 From nobody Wed Oct 1 21:27:16 2025 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBD32213236; Sun, 28 Sep 2025 08:59:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049950; cv=none; b=N+boKL/AwRfCAqbTOiCjTPN0BRkKCdzQ2FseJm8ZYcXOK65VM59Z4+TaQSS1R+K6E92C6SfPee2VEbrjnL88otY1OueMoYg+1BuolKofWy4sUnonlly7T6KMhmrjm+fcTx8OqcOFkGmsuf5fdL9s3X+qpiNZo9LUcuqA27WbSgo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049950; c=relaxed/simple; bh=sltJehwGmgNGNkXehUDxNoleo8qQh6YQJ9OKkJ9KvnM=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=TImqSQo9amtpJmj0B3AjxPnTwOBZd+EXPmXySyponrBIkMh9Alp76c4fThmwYGOFTB3cl43gcaWRTSOU1gd/LA1l4qSELQ0GrXEnq8TJ5q/nZqSNSR4fmRiGQmsOAic11/xPMycsQSzXPgr6WkRibngZApbk+uu32QK6dG1vs80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=FJSx76mj; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="FJSx76mj" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dRHUASpZNpL3VRyQX74pzizWthRGiNuqvRODSjFvKBc=; b=FJSx76mj23T79CLUxd3KbBKvJL rnM5mlqwn4ussFrt7nROV+s/Aim8RZblq2mqVDi1UlaQTZjYGycszBu0LdXKJdtARbKg7eMZsqTrs 78iUYJ9rMzgkcAkzIYk7mvbBxTfBnLirjERnvtpN2t1nc2oADPylLIXoEf7JzNGAuLLEaxNiSPrnc 5HgFlScs7M6ljpdVDEDRnHedDLeKFZL+yrD2dbU8l/GfPSwLlQidYkX1wuJFaFEpUXPj25ERXUiJ3 gfn9JXFIJE9uORGTpJaQvNEzGTsSuHZSdSJxBRbRfTmAPybyLLuPKsuofUP4ZUJOayDzuuhOVw6zq fuOzqM5Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36008 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1v2nFE-000000005Ak-27a8; Sun, 28 Sep 2025 09:59:00 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1v2nFD-00000007jXP-0fX2; Sun, 28 Sep 2025 09:58:59 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit , Florian Fainelli , Gatien Chevallier Cc: Alexandre Torgue , Andrew Lunn , Andrew Lunn , Christophe Roullier , Conor Dooley , "David S. Miller" , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Jakub Kicinski , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Rob Herring , Simon Horman , Tristram Ha Subject: [PATCH RFC net-next 2/6] net: phy: add phy_may_wakeup() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sun, 28 Sep 2025 09:58:59 +0100 Add phy_may_wakeup() which uses the driver model's device_may_wakeup() when the PHY driver has marked the device as wakeup capable in the driver model, otherwise use phy_drv_wol_enabled(). Replace the sites that used to call phy_drv_wol_enabled() with this as checking the driver model will be more efficient than checking the WoL state. Export phy_may_wakeup() so that phylink can use it. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phy_device.c | 14 ++++++++++++-- include/linux/phy.h | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 01269b865f5e..4c8df9f02eb3 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -251,6 +251,16 @@ static bool phy_drv_wol_enabled(struct phy_device *phy= dev) return wol.wolopts !=3D 0; } =20 +bool phy_may_wakeup(struct phy_device *phydev) +{ + /* If the PHY is using driver-model based wakeup, use that state. */ + if (phy_can_wakeup(phydev)) + return device_may_wakeup(&phydev->mdio.dev); + + return phy_drv_wol_enabled(phydev); +} +EXPORT_SYMBOL_GPL(phy_may_wakeup); + static void phy_link_change(struct phy_device *phydev, bool up) { struct net_device *netdev =3D phydev->attached_dev; @@ -302,7 +312,7 @@ static bool mdio_bus_phy_may_suspend(struct phy_device = *phydev) /* If the PHY on the mido bus is not attached but has WOL enabled * we cannot suspend the PHY. */ - if (!netdev && phy_drv_wol_enabled(phydev)) + if (!netdev && phy_may_wakeup(phydev)) return false; =20 /* PHY not attached? May suspend if the PHY has not already been @@ -1909,7 +1919,7 @@ int phy_suspend(struct phy_device *phydev) if (phydev->suspended || !phydrv) return 0; =20 - phydev->wol_enabled =3D phy_drv_wol_enabled(phydev) || + phydev->wol_enabled =3D phy_may_wakeup(phydev) || (netdev && netdev->ethtool->wol_enabled); /* If the device has WOL enabled, we cannot suspend the PHY */ if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND)) diff --git a/include/linux/phy.h b/include/linux/phy.h index 7f6758198948..2292ee9a93c0 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1391,6 +1391,15 @@ static inline bool phy_can_wakeup(struct phy_device = *phydev) return device_can_wakeup(&phydev->mdio.dev); } =20 +/** + * phy_may_wakeup() - indicate whether PHY has driver model wakeup is enab= led + * @phydev: The phy_device struct + * + * Returns: true/false depending on the PHY driver's device_set_wakeup_ena= bled() + * setting. + */ +bool phy_may_wakeup(struct phy_device *phydev); + void phy_resolve_aneg_pause(struct phy_device *phydev); void phy_resolve_aneg_linkmode(struct phy_device *phydev); =20 --=20 2.47.3 From nobody Wed Oct 1 21:27:16 2025 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32D252BF00A; Sun, 28 Sep 2025 08:59:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049961; cv=none; b=FM/vchsDrlSMAXLy0e7bqUo5ZEJblzHF0AQrpV1+/LnkK5WR1vjQf+7BHt3BByEyaSu/DpdN4FLQpKgYcc03JMn4nTR6+C3yxAvJ73tdNiRYjR4CVlBlpA/KmsioRDNAwF4rqAyxW2wAgcUIErXycP9NujLuV5JMADyzEU0GrMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049961; c=relaxed/simple; bh=7xTnRXG0VOxNuO0hi/wTWjNgiWGT5a1unwsIKyZI9tw=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=meP5d9HhO0cEC28Uq632ZqxSWCZ0D4Y1nhuJ9136iWyOZOueQBQ+w4Ljlv+ndpTtJ2mFcpksjLiYDoMPUyeg7elZB/3cTx63jaHcoUl320vI8e3+BZi9in1cu+13rW3plvuQCEL4QqBVcO3+RGoJlTc0KAkauDYLPSrtn58+fi0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=aHdaB0Iz; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="aHdaB0Iz" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mV9Xx0e2xiFAQKlX3WQG8ifo/vHNogs8i5Upjp7iN6U=; b=aHdaB0IzQK+eNrGguUy4O73kcv CmaePoFrti0sL3Dv+J6nXqGKjuPsvZxUlDHYCiX3Ly9x0DeDLDltjmt2EbQHk97YxibEVcekwXZn8 eAkPoWrv0ZtG82b/7WRVSLJsQO8H46L4T7FEzVrH0iQw6iqVp2HX+MEq1Fx8qSo+fXB9bBQNKD/QE 3lRLlZRwxlOYWIxShkgHLeI83HLVn5m5UXqOlXx3eVhZULpizg40WedWAbyiML8nFhEI6ojrOvnJ9 L79gR3bA5G93Qg3E8smKShafWqFF83wy7CyaKLTtxsadJnKrSTYciwyksa1VdXAS6LjriXtG6z9O6 xKjhWK7w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36018 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1v2nFJ-000000005Ay-1nKn; Sun, 28 Sep 2025 09:59:06 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1v2nFI-00000007jXV-1BYa; Sun, 28 Sep 2025 09:59:04 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit , Florian Fainelli , Gatien Chevallier Cc: Alexandre Torgue , Andrew Lunn , Andrew Lunn , Christophe Roullier , Conor Dooley , "David S. Miller" , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Jakub Kicinski , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Rob Herring , Simon Horman , Tristram Ha Subject: [PATCH RFC net-next 3/6] net: phylink: add phylink managed MAC Wake-on-Lan support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sun, 28 Sep 2025 09:59:04 +0100 Add core phylink Wake-on-Lan support. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 77 +++++++++++++++++++++++++++++++++++++-- include/linux/phylink.h | 26 +++++++++++++ 2 files changed, 99 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 9d7799ea1c17..9a3783e719bc 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -93,6 +93,9 @@ struct phylink { u8 sfp_port; =20 struct eee_config eee_cfg; + + u32 wolopts_mac; + u8 wol_sopass[SOPASS_MAX]; }; =20 #define phylink_printk(level, pl, fmt, ...) \ @@ -2575,11 +2578,17 @@ EXPORT_SYMBOL_GPL(phylink_rx_clk_stop_unblock); * can also bring down the link between the MAC and PHY. * - If Wake-on-Lan is active, but being handled by the MAC, the MAC * still needs to receive packets, so we can not bring the link down. + * + * Note: when phylink managed Wake-on-Lan is in use, @mac_wol is ignored. + * (struct phylink_mac_ops.mac_set_wol populated.) */ void phylink_suspend(struct phylink *pl, bool mac_wol) { ASSERT_RTNL(); =20 + if (phylink_mac_supports_wol(pl)) + mac_wol =3D !!pl->wolopts_mac; + if (mac_wol && (!pl->netdev || pl->netdev->ethtool->wol_enabled)) { /* Wake-on-Lan enabled, MAC handling */ mutex_lock(&pl->state_mutex); @@ -2673,6 +2682,17 @@ void phylink_resume(struct phylink *pl) } EXPORT_SYMBOL_GPL(phylink_resume); =20 +static bool phylink_mac_supports_wol(struct phylink *pl) +{ + return !!pl->mac_ops->mac_wol_set; +} + +static bool phylink_phy_supports_wol(struct phylink *pl, + struct phy_device *phydev) +{ + return phydev && (pl->config->wol_phy_legacy || phy_can_wakeup(phydev)); +} + /** * phylink_ethtool_get_wol() - get the wake on lan parameters for the PHY * @pl: a pointer to a &struct phylink returned from phylink_create() @@ -2689,8 +2709,21 @@ void phylink_ethtool_get_wol(struct phylink *pl, str= uct ethtool_wolinfo *wol) wol->supported =3D 0; wol->wolopts =3D 0; =20 - if (pl->phydev) - phy_ethtool_get_wol(pl->phydev, wol); + if (phylink_mac_supports_wol(pl)) { + if (phylink_phy_supports_wol(pl, pl->phydev)) + phy_ethtool_get_wol(pl->phydev, wol); + + /* Where the MAC augments the WoL support, merge its support and + * current configuration. + */ + wol->supported |=3D pl->config->wol_mac_support; + wol->wolopts |=3D pl->wolopts_mac; + memcpy(wol->sopass, pl->wol_sopass, sizeof(wol->sopass)); + } else { + /* Legacy */ + if (pl->phydev) + phy_ethtool_get_wol(pl->phydev, wol); + } } EXPORT_SYMBOL_GPL(phylink_ethtool_get_wol); =20 @@ -2707,12 +2740,48 @@ EXPORT_SYMBOL_GPL(phylink_ethtool_get_wol); */ int phylink_ethtool_set_wol(struct phylink *pl, struct ethtool_wolinfo *wo= l) { + struct ethtool_wolinfo w; int ret =3D -EOPNOTSUPP; + bool changed; + u32 wolopts; =20 ASSERT_RTNL(); =20 - if (pl->phydev) - ret =3D phy_ethtool_set_wol(pl->phydev, wol); + if (phylink_mac_supports_wol(pl)) { + wolopts =3D wol->wolopts; + + if (phylink_phy_supports_wol(pl, pl->phydev)) { + ret =3D phy_ethtool_set_wol(pl->phydev, wol); + if (ret !=3D 0 && ret !=3D -EOPNOTSUPP) + return ret; + + phy_ethtool_get_wol(pl->phydev, &w); + + /* Any Wake-on-Lan modes which the PHY is handling + * should not be passed on to the MAC. + */ + wolopts &=3D ~w.wolopts; + } + + wolopts &=3D pl->config->wol_mac_support; + changed =3D pl->wolopts_mac !=3D wolopts; + if (wolopts & WAKE_MAGICSECURE) + changed |=3D !!memcmp(wol->sopass, pl->wol_sopass, + sizeof(wol->sopass)); + memcpy(pl->wol_sopass, wol->sopass, sizeof(pl->wol_sopass)); + + if (changed) { + ret =3D pl->mac_ops->mac_wol_set(pl->config, wolopts, + wol->sopass); + if (!ret) + pl->wolopts_mac =3D wolopts; + } else { + ret =3D 0; + } + } else { + if (pl->phydev) + ret =3D phy_ethtool_set_wol(pl->phydev, wol); + } =20 return ret; } diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 9af0411761d7..59cb58b29d1d 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -156,6 +156,8 @@ enum phylink_op_type { * @lpi_capabilities: MAC speeds which can support LPI signalling * @lpi_timer_default: Default EEE LPI timer setting. * @eee_enabled_default: If set, EEE will be enabled by phylink at creatio= n time + * @wol_phy_legacy: Use Wake-on-Lan with PHY even if phy_can_wakeup() is f= alse + * @wol_mac_support: Bitmask of MAC supported %WAKE_* options */ struct phylink_config { struct device *dev; @@ -173,6 +175,10 @@ struct phylink_config { unsigned long lpi_capabilities; u32 lpi_timer_default; bool eee_enabled_default; + + /* Wake-on-Lan support */ + bool wol_phy_legacy; + u32 wol_mac_support; }; =20 void phylink_limit_mac_speed(struct phylink_config *config, u32 max_speed); @@ -188,6 +194,7 @@ void phylink_limit_mac_speed(struct phylink_config *con= fig, u32 max_speed); * @mac_link_up: allow the link to come up. * @mac_disable_tx_lpi: disable LPI. * @mac_enable_tx_lpi: enable and configure LPI. + * @mac_wol_set: configure Wake-on-Lan settings at the MAC. * * The individual methods are described more fully below. */ @@ -211,6 +218,9 @@ struct phylink_mac_ops { void (*mac_disable_tx_lpi)(struct phylink_config *config); int (*mac_enable_tx_lpi)(struct phylink_config *config, u32 timer, bool tx_clk_stop); + + int (*mac_wol_set)(struct phylink_config *config, u32 wolopts, + const u8 *sopass); }; =20 #if 0 /* For kernel-doc purposes only. */ @@ -440,6 +450,22 @@ void mac_disable_tx_lpi(struct phylink_config *config); */ int mac_enable_tx_lpi(struct phylink_config *config, u32 timer, bool tx_clk_stop); + +/** + * mac_wol_set() - configure the Wake-on-Lan parameters + * @config: a pointer to a &struct phylink_config. + * @wolopts: Bitmask of %WAKE_* flags for enabled Wake-On-Lan modes. + * @sopass: SecureOn(tm) password; meaningful only for %WAKE_MAGICSECURE + * + * Enable the specified Wake-on-Lan options at the MAC. Options that the + * PHY can handle will have been removed from @wolopts. + * + * The presence of this method enables phylink-managed WoL support. + * + * Returns: 0 on success. + */ +int (*mac_wol_set)(struct phylink_config *config, u32 wolopts, + const u8 *sopass); #endif =20 struct phylink_pcs_ops; --=20 2.47.3 From nobody Wed Oct 1 21:27:16 2025 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 705522C0274; Sun, 28 Sep 2025 08:59:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049968; cv=none; b=o15ydPOPS9K8X7qS8n0TndolI+hfkbgh9T47nSqtpymmIJ37w9Hv8txupLBdabB+Lk27fO8LGasV2wkctR/w6iyWcaYzcv1qVTe9MYW1znht3KsaQ6dDxV5fb7p/AmJT0i+hbjgh/MTYMoWlAz4ql36SMmJNRrltLnQtzFWoOx8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049968; c=relaxed/simple; bh=k8HXsKN2I6Age9nGtZCWSwvJPLDOE9OIXSz0/tiDLhc=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=MZX+bji3COUPiTMOugAse/rhESJT+rWOYrlEvIulCyP9t79dRd3Ghyn+EmvWZ++vPjoyJ1RwjVVxG/kCZBheHxZF8usMriqV8c+gbA8Y31OmvSXK7IVqoo78V+69sk1k9UniYUBprf66+uJ5gBwA8aZkxpt2nc52JVd7ufEiceI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=haAs3jFs; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="haAs3jFs" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2YaJLzurlCfXcfc8Px72NgfNrq2XZEVc2OMspglX/3M=; b=haAs3jFsBNvXmRoBLY8HGisP5R NzxlqpB2TVCJ4Rlqr2c5ATKDVebzg1S6dMWLmF9+2LNwXqT+pCUonHnC7Ksv4/zszou4V4aB7WPAM tbTSRMuKYkwMBEstIH7xzbEqbay7pNroe+gMLBPKS8oAhfWK8RZ6hDGToobRCWtsJbiYVU8fXXBfX 1grsVfazI5iPjTI4G0vq7DeGEAi9XamSLvrEX94zk/XwAP9Jegg9E37sA4kRsMEFiv3IW60gnV7TW sw3Trj91Z4VzlZJyC2qQgrHWTjXdfuo6N8qr0x5oe5CLq96GIrQG29i5nVbhPar+zifAyDL1BaoEM wnljmbjg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:54426 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1v2nFO-000000005BG-2e4q; Sun, 28 Sep 2025 09:59:10 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1v2nFN-00000007jXb-1kj0; Sun, 28 Sep 2025 09:59:09 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit , Florian Fainelli , Gatien Chevallier Cc: Alexandre Torgue , Andrew Lunn , Andrew Lunn , Christophe Roullier , Conor Dooley , "David S. Miller" , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Jakub Kicinski , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Rob Herring , Simon Horman , Tristram Ha Subject: [PATCH RFC net-next 4/6] net: phylink: add phylink managed wake-on-lan PHY speed control Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sun, 28 Sep 2025 09:59:09 +0100 Some drivers, e.g. stmmac, use the speed_up()/speed_down() APIs to gain additional power saving during Wake-on-LAN where the PHY is managing the state. Add support to phylink for this, which can be enabled by the MAC driver. Only change the PHY speed if the PHY is configured for wake-up, but without any wake-up on the MAC side, as MAC side means changing the configuration once the negotiation has completed. Signed-off-by: Russell King (Oracle) --- drivers/net/phy/phylink.c | 12 ++++++++++++ include/linux/phylink.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 9a3783e719bc..3e48b0319634 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -2565,6 +2565,12 @@ void phylink_rx_clk_stop_unblock(struct phylink *pl) } EXPORT_SYMBOL_GPL(phylink_rx_clk_stop_unblock); =20 +static bool phylink_phy_pm_speed_ctrl(struct phylink *pl) +{ + return pl->config->wol_phy_speed_ctrl && !pl->wolopts_mac && + pl->phydev && phy_may_wakeup(pl->phydev); +} + /** * phylink_suspend() - handle a network device suspend event * @pl: a pointer to a &struct phylink returned from phylink_create() @@ -2614,6 +2620,9 @@ void phylink_suspend(struct phylink *pl, bool mac_wol) } else { phylink_stop(pl); } + + if (phylink_phy_pm_speed_ctrl(pl)) + phy_speed_down(pl->phydev, false); } EXPORT_SYMBOL_GPL(phylink_suspend); =20 @@ -2653,6 +2662,9 @@ void phylink_resume(struct phylink *pl) { ASSERT_RTNL(); =20 + if (phylink_phy_pm_speed_ctrl(pl)) + phy_speed_up(pl->phydev); + if (test_bit(PHYLINK_DISABLE_MAC_WOL, &pl->phylink_disable_state)) { /* Wake-on-Lan enabled, MAC handling */ =20 diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 59cb58b29d1d..38363e566ac3 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -157,6 +157,7 @@ enum phylink_op_type { * @lpi_timer_default: Default EEE LPI timer setting. * @eee_enabled_default: If set, EEE will be enabled by phylink at creatio= n time * @wol_phy_legacy: Use Wake-on-Lan with PHY even if phy_can_wakeup() is f= alse + * @wol_phy_speed_ctrl: Use phy speed control on suspend/resume * @wol_mac_support: Bitmask of MAC supported %WAKE_* options */ struct phylink_config { @@ -178,6 +179,7 @@ struct phylink_config { =20 /* Wake-on-Lan support */ bool wol_phy_legacy; + bool wol_phy_speed_ctrl; u32 wol_mac_support; }; =20 --=20 2.47.3 From nobody Wed Oct 1 21:27:16 2025 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 893CC2C0F64; Sun, 28 Sep 2025 08:59:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049971; cv=none; b=jg10W53kmIwJkyIFJiEDUznCB3E2dpL8yE6G7mJ20a/8nlUbVGnH4LJlXGW4l8iTQ/8QJbwSMLemD+5KmwaVFG3zfaAfKWRUMrdQKNR9LxEGAWs7UjTYY5XPRX70sU9ZeDvlX/y6NSZWgBJbVob2RBTBEzfcTR8c3jN/qSu8j7M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049971; c=relaxed/simple; bh=i1YOrtz3EopWLqXHOIZ06/rvP2jym7d3/PsSNaIgZ1M=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=csingBee0Tl2MVIWPz9jFwFB35VuzJzaoBs8p+V1cWaUCorC/HBF5scgtiF7Jxrnz/JupLh3nXGXCdtiSQEDJnVFJD9m6iJEd+obod1RGjBHggrLN7y6oSKDyB/A5H0DxO8kI+6jOAYTIC6KJ99t3OOg1TNUMBaJsY35jD2uuok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=sC/Ewk15; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="sC/Ewk15" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=C4UQo3+08xrxFnLlCDCPAotpduzq+WH7VjrKUHG4XAA=; b=sC/Ewk15B8wkmRqbgbzNxY56xo H29uXyjVQKt6LjnTJm7zJTTIOqvSwd7I7mnMmonXATPWvgkjsR6jQXbMtQbnBnJWtJFcL/JVAWWnN 5JsdPAIlo+1O4b1bHFNzDpzcb1jTYlUONVEpj7uNiGNvkKuYcBPQx0FUA4TKAa6E54+608nnWaaGg zii/1VndDKctk9dIFDUwVtPd3a1abjNQFOId1s0K3pBHWACWaoJhJ3jX8hGb9Pve6MhPl0Nxnv2Tu TipsyohMqB1XtdXBDo3DwvYM7dGE62aoVwvq/64CD67CAnY0k9NtjLHj5baMn0tR5amsU2m/kQ5sV pejCINrQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:54438 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1v2nFV-000000005BW-3bml; Sun, 28 Sep 2025 09:59:18 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1v2nFS-00000007jXh-2HC2; Sun, 28 Sep 2025 09:59:14 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit , Florian Fainelli , Gatien Chevallier Cc: Alexandre Torgue , Andrew Lunn , Andrew Lunn , Christophe Roullier , Conor Dooley , "David S. Miller" , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Jakub Kicinski , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Rob Herring , Simon Horman , Tristram Ha Subject: [PATCH RFC net-next 5/6] net: stmmac: convert to phylink-managed Wake-on-Lan Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sun, 28 Sep 2025 09:59:14 +0100 Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 6 +--- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 34 ++++--------------- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 30 ++++++++++++++-- .../ethernet/stmicro/stmmac/stmmac_platform.c | 4 +-- 4 files changed, 36 insertions(+), 38 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/eth= ernet/stmicro/stmmac/stmmac.h index 7ca5477be390..db4f82672d9a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -287,6 +287,7 @@ struct stmmac_priv { int hw_cap_support; int synopsys_id; u32 msg_enable; + /* Our MAC Wake-on-Lan options */ int wolopts; int wol_irq; u32 gmii_address_bus_config; @@ -375,11 +376,6 @@ enum stmmac_state { =20 extern const struct dev_pm_ops stmmac_simple_pm_ops; =20 -static inline bool stmmac_wol_enabled_mac(struct stmmac_priv *priv) -{ - return priv->plat->pmt && device_may_wakeup(priv->device); -} - static inline bool stmmac_wol_enabled_phy(struct stmmac_priv *priv) { return !priv->plat->pmt && device_may_wakeup(priv->device); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers= /net/ethernet/stmicro/stmmac/stmmac_ethtool.c index 39fa1ec92f82..fd29b551a082 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -787,41 +787,19 @@ static void stmmac_get_wol(struct net_device *dev, st= ruct ethtool_wolinfo *wol) { struct stmmac_priv *priv =3D netdev_priv(dev); =20 - if (!priv->plat->pmt) - return phylink_ethtool_get_wol(priv->phylink, wol); - - mutex_lock(&priv->lock); - if (device_can_wakeup(priv->device)) { - wol->supported =3D WAKE_MAGIC | WAKE_UCAST; - if (priv->hw_cap_support && !priv->dma_cap.pmt_magic_frame) - wol->supported &=3D ~WAKE_MAGIC; - wol->wolopts =3D priv->wolopts; - } - mutex_unlock(&priv->lock); + return phylink_ethtool_get_wol(priv->phylink, wol); } =20 static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *= wol) { struct stmmac_priv *priv =3D netdev_priv(dev); + int ret; =20 - if (!device_can_wakeup(priv->device)) - return -EOPNOTSUPP; - - if (!priv->plat->pmt) { - int ret =3D phylink_ethtool_set_wol(priv->phylink, wol); - - if (!ret) - device_set_wakeup_enable(priv->device, !!wol->wolopts); - return ret; - } - - device_set_wakeup_enable(priv->device, !!wol->wolopts); + ret =3D phylink_ethtool_set_wol(priv->phylink, wol); + if (!ret) + device_set_wakeup_enable(priv->device, !!wol->wolopts); =20 - mutex_lock(&priv->lock); - priv->wolopts =3D wol->wolopts; - mutex_unlock(&priv->lock); - - return 0; + return ret; } =20 static int stmmac_ethtool_op_get_eee(struct net_device *dev, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index cdc092e2ed9b..abe88b74239a 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1065,6 +1065,20 @@ static int stmmac_mac_enable_tx_lpi(struct phylink_c= onfig *config, u32 timer, return 0; } =20 +static int stmmac_mac_wol_set(struct phylink_config *config, u32 wolopts, + const u8 *sopass) +{ + struct stmmac_priv *priv =3D netdev_priv(to_net_dev(config->dev)); + + device_set_wakeup_enable(priv->device, !!wolopts); + + mutex_lock(&priv->lock); + priv->wolopts =3D wolopts; + mutex_unlock(&priv->lock); + + return 0; +} + static const struct phylink_mac_ops stmmac_phylink_mac_ops =3D { .mac_get_caps =3D stmmac_mac_get_caps, .mac_select_pcs =3D stmmac_mac_select_pcs, @@ -1074,6 +1088,7 @@ static const struct phylink_mac_ops stmmac_phylink_ma= c_ops =3D { .mac_link_up =3D stmmac_mac_link_up, .mac_disable_tx_lpi =3D stmmac_mac_disable_tx_lpi, .mac_enable_tx_lpi =3D stmmac_mac_enable_tx_lpi, + .mac_wol_set =3D stmmac_mac_wol_set, }; =20 /** @@ -1250,6 +1265,15 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) config->eee_enabled_default =3D true; } =20 + if (priv->plat->flags & STMMAC_FLAG_USE_PHY_WOL) { + config->wol_phy_legacy =3D true; + } else { + if (priv->dma_cap.pmt_remote_wake_up) + config->wol_mac_support |=3D WAKE_UCAST; + if (priv->dma_cap.pmt_magic_frame) + config->wol_mac_support |=3D WAKE_MAGIC; + } + fwnode =3D priv->plat->port_node; if (!fwnode) fwnode =3D dev_fwnode(priv->device); @@ -7760,7 +7784,7 @@ int stmmac_suspend(struct device *dev) priv->plat->serdes_powerdown(ndev, priv->plat->bsp_priv); =20 /* Enable Power down mode by programming the PMT regs */ - if (stmmac_wol_enabled_mac(priv)) { + if (priv->wolopts) { stmmac_pmt(priv, priv->hw, priv->wolopts); priv->irq_wake =3D 1; } else { @@ -7774,7 +7798,7 @@ int stmmac_suspend(struct device *dev) if (stmmac_wol_enabled_phy(priv)) phylink_speed_down(priv->phylink, false); =20 - phylink_suspend(priv->phylink, stmmac_wol_enabled_mac(priv)); + phylink_suspend(priv->phylink, !!priv->wolopts); rtnl_unlock(); =20 if (stmmac_fpe_supported(priv)) @@ -7850,7 +7874,7 @@ int stmmac_resume(struct device *dev) * this bit because it can generate problems while resuming * from another devices (e.g. serial console). */ - if (stmmac_wol_enabled_mac(priv)) { + if (priv->wolopts) { mutex_lock(&priv->lock); stmmac_pmt(priv, priv->hw, 0); mutex_unlock(&priv->lock); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/driver= s/net/ethernet/stmicro/stmmac/stmmac_platform.c index 27bcaae07a7f..ed38925eb6f6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -970,7 +970,7 @@ static int __maybe_unused stmmac_pltfr_noirq_suspend(st= ruct device *dev) if (!netif_running(ndev)) return 0; =20 - if (!stmmac_wol_enabled_mac(priv)) { + if (!priv->wolopts) { /* Disable clock in case of PWM is off */ clk_disable_unprepare(priv->plat->clk_ptp_ref); =20 @@ -991,7 +991,7 @@ static int __maybe_unused stmmac_pltfr_noirq_resume(str= uct device *dev) if (!netif_running(ndev)) return 0; =20 - if (!stmmac_wol_enabled_mac(priv)) { + if (!priv->wolopts) { /* enable the clk previously disabled */ ret =3D pm_runtime_force_resume(dev); if (ret) --=20 2.47.3 From nobody Wed Oct 1 21:27:16 2025 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5CC32BEFF8; Sun, 28 Sep 2025 08:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049979; cv=none; b=vBIK5tdYR3dqbWB5KKpGQuPeDstoK25gvVcbvQWkzh4GnHthYADzSUL4Q2IOs+0Bex70iP3lMZ17A+BeB406IXes7QyODufBGVxc0L7aXcZZVHihyi89klt3RiV4KF8OP68X1scG/brygjAQvg24jTvbFuyA/GUAVi9v3vX0z+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759049979; c=relaxed/simple; bh=4vniLi8C9goigp8i7K2za5WqcBRykgM+uRE16WVj3ZY=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=CPL6ijtFrLIh9i2F9CLdmHg195Dr4LC5h2RvvifoQkbqzj5GvhQSYTvFs/UPyo5p/3qXxD1nIGpwJ8KCmgoU1E8q7iMYxmLQ/yEqDTdt4Z9JUs9JMPvq2k+7FhduVSmkTgGky4PqV9xgSSFJ5P0hdbsuoqa0nLSa+BjYUuKF7NA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=DqgYUnER; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="DqgYUnER" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=g1oVnAqIRynEdvtoz62JGVAuoit/j3pFYMM2fpFBQec=; b=DqgYUnERY07W98n11vJicdqk2c go4P3eNuR4PhwpX9UriGbqN914adWhCxKX1xklzqxcuTc4WmC5k02LkVbwLSVp54/6p8645fclIJn vueeOYLqex3ojNdfYWAuFARcfeBNOWUVCfQLP6Q2RSygJEgzcmt3+9I5f+SfaroLxbOhYpFRqa4i7 wpGNXMxzMSWFf3888PzzEy89aR38G61KzonQZNpJ/aIXPbJO+M47tOWIvUPRUyLG1o8CPZhZKvjga Sg74MoNL7UDBbccqR6Xv+4k7MPU3ZshqYrn3D7T8YbGTE7ovXzAYVZ1IntRvaAC2zvvbmiGXor5cC kTqK31iA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:40264 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1v2nFd-000000005Bv-3hCj; Sun, 28 Sep 2025 09:59:26 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1v2nFX-00000007jXn-2pUD; Sun, 28 Sep 2025 09:59:19 +0100 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit , Florian Fainelli , Gatien Chevallier Cc: Alexandre Torgue , Andrew Lunn , Andrew Lunn , Christophe Roullier , Conor Dooley , "David S. Miller" , devicetree@vger.kernel.org, Eric Dumazet , Heiner Kallweit , Jakub Kicinski , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Maxime Coquelin , netdev@vger.kernel.org, Paolo Abeni , Rob Herring , Simon Horman , Tristram Ha Subject: [PATCH RFC net-next 6/6] net: stmmac: convert to phylink managed WoL PHY speed Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Sun, 28 Sep 2025 09:59:19 +0100 Convert stmmac to use phylink's management of the PHY speed when Wake-on-Lan is enabled. Signed-off-by: Russell King (Oracle) --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 5 ----- .../net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 7 +------ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 +-------------- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/eth= ernet/stmicro/stmmac/stmmac.h index db4f82672d9a..d10da13ad645 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -376,11 +376,6 @@ enum stmmac_state { =20 extern const struct dev_pm_ops stmmac_simple_pm_ops; =20 -static inline bool stmmac_wol_enabled_phy(struct stmmac_priv *priv) -{ - return !priv->plat->pmt && device_may_wakeup(priv->device); -} - int stmmac_mdio_unregister(struct net_device *ndev); int stmmac_mdio_register(struct net_device *ndev); int stmmac_mdio_reset(struct mii_bus *mii); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers= /net/ethernet/stmicro/stmmac/stmmac_ethtool.c index fd29b551a082..7ab736de308f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c @@ -793,13 +793,8 @@ static void stmmac_get_wol(struct net_device *dev, str= uct ethtool_wolinfo *wol) static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *= wol) { struct stmmac_priv *priv =3D netdev_priv(dev); - int ret; =20 - ret =3D phylink_ethtool_set_wol(priv->phylink, wol); - if (!ret) - device_set_wakeup_enable(priv->device, !!wol->wolopts); - - return ret; + return phylink_ethtool_set_wol(priv->phylink, wol); } =20 static int stmmac_ethtool_op_get_eee(struct net_device *dev, diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/ne= t/ethernet/stmicro/stmmac/stmmac_main.c index abe88b74239a..7b4f0c54b9ec 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1189,14 +1189,6 @@ static int stmmac_init_phy(struct net_device *dev) phylink_ethtool_set_eee(priv->phylink, &eee); } =20 - if (!priv->plat->pmt) { - struct ethtool_wolinfo wol =3D { .cmd =3D ETHTOOL_GWOL }; - - phylink_ethtool_get_wol(priv->phylink, &wol); - device_set_wakeup_capable(priv->device, !!wol.supported); - device_set_wakeup_enable(priv->device, !!wol.wolopts); - } - return 0; } =20 @@ -1265,6 +1257,7 @@ static int stmmac_phy_setup(struct stmmac_priv *priv) config->eee_enabled_default =3D true; } =20 + config->wol_phy_speed_ctrl =3D true; if (priv->plat->flags & STMMAC_FLAG_USE_PHY_WOL) { config->wol_phy_legacy =3D true; } else { @@ -7795,9 +7788,6 @@ int stmmac_suspend(struct device *dev) mutex_unlock(&priv->lock); =20 rtnl_lock(); - if (stmmac_wol_enabled_phy(priv)) - phylink_speed_down(priv->phylink, false); - phylink_suspend(priv->phylink, !!priv->wolopts); rtnl_unlock(); =20 @@ -7936,9 +7926,6 @@ int stmmac_resume(struct device *dev) * workqueue thread, which will race with initialisation. */ phylink_resume(priv->phylink); - if (stmmac_wol_enabled_phy(priv)) - phylink_speed_up(priv->phylink); - rtnl_unlock(); =20 netif_device_attach(ndev); --=20 2.47.3