linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM / suspend: Abort suspend if somebody holds wakelock
@ 2021-10-06 16:27 Mukesh Ojha
  2021-10-06 16:33 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Mukesh Ojha @ 2021-10-06 16:27 UTC (permalink / raw)
  To: linux-pm, linux-kernel; +Cc: rafael, len.brown, pavel, Mukesh Ojha

There could be a scenario, where request_firmware() call results in
user land process trying to load firmwares into memory and
parallely one miscellaneous process is trying to invoke manual
suspend and due to which user mode helper gets disabled during
freezing of processes and that aborts loading of firmware even
though request_firmware() thread has taken wakelock.

Although, we are checking for any wakeup event inside
try_to_freeze_tasks() but that could be too late for the
above scenario.

Let's add a check before freezing/disable user land process in
suspend path.

Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
---
 kernel/power/process.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/power/process.c b/kernel/power/process.c
index 37401c9..3e0d3d6 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -124,6 +124,9 @@ int freeze_processes(void)
 {
 	int error;
 
+	if (pm_wakeup_pending())
+		return -EBUSY;
+
 	error = __usermodehelper_disable(UMH_FREEZING);
 	if (error)
 		return error;
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PM / suspend: Abort suspend if somebody holds wakelock
  2021-10-06 16:27 [PATCH] PM / suspend: Abort suspend if somebody holds wakelock Mukesh Ojha
@ 2021-10-06 16:33 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-10-06 16:33 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Linux PM, Linux Kernel Mailing List, Rafael J. Wysocki,
	Len Brown, Pavel Machek

On Wed, Oct 6, 2021 at 6:27 PM Mukesh Ojha <mojha@codeaurora.org> wrote:
>
> There could be a scenario, where request_firmware() call results in
> user land process trying to load firmwares into memory and
> parallely one miscellaneous process is trying to invoke manual
> suspend and due to which user mode helper gets disabled during
> freezing of processes and that aborts loading of firmware even
> though request_firmware() thread has taken wakelock.
>
> Although, we are checking for any wakeup event inside
> try_to_freeze_tasks() but that could be too late for the
> above scenario.
>
> Let's add a check before freezing/disable user land process in
> suspend path.

If a laptop lid is closed and the system is expected to suspend, it
must suspend.

This takes precedence over the loading of firmware.  Sorry.

> Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
> ---
>  kernel/power/process.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/kernel/power/process.c b/kernel/power/process.c
> index 37401c9..3e0d3d6 100644
> --- a/kernel/power/process.c
> +++ b/kernel/power/process.c
> @@ -124,6 +124,9 @@ int freeze_processes(void)
>  {
>         int error;
>
> +       if (pm_wakeup_pending())
> +               return -EBUSY;
> +
>         error = __usermodehelper_disable(UMH_FREEZING);
>         if (error)
>                 return error;
> --
> Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
> Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-06 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 16:27 [PATCH] PM / suspend: Abort suspend if somebody holds wakelock Mukesh Ojha
2021-10-06 16:33 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).