]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PM: core: Tweak pm_runtime_block_if_disabled() return value
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 27 Feb 2025 10:49:12 +0000 (11:49 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 3 Mar 2025 13:35:07 +0000 (14:35 +0100)
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
drivers/base/power/main.c
drivers/base/power/runtime.c

index 2f86d7cfdbbce1037b70f9671115ba902fb28875..9215ec9f326b282e90afe106fb05d6155d5bad4a 100644 (file)
@@ -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);
 
index 42a58ed45a0864f2691860bee70463139317bc75..18e40dce460a29fd0b2875a9c16a0ff8f07716a7 100644 (file)
@@ -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);