linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dexuan Cui <decui@microsoft.com>
To: linux-pm@vger.kernel.org, rjw@rjwysocki.net, len.brown@intel.com,
	pavel@ucw.cz, bvanassche@acm.org, mikelley@microsoft.com,
	longli@microsoft.com
Cc: linux-kernel@vger.kernel.org, ming.lei@redhat.com,
	wei.liu@kernel.org, sthemmin@microsoft.com,
	haiyangz@microsoft.com, kys@microsoft.com,
	Dexuan Cui <decui@microsoft.com>,
	stable@vger.kernel.org
Subject: [PATCH] PM: hibernate: Freeze kernel threads in software_resume()
Date: Thu, 23 Apr 2020 20:40:16 -0700	[thread overview]
Message-ID: <20200424034016.42046-1-decui@microsoft.com> (raw)

Currently the kernel threads are not frozen in software_resume(), so
between dpm_suspend_start(PMSG_QUIESCE) and resume_target_kernel(),
system_freezable_power_efficient_wq can still try to submit SCSI
commands and this can cause a panic since the low level SCSI driver
(e.g. hv_storvsc) has quiesced the SCSI adapter and can not accept
any SCSI commands: https://lkml.org/lkml/2020/4/10/47

At first I posted a fix (https://lkml.org/lkml/2020/4/21/1318) trying
to resolve the issue from hv_storvsc, but with the help of
Bart Van Assche, I realized it's better to fix software_resume(),
since this looks like a generic issue, not only pertaining to SCSI.

Cc: Bart Van Assche <bvanassche@acm.org>
Cc: stable@vger.kernel.org
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
 kernel/power/hibernate.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 86aba8706b16..30bd28d1d418 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -898,6 +898,13 @@ static int software_resume(void)
 	error = freeze_processes();
 	if (error)
 		goto Close_Finish;
+
+	error = freeze_kernel_threads();
+	if (error) {
+		thaw_processes();
+		goto Close_Finish;
+	}
+
 	error = load_image_and_restore();
 	thaw_processes();
  Finish:
-- 
2.19.1


             reply	other threads:[~2020-04-24  3:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24  3:40 Dexuan Cui [this message]
2020-04-26 15:03 ` [PATCH] PM: hibernate: Freeze kernel threads in software_resume() Sasha Levin
2020-04-26 16:24 ` Rafael J. Wysocki
2020-04-26 18:33   ` Bart Van Assche
2020-04-27  0:58     ` Dexuan Cui
2020-04-27  8:43     ` 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=20200424034016.42046-1-decui@microsoft.com \
    --to=decui@microsoft.com \
    --cc=bvanassche@acm.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=mikelley@microsoft.com \
    --cc=ming.lei@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=stable@vger.kernel.org \
    --cc=sthemmin@microsoft.com \
    --cc=wei.liu@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;
as well as URLs for NNTP newsgroup(s).