diff mbox series

[v1,3/3] PM: core: Tweak pm_runtime_block_if_disabled() return value

Message ID 13718674.uLZWGnKmhe@rjwysocki.net (mailing list archive)
State Queued
Delegated to: Rafael Wysocki
Headers show
Series PM: Tweaks on top of "smart suspend" handling changes | expand

Commit Message

Rafael J. Wysocki Feb. 27, 2025, 10:49 a.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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>
---
 drivers/base/power/main.c    |    2 +-
 drivers/base/power/runtime.c |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1891,7 +1891,7 @@ 
 		pm_runtime_put(dev);
 		return ret;
 	}
-	/* Do not enable "smart suspend" for devices without runtime PM. */
+	/* Do not enable "smart suspend" for devices with disabled runtime PM. */
 	if (smart_suspend)
 		smart_suspend = device_prepare_smart_suspend(dev);
 
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1466,8 +1466,8 @@ 
 
 	spin_lock_irq(&dev->power.lock);
 
-	ret = dev->power.disable_depth && dev->power.last_status == RPM_INVALID;
-	if (ret)
+	ret = !pm_runtime_enabled(dev);
+	if (ret && dev->power.last_status == RPM_INVALID)
 		dev->power.last_status = RPM_BLOCKED;
 
 	spin_unlock_irq(&dev->power.lock);