linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Bo Yan <byan@nvidia.com>
Cc: viresh.kumar@linaro.org, sgurrappadi@nvidia.com,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: skip cpufreq resume if it's not suspended
Date: Fri, 02 Feb 2018 12:54:17 +0100	[thread overview]
Message-ID: <17447147.z6jfkRxuEB@aspire.rjw.lan> (raw)
In-Reply-To: <913f1715-bdd0-1c03-ad76-38be9d3d2298@nvidia.com>

On Wednesday, January 24, 2018 9:53:14 PM CET Bo Yan wrote:
> 
> On 01/23/2018 06:02 PM, Rafael J. Wysocki wrote:
> > On Tuesday, January 23, 2018 10:57:55 PM CET Bo Yan wrote:
> >>   drivers/cpufreq/cpufreq.c | 4 ++++
> >>   1 file changed, 4 insertions(+)
> >>
> >> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> >> index 41d148af7748..95b1c4afe14e 100644
> >> --- a/drivers/cpufreq/cpufreq.c
> >> +++ b/drivers/cpufreq/cpufreq.c
> >> @@ -1680,6 +1680,10 @@ void cpufreq_resume(void)
> >>   	if (!cpufreq_driver)
> >>   		return;
> >>   
> >> +	if (unlikely(!cpufreq_suspended)) {
> >> +		pr_warn("%s: resume after failing suspend\n", __func__);
> >> +		return;
> >> +	}
> >>   	cpufreq_suspended = false;
> >>   
> >>   	if (!has_target() && !cpufreq_driver->resume)
> >>
> > Good catch, but rather than doing this it would be better to avoid
> > calling cpufreq_resume() at all if cpufreq_suspend() has not been called.
> Yes, I thought about that, but there is no good way to skip over it 
> without introducing another flag. cpufreq_resume is called by 
> dpm_resume, cpufreq_suspend is called by dpm_suspend. In the failure 
> case, dpm_resume is called, but dpm_suspend is not. So on a higher level 
> it's already unbalanced.
> 
> One possibility is to rely on the pm_transition flag. So something like:
> 
> 
> diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
> index dc259d20c967..8469e6fc2b2c 100644
> --- a/drivers/base/power/main.c
> +++ b/drivers/base/power/main.c
> @@ -842,6 +842,7 @@ static void async_resume(void *data, async_cookie_t 
> cookie)
>   void dpm_resume(pm_message_t state)
>   {
>          struct device *dev;
> +       bool suspended = (pm_transition.event != PM_EVENT_ON);
>          ktime_t starttime = ktime_get();
> 
>          trace_suspend_resume(TPS("dpm_resume"), state.event, true);
> @@ -885,7 +886,8 @@ void dpm_resume(pm_message_t state)
>          async_synchronize_full();
>          dpm_show_time(starttime, state, NULL);
> 
> -       cpufreq_resume();
> +       if (likely(suspended))
> +               cpufreq_resume();
>          trace_suspend_resume(TPS("dpm_resume"), state.event, false);
>   }

I was thinking about something else.

Anyway, I think your original patch is OK too, but without printing the
message.  Just combine the cpufreq_suspended check with the cpufreq_driver
one and the unlikely() thing is not necessary.

Thanks,
Rafael

  reply	other threads:[~2018-02-02 11:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-23 21:57 [PATCH] cpufreq: skip cpufreq resume if it's not suspended Bo Yan
2018-01-24  2:02 ` Rafael J. Wysocki
2018-01-24 20:53   ` Bo Yan
2018-02-02 11:54     ` Rafael J. Wysocki [this message]
2018-02-02 19:34       ` Saravana Kannan
2018-02-02 21:28         ` Bo Yan
2018-02-05  4:01           ` Viresh Kumar
2018-02-05  8:50             ` Rafael J. Wysocki
2018-02-05  9:05               ` Viresh Kumar
2018-02-15 21:27                 ` Saravana Kannan
2018-02-15 22:06                   ` Rafael J. Wysocki
2018-01-25 19:15   ` [PATCH v2] " Bo Yan
2018-02-05  9:19 ` [PATCH] " Rafael J. Wysocki
2018-02-05  9:23   ` Viresh Kumar

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=17447147.z6jfkRxuEB@aspire.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=byan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=sgurrappadi@nvidia.com \
    --cc=viresh.kumar@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).