Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: phy: fix may not suspend when phy has WoL and not attached to ne… #430

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,19 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
if (!drv || !phydrv->suspend)
return false;

/* 1.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.
* 2.Phy may not attached to netdev, but enabled wol.
*/
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;
}

/* PHY not attached? May suspend if the PHY has not already been
* suspended as part of a prior call to phy_disconnect() ->
* phy_detach() -> phy_suspend() because the parent netdev might be the
Expand All @@ -288,18 +301,6 @@ static bool mdio_bus_phy_may_suspend(struct phy_device *phydev)
if (netdev->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.
Expand Down
Loading