Linux Power Management development
 help / color / mirror / Atom feed
From: Mukesh Ojha <mojha@codeaurora.org>
To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: rafael@kernel.org, len.brown@intel.com, pavel@ucw.cz,
	Mukesh Ojha <mojha@codeaurora.org>
Subject: [PATCH] PM / suspend: Abort suspend if somebody holds wakelock
Date: Wed,  6 Oct 2021 21:57:20 +0530	[thread overview]
Message-ID: <1633537640-15800-1-git-send-email-mojha@codeaurora.org> (raw)

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


             reply	other threads:[~2021-10-06 16:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 16:27 Mukesh Ojha [this message]
2021-10-06 16:33 ` [PATCH] PM / suspend: Abort suspend if somebody holds wakelock Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1633537640-15800-1-git-send-email-mojha@codeaurora.org \
    --to=mojha@codeaurora.org \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox