PCI/PM: Report wakeup events before resuming devices
authorRafael J. Wysocki <rjw@sisk.pl>
Wed, 29 Dec 2010 12:22:08 +0000 (13:22 +0100)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Fri, 14 Jan 2011 16:55:43 +0000 (08:55 -0800)
Make wakeup events be reported by the PCI subsystem before attempting to
resume devices or queuing up runtime resume requests for them, because
wakeup events should be reported as soon as they have been detected.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/pci-acpi.c
drivers/pci/pci.c
drivers/pci/pcie/pme.c

index d7ea699b8ddcba0567561b5846c01419a95674fa..6fe0772e0e7de2432d9353d8871b3bc5e8ba04ee 100644 (file)
@@ -46,9 +46,9 @@ static void pci_acpi_wake_dev(acpi_handle handle, u32 event, void *context)
        struct pci_dev *pci_dev = context;
 
        if (event == ACPI_NOTIFY_DEVICE_WAKE && pci_dev) {
+               pci_wakeup_event(pci_dev);
                pci_check_pme_status(pci_dev);
                pm_runtime_resume(&pci_dev->dev);
-               pci_wakeup_event(pci_dev);
                if (pci_dev->subordinate)
                        pci_pme_wakeup_bus(pci_dev->subordinate);
        }
index bf7ad2c09955f3b33a198a1fc471be7bc7225742..b714d787bdddeb8306324dada56412c6eef2ac68 100644 (file)
@@ -1308,8 +1308,8 @@ bool pci_check_pme_status(struct pci_dev *dev)
 static int pci_pme_wakeup(struct pci_dev *dev, void *ign)
 {
        if (pci_check_pme_status(dev)) {
-               pm_request_resume(&dev->dev);
                pci_wakeup_event(dev);
+               pm_request_resume(&dev->dev);
        }
        return 0;
 }
index 073f0308c6b219f6f1cbb4f7bed32d3d59a0f1ec..0057344a3fcb231507a115d4d97ac84125da2161 100644 (file)
@@ -84,8 +84,8 @@ static bool pcie_pme_walk_bus(struct pci_bus *bus)
        list_for_each_entry(dev, &bus->devices, bus_list) {
                /* Skip PCIe devices in case we started from a root port. */
                if (!pci_is_pcie(dev) && pci_check_pme_status(dev)) {
-                       pm_request_resume(&dev->dev);
                        pci_wakeup_event(dev);
+                       pm_request_resume(&dev->dev);
                        ret = true;
                }
 
@@ -187,8 +187,8 @@ static void pcie_pme_handle_request(struct pci_dev *port, u16 req_id)
                /* The device is there, but we have to check its PME status. */
                found = pci_check_pme_status(dev);
                if (found) {
-                       pm_request_resume(&dev->dev);
                        pci_wakeup_event(dev);
+                       pm_request_resume(&dev->dev);
                }
                pci_dev_put(dev);
        } else if (devfn) {