Skip to content

Commit

Permalink
PCI: PM: Fix ordering of operations in pci_back_from_sleep()
Browse files Browse the repository at this point in the history
The ordering of operations in pci_back_from_sleep() is incorrect,
because the device may be in D3cold when it runs and pci_enable_wake()
needs to access the device's configuration space which cannot be
done in D3cold.

Fix this by calling pci_set_power_state() to put the device into D0
before calling pci_enable_wake() for it.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
  • Loading branch information
Rafael J. Wysocki committed Oct 21, 2021
1 parent fa1a25c commit 6f9f0ee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2638,8 +2638,13 @@ EXPORT_SYMBOL(pci_prepare_to_sleep);
*/
int pci_back_from_sleep(struct pci_dev *dev)
{
int ret = pci_set_power_state(dev, PCI_D0);

if (ret)
return ret;

pci_enable_wake(dev, PCI_D0, false);
return pci_set_power_state(dev, PCI_D0);
return 0;
}
EXPORT_SYMBOL(pci_back_from_sleep);

Expand Down

0 comments on commit 6f9f0ee

Please sign in to comment.