Skip to content

Commit

Permalink
PM / Runtime: don't forget to wake up waitqueue on failure
Browse files Browse the repository at this point in the history
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 <stern@rowland.harvard.edu>
CC: <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
Alan Stern authored and Rafael J. Wysocki committed Mar 26, 2012
1 parent e22057c commit f2791d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/base/power/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ static int rpm_suspend(struct device *dev, int rpmflags)
dev->power.suspend_time = ktime_set(0, 0);
dev->power.max_time_suspended_ns = -1;
dev->power.deferred_resume = false;
wake_up_all(&dev->power.wait_queue);

if (retval == -EAGAIN || retval == -EBUSY) {
dev->power.runtime_error = 0;

Expand All @@ -547,7 +549,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;
}

Expand Down

0 comments on commit f2791d7

Please sign in to comment.