Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI / PM: Resume runtime-suspended devices later during system suspend

Runtime-suspended devices are resumed during system suspend by
acpi_subsys_prepare() for two reasons: First, because they may need
to be reprogrammed in order to change their wakeup settings and,
second, because they may need to be operatonal for their children
to be successfully suspended. That is a problem, though, if there
are many runtime-suspended devices that need to be resumed this
way during system suspend, because the .prepare() PM callbacks of
devices are executed sequentially and the times taken by them
accumulate, which may increase the total system suspend time quite
a bit.

For this reason, move the resume of runtime-suspended devices up
to the next phase of device suspend (during system suspend), except
for the ones that have power.ignore_children set. The exception is
made, because the devices with power.ignore_children set may still
be necessary for their children to be successfully suspended (during
system suspend) and they won't be resumed automatically as a result
of the runtime resume of their children.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

+38 -3
+38 -3
drivers/acpi/device_pm.c
··· 901 901 int acpi_subsys_prepare(struct device *dev) 902 902 { 903 903 /* 904 - * Follow PCI and resume devices suspended at run time before running 905 - * their system suspend callbacks. 904 + * Devices having power.ignore_children set may still be necessary for 905 + * suspending their children in the next phase of device suspend. 906 906 */ 907 - pm_runtime_resume(dev); 907 + if (dev->power.ignore_children) 908 + pm_runtime_resume(dev); 909 + 908 910 return pm_generic_prepare(dev); 909 911 } 910 912 EXPORT_SYMBOL_GPL(acpi_subsys_prepare); 913 + 914 + /** 915 + * acpi_subsys_suspend - Run the device driver's suspend callback. 916 + * @dev: Device to handle. 917 + * 918 + * Follow PCI and resume devices suspended at run time before running their 919 + * system suspend callbacks. 920 + */ 921 + int acpi_subsys_suspend(struct device *dev) 922 + { 923 + pm_runtime_resume(dev); 924 + return pm_generic_suspend(dev); 925 + } 911 926 912 927 /** 913 928 * acpi_subsys_suspend_late - Suspend device using ACPI. ··· 952 937 return ret ? ret : pm_generic_resume_early(dev); 953 938 } 954 939 EXPORT_SYMBOL_GPL(acpi_subsys_resume_early); 940 + 941 + /** 942 + * acpi_subsys_freeze - Run the device driver's freeze callback. 943 + * @dev: Device to handle. 944 + */ 945 + int acpi_subsys_freeze(struct device *dev) 946 + { 947 + /* 948 + * This used to be done in acpi_subsys_prepare() for all devices and 949 + * some drivers may depend on it, so do it here. Ideally, however, 950 + * runtime-suspended devices should not be touched during freeze/thaw 951 + * transitions. 952 + */ 953 + pm_runtime_resume(dev); 954 + return pm_generic_freeze(dev); 955 + } 956 + 955 957 #endif /* CONFIG_PM_SLEEP */ 956 958 957 959 static struct dev_pm_domain acpi_general_pm_domain = { ··· 979 947 #endif 980 948 #ifdef CONFIG_PM_SLEEP 981 949 .prepare = acpi_subsys_prepare, 950 + .suspend = acpi_subsys_suspend, 982 951 .suspend_late = acpi_subsys_suspend_late, 983 952 .resume_early = acpi_subsys_resume_early, 953 + .freeze = acpi_subsys_freeze, 954 + .poweroff = acpi_subsys_suspend, 984 955 .poweroff_late = acpi_subsys_suspend_late, 985 956 .restore_early = acpi_subsys_resume_early, 986 957 #endif