From: Kazuki Hashimoto <kazukih0205@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Hector Martin <marcan@marcan.st>,
Kazuki Hashimoto <kazukih0205@gmail.com>
Subject: [PATCH 2/2] PM: s2idle: Fully prevent the system from entering s2idle when cpuidle isn't supported
Date: Tue, 11 Jul 2023 14:54:22 +0900 [thread overview]
Message-ID: <20230711-cpuidle-v1-2-f391224b3140@gmail.com> (raw)
In-Reply-To: <20230711-cpuidle-v1-0-f391224b3140@gmail.com>
In order for systems to properly enter s2idle, we need functions both in
the idle subsystem (such as call_cpuidle_s2idle()) and the suspend subsystem
to be executed.
s2idle got blocked in the idle subsystem on platforms without cpuidle after
commit ef2b22ac540c ("cpuidle / sleep: Use broadcast timer for states that stop
local timer"). However, the suspend subsystem doesn't have this, which can cause
the suspend subsystem to begin entering s2idle behind the idle subsystem's back,
which in turn can cause the system to enter s2idle even though all the functions
necessary for s2idle hasn't been executed, breaking the system
(e.g. ClOCK_MONOTONIC keeps ticking during suspend even though it's not supposed
to).
Prevent the system from entering s2idle when cpuidle isn't supported in the
suspend subsystem as well.
Fixes: ef2b22ac540c ("cpuidle / sleep: Use broadcast timer for states that stop local timer")
Signed-off-by: Kazuki Hashimoto <kazukih0205@gmail.com>
---
kernel/power/main.c | 12 +++++++++---
kernel/power/suspend.c | 5 +++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/kernel/power/main.c b/kernel/power/main.c
index f6425ae3e8b0..82fedcf6032d 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -174,6 +174,8 @@ static ssize_t mem_sleep_show(struct kobject *kobj, struct kobj_attribute *attr,
for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++) {
if (i >= PM_SUSPEND_MEM && cxl_mem_active())
continue;
+ if (i == PM_SUSPEND_TO_IDLE && cpuidle_not_available())
+ continue;
if (mem_sleep_states[i]) {
const char *label = mem_sleep_states[i];
@@ -226,11 +228,15 @@ static ssize_t mem_sleep_store(struct kobject *kobj, struct kobj_attribute *attr
}
state = decode_suspend_state(buf, n);
- if (state < PM_SUSPEND_MAX && state > PM_SUSPEND_ON)
+ if (state == PM_SUSPEND_TO_IDLE && cpuidle_not_available())
+ goto err;
+ if (state < PM_SUSPEND_MAX && state > PM_SUSPEND_ON) {
mem_sleep_current = state;
- else
- error = -EINVAL;
+ goto out;
+ }
+ err:
+ error = -EINVAL;
out:
pm_autosleep_unlock();
return error ? error : n;
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index fa3bf161d13f..02cc76c9109e 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -556,6 +556,11 @@ static int enter_state(suspend_state_t state)
trace_suspend_resume(TPS("suspend_enter"), state, true);
if (state == PM_SUSPEND_TO_IDLE) {
+ if (cpuidle_not_available()) {
+ pr_warn("s2idle is unsupported when cpuidle is unavailable");
+ return -EINVAL;
+ }
+
#ifdef CONFIG_PM_DEBUG
if (pm_test_level != TEST_NONE && pm_test_level <= TEST_CPUS) {
pr_warn("Unsupported test mode for suspend to idle, please choose none/freezer/devices/platform.\n");
--
2.41.0
next prev parent reply other threads:[~2023-07-11 5:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-11 5:54 [PATCH 0/2] s2idle fixes for systems without cpuidle Kazuki Hashimoto
2023-07-11 5:54 ` [PATCH 1/2] cpuidle: Don't pass any values to cpuidle_not_available Kazuki Hashimoto
2023-07-11 7:42 ` Peter Zijlstra
2023-07-11 18:48 ` Kazuki Hashimoto
2023-07-11 5:54 ` Kazuki Hashimoto [this message]
2023-07-11 17:55 ` [PATCH 2/2] PM: s2idle: Fully prevent the system from entering s2idle when cpuidle isn't supported Rafael J. Wysocki
2023-07-11 18:38 ` Kazuki H
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=20230711-cpuidle-v1-2-f391224b3140@gmail.com \
--to=kazukih0205@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=mingo@redhat.com \
--cc=pavel@ucw.cz \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--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;
as well as URLs for NNTP newsgroup(s).