linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
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 1/2] cpuidle: Avoid calls to cpuidle_resume|pause() for s2idle
Date: Mon, 11 Oct 2021 12:04:44 +0200	[thread overview]
Message-ID: <CAPDyKFoo+xXxgqQ71eSObrHyB-djKWkTtOO+nKdhBybOppNgBQ@mail.gmail.com> (raw)
In-Reply-To: <4692163.31r3eYUQgx@kreacher>

On Sat, 9 Oct 2021 at 17:39, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>
> On Wednesday, September 29, 2021 4:44:50 PM CEST Ulf Hansson wrote:
> > In s2idle_enter(), cpuidle_resume|pause() are invoked to re-allow calls to
> > the cpuidle callbacks during s2idle operations. This is needed because
> > cpuidle is paused in-between in dpm_suspend_noirq() and dpm_resume_noirq().
>
> Well, in fact, doing that last thing for s2idle is pointless, because cpuidle
> is going to be resumed eventually anyway in that case and the breakage expected
> to be prevented by the pausing will still occur.
>
> So I would rather do something like the patch below (untested).

Hi Rafael,

From a standalone change point of view, what you suggest seems reasonable to me.

However, the main issue I am really trying to fix in this series is
being done in patch2/2. And unfortunately, the below change doesn't
really fit with what I suggest in patch2/2. Can you please have a look
at patch2 as well?

If you think it may be better, I squash the two patches?

Kind regards
Uffe

>
> ---
>  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:
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-10-11 10:12 UTC|newest]

Thread overview: 27+ 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
     [not found]   ` <07e6821c-c221-e90d-c977-4d6b55c1ab8d@codeaurora.org>
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 [this message]
2021-09-29 14:44 ` [PATCH 2/2] PM: sleep: Fix runtime PM based cpuidle support Ulf Hansson
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
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 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=CAPDyKFoo+xXxgqQ71eSObrHyB-djKWkTtOO+nKdhBybOppNgBQ@mail.gmail.com \
    --to=ulf.hansson@linaro.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=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --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: 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).