Re: [PATCH] r8152: Suspend USB device before shutdown when WoL is enabled

From: Alan Stern
Date: Fri Jul 07 2023 - 21:51:39 EST


On Fri, Jul 07, 2023 at 05:12:25PM -0700, Jakub Kicinski wrote:
> On Thu, 6 Jul 2023 18:28:58 +0000 Alexandru Gagniuc wrote:
> > For Wake-on-LAN to work from S5 (shutdown), the USB link must be put
> > in U3 state. If it is not, and the host "disappears", the chip will
> > no longer respond to WoL triggers.
> >
> > To resolve this, add a notifier block and register it as a reboot
> > notifier. When WoL is enabled, work through the usb_device struct to
> > get to the suspend function. Calling this function puts the link in
> > the correct state for WoL to function.
>
> Would be good to hear from USB experts on this one, to an outside seems
> like something that the bus should be doing, possibly based on some
> driver opt-in..

The USB spec does not include any discussion of what things should be
done when the system is turned off -- it doesn't even really acknowledge
the existence of different system-wide power states. As a result, the
USB subsystem never developed any support for power-off callbacks or
anything else of the sort.

Of course, this kind of thing can always be added. But I don't think
there's any way to distinguish (at the USB level) between wakeup from
S5-off and wakeup from any other low-power system state. And the PM
part of the device model doesn't have multiple types of "enable-wakeup"
flags -- either a device is enabled for wakeup or it isn't.

Alan Stern