PCI / PM: Disable wakeup during shutdown for devices not enabled to wake up
authorRafael J. Wysocki <rjw@sisk.pl>
Mon, 6 Feb 2012 23:50:35 +0000 (00:50 +0100)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Fri, 17 Feb 2012 17:22:04 +0000 (09:22 -0800)
If a PCI device is enabled to generate wakeup signals (PME) when put
into a low-power state by runtime PM, it will be still enabled to
generate those signals after the system shutdown, unless its driver's
.shutdown() callback takes care of the wakeup signals generation
setting.  Moreover, there are devices that are not enabled to wake
up the system and that are configured by runtime PM to generate
wakeup signals so that (runtime) remote wakeup works with them.
Those devices should be reconfigured during system shutdown so that
they don't generate wakeup signals, but at least some drivers don't
do that.  However, that very well may be done by the PCI core so
that drivers don't have to worry about it.  For this reason, modify
pci_device_shutdown() to disable the generation of wakeup events for
devices not supposed to wake up the system.

References: https://bugzilla.kernel.org/show_bug.cgi?id=37952
Reported-and-tested-by: Kamil Iskra <kamil.54002@iskra.name>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/pci-driver.c

index 3623d65..5d19695 100644 (file)
@@ -430,6 +430,16 @@ static void pci_device_shutdown(struct device *dev)
                drv->shutdown(pci_dev);
        pci_msi_shutdown(pci_dev);
        pci_msix_shutdown(pci_dev);
+
+       /*
+        * Devices may be enabled to wake up by runtime PM, but they need not
+        * be supposed to wake up the system from its "power off" state (e.g.
+        * ACPI S5).  Therefore disable wakeup for all devices that aren't
+        * supposed to wake up the system at this point.  The state argument
+        * will be ignored by pci_enable_wake().
+        */
+       if (!device_may_wakeup(dev))
+               pci_enable_wake(pci_dev, PCI_UNKNOWN, false);
 }
 
 #ifdef CONFIG_PM