Re: [PATCH net-next 1/3] net: phy: Let drivers check Wake-on-LAN status

From: Florian Fainelli
Date: Mon May 08 2023 - 15:17:53 EST


On 5/8/23 12:02, Andrew Lunn wrote:
On Mon, May 08, 2023 at 11:43:07AM -0700, Florian Fainelli wrote:
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 framework to always call into the PHY driver's
->suspend routine whether Wake-on-LAN is enabled or not, provide a
phydev::wol_enabled boolean that tracks whether the PHY or the attached
MAC has Wake-on-LAN enabled.

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.

Hi Florian

Did you look at using late_suspend for this? Then there would not be
any need to change all these drivers which are happy as they are.

I did not know its existence until you mentioned it, this would require plumbing all the way from the MDIO bus driver down to the PHY driver level, which could be done, but for a single driver? The way Linux suspends devices currently, and the fact that the interrupt is driven level low, it does not give much room if at all for missing the interrupt AFAICT.

phy_suspend() is called both from the system suspend path, but also whenever the PHY is unused, and this is a nice property because we do not really need to differentiate these paths usually, that includes Wake-on-LAN.

Besides there are drivers like drivers/net/phy/at803x.c that wish to isolate the PHY if WoL is enabled and which are currently not doing it because this never gets called.
--
Florian

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature