diff mbox series

[v1,03/10] PM: runtime: Use pm_runtime_no_support() in pm_runtime_force_suspend()

Message ID 9421808.CDJkKcVGEf@rjwysocki.net (mailing list archive)
State Superseded, archived
Headers show
Series PM: Make the core and pm_runtime_force_suspend/resume() agree more | expand

Commit Message

Rafael J. Wysocki Feb. 11, 2025, 9:05 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Currently, pm_runtime_force_suspend() does not distinguish devices
without runtime PM enabled and it may be called for such devices
incidentally.  In that case, it works inconsistently depending on
the device runtime PM status value which generally is not expected
to be meaningful for devices with runtime PM permanently disabled.

Namely, if the runtime PM status of the device is RPM_SUSPENDED, it
will be ignored as though it had been runtime-suspended, but if its
runtime PM status is RPM_ACTIVE, pm_runtime_force_suspend() will
attempt to suspend it which may not work.

Make pm_runtime_force_suspend() more consistent by adding a
pm_runtime_no_support() check to it that will cause it to skip
devices with no runtime PM support.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/base/power/runtime.c |    6 +++++-
 include/linux/pm_runtime.h   |   14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
diff mbox series

Patch

--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -1908,7 +1908,11 @@ 
 	int ret;
 
 	pm_runtime_disable(dev);
-	if (pm_runtime_status_suspended(dev))
+	/*
+	 * Do not attempt to suspend devices that have been suspended already or
+	 * that have never had runtime PM enabled.
+	 */
+	if (pm_runtime_status_suspended(dev) || pm_runtime_no_support(dev))
 		return 0;
 
 	callback = RPM_GET_CALLBACK(dev, runtime_suspend);