linux/drivers/base/power
Shibo Zhu cb258d651d PM: sleep: Unblock runtime PM when device prepare fails
device_prepare() blocks runtime PM for a device with runtime PM disabled
before invoking its system-sleep ->prepare() callback. For a device that
has never enabled runtime PM, this changes dev->power.last_status from
RPM_INVALID to RPM_BLOCKED.

If the callback returns an error, dpm_prepare() does not move the device
to dpm_prepared_list. Consequently, the recovery path through
dpm_complete() never calls device_complete() for the failing device.

The error path drops the runtime PM usage reference, but does not clear
RPM_BLOCKED. A later legitimate pm_runtime_enable() then reports:

  Attempt to enable runtime PM when it is blocked

before clearing the stale state.

Call pm_runtime_unblock() on the prepare error path before dropping the
runtime PM reference, matching the cleanup performed by device_complete().

The issue was reproduced with a platform test device whose ->prepare()
callback returns -EIO while runtime PM has never been enabled. Before
the fix, last_status remained RPM_BLOCKED after the failed suspend and
the first pm_runtime_enable() produced the warning above. With the fix,
last_status is restored to RPM_INVALID and the warning is absent.

Fixes: 3e5eee147b ("PM: Block enabling of runtime PM during system suspend")
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Shibo Zhu <3499129952@qq.com>
Link: https://patch.msgid.link/tencent_C5AC0A02FC01F700E764F8C2E3ECE4F41009@qq.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-08-20 23:18:15 +02:00
..
clock_ops.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
common.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
generic_ops.c PM: sleep: Introduce CALL_PM_OP() macro to simplify code 2025-10-20 19:54:25 +02:00
main.c PM: sleep: Unblock runtime PM when device prepare fails 2026-08-20 23:18:15 +02:00
Makefile PM: runtime: Add basic kunit tests for API contracts 2025-09-27 13:41:47 +02:00
power.h PM: wakeup: Add kfuncs to traverse over wakeup_sources 2026-05-14 16:04:35 -07:00
qos-test.c kunit: allow kunit tests to be loaded as a module 2020-01-09 16:42:29 -07:00
qos.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
runtime-test.c PM: runtime: Stop checking pm_runtime_barrier() return code 2025-12-04 20:38:13 +01:00
runtime.c PM: runtime: Only set runtime_error on suspend callback failures 2026-07-09 16:50:18 +02:00
sysfs.c PM: sysfs: Move debug runtime PM attributes to runtime_attrs[] 2025-05-09 15:59:27 +02:00
trace.c PM: sleep: Replace snprintf() with scnprintf() in show_trace_dev_match() 2025-10-13 21:19:12 +02:00
wakeirq.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
wakeup_stats.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
wakeup.c PM: wakeup: Add kfuncs to traverse over wakeup_sources 2026-05-14 16:04:35 -07:00