linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown
@ 2021-07-06  9:02 Ling Pei Lee
  2021-07-06 13:14 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Ling Pei Lee @ 2021-07-06  9:02 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, davem,
	Jakub Kicinski, Ioana Ciornei, netdev, linux-kernel
  Cc: pei.lee.ling, weifeng.voon, vee.khee.wong, vee.khee.wong,
	mohammad.athari.ismail

From: Mohammad Athari Bin Ismail <mohammad.athari.ismail@intel.com>

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 <mohammad.athari.ismail@intel.com>
Signed-off-by: Ling PeiLee <pei.lee.ling@intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown
  2021-07-06  9:02 [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown Ling Pei Lee
@ 2021-07-06 13:14 ` Andrew Lunn
  2021-07-07  0:36   ` Ismail, Mohammad Athari
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2021-07-06 13:14 UTC (permalink / raw)
  To: Ling Pei Lee
  Cc: Heiner Kallweit, Russell King, davem, Jakub Kicinski,
	Ioana Ciornei, netdev, linux-kernel, weifeng.voon, vee.khee.wong,
	vee.khee.wong, mohammad.athari.ismail

On Tue, Jul 06, 2021 at 05:02:09PM +0800, Ling Pei Lee wrote:
> From: Mohammad Athari Bin Ismail <mohammad.athari.ismail@intel.com>
> 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown
  2021-07-06 13:14 ` Andrew Lunn
@ 2021-07-07  0:36   ` Ismail, Mohammad Athari
  2021-07-07  0:57     ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Ismail, Mohammad Athari @ 2021-07-07  0:36 UTC (permalink / raw)
  To: Andrew Lunn, Ling, Pei Lee
  Cc: Heiner Kallweit, Russell King, davem, Jakub Kicinski,
	Ioana Ciornei, netdev, linux-kernel, Voon, Weifeng,
	vee.khee.wong, Wong, Vee Khee



> -----Original Message-----
> From: Andrew Lunn <andrew@lunn.ch>
> Sent: Tuesday, July 6, 2021 9:14 PM
> To: Ling, Pei Lee <pei.lee.ling@intel.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>; Russell King
> <linux@armlinux.org.uk>; davem@davemloft.net; Jakub Kicinski
> <kuba@kernel.org>; Ioana Ciornei <ioana.ciornei@nxp.com>;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Voon, Weifeng
> <weifeng.voon@intel.com>; vee.khee.wong@linux.intel.com; Wong, Vee Khee
> <vee.khee.wong@intel.com>; Ismail, Mohammad Athari
> <mohammad.athari.ismail@intel.com>
> 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 <mohammad.athari.ismail@intel.com>
> >
> > 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown
  2021-07-07  0:36   ` Ismail, Mohammad Athari
@ 2021-07-07  0:57     ` Andrew Lunn
  2021-07-07  2:51       ` Florian Fainelli
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2021-07-07  0:57 UTC (permalink / raw)
  To: Ismail, Mohammad Athari
  Cc: Ling, Pei Lee, Heiner Kallweit, Russell King, davem,
	Jakub Kicinski, Ioana Ciornei, netdev, linux-kernel, Voon,
	Weifeng, vee.khee.wong, Wong, Vee Khee

On Wed, Jul 07, 2021 at 12:36:30AM +0000, Ismail, Mohammad Athari wrote:
> 
> 
> > -----Original Message-----
> > From: Andrew Lunn <andrew@lunn.ch>
> > Sent: Tuesday, July 6, 2021 9:14 PM
> > To: Ling, Pei Lee <pei.lee.ling@intel.com>
> > Cc: Heiner Kallweit <hkallweit1@gmail.com>; Russell King
> > <linux@armlinux.org.uk>; davem@davemloft.net; Jakub Kicinski
> > <kuba@kernel.org>; Ioana Ciornei <ioana.ciornei@nxp.com>;
> > netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Voon, Weifeng
> > <weifeng.voon@intel.com>; vee.khee.wong@linux.intel.com; Wong, Vee Khee
> > <vee.khee.wong@intel.com>; Ismail, Mohammad Athari
> > <mohammad.athari.ismail@intel.com>
> > 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 <mohammad.athari.ismail@intel.com>
> > >
> > > 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown
  2021-07-07  0:57     ` Andrew Lunn
@ 2021-07-07  2:51       ` Florian Fainelli
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2021-07-07  2:51 UTC (permalink / raw)
  To: Andrew Lunn, Ismail, Mohammad Athari
  Cc: Ling, Pei Lee, Heiner Kallweit, Russell King, davem,
	Jakub Kicinski, Ioana Ciornei, netdev, linux-kernel, Voon,
	Weifeng, vee.khee.wong, Wong, Vee Khee



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 <andrew@lunn.ch>
>>> Sent: Tuesday, July 6, 2021 9:14 PM
>>> To: Ling, Pei Lee <pei.lee.ling@intel.com>
>>> Cc: Heiner Kallweit <hkallweit1@gmail.com>; Russell King
>>> <linux@armlinux.org.uk>; davem@davemloft.net; Jakub Kicinski
>>> <kuba@kernel.org>; Ioana Ciornei <ioana.ciornei@nxp.com>;
>>> netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Voon, Weifeng
>>> <weifeng.voon@intel.com>; vee.khee.wong@linux.intel.com; Wong, Vee Khee
>>> <vee.khee.wong@intel.com>; Ismail, Mohammad Athari
>>> <mohammad.athari.ismail@intel.com>
>>> 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 <mohammad.athari.ismail@intel.com>
>>>>
>>>> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-07  2:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06  9:02 [PATCH net] net: phy: skip disabling interrupt when WOL is enabled in shutdown Ling Pei Lee
2021-07-06 13:14 ` Andrew Lunn
2021-07-07  0:36   ` Ismail, Mohammad Athari
2021-07-07  0:57     ` Andrew Lunn
2021-07-07  2:51       ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).