From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Ulf Hansson <ulf.hansson@linaro.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: [PATCH 1/2] PM: suspend: Do not pause cpuidle in the suspend-to-idle path
Date: Fri, 22 Oct 2021 18:04:02 +0200 [thread overview]
Message-ID: <1813297.tdWV9SEqCh@kreacher> (raw)
In-Reply-To: <2230995.ElGaqSPkdT@kreacher>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
It is pointless to pause cpuidle in the suspend-to-idle path,
because it is going to be resumed in the same path later and
pausing it does not serve any particular purpose in that case.
Rework the code to avoid doing that.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/base/power/main.c | 11 ++++++-----
kernel/power/suspend.c | 8 ++++++--
2 files changed, 12 insertions(+), 7 deletions(-)
Index: linux-pm/drivers/base/power/main.c
===================================================================
--- linux-pm.orig/drivers/base/power/main.c
+++ linux-pm/drivers/base/power/main.c
@@ -747,8 +747,6 @@ void dpm_resume_noirq(pm_message_t state
resume_device_irqs();
device_wakeup_disarm_wake_irqs();
-
- cpuidle_resume();
}
/**
@@ -881,6 +879,7 @@ void dpm_resume_early(pm_message_t state
void dpm_resume_start(pm_message_t state)
{
dpm_resume_noirq(state);
+ cpuidle_resume();
dpm_resume_early(state);
}
EXPORT_SYMBOL_GPL(dpm_resume_start);
@@ -1336,8 +1335,6 @@ int dpm_suspend_noirq(pm_message_t state
{
int ret;
- cpuidle_pause();
-
device_wakeup_arm_wake_irqs();
suspend_device_irqs();
@@ -1521,9 +1518,13 @@ int dpm_suspend_end(pm_message_t state)
if (error)
goto out;
+ cpuidle_pause();
+
error = dpm_suspend_noirq(state);
- if (error)
+ if (error) {
+ cpuidle_resume();
dpm_resume_early(resume_event(state));
+ }
out:
dpm_show_time(starttime, state, error, "end");
Index: linux-pm/kernel/power/suspend.c
===================================================================
--- linux-pm.orig/kernel/power/suspend.c
+++ linux-pm/kernel/power/suspend.c
@@ -97,7 +97,6 @@ static void s2idle_enter(void)
raw_spin_unlock_irq(&s2idle_lock);
cpus_read_lock();
- cpuidle_resume();
/* Push all the CPUs into the idle loop. */
wake_up_all_idle_cpus();
@@ -105,7 +104,6 @@ static void s2idle_enter(void)
swait_event_exclusive(s2idle_wait_head,
s2idle_state == S2IDLE_STATE_WAKE);
- cpuidle_pause();
cpus_read_unlock();
raw_spin_lock_irq(&s2idle_lock);
@@ -405,6 +403,9 @@ static int suspend_enter(suspend_state_t
if (error)
goto Devices_early_resume;
+ if (state != PM_SUSPEND_TO_IDLE)
+ cpuidle_pause();
+
error = dpm_suspend_noirq(PMSG_SUSPEND);
if (error) {
pr_err("noirq suspend of devices failed\n");
@@ -459,6 +460,9 @@ static int suspend_enter(suspend_state_t
dpm_resume_noirq(PMSG_RESUME);
Platform_early_resume:
+ if (state != PM_SUSPEND_TO_IDLE)
+ cpuidle_resume();
+
platform_resume_early(state);
Devices_early_resume:
next prev parent reply other threads:[~2021-10-22 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 16:02 [PATCH 0/2] PM: sleep: Rework cpuidle handling during system-wide PM transitions Rafael J. Wysocki
2021-10-22 16:04 ` Rafael J. Wysocki [this message]
2021-10-25 14:23 ` [PATCH 1/2] PM: suspend: Do not pause cpuidle in the suspend-to-idle path Ulf Hansson
2021-10-22 16:07 ` [PATCH 2/2] PM: sleep: Pause cpuidle later and resume it earlier during system transitions Rafael J. Wysocki
2021-10-25 14:24 ` Ulf Hansson
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=1813297.tdWV9SEqCh@kreacher \
--to=rjw@rjwysocki.net \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=ulf.hansson@linaro.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).