From: Wentao Guan <guanwentao@uniontech.com>
To: pabeni@redhat.com, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, guanwentao@uniontech.com
Subject: [RFC v2 net] net: phy: fix may not suspend when phy has WoL
Date: Tue, 27 Aug 2024 17:24:46 +0800 [thread overview]
Message-ID: <20240827092446.7948-1-guanwentao@uniontech.com> (raw)
When system suspend, and mdio_bus_phy goes to suspend,
if the phy enabled wol, phy_suspend will returned -EBUSY,
and break system suspend.
93f41e67(net: phy: fix WoL handling when suspending the PHY)
Fix the case when netdev->wol_enabled=1, but some case,
netdev->wol_enabled=0 and phydev set wol_enabled enabled,
so check phydev->wol_enabled.
I dont know why
481b5d93(net: phy: provide phy_resume/phy_suspend helpers)
think that it should return -EBUSY when WoL.
I met the case when use some out of tree ethernet driver or
phy driver.
Log:
YT8531S Gigabit Ethernet phytmac_mii_bus-PHYT0046:00:07: PM: dpm_run_callback(): mdio_bus_phy_suspend+0x0/0x10c returns -16
YT8531S Gigabit Ethernet phytmac_mii_bus-PHYT0046:00:07: PM: failed to suspend: error -16
PM: Some devices failed to suspend, or early wake event detected
YT8531S Gigabit Ethernet phytmac_mii_bus-PHYT0046:00:07: PM: dpm_run_callback(): mdio_bus_phy_suspend+0x0/0x10c returns -16
YT8531S Gigabit Ethernet phytmac_mii_bus-PHYT0046:00:07: PM: failed to suspend: error -16
PM: Some devices failed to suspend, or early wake event detected
YT8531S Gigabit Ethernet phytmac_mii_bus-PHYT0046:00:07: PM: dpm_run_callback(): mdio_bus_phy_suspend+0x0/0x10c returns -16
YT8531S Gigabit Ethernet phytmac_mii_bus-PHYT0046:00:07: PM: failed to freeze: error -16
v2: change warning message and fix build error.
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
---
drivers/net/phy/phy_device.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 7752e9386b40..c984f91a2c0c 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -299,6 +299,18 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
if (netdev->ethtool->wol_enabled)
return false;
+ /* Ethernet and phy device wol state may not same, netdev->wol_enabled
+ * disabled,and phydev set wol_enabled enabled, so netdev->wol_enabled
+ * is not enough, so check phydev->wol_enabled.
+ */
+ struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
+
+ phy_ethtool_get_wol(phydev, &wol);
+ if (wol.wolopts) {
+ phydev_warn(phydev, "Phy and mac wol are not compatible\n");
+ return false;
+ }
+
/* As long as not all affected network drivers support the
* wol_enabled flag, let's check for hints that WoL is enabled.
* Don't suspend PHY if the attached netdev parent may wake up.
--
2.20.1
reply other threads:[~2024-08-27 9:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240827092446.7948-1-guanwentao@uniontech.com \
--to=guanwentao@uniontech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®