Re: [PATCH RFC net-next 2/6] net: phy: add phy_may_wakeup()

From: Russell King (Oracle)

Date: Tue Sep 30 2025 - 06:54:20 EST


On Tue, Sep 30, 2025 at 11:04:28AM +0200, Gatien CHEVALLIER wrote:
> Hi Russell,
>
> First of all, thank you for taking the time to propose something.
>
> IIUC, using ethtool to enable WoL with, e.g: "ethtool -s end0 wol g"
> even if the WoL isn't really supported will prevent the phy suspend.

This is correct - whenever a PHY has WoL enabled, it won't be suspended
as it has to listen for the configured wake-up packet(s).

> Therefore, PHY drivers should be adapted to implement something like:
>
> if (!device_can_wakeup(&dev->mdio.dev))
> return -EOPNOTSUPP;
>
> in their set_wol() ops to fully adapt to what you propose, right?

That's not sufficient. Yes, it's one of the things they need to do.

1. get_wol() should set ->supported to 0 (or at least not add anything
to it) if wake-up is not possible.

2. set_wol() should not enable WoL modes or return -EOPNOTSUPP as you
have above if wake-up is not possible. It should also call
device_set_wakeup_enable() to indicate whether wake-up has been
enabled for this device or not.

3. the PHY driver's probe function needs to be modified to call
device_set_wakeup_capable() to configure whether this device _really_
can wake-up the system. See realtek_main.c::rtl8211f_probe() and
broadcom.c as examples.

4. if using interrupt-based wake-up, use devm_pm_set_wake_irq() so
the driver core can manage the irq-wake configuration.

See realtek_main.c - that's the driver I recently fixed (it had many
issues).

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!