Skip to content

Commit a8636c8

Browse files
storulfrafaeljw
authored andcommitted
PM / Runtime: Don't allow to suspend a device with an active child
When resuming a device in __pm_runtime_set_status(), the prerequisite is that its parent must already be active, else an error code is returned and the device's status remains suspended. When suspending a device there is no similar constraints being validated. Let's change this to make the behaviour consistent, by not allowing to suspend a device with an active child, unless it has been explicitly set to ignore its children. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 8812872 commit a8636c8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/base/power/runtime.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,17 @@ int __pm_runtime_set_status(struct device *dev, unsigned int status)
10281028
goto out_set;
10291029

10301030
if (status == RPM_SUSPENDED) {
1031-
/* It always is possible to set the status to 'suspended'. */
1031+
/*
1032+
* It is invalid to suspend a device with an active child,
1033+
* unless it has been set to ignore its children.
1034+
*/
1035+
if (!dev->power.ignore_children &&
1036+
atomic_read(&dev->power.child_count)) {
1037+
dev_err(dev, "runtime PM trying to suspend device but active child\n");
1038+
error = -EBUSY;
1039+
goto out;
1040+
}
1041+
10321042
if (parent) {
10331043
atomic_add_unless(&parent->power.child_count, -1, 0);
10341044
notify_parent = !parent->power.ignore_children;

0 commit comments

Comments
 (0)