2021-07-06 09:06:19

by Ling Pei Lee

[permalink] [raw]
Subject: [PATCH net] 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")
Signed-off-by: Mohammad Athari Bin Ismail <[email protected]>
Signed-off-by: Ling PeiLee <[email protected]>
---
drivers/net/phy/phy_device.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 1539ea021ac0..f4b88f613dc1 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -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);
}

/**
--
2.25.1


2021-07-06 13:19:31

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown

On Tue, Jul 06, 2021 at 05:02:09PM +0800, Ling Pei Lee wrote:
> 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

2021-07-07 00:39:00

by Ismail, Mohammad Athari

[permalink] [raw]
Subject: RE: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown



> -----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
>
> On Tue, Jul 06, 2021 at 05:02:09PM +0800, Ling Pei Lee wrote:
> > 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-

> Andrew

2021-07-07 00:58:39

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown

On Wed, Jul 07, 2021 at 12:36:30AM +0000, Ismail, Mohammad Athari wrote:
>
>
> > -----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
> >
> > On Tue, Jul 06, 2021 at 05:02:09PM +0800, Ling Pei Lee wrote:
> > > 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.

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

2021-07-07 02:52:18

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown



On 7/6/2021 5:57 PM, Andrew Lunn wrote:
> On Wed, Jul 07, 2021 at 12:36:30AM +0000, Ismail, Mohammad Athari wrote:
>>
>>
>>> -----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
>>>
>>> On Tue, Jul 06, 2021 at 05:02:09PM +0800, Ling Pei Lee wrote:
>>>> 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.
>
> 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.

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


--
Florian