PM / PCI / ACPI: Kick devices that might have been reset by firmware
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 6 Oct 2015 22:50:24 +0000 (00:50 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 14 Oct 2015 00:17:34 +0000 (02:17 +0200)
There is a concern that if the platform firmware was involved in
the system resume that's being completed,  some devices might have
been reset by it and if those devices had the power.direct_complete
flag set during the preceding suspend transition, they may stay
in a reset-power-on state indefinitely (until they are runtime-resumed
and then suspended again).  That may not be a big deal from the
individual device's perspective, but if the system is an SoC, it may
be prevented from entering deep SoC-wide low-power states on idle
because of that.

The devices that are most likely to be affected by this issue are
PCI devices and ACPI-enumerated devices using the general ACPI PM
domain, so to prevent it from happening for those devices, force a
runtime resume for them if they have their power.direct_complete
flags set and the platform firmware was involved in the resume
transition currently in progress.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpi_lpss.c
drivers/acpi/device_pm.c
drivers/base/power/generic_ops.c
drivers/pci/pci-driver.c
include/linux/pm.h

index f51bd0d0bc17ceced34eab34463c8f048430de91..f9e0d09f7c66cf6bebfdaab992b3b1780b563766 100644 (file)
@@ -664,7 +664,7 @@ static struct dev_pm_domain acpi_lpss_pm_domain = {
 #ifdef CONFIG_PM
 #ifdef CONFIG_PM_SLEEP
                .prepare = acpi_subsys_prepare,
-               .complete = acpi_subsys_complete,
+               .complete = pm_complete_with_resume_check,
                .suspend = acpi_subsys_suspend,
                .suspend_late = acpi_lpss_suspend_late,
                .resume_early = acpi_lpss_resume_early,
index 4806b7f856c46047bb0b4bd38bbc66717e33a6e0..08a02cdc737c193d608970b6eec0b45781137d76 100644 (file)
@@ -962,23 +962,6 @@ int acpi_subsys_prepare(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(acpi_subsys_prepare);
 
-/**
- * acpi_subsys_complete - Finalize device's resume during system resume.
- * @dev: Device to handle.
- */
-void acpi_subsys_complete(struct device *dev)
-{
-       pm_generic_complete(dev);
-       /*
-        * If the device had been runtime-suspended before the system went into
-        * the sleep state it is going out of and it has never been resumed till
-        * now, resume it in case the firmware powered it up.
-        */
-       if (dev->power.direct_complete)
-               pm_request_resume(dev);
-}
-EXPORT_SYMBOL_GPL(acpi_subsys_complete);
-
 /**
  * acpi_subsys_suspend - Run the device driver's suspend callback.
  * @dev: Device to handle.
@@ -1047,7 +1030,7 @@ static struct dev_pm_domain acpi_general_pm_domain = {
                .runtime_resume = acpi_subsys_runtime_resume,
 #ifdef CONFIG_PM_SLEEP
                .prepare = acpi_subsys_prepare,
-               .complete = acpi_subsys_complete,
+               .complete = pm_complete_with_resume_check,
                .suspend = acpi_subsys_suspend,
                .suspend_late = acpi_subsys_suspend_late,
                .resume_early = acpi_subsys_resume_early,
index b2ed606265a8115a689ecf84979dc16f4dda645c..07c3c4a9522d4e6bec1f0f540bd38f8c1ce6ed00 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
 #include <linux/export.h>
+#include <linux/suspend.h>
 
 #ifdef CONFIG_PM
 /**
@@ -297,4 +298,26 @@ void pm_generic_complete(struct device *dev)
        if (drv && drv->pm && drv->pm->complete)
                drv->pm->complete(dev);
 }
+
+/**
+ * pm_complete_with_resume_check - Complete a device power transition.
+ * @dev: Device to handle.
+ *
+ * Complete a device power transition during a system-wide power transition and
+ * optionally schedule a runtime resume of the device if the system resume in
+ * progress has been initated by the platform firmware and the device had its
+ * power.direct_complete flag set.
+ */
+void pm_complete_with_resume_check(struct device *dev)
+{
+       pm_generic_complete(dev);
+       /*
+        * If the device had been runtime-suspended before the system went into
+        * the sleep state it is going out of and it has never been resumed till
+        * now, resume it in case the firmware powered it up.
+        */
+       if (dev->power.direct_complete && pm_resume_via_firmware())
+               pm_request_resume(dev);
+}
+EXPORT_SYMBOL_GPL(pm_complete_with_resume_check);
 #endif /* CONFIG_PM_SLEEP */
index c9ce3073d7fe981686211dbfb1e56850d050614e..306124bba61e2a1dbf3e116e33b8768db192bc25 100644 (file)
@@ -687,7 +687,7 @@ static int pci_pm_prepare(struct device *dev)
 static void pci_pm_complete(struct device *dev)
 {
        pci_dev_complete_resume(to_pci_dev(dev));
-       pm_generic_complete(dev);
+       pm_complete_with_resume_check(dev);
 }
 
 #else /* !CONFIG_PM_SLEEP */
index 35d599e7250d2d8c29defd0373ff25fed0b03467..528be6787796b52a405fbc0af8bf707c31d55192 100644 (file)
@@ -732,6 +732,7 @@ extern int pm_generic_poweroff_noirq(struct device *dev);
 extern int pm_generic_poweroff_late(struct device *dev);
 extern int pm_generic_poweroff(struct device *dev);
 extern void pm_generic_complete(struct device *dev);
+extern void pm_complete_with_resume_check(struct device *dev);
 
 #else /* !CONFIG_PM_SLEEP */