===================================================================
@@ -907,20 +907,44 @@ int acpi_subsys_prepare(struct device *d
if (dev->power.ignore_children)
pm_runtime_resume(dev);
+ pm_set_direct_resume(dev, true);
return pm_generic_prepare(dev);
}
EXPORT_SYMBOL_GPL(acpi_subsys_prepare);
/**
- * acpi_subsys_suspend - Run the device driver's suspend callback.
+ * acpi_subsys_suspend - Handle device suspend stage of system suspend.
* @dev: Device to handle.
- *
- * Follow PCI and resume devices suspended at run time before running their
- * system suspend callbacks.
*/
int acpi_subsys_suspend(struct device *dev)
{
+ struct acpi_device *adev = ACPI_COMPANION(dev);
+ u32 sys_target;
+
+ if (!adev || !pm_runtime_enabled_and_suspended(dev)) {
+ pm_set_direct_resume(dev, false);
+ goto out;
+ }
+ if (!pm_direct_resume_is_set(dev)
+ || device_may_wakeup(dev) != !!adev->wakeup.prepare_count)
+ goto resume;
+
+ sys_target = acpi_target_system_state();
+ if (sys_target != ACPI_STATE_S0) {
+ int ret, state;
+
+ if (adev->power.flags.dsw_present)
+ goto resume;
+
+ ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state);
+ if (!ret && state == adev->power.state)
+ return 0;
+ }
+
+ resume:
pm_runtime_resume(dev);
+
+ out:
return pm_generic_suspend(dev);
}
@@ -954,6 +978,19 @@ int acpi_subsys_resume_early(struct devi
EXPORT_SYMBOL_GPL(acpi_subsys_resume_early);
/**
+ * acpi_subsys_resume - Handle device resume stage of system resume.
+ * @dev: Device to handle.
+ */
+int acpi_subsys_resume(struct device *dev)
+{
+ if (pm_direct_resume_is_set(dev)) {
+ pm_runtime_resume(dev);
+ return 0;
+ }
+ return pm_generic_resume(dev);
+}
+
+/**
* acpi_subsys_freeze - Run the device driver's freeze callback.
* @dev: Device to handle.
*/
@@ -982,6 +1019,7 @@ static struct dev_pm_domain acpi_general
.suspend = acpi_subsys_suspend,
.suspend_late = acpi_subsys_suspend_late,
.resume_early = acpi_subsys_resume_early,
+ .resume = acpi_subsys_resume,
.freeze = acpi_subsys_freeze,
.poweroff = acpi_subsys_suspend,
.poweroff_late = acpi_subsys_suspend_late,
===================================================================
@@ -261,7 +261,8 @@ struct acpi_device_power_flags {
u32 inrush_current:1; /* Serialize Dx->D0 */
u32 power_removed:1; /* Optimize Dx->D0 */
u32 ignore_parent:1; /* Power is independent of parent power state */
- u32 reserved:27;
+ u32 dsw_present:1; /* _DSW present? */
+ u32 reserved:26;
};
struct acpi_device_power_state {
===================================================================
@@ -1551,9 +1551,13 @@ static void acpi_bus_get_power_flags(str
*/
if (acpi_has_method(device->handle, "_PSC"))
device->power.flags.explicit_get = 1;
+
if (acpi_has_method(device->handle, "_IRC"))
device->power.flags.inrush_current = 1;
+ if (acpi_has_method(device->handle, "_DSW"))
+ device->power.flags.dsw_present = 1;
+
/*
* Enumerate supported power management states
*/