OpenCloudOS-Kernel/drivers/base/power
Brian Norris 6f75c3fd56 PM / sleep: don't suspend parent when async child suspend_{noirq, late} fails
Consider two devices, A and B, where B is a child of A, and B utilizes
asynchronous suspend (it does not matter whether A is sync or async). If
B fails to suspend_noirq() or suspend_late(), or is interrupted by a
wakeup (pm_wakeup_pending()), then it aborts and sets the async_error
variable. However, device A does not (immediately) check the async_error
variable; it may continue to run its own suspend_noirq()/suspend_late()
callback. This is bad.

We can resolve this problem by doing our error and wakeup checking
(particularly, for the async_error flag) after waiting for children to
suspend, instead of before. This also helps align the logic for the noirq and
late suspend cases with the logic in __device_suspend().

It's easy to observe this erroneous behavior by, for example, forcing a
device to sleep a bit in its suspend_noirq() (to ensure the parent is
waiting for the child to complete), then return an error, and watch the
parent suspend_noirq() still get called. (Or similarly, fake a wakeup
event at the right (or is it wrong?) time.)

Fixes: de377b3972 (PM / sleep: Asynchronous threads for suspend_late)
Fixes: 28b6fd6e37 (PM / sleep: Asynchronous threads for suspend_noirq)
Reported-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2016-11-11 01:29:09 +01:00
..
opp PM / OPP: Don't support OPP if it provides supported-hw but platform does not 2016-09-26 15:13:31 +02:00
Makefile PM / OPP: Move opp core to its own directory 2015-09-15 02:03:16 +02:00
clock_ops.c PM / clk: Add support for adding a specific clock from device-tree 2016-06-28 00:42:10 +02:00
common.c PM: Avoid false-positive warnings in dev_pm_domain_set() 2016-02-03 19:10:37 +01:00
domain.c PM / Domains: Rename pm_genpd_sync_poweron|poweroff() 2016-09-24 01:54:29 +02:00
domain_governor.c PM / Domains: Rename stop_ok to suspend_ok for the genpd governor 2016-04-22 02:29:17 +02:00
generic_ops.c PM / PCI / ACPI: Kick devices that might have been reset by firmware 2015-10-14 02:17:34 +02:00
main.c PM / sleep: don't suspend parent when async child suspend_{noirq, late} fails 2016-11-11 01:29:09 +01:00
power.h PM / sleep: Go direct_complete if driver has no callbacks 2016-01-08 01:12:06 +01:00
qos.c PM / QoS: Make it possible to expose device latency tolerance to userspace 2015-07-28 08:50:41 +01:00
runtime.c PM / runtime: Use _rcuidle for runtime suspend tracepoints 2016-09-16 02:59:58 +02:00
sysfs.c PM / QoS: Make it possible to expose device latency tolerance to userspace 2015-07-28 08:50:41 +01:00
trace.c char/genrtc: x86: remove remnants of asm/rtc.h 2016-06-04 00:20:07 +02:00
wakeirq.c PM / wakeirq: check that wake IRQ is valid before accepting it 2015-11-16 23:10:20 +01:00
wakeup.c PM-wakeup: Delete unnecessary checks before three function calls 2016-07-28 23:51:04 +02:00