Skip to content

Commit a84c2a8

Browse files
committed
PM: core: Tweak pm_runtime_block_if_disabled() return value
Modify pm_runtime_block_if_disabled() to return true when runtime PM is disabled for the device, regardless of the power.last_status value. This effectively prevents "smart suspend" from being enabled for devices with runtime PM disabled in device_prepare(), even transiently, so update the related comment in that function accordingly. If a device has runtime PM disabled in device_prepare(), it is not actually known whether or not runtime PM will be enabled for that device going forward, so it is more appropriate to postpone the "smart suspend" optimization for the device in the given system suspend-resume cycle than to enable it and get confused going forward. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://patch.msgid.link/13718674.uLZWGnKmhe@rjwysocki.net
1 parent 1476bb2 commit a84c2a8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

drivers/base/power/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ static int device_prepare(struct device *dev, pm_message_t state)
18971897
pm_runtime_put(dev);
18981898
return ret;
18991899
}
1900-
/* Do not enable "smart suspend" for devices without runtime PM. */
1900+
/* Do not enable "smart suspend" for devices with disabled runtime PM. */
19011901
if (smart_suspend)
19021902
smart_suspend = device_prepare_smart_suspend(dev);
19031903

drivers/base/power/runtime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,8 +1466,8 @@ bool pm_runtime_block_if_disabled(struct device *dev)
14661466

14671467
spin_lock_irq(&dev->power.lock);
14681468

1469-
ret = dev->power.disable_depth && dev->power.last_status == RPM_INVALID;
1470-
if (ret)
1469+
ret = !pm_runtime_enabled(dev);
1470+
if (ret && dev->power.last_status == RPM_INVALID)
14711471
dev->power.last_status = RPM_BLOCKED;
14721472

14731473
spin_unlock_irq(&dev->power.lock);

0 commit comments

Comments
 (0)