Re: [PATCH] PM: sleep: Use complete() instead of complete_all() in device_pm_sleep_init()
From: Rafael J. Wysocki
Date: Tue May 12 2026 - 15:26:00 EST
On Sat, May 9, 2026 at 11:27 AM Jiakai Xu <xujiakai24@xxxxxxxxxxxxxxxx> wrote:
>
> device_pm_sleep_init() is called during device initialization via
> device_initialize(), where no threads can be waiting on
> dev->power.completion. Using complete_all() here triggers a false-positive
> WARNING from lockdep_assert_RT_in_threaded_ctx() when
> CONFIG_PROVE_RAW_LOCK_NESTING is enabled, because holding a raw_spinlock
> elsewhere in the call chain makes lockdep_hardirq_context() appear non-zero.
>
> Replace complete_all() with complete(), which is semantically equivalent
> when no waiters exist (sets done to 1 instead of UINT_MAX). The completion
> is always reinitialized via reinit_completion() in dpm_clear_async_state()
> before each suspend/resume phase, so this initialization value has no
> effect on later suspend operations.
>
> Signed-off-by: Jiakai Xu <xujiakai24@xxxxxxxxxxxxxxxx>
> Fixes: 152e1d592071c ("PM: Prevent waiting forever on asynchronous resume after failing suspend")
> ---
> drivers/base/power/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index e1b550664bab..7a948dd134df 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -115,7 +115,7 @@ void device_pm_sleep_init(struct device *dev)
> dev->power.is_noirq_suspended = false;
> dev->power.is_late_suspended = false;
> init_completion(&dev->power.completion);
> - complete_all(&dev->power.completion);
> + complete(&dev->power.completion);
> dev->power.wakeup = NULL;
> INIT_LIST_HEAD(&dev->power.entry);
> }
> --
sashiko.dev complains about this one:
https://sashiko.dev/#/patchset/20260509092707.3426533-1-xujiakai24%40mails.ucas.ac.cn
and I think that it has a point.
Before this change, dpm_wait() needs to be updated to skip devices
with no PM support.