From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: davem@davemloft.net, Andrew Lunn <andrew@lunn.ch>,
Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Russell King <linux@armlinux.org.uk>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Heiner Kallweit <hkallweit1@gmail.com>
Cc: "Maxime Chevallier" <maxime.chevallier@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
thomas.petazzoni@bootlin.com, "Simon Horman" <horms@kernel.org>,
"Herve Codina" <herve.codina@bootlin.com>,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH net-next v3 04/10] net: freescale: ucc_geth: Fix WOL configuration
Date: Tue, 3 Dec 2024 13:43:15 +0100 [thread overview]
Message-ID: <20241203124323.155866-5-maxime.chevallier@bootlin.com> (raw)
In-Reply-To: <20241203124323.155866-1-maxime.chevallier@bootlin.com>
The get/set_wol ethtool ops rely on querying the PHY for its WoL
capabilities, checking for the presence of a PHY and a PHY interrupts
isn't enough. Address that by cleaning up the WoL configuration
sequence.
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
V3: No changes
drivers/net/ethernet/freescale/ucc_geth.c | 4 +--
drivers/net/ethernet/freescale/ucc_geth.h | 1 +
.../net/ethernet/freescale/ucc_geth_ethtool.c | 36 +++++++++++++++----
3 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index cc5f9ca42a78..587bcbc079da 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3413,11 +3413,11 @@ static int ucc_geth_suspend(struct platform_device *ofdev, pm_message_t state)
*/
ugeth_disable(ugeth, COMM_DIR_RX_AND_TX);
- if (ugeth->wol_en & WAKE_MAGIC) {
+ if (ugeth->wol_en & WAKE_MAGIC && !ugeth->phy_wol_en) {
setbits32(ugeth->uccf->p_uccm, UCC_GETH_UCCE_MPD);
setbits32(&ugeth->ug_regs->maccfg2, MACCFG2_MPE);
ucc_fast_enable(ugeth->uccf, COMM_DIR_RX_AND_TX);
- } else if (!(ugeth->wol_en & WAKE_PHY)) {
+ } else if (!ugeth->phy_wol_en) {
phy_stop(ndev->phydev);
}
diff --git a/drivers/net/ethernet/freescale/ucc_geth.h b/drivers/net/ethernet/freescale/ucc_geth.h
index c08a56b7c9fe..e08cfc8d8904 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.h
+++ b/drivers/net/ethernet/freescale/ucc_geth.h
@@ -1217,6 +1217,7 @@ struct ucc_geth_private {
int oldduplex;
int oldlink;
int wol_en;
+ u32 phy_wol_en;
struct device_node *node;
};
diff --git a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c b/drivers/net/ethernet/freescale/ucc_geth_ethtool.c
index fb5254d7d1ba..89b323ef8145 100644
--- a/drivers/net/ethernet/freescale/ucc_geth_ethtool.c
+++ b/drivers/net/ethernet/freescale/ucc_geth_ethtool.c
@@ -346,26 +346,48 @@ static void uec_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
struct ucc_geth_private *ugeth = netdev_priv(netdev);
struct phy_device *phydev = netdev->phydev;
- if (phydev && phydev->irq)
- wol->supported |= WAKE_PHY;
+ wol->supported = 0;
+ wol->wolopts = 0;
+
+ if (phydev)
+ phy_ethtool_get_wol(phydev, wol);
+
if (qe_alive_during_sleep())
wol->supported |= WAKE_MAGIC;
- wol->wolopts = ugeth->wol_en;
+ wol->wolopts |= ugeth->wol_en;
}
static int uec_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
{
struct ucc_geth_private *ugeth = netdev_priv(netdev);
struct phy_device *phydev = netdev->phydev;
+ int ret = 0;
- if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC))
- return -EINVAL;
- else if (wol->wolopts & WAKE_PHY && (!phydev || !phydev->irq))
+ if (phydev) {
+ ret = phy_ethtool_set_wol(phydev, wol);
+ if (ret == -EOPNOTSUPP) {
+ ugeth->phy_wol_en = 0;
+ } else if (ret) {
+ return ret;
+ } else {
+ ugeth->phy_wol_en = wol->wolopts;
+ goto out;
+ }
+ }
+
+ /* If the PHY isn't handling the WoL and the MAC is asked to more than
+ * WAKE_MAGIC, error-out
+ */
+ if (!ugeth->phy_wol_en &&
+ wol->wolopts & ~WAKE_MAGIC)
return -EINVAL;
- else if (wol->wolopts & WAKE_MAGIC && !qe_alive_during_sleep())
+
+ if (wol->wolopts & WAKE_MAGIC &&
+ !qe_alive_during_sleep())
return -EINVAL;
+out:
ugeth->wol_en = wol->wolopts;
device_set_wakeup_enable(&netdev->dev, ugeth->wol_en);
--
2.47.0
next prev parent reply other threads:[~2024-12-03 12:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 12:43 [PATCH net-next v3 00/10] net: freescale: ucc_geth: Phylink conversion Maxime Chevallier
2024-12-03 12:43 ` [PATCH net-next v3 01/10] net: freescale: ucc_geth: Drop support for the "interface" DT property Maxime Chevallier
2024-12-03 12:43 ` [PATCH net-next v3 02/10] net: freescale: ucc_geth: split adjust_link for phylink conversion Maxime Chevallier
2024-12-03 12:43 ` [PATCH net-next v3 03/10] net: freescale: ucc_geth: Use netdev->phydev to access the PHY Maxime Chevallier
2024-12-03 12:43 ` Maxime Chevallier [this message]
2024-12-04 1:58 ` [PATCH net-next v3 04/10] net: freescale: ucc_geth: Fix WOL configuration Andrew Lunn
2024-12-03 12:43 ` [PATCH net-next v3 05/10] net: freescale: ucc_geth: Use the correct type to store WoL opts Maxime Chevallier
2024-12-04 1:59 ` Andrew Lunn
2024-12-03 12:43 ` [PATCH net-next v3 06/10] net: freescale: ucc_geth: Simplify frame length check Maxime Chevallier
2024-12-03 12:43 ` [PATCH net-next v3 07/10] net: freescale: ucc_geth: Hardcode the preamble length to 7 bytes Maxime Chevallier
2024-12-03 12:43 ` [PATCH net-next v3 08/10] net: freescale: ucc_geth: Move the serdes configuration around Maxime Chevallier
2024-12-04 2:12 ` Andrew Lunn
2024-12-03 12:43 ` [PATCH net-next v3 09/10] net: freescale: ucc_geth: Introduce a helper to check Reduced modes Maxime Chevallier
2024-12-04 2:15 ` Andrew Lunn
2024-12-04 8:22 ` Maxime Chevallier
2024-12-04 15:41 ` Andrew Lunn
2024-12-05 7:32 ` Maxime Chevallier
2024-12-03 12:43 ` [PATCH net-next v3 10/10] net: freescale: ucc_geth: phylink conversion Maxime Chevallier
2024-12-06 13:50 ` [PATCH net-next v3 00/10] net: freescale: ucc_geth: Phylink conversion patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241203124323.155866-5-maxime.chevallier@bootlin.com \
--to=maxime.chevallier@bootlin.com \
--cc=andrew@lunn.ch \
--cc=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herve.codina@bootlin.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=u.kleine-koenig@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.