Skip to contentSkip to conversation

net: phy: skip disabling interrupt when WOL is enabled in shutdown

PATCH In review Ling Pei Lee 4 participants 5 messages Jul 6, 2021 – Jul 7, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: skip disabling interrupt when WOL is enabled in shutdown

From: Mohammad Athari Bin Ismail <[email protected]>

PHY WOL requires WOL interrupt event to trigger the WOL signal in order to wake up the system. Hence, the PHY driver should not disable the interrupt during shutdown if PHY WOL is enabled.

Fixes e2f016cf7751 ("net: phy: add a shutdown procedure")
---
 drivers/net/phy/phy_device.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/phy/phy_device.c +5 -1
index 1539ea021ac0..f4b88f613dc1 100644
@@ -2994,9 +2994,13 @@ static int phy_remove(struct device *dev)
 
 static void phy_shutdown(struct device *dev)
 {
+	struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
 	struct phy_device *phydev = to_phy_device(dev);
 
-	phy_disable_interrupts(phydev);
+	/* If the device has WOL enabled, don't disable interrupts. */
+	phy_ethtool_get_wol(phydev, &wol);
+	if (!wol.wolopts)
+		phy_disable_interrupts(phydev);
 }
 
 /**
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 5 lines · Ling Pei Lee

From: Mohammad Athari Bin Ismail <[email protected]>

PHY WOL requires WOL interrupt event to trigger the WOL signal in order to wake up the system. Hence, the PHY driver should not disable the interrupt during shutdown if PHY WOL is enabled.

If the device is being used to wake the system up, why is it being shutdown?

Andrew

#2 lore raw
Quoted 16 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Tuesday, July 6, 2021 9:14 PM
To: Ling, Pei Lee <[email protected]>
Cc: Heiner Kallweit <[email protected]>; Russell King <[email protected]>; [email protected]; Jakub Kicinski <[email protected]>; Ioana Ciornei <[email protected]>; [email protected]; [email protected]; Voon, Weifeng <[email protected]>; [email protected]; Wong, Vee Khee <[email protected]>; Ismail, Mohammad Athari <[email protected]>
Subject: Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown

Quoted 9 lines
Quoted 5 lines · Ling Pei Lee

From: Mohammad Athari Bin Ismail <[email protected]>

PHY WOL requires WOL interrupt event to trigger the WOL signal in order to wake up the system. Hence, the PHY driver should not disable the interrupt during shutdown if PHY WOL is enabled.

If the device is being used to wake the system up, why is it being shutdown?

Hi Andrew,

When the platform goes to S5 state (ex: shutdown -h now), regardless PHY WOL is enabled or not, phy_shutdown() is called. So, for the platform that support WOL from S5, we need to make sure the PHY still can trigger WOL event. Disabling the interrupt through phy_disable_interrupts() in phy_shutdown() will disable WOL interrupt as well and cause the PHY WOL not able to trigger.

-Athari-

Quoted 1 line

Andrew

maintainer
#3 lore raw
Quoted 29 lines · Mohammad Athari
Quoted 16 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Tuesday, July 6, 2021 9:14 PM
To: Ling, Pei Lee <[email protected]>
Cc: Heiner Kallweit <[email protected]>; Russell King <[email protected]>; [email protected]; Jakub Kicinski <[email protected]>; Ioana Ciornei <[email protected]>; [email protected]; [email protected]; Voon, Weifeng <[email protected]>; [email protected]; Wong, Vee Khee <[email protected]>; Ismail, Mohammad Athari <[email protected]>
Subject: Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown

Quoted 9 lines
Quoted 5 lines · Ling Pei Lee

From: Mohammad Athari Bin Ismail <[email protected]>

PHY WOL requires WOL interrupt event to trigger the WOL signal in order to wake up the system. Hence, the PHY driver should not disable the interrupt during shutdown if PHY WOL is enabled.

If the device is being used to wake the system up, why is it being shutdown?

Hi Andrew,

Quoted 6 lines

When the platform goes to S5 state (ex: shutdown -h now), regardless PHY WOL is enabled or not, phy_shutdown() is called. So, for the platform that support WOL from S5, we need to make sure the PHY still can trigger WOL event. Disabling the interrupt through phy_disable_interrupts() in phy_shutdown() will disable WOL interrupt as well and cause the PHY WOL not able to trigger.

This sounds like a firmware problem. If linux is shutdown, linux is not controlling the hardware, the firmware is. So the firmware should probably be configuring the PHY after Linux powers off.

If Linux is suspended, then Linux is still controlling the hardware, and it will not shutdown the PHY.

Andrew

#4 lore raw
Quoted 37 lines · Andrew Lunn
Quoted 29 lines · Mohammad Athari
Quoted 16 lines

-----Original Message-----
From: Andrew Lunn <[email protected]>
Sent: Tuesday, July 6, 2021 9:14 PM
To: Ling, Pei Lee <[email protected]>
Cc: Heiner Kallweit <[email protected]>; Russell King <[email protected]>; [email protected]; Jakub Kicinski <[email protected]>; Ioana Ciornei <[email protected]>; [email protected]; [email protected]; Voon, Weifeng <[email protected]>; [email protected]; Wong, Vee Khee <[email protected]>; Ismail, Mohammad Athari <[email protected]>
Subject: Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown

Quoted 9 lines
Quoted 5 lines · Ling Pei Lee

From: Mohammad Athari Bin Ismail <[email protected]>

PHY WOL requires WOL interrupt event to trigger the WOL signal in order to wake up the system. Hence, the PHY driver should not disable the interrupt during shutdown if PHY WOL is enabled.

If the device is being used to wake the system up, why is it being shutdown?

Hi Andrew,

Quoted 6 lines

When the platform goes to S5 state (ex: shutdown -h now), regardless PHY WOL is enabled or not, phy_shutdown() is called. So, for the platform that support WOL from S5, we need to make sure the PHY still can trigger WOL event. Disabling the interrupt through phy_disable_interrupts() in phy_shutdown() will disable WOL interrupt as well and cause the PHY WOL not able to trigger.

Quoted 3 lines

This sounds like a firmware problem. If linux is shutdown, linux is not controlling the hardware, the firmware is. So the firmware should probably be configuring the PHY after Linux powers off.

There are platforms supporting S5 shutdown that don't run firmware and would also expect to be able to be woken-up from an Ethernet PHY/Wake-on-LAN scheme.

The problem that is being addressed here is that even if your Ethernet driver was playing through properly and attempting not to disable the Ethernet PHY in suspend or shutdown callback, that decision would be overridden by phy_shutdown() when the MDIO bus' shutdown is called and that breaks up that wake-up mode.

Quoted 3 lines

If Linux is suspended, then Linux is still controlling the hardware, and it will not shutdown the PHY.

Signature · 1 line
Florian