From 3853eee3a7aae2eda1bb8f9f0c9b8226cbba4bfb Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Mon, 26 Mar 2012 22:46:52 +0200 Subject: [PATCH] PM / Runtime: don't forget to wake up waitqueue on failure commit f2791d733a2f06997b573d1a3cfde21e6f529826 upstream. This patch (as1535) fixes a bug in the runtime PM core. When a runtime suspend attempt completes, whether successfully or not, the device's power.wait_queue is supposed to be signalled. But this doesn't happen in the failure pathway of rpm_suspend() when another autosuspend attempt is rescheduled. As a result, a task can get stuck indefinitely on the wait queue (I have seen this happen in testing). The patch fixes the problem by moving the wake_up_all() call up near the start of the failure code. Signed-off-by: Alan Stern Signed-off-by: Rafael J. Wysocki [bwh: Backported to 3.2: adjust context and indentation] Signed-off-by: Ben Hutchings --- drivers/base/power/runtime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 8c78443..2424be5 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -417,6 +417,8 @@ static int rpm_suspend(struct device *dev, int rpmflags) if (retval) { __update_runtime_status(dev, RPM_ACTIVE); dev->power.deferred_resume = false; + wake_up_all(&dev->power.wait_queue); + if (retval == -EAGAIN || retval == -EBUSY) { dev->power.runtime_error = 0; @@ -432,7 +434,6 @@ static int rpm_suspend(struct device *dev, int rpmflags) } else { pm_runtime_cancel_pending(dev); } - wake_up_all(&dev->power.wait_queue); goto out; } no_callback: -- 1.7.9.5