]>
Commit | Line | Data |
---|---|---|
7c34048e GKH |
1 | From 69e445ab8b66a9f30519842ef18be555d3ee9b51 Mon Sep 17 00:00:00 2001 |
2 | From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com> | |
3 | Date: Thu, 4 Oct 2018 11:08:12 +0200 | |
4 | Subject: PM / core: Clear the direct_complete flag on errors | |
5 | ||
6 | From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | |
7 | ||
8 | commit 69e445ab8b66a9f30519842ef18be555d3ee9b51 upstream. | |
9 | ||
10 | If __device_suspend() runs asynchronously (in which case the device | |
11 | passed to it is in dpm_suspended_list at that point) and it returns | |
12 | early on an error or pending wakeup, and the power.direct_complete | |
13 | flag has been set for the device already, the subsequent | |
14 | device_resume() will be confused by that and it will call | |
15 | pm_runtime_enable() incorrectly, as runtime PM has not been | |
16 | disabled for the device by __device_suspend(). | |
17 | ||
18 | To avoid that, clear power.direct_complete if __device_suspend() | |
19 | is not going to disable runtime PM for the device before returning. | |
20 | ||
21 | Fixes: aae4518b3124 (PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily) | |
22 | Reported-by: Al Cooper <alcooperx@gmail.com> | |
23 | Tested-by: Al Cooper <alcooperx@gmail.com> | |
24 | Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> | |
25 | Cc: 3.16+ <stable@vger.kernel.org> # 3.16+ | |
26 | Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> | |
27 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
28 | ||
29 | --- | |
30 | drivers/base/power/main.c | 5 ++++- | |
31 | 1 file changed, 4 insertions(+), 1 deletion(-) | |
32 | ||
33 | --- a/drivers/base/power/main.c | |
34 | +++ b/drivers/base/power/main.c | |
35 | @@ -1713,8 +1713,10 @@ static int __device_suspend(struct devic | |
36 | ||
37 | dpm_wait_for_subordinate(dev, async); | |
38 | ||
39 | - if (async_error) | |
40 | + if (async_error) { | |
41 | + dev->power.direct_complete = false; | |
42 | goto Complete; | |
43 | + } | |
44 | ||
45 | /* | |
46 | * If a device configured to wake up the system from sleep states | |
47 | @@ -1726,6 +1728,7 @@ static int __device_suspend(struct devic | |
48 | pm_wakeup_event(dev, 0); | |
49 | ||
50 | if (pm_wakeup_pending()) { | |
51 | + dev->power.direct_complete = false; | |
52 | async_error = -EBUSY; | |
53 | goto Complete; | |
54 | } |