On Wed, May 26, 2021 at 10:03:47AM -0700, Florian Fainelli wrote: > On 5/25/21 2:18 PM, Bjorn Helgaas wrote: > > On Tue, Apr 27, 2021 at 01:51:39PM -0400, Jim Quinlan wrote: > >> The shutdown() call is similar to the remove() call except the former does > >> not need to invoke pci_{stop,remove}_root_bus(), and besides, errors occur > >> if it does. > > > > This doesn't explain why shutdown() is necessary. "errors occur" > > might be a hint, except that AFAICT, many similar drivers do invoke > > pci_stop_root_bus() and pci_remove_root_bus() (several of them while > > holding pci_lock_rescan_remove()), without implementing .shutdown(). > > We have to implement .shutdown() in order to meet a certain power budget > while the chip is being put into S5 (soft off) state and still support > Wake-on-WLAN, for our latest chips this translates into roughly 200mW of > power savings at the wall. We could probably add a word or two in a v2 > that indicates this is done for power savings. "Saving power" is a great reason to do this. But we still need to connect this to the driver model and the system-level behavior somehow. The pci_driver comment says @shutdown is to "stop idling DMA operations" and it hooks into reboot_notifier_list in kernel/sys.c. That's incorrect or at least incomplete because reboot_notifier_list isn't mentioned at all in kernel/sys.c, and I don't see the connection between @shutdown and reboot_notifier_list. AFAICT, @shutdown is currently used in this path: kernel_restart_prepare or kernel_shutdown_prepare device_shutdown dev->bus->shutdown pci_device_shutdown # pci_bus_type.shutdown drv->shutdown so we're going to either reboot or halt/power-off the entire system, and we're not going to use this device again until we're in a brand-new kernel and we re-enumerate the device and re-register the driver. I'm not quite sure how either of those fits into the power-saving reason. I guess going to S5 is probably via the kernel_power_off() path and that by itself doesn't turn off as much power to the PCIe controller as it could? And this new .shutdown() method will get called in that path and will turn off more power, but will still leave enough for wake-on-LAN to work? And when we *do* wake from S5, obviously that means a complete boot with a new kernel. Bjorn