PCI / PM: Drop pme_interrupt flag from struct pci_dev
[sfrench/cifs-2.6.git] / drivers / pci / pci-acpi.c
index 001860361434623fcf84de1c2533df03835de8a0..de255bc9736b8640625a6cc7e7926224c610de58 100644 (file)
 #include "pci.h"
 
 /*
- * The UUID is defined in the PCI Firmware Specification available here:
+ * The GUID is defined in the PCI Firmware Specification available here:
  * https://www.pcisig.com/members/downloads/pcifw_r3_1_13Dec10.pdf
  */
-const u8 pci_acpi_dsm_uuid[] = {
-       0xd0, 0x37, 0xc9, 0xe5, 0x53, 0x35, 0x7a, 0x4d,
-       0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d
-};
+const guid_t pci_acpi_dsm_guid =
+       GUID_INIT(0xe5c937d0, 0x3553, 0x4d7a,
+                 0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d);
 
 #if defined(CONFIG_PCI_QUIRKS) && defined(CONFIG_ARM64)
 static int acpi_get_rc_addr(struct acpi_device *adev, struct resource *res)
@@ -395,29 +394,26 @@ bool pciehp_is_native(struct pci_dev *pdev)
 
 /**
  * pci_acpi_wake_bus - Root bus wakeup notification fork function.
- * @work: Work item to handle.
+ * @context: Device wakeup context.
  */
-static void pci_acpi_wake_bus(struct work_struct *work)
+static void pci_acpi_wake_bus(struct acpi_device_wakeup_context *context)
 {
        struct acpi_device *adev;
        struct acpi_pci_root *root;
 
-       adev = container_of(work, struct acpi_device, wakeup.context.work);
+       adev = container_of(context, struct acpi_device, wakeup.context);
        root = acpi_driver_data(adev);
        pci_pme_wakeup_bus(root->bus);
 }
 
 /**
  * pci_acpi_wake_dev - PCI device wakeup notification work function.
- * @handle: ACPI handle of a device the notification is for.
- * @work: Work item to handle.
+ * @context: Device wakeup context.
  */
-static void pci_acpi_wake_dev(struct work_struct *work)
+static void pci_acpi_wake_dev(struct acpi_device_wakeup_context *context)
 {
-       struct acpi_device_wakeup_context *context;
        struct pci_dev *pci_dev;
 
-       context = container_of(work, struct acpi_device_wakeup_context, work);
        pci_dev = to_pci_dev(context->dev);
 
        if (pci_dev->pme_poll)
@@ -425,7 +421,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
 
        if (pci_dev->current_state == PCI_D3cold) {
                pci_wakeup_event(pci_dev);
-               pm_runtime_resume(&pci_dev->dev);
+               pm_request_resume(&pci_dev->dev);
                return;
        }
 
@@ -434,7 +430,7 @@ static void pci_acpi_wake_dev(struct work_struct *work)
                pci_check_pme_status(pci_dev);
 
        pci_wakeup_event(pci_dev);
-       pm_runtime_resume(&pci_dev->dev);
+       pm_request_resume(&pci_dev->dev);
 
        pci_pme_wakeup_bus(pci_dev->subordinate);
 }
@@ -573,67 +569,29 @@ static pci_power_t acpi_pci_get_power_state(struct pci_dev *dev)
        return state_conv[state];
 }
 
-static bool acpi_pci_can_wakeup(struct pci_dev *dev)
-{
-       struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
-       return adev ? acpi_device_can_wakeup(adev) : false;
-}
-
-static void acpi_pci_propagate_wakeup_enable(struct pci_bus *bus, bool enable)
-{
-       while (bus->parent) {
-               if (!acpi_pm_device_sleep_wake(&bus->self->dev, enable))
-                       return;
-               bus = bus->parent;
-       }
-
-       /* We have reached the root bus. */
-       if (bus->bridge)
-               acpi_pm_device_sleep_wake(bus->bridge, enable);
-}
-
-static int acpi_pci_sleep_wake(struct pci_dev *dev, bool enable)
-{
-       if (acpi_pci_can_wakeup(dev))
-               return acpi_pm_device_sleep_wake(&dev->dev, enable);
-
-       acpi_pci_propagate_wakeup_enable(dev->bus, enable);
-       return 0;
-}
-
-static void acpi_pci_propagate_run_wake(struct pci_bus *bus, bool enable)
+static int acpi_pci_propagate_wakeup(struct pci_bus *bus, bool enable)
 {
        while (bus->parent) {
-               struct pci_dev *bridge = bus->self;
+               if (acpi_pm_device_can_wakeup(&bus->self->dev))
+                       return acpi_pm_set_device_wakeup(&bus->self->dev, enable);
 
-               if (bridge->pme_interrupt)
-                       return;
-               if (!acpi_pm_device_run_wake(&bridge->dev, enable))
-                       return;
                bus = bus->parent;
        }
 
        /* We have reached the root bus. */
-       if (bus->bridge)
-               acpi_pm_device_run_wake(bus->bridge, enable);
+       if (bus->bridge) {
+               if (acpi_pm_device_can_wakeup(bus->bridge))
+                       return acpi_pm_set_device_wakeup(bus->bridge, enable);
+       }
+       return 0;
 }
 
-static int acpi_pci_run_wake(struct pci_dev *dev, bool enable)
+static int acpi_pci_wakeup(struct pci_dev *dev, bool enable)
 {
-       /*
-        * Per PCI Express Base Specification Revision 2.0 section
-        * 5.3.3.2 Link Wakeup, platform support is needed for D3cold
-        * waking up to power on the main link even if there is PME
-        * support for D3cold
-        */
-       if (dev->pme_interrupt && !dev->runtime_d3cold)
-               return 0;
+       if (acpi_pm_device_can_wakeup(&dev->dev))
+               return acpi_pm_set_device_wakeup(&dev->dev, enable);
 
-       if (!acpi_pm_device_run_wake(&dev->dev, enable))
-               return 0;
-
-       acpi_pci_propagate_run_wake(dev->bus, enable);
-       return 0;
+       return acpi_pci_propagate_wakeup(dev->bus, enable);
 }
 
 static bool acpi_pci_need_resume(struct pci_dev *dev)
@@ -657,8 +615,8 @@ static const struct pci_platform_pm_ops acpi_pci_platform_pm = {
        .set_state = acpi_pci_set_power_state,
        .get_state = acpi_pci_get_power_state,
        .choose_state = acpi_pci_choose_state,
-       .sleep_wake = acpi_pci_sleep_wake,
-       .run_wake = acpi_pci_run_wake,
+       .sleep_wake = acpi_pci_wakeup,
+       .run_wake = acpi_pci_wakeup,
        .need_resume = acpi_pci_need_resume,
 };
 
@@ -680,7 +638,7 @@ void acpi_pci_add_bus(struct pci_bus *bus)
        if (!pci_is_root_bus(bus))
                return;
 
-       obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), pci_acpi_dsm_uuid, 3,
+       obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), &pci_acpi_dsm_guid, 3,
                                RESET_DELAY_DSM, NULL);
        if (!obj)
                return;
@@ -745,7 +703,7 @@ static void pci_acpi_optimize_delay(struct pci_dev *pdev,
        if (bridge->ignore_reset_delay)
                pdev->d3cold_delay = 0;
 
-       obj = acpi_evaluate_dsm(handle, pci_acpi_dsm_uuid, 3,
+       obj = acpi_evaluate_dsm(handle, &pci_acpi_dsm_guid, 3,
                                FUNCTION_DELAY_DSM, NULL);
        if (!obj)
                return;
@@ -781,9 +739,8 @@ static void pci_acpi_setup(struct device *dev)
                return;
 
        device_set_wakeup_capable(dev, true);
-       acpi_pci_sleep_wake(pci_dev, false);
-       if (adev->wakeup.flags.run_wake)
-               device_set_run_wake(dev, true);
+       device_set_run_wake(dev, true);
+       acpi_pci_wakeup(pci_dev, false);
 }
 
 static void pci_acpi_cleanup(struct device *dev)