]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.18.14/pm-core-clear-the-direct_complete-flag-on-errors.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.18.14 / pm-core-clear-the-direct_complete-flag-on-errors.patch
CommitLineData
7c34048e
GKH
1From 69e445ab8b66a9f30519842ef18be555d3ee9b51 Mon Sep 17 00:00:00 2001
2From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
3Date: Thu, 4 Oct 2018 11:08:12 +0200
4Subject: PM / core: Clear the direct_complete flag on errors
5
6From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7
8commit 69e445ab8b66a9f30519842ef18be555d3ee9b51 upstream.
9
10If __device_suspend() runs asynchronously (in which case the device
11passed to it is in dpm_suspended_list at that point) and it returns
12early on an error or pending wakeup, and the power.direct_complete
13flag has been set for the device already, the subsequent
14device_resume() will be confused by that and it will call
15pm_runtime_enable() incorrectly, as runtime PM has not been
16disabled for the device by __device_suspend().
17
18To avoid that, clear power.direct_complete if __device_suspend()
19is not going to disable runtime PM for the device before returning.
20
21Fixes: aae4518b3124 (PM / sleep: Mechanism to avoid resuming runtime-suspended devices unnecessarily)
22Reported-by: Al Cooper <alcooperx@gmail.com>
23Tested-by: Al Cooper <alcooperx@gmail.com>
24Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
25Cc: 3.16+ <stable@vger.kernel.org> # 3.16+
26Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
27Signed-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 }