From nobody Wed Oct 1 22:26:33 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