[PATCH] PM: sleep: Drop superfluous might_sleep() calls

Zhongqiu Han posted 1 patch 3 months, 3 weeks ago
drivers/base/power/main.c | 3 ---
1 file changed, 3 deletions(-)
[PATCH] PM: sleep: Drop superfluous might_sleep() calls
Posted by Zhongqiu Han 3 months, 3 weeks ago
Drop superfluous might_sleep() calls from dpm_resume(), dpm_complete(),
and dpm_prepare(). These functions already invoke primitives that
implicitly check for sleep in atomic context:

- dpm_resume() and dpm_complete() invoke mutex_lock(), which internally
  triggers might_sleep()
- dpm_prepare() calls wait_for_device_probe(), which internally uses
  flush_work(), and thus might_sleep()

These annotations are unnecessary and can be dropped to reduce clutter.

Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
---
 drivers/base/power/main.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index eebe699fdf4f..0f40c00c1401 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1095,7 +1095,6 @@ void dpm_resume(pm_message_t state)
 	ktime_t starttime = ktime_get();
 
 	trace_suspend_resume(TPS("dpm_resume"), state.event, true);
-	might_sleep();
 
 	pm_transition = state;
 	async_error = 0;
@@ -1198,7 +1197,6 @@ void dpm_complete(pm_message_t state)
 	struct list_head list;
 
 	trace_suspend_resume(TPS("dpm_complete"), state.event, true);
-	might_sleep();
 
 	INIT_LIST_HEAD(&list);
 	mutex_lock(&dpm_list_mtx);
@@ -2109,7 +2107,6 @@ int dpm_prepare(pm_message_t state)
 	int error = 0;
 
 	trace_suspend_resume(TPS("dpm_prepare"), state.event, true);
-	might_sleep();
 
 	/*
 	 * Give a chance for the known devices to complete their probes, before
-- 
2.43.0
Re: [PATCH] PM: sleep: Drop superfluous might_sleep() calls
Posted by Rafael J. Wysocki 3 months, 1 week ago
On Tue, Jun 17, 2025 at 10:47 AM Zhongqiu Han <quic_zhonhan@quicinc.com> wrote:
>
> Drop superfluous might_sleep() calls from dpm_resume(), dpm_complete(),
> and dpm_prepare(). These functions already invoke primitives that
> implicitly check for sleep in atomic context:
>
> - dpm_resume() and dpm_complete() invoke mutex_lock(), which internally
>   triggers might_sleep()
> - dpm_prepare() calls wait_for_device_probe(), which internally uses
>   flush_work(), and thus might_sleep()
>
> These annotations are unnecessary and can be dropped to reduce clutter.
>
> Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com>
> ---
>  drivers/base/power/main.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index eebe699fdf4f..0f40c00c1401 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -1095,7 +1095,6 @@ void dpm_resume(pm_message_t state)
>         ktime_t starttime = ktime_get();
>
>         trace_suspend_resume(TPS("dpm_resume"), state.event, true);
> -       might_sleep();
>
>         pm_transition = state;
>         async_error = 0;
> @@ -1198,7 +1197,6 @@ void dpm_complete(pm_message_t state)
>         struct list_head list;
>
>         trace_suspend_resume(TPS("dpm_complete"), state.event, true);
> -       might_sleep();
>
>         INIT_LIST_HEAD(&list);
>         mutex_lock(&dpm_list_mtx);
> @@ -2109,7 +2107,6 @@ int dpm_prepare(pm_message_t state)
>         int error = 0;
>
>         trace_suspend_resume(TPS("dpm_prepare"), state.event, true);
> -       might_sleep();
>
>         /*
>          * Give a chance for the known devices to complete their probes, before
> --

Applied as 6.17 material, thanks!