Skip to content

Commit a7e3448

Browse files
ffainellidavem330
authored andcommitted
net: phy: Allow drivers to always call into ->suspend()
A few PHY drivers are currently attempting to not suspend the PHY when Wake-on-LAN is enabled, however that code is not currently executing at all due to an early check in phy_suspend(). This prevents PHY drivers from making an appropriate decisions and put the hardware into a low power state if desired. In order to allow the PHY drivers to opt into getting their ->suspend routine to be called, add a PHY_ALWAYS_CALL_SUSPEND bit which can be set. A boolean that tracks whether the PHY or the attached MAC has Wake-on-LAN enabled is also provided for convenience. If phydev::wol_enabled then the PHY shall not prevent its own Wake-on-LAN detection logic from working and shall not prevent the Ethernet MAC from receiving packets for matching. Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba79e9a commit a7e3448

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

drivers/net/phy/phy_device.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,9 +1860,10 @@ int phy_suspend(struct phy_device *phydev)
18601860
if (phydev->suspended)
18611861
return 0;
18621862

1863-
/* If the device has WOL enabled, we cannot suspend the PHY */
18641863
phy_ethtool_get_wol(phydev, &wol);
1865-
if (wol.wolopts || (netdev && netdev->wol_enabled))
1864+
phydev->wol_enabled = wol.wolopts || (netdev && netdev->wol_enabled);
1865+
/* If the device has WOL enabled, we cannot suspend the PHY */
1866+
if (phydev->wol_enabled && !(phydrv->flags & PHY_ALWAYS_CALL_SUSPEND))
18661867
return -EBUSY;
18671868

18681869
if (!phydrv || !phydrv->suspend)

include/linux/phy.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ extern const int phy_10gbit_features_array[1];
8686
#define PHY_IS_INTERNAL 0x00000001
8787
#define PHY_RST_AFTER_CLK_EN 0x00000002
8888
#define PHY_POLL_CABLE_TEST 0x00000004
89+
#define PHY_ALWAYS_CALL_SUSPEND 0x00000008
8990
#define MDIO_DEVICE_IS_PHY 0x80000000
9091

9192
/**
@@ -548,6 +549,8 @@ struct macsec_ops;
548549
* @downshifted_rate: Set true if link speed has been downshifted.
549550
* @is_on_sfp_module: Set true if PHY is located on an SFP module.
550551
* @mac_managed_pm: Set true if MAC driver takes of suspending/resuming PHY
552+
* @wol_enabled: Set to true if the PHY or the attached MAC have Wake-on-LAN
553+
* enabled.
551554
* @state: State of the PHY for management purposes
552555
* @dev_flags: Device-specific flags used by the PHY driver.
553556
*
@@ -644,6 +647,7 @@ struct phy_device {
644647
unsigned downshifted_rate:1;
645648
unsigned is_on_sfp_module:1;
646649
unsigned mac_managed_pm:1;
650+
unsigned wol_enabled:1;
647651

648652
unsigned autoneg:1;
649653
/* The most recently read link state */

0 commit comments

Comments
 (0)