From: Rafael J. Wysocki Date: Thu, 27 Feb 2025 10:49:12 +0000 (+0100) Subject: PM: core: Tweak pm_runtime_block_if_disabled() return value X-Git-Tag: v6.15-rc1~191^2~1^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a84c2a885bc62a61e08fbcd9976a2a40400470c0;p=thirdparty%2Flinux.git 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 Reviewed-by: Ulf Hansson Link: https://patch.msgid.link/13718674.uLZWGnKmhe@rjwysocki.net --- diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 2f86d7cfdbbce..9215ec9f326b2 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1897,7 +1897,7 @@ unlock: 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); diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 42a58ed45a086..18e40dce460a2 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1466,8 +1466,8 @@ bool pm_runtime_block_if_disabled(struct device *dev) 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);