Skip to contentSkip to conversation

PM: runtime: Document that force_suspend() is incompatible with SMART_SUSPEND

PATCH Applied Richard Fitzgerald 2 participants 2 messages Dec 13, 2022 – Jan 13, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: runtime: Document that force_suspend() is incompatible with SMART_SUSPEND

pm_runtime_force_suspend() cannot be used with DPM_FLAG_SMART_SUSPEND, so note this in the kerneldoc.

If DPM_FLAG_SMART_SUSPEND is set and the PM core cannot skip system resume it will call pm_runtime_active() on the driver. This can lead to an inconsistent state where:

pm_runtime_force_suspend() called ->runtime_suspend

but

device_resume_noirq() called pm_runtime_set_active()

This leaves the driver actually suspended but marked as active.

---
 drivers/base/power/runtime.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/base/power/runtime.c +4 -0
index 50e726b6c2cf..b29be7d4d7d0 100644
@@ -1864,6 +1864,10 @@ static bool pm_runtime_need_not_resume(struct device *dev)
  * sure the device is put into low power state and it should only be used during
  * system-wide PM transitions to sleep states.  It assumes that the analogous
  * pm_runtime_force_resume() will be used to resume the device.
+ *
+ * Do not use with DPM_FLAG_SMART_SUSPEND as this can lead to an inconsistent
+ * state where this function has called the ->runtime_suspend callback but the
+ * PM core marks the driver as runtime active.
  */
 int pm_runtime_force_suspend(struct device *dev)
 {
Signature · 1 line
2.30.2
maintainer Applied
#1 lore raw
Quoted 27 lines · Richard Fitzgerald

pm_runtime_force_suspend() cannot be used with DPM_FLAG_SMART_SUSPEND, so note this in the kerneldoc.

If DPM_FLAG_SMART_SUSPEND is set and the PM core cannot skip system resume it will call pm_runtime_active() on the driver. This can lead to an inconsistent state where:

pm_runtime_force_suspend() called ->runtime_suspend

but

device_resume_noirq() called pm_runtime_set_active()

This leaves the driver actually suspended but marked as active.

---
 drivers/base/power/runtime.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/base/power/runtime.c +0 -0
index 50e726b6c2cf..b29be7d4d7d0 100644
@@ -1864,6 +1864,10 @@ static bool pm_runtime_need_not_resume(struct device *dev)
  * sure the device is put into low power state and it should only be used during

drivers/base/power/runtime.c static bool pm_runtime_need_not_resume(struct device *dev)

Quoted 10 lines
drivers/base/power/runtime.c +4 -1
  * system-wide PM transitions to sleep states.  It assumes that the analogous
  * pm_runtime_force_resume() will be used to resume the device.
+ *
+ * Do not use with DPM_FLAG_SMART_SUSPEND as this can lead to an inconsistent
+ * state where this function has called the ->runtime_suspend callback but the
+ * PM core marks the driver as runtime active.
  */
 int pm_runtime_force_suspend(struct device *dev)
 {
--

Applied as 6.3 material, thanks!