LKML Archive on lore.kernel.org help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org> To: Ulf Hansson <ulf.hansson@linaro.org> Cc: "Rafael J. Wysocki" <rafael@kernel.org>, Daniel Lezcano <daniel.lezcano@linaro.org>, Linux PM <linux-pm@vger.kernel.org>, Maulik Shah <mkshah@codeaurora.org>, Peter Zijlstra <peterz@infradead.org>, Vincent Guittot <vincent.guittot@linaro.org>, Len Brown <len.brown@intel.com>, Bjorn Andersson <bjorn.andersson@linaro.org>, Linux ARM <linux-arm-kernel@lists.infradead.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org> Subject: Re: [PATCH 2/2] PM: sleep: Fix runtime PM based cpuidle support Date: Thu, 21 Oct 2021 17:09:11 +0200 [thread overview] Message-ID: <CAJZ5v0iA4O=tx7qiLKCOze87dcUtwtDJqi2B+2O=oOyCSzgmtQ@mail.gmail.com> (raw) In-Reply-To: <CAPDyKFqeAFhgCFSaFAWnp5xorxSVwAL=z2g6vHJ0PWjtt9GDNg@mail.gmail.com> On Thu, Oct 21, 2021 at 4:05 PM Ulf Hansson <ulf.hansson@linaro.org> wrote: > > On Thu, 21 Oct 2021 at 15:45, Rafael J. Wysocki <rafael@kernel.org> wrote: > > > > On Thu, Oct 21, 2021 at 1:49 PM Ulf Hansson <ulf.hansson@linaro.org> wrote: > > > > > > On Wed, 20 Oct 2021 at 20:18, Rafael J. Wysocki <rafael@kernel.org> wrote: > > > > > > > > On Wed, Sep 29, 2021 at 4:44 PM Ulf Hansson <ulf.hansson@linaro.org> wrote: > > > > > > > > > > In the cpuidle-psci case, runtime PM in combination with the generic PM > > > > > domain (genpd), may be used when entering/exiting an idlestate. More > > > > > precisely, genpd relies on runtime PM to be enabled for the attached device > > > > > (in this case it belongs to a CPU), to properly manage the reference > > > > > counting of its PM domain. > > > > > > > > > > This works fine most of the time, but during system suspend in the > > > > > dpm_suspend_late() phase, the PM core disables runtime PM for all devices. > > > > > Beyond this point and until runtime PM becomes re-enabled in the > > > > > dpm_resume_early() phase, calls to pm_runtime_get|put*() will fail. > > > > > > > > > > To make sure the reference counting in genpd becomes correct, we need to > > > > > prevent cpuidle-psci from using runtime PM when it has been disabled for > > > > > the device. Therefore, let's move the call to cpuidle_pause() from > > > > > dpm_suspend_noirq() to dpm_suspend_late() - and cpuidle_resume() from > > > > > dpm_resume_noirq() into dpm_resume_early(). > > > > > > > > > > Diagnosed-by: Maulik Shah <mkshah@codeaurora.org> > > > > > Suggested-by: Maulik Shah <mkshah@codeaurora.org> > > > > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > > > > > --- > > > > > drivers/base/power/main.c | 6 ++---- > > > > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > > > > > > > diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c > > > > > index cbea78e79f3d..1c753b651272 100644 > > > > > --- a/drivers/base/power/main.c > > > > > +++ b/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(); > > > > > } > > > > > > > > > > /** > > > > > @@ -870,6 +868,7 @@ void dpm_resume_early(pm_message_t state) > > > > > } > > > > > mutex_unlock(&dpm_list_mtx); > > > > > async_synchronize_full(); > > > > > + cpuidle_resume(); > > > > > dpm_show_time(starttime, state, 0, "early"); > > > > > trace_suspend_resume(TPS("dpm_resume_early"), state.event, false); > > > > > } > > > > > @@ -1336,8 +1335,6 @@ int dpm_suspend_noirq(pm_message_t state) > > > > > { > > > > > int ret; > > > > > > > > > > - cpuidle_pause(); > > > > > - > > > > > device_wakeup_arm_wake_irqs(); > > > > > suspend_device_irqs(); > > > > > > > > > > @@ -1467,6 +1464,7 @@ int dpm_suspend_late(pm_message_t state) > > > > > int error = 0; > > > > > > > > > > trace_suspend_resume(TPS("dpm_suspend_late"), state.event, true); > > > > > + cpuidle_pause(); > > > > > mutex_lock(&dpm_list_mtx); > > > > > pm_transition = state; > > > > > async_error = 0; > > > > > -- > > > > > > > > Well, this is somewhat heavy-handed and it affects even the systems > > > > that don't really need to pause cpuidle at all in the suspend path. > > > > > > Yes, I agree. > > > > > > Although, I am not really changing the behaviour in regards to this. > > > cpuidle_pause() is already being called in dpm_suspend_noirq(), for > > > everybody today. > > > > Yes, it is, but pausing it earlier will cause more energy to be spent, > > potentially. > > > > That said, there are not too many users of suspend_late callbacks in > > the tree, so it may not matter too much. > > > > > > > > > > Also, IIUC you don't need to pause cpuidle completely, but make it > > > > temporarily avoid idle states potentially affected by this issue. An > > > > additional CPUIDLE_STATE_DISABLED_ flag could be used for that I > > > > suppose and it could be set via cpuidle_suspend() called from the core > > > > next to cpufreq_suspend(). > > > > > > cpuidle_suspend() would then need to go and fetch the cpuidle driver > > > instance, which in some cases is one driver per CPU. Doesn't that get > > > rather messy? > > > > Per-CPU variables are used for that, so it is quite straightforward. > > > > > Additionally, since find_deepest_state() is being called for > > > cpuidle_enter_s2idle() too, we would need to treat the new > > > CPUIDLE_STATE_DISABLED_ flag in a special way, right? > > > > No, it already checks "disabled". > > Yes, but that would be wrong. Hmmm. > The use case I want to support, for cpuidle-psci, is to allow all idle > states in suspend-to-idle, So does PM-runtime work in suspend-to-idle? How? > but prevent those that rely on runtime PM > (after it has been disabled) for the regular idle path. Do you have a special suspend-to-idle handling of those states that doesn't require PM-runtime? > > > > > Is this really what we want? > > > > > > > > > > > The other guys who rely on the cpuidle pausing today could be switched > > > > over to this new mechanism later and it would be possible to get rid > > > > of the pausing from the system suspend path completely. > > > > > > Avoiding to pause cpuidle when it's not needed makes perfect sense. > > > Although, it looks to me that we could also implement that on top of > > > $subject patch. > > > > Yes, it could. > > > > > Unless you insist on the CPUIDLE_STATE_DISABLED_ way, I would probably > > > explore an option to let a cpuidle driver to set a global cpuidle flag > > > during ->probe(). Depending if this flag is set, we can simply skip > > > calling cpuidle_pause() during system suspend. > > > > > > What do you think? > > > > Well, which driver in particular is in question here? > > Honestly, I don't know. It has not been my goal to entirely prevent > calling cpuidle_pause(). > > In any case, it was introduced in the below commit, perhaps that can > give us a hint when this is still needed? > > commit 8651f97bd951d0bb1c10fa24e3fa3455193f3548 > Author: Preeti U Murthy <preeti@linux.vnet.ibm.com> > Date: Mon Jul 9 10:12:56 2012 +0200 > PM / cpuidle: System resume hang fix with cpuidle Yes, I remember that.
next prev parent reply other threads:[~2021-10-21 15:09 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-29 14:44 [PATCH 0/2] cpuidle: Fix runtime PM based cpuidle for s2idle Ulf Hansson 2021-09-29 14:44 ` [PATCH 1/2] cpuidle: Avoid calls to cpuidle_resume|pause() " Ulf Hansson 2021-10-06 10:22 ` Maulik Shah 2021-10-06 13:10 ` Ulf Hansson 2021-10-09 15:42 ` Rafael J. Wysocki 2021-10-09 15:39 ` Rafael J. Wysocki 2021-10-11 10:04 ` Ulf Hansson 2021-09-29 14:44 ` [PATCH 2/2] PM: sleep: Fix runtime PM based cpuidle support Ulf Hansson 2021-10-06 10:28 ` Maulik Shah 2021-10-20 18:18 ` Rafael J. Wysocki 2021-10-21 11:48 ` Ulf Hansson 2021-10-21 13:45 ` Rafael J. Wysocki 2021-10-21 14:04 ` Ulf Hansson 2021-10-21 15:09 ` Rafael J. Wysocki [this message] 2021-10-21 15:45 ` Rafael J. Wysocki 2021-10-21 16:28 ` Ulf Hansson 2021-10-21 16:41 ` Rafael J. Wysocki 2021-10-21 17:05 ` Rafael J. Wysocki 2021-10-21 18:49 ` Ulf Hansson 2021-10-21 18:36 ` Ulf Hansson 2021-10-21 16:16 ` Ulf Hansson 2021-10-21 16:33 ` Rafael J. Wysocki 2021-10-21 18:11 ` Ulf Hansson 2021-10-21 19:02 ` Rafael J. Wysocki 2021-10-21 19:56 ` Ulf Hansson 2021-10-22 9:15 ` Maulik Shah 2021-10-22 10:18 ` Ulf Hansson 2021-10-22 12:02 ` Rafael J. Wysocki 2021-10-22 12:56 ` Ulf Hansson 2021-10-22 13:08 ` 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='CAJZ5v0iA4O=tx7qiLKCOze87dcUtwtDJqi2B+2O=oOyCSzgmtQ@mail.gmail.com' \ --to=rafael@kernel.org \ --cc=bjorn.andersson@linaro.org \ --cc=daniel.lezcano@linaro.org \ --cc=len.brown@intel.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pm@vger.kernel.org \ --cc=mkshah@codeaurora.org \ --cc=peterz@infradead.org \ --cc=ulf.hansson@linaro.org \ --cc=vincent.guittot@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: linkBe 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).