PCI / PM: Check device_may_wakeup() in pci_enable_wake()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 8 May 2018 22:18:32 +0000 (00:18 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 10 May 2018 14:50:26 +0000 (16:50 +0200)
commitcfcadfaad7251d8b640713724b388164d75465b2
tree7884aafbceb05c029aef956448a55c60fe6a5b36
parent8feaec33b9868582654cd3d5355225dcb79aeca6
PCI / PM: Check device_may_wakeup() in pci_enable_wake()

Commit 0847684cfc5f0 (PCI / PM: Simplify device wakeup settings code)
went too far and dropped the device_may_wakeup() check from
pci_enable_wake() which causes wakeup to be enabled during system
suspend, hibernation or shutdown for some PCI devices that are not
allowed by user space to wake up the system from sleep (or power off).

As a result of this, excessive power is drawn by some of the affected
systems while in sleep states or off.

Restore the device_may_wakeup() check in pci_enable_wake(), but make
sure that the PCI bus type's runtime suspend callback will not call
device_may_wakeup() which is about system wakeup from sleep and not
about device wakeup from runtime suspend.

Fixes: 0847684cfc5f0 (PCI / PM: Simplify device wakeup settings code)
Reported-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Cc: 4.13+ <stable@vger.kernel.org> # 4.13+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c