diff mbox

PM / Runtime: Fix error path in pm_runtime_force_resume()

Message ID 1460113823-32290-1-git-send-email-ulf.hansson@linaro.org
State Accepted
Commit 0ae3aeefabbeef26294e7a349b51f1c761d46c9f
Headers show

Commit Message

Ulf Hansson April 8, 2016, 11:10 a.m. UTC
As pm_runtime_set_active() may fail because the device's parent isn't
active, we can end up executing the ->runtime_resume() callback for the
device when it isn't allowed.

Fix this by invoking pm_runtime_set_active() before running the callback
and let's also deal with the error code.

Fixes: 37f204164dfb ("PM: Add pm_runtime_suspend|resume_force functions")
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---
 drivers/base/power/runtime.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

-- 
1.9.1

Comments

Linus Walleij April 9, 2016, 4:18 p.m. UTC | #1
On Fri, Apr 8, 2016 at 1:10 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> As pm_runtime_set_active() may fail because the device's parent isn't

> active, we can end up executing the ->runtime_resume() callback for the

> device when it isn't allowed.

>

> Fix this by invoking pm_runtime_set_active() before running the callback

> and let's also deal with the error code.

>

> Fixes: 37f204164dfb ("PM: Add pm_runtime_suspend|resume_force functions")

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


Oh I recognize that. I saw that behaviour. This should fix it.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>


Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 4c70550..b746904 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1506,11 +1506,16 @@  int pm_runtime_force_resume(struct device *dev)
 		goto out;
 	}
 
-	ret = callback(dev);
+	ret = pm_runtime_set_active(dev);
 	if (ret)
 		goto out;
 
-	pm_runtime_set_active(dev);
+	ret = callback(dev);
+	if (ret) {
+		pm_runtime_set_suspended(dev);
+		goto out;
+	}
+
 	pm_runtime_mark_last_busy(dev);
 out:
 	pm_runtime_enable(dev);