public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: Re: [PATCH] cpufreq: Restore policy min/max limits on CPU online
Date: Fri, 17 Mar 2017 08:50:16 +0530	[thread overview]
Message-ID: <20170317032016.GC31040@vireshk-i7> (raw)
In-Reply-To: <2084010.4xkKok06Gp@aspire.rjw.lan>

On 16-03-17, 23:42, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> On CPU online the cpufreq core restores the previous governor (or
> the previous "policy" setting for ->setpolicy drivers), but it does
> not restore the min/max limits at the same time, which is confusing,
> inconsistent and real pain for users who set the limits and then
> suspend/resume the system (using full suspend), in which case the
> limits are reset on all CPUs except for the boot one.
> 
> Fix this by making cpufreq_init_policy() restore the limits when it
> sees that this is CPU online and not initialization from scratch.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/cpufreq/cpufreq.c |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> Index: linux-pm/drivers/cpufreq/cpufreq.c
> ===================================================================
> --- linux-pm.orig/drivers/cpufreq/cpufreq.c
> +++ linux-pm/drivers/cpufreq/cpufreq.c
> @@ -979,6 +979,8 @@ static int cpufreq_init_policy(struct cp
>  	/* Update governor of new_policy to the governor used before hotplug */
>  	gov = find_governor(policy->last_governor);
>  	if (gov) {
> +		new_policy.min = policy->user_policy.min;
> +		new_policy.max = policy->user_policy.max;
>  		pr_debug("Restoring governor %s for cpu %d\n",
>  				policy->governor->name, policy->cpu);
>  	} else {
> @@ -991,11 +993,14 @@ static int cpufreq_init_policy(struct cp
>  
>  	/* Use the default policy if there is no last_policy. */
>  	if (cpufreq_driver->setpolicy) {
> -		if (policy->last_policy)
> +		if (policy->last_policy) {
>  			new_policy.policy = policy->last_policy;
> -		else
> +			new_policy.min = policy->user_policy.min;
> +			new_policy.max = policy->user_policy.max;
> +		} else {
>  			cpufreq_parse_governor(gov->name, &new_policy.policy,
>  					       NULL);
> +		}
>  	}
>  	/* set default policy */
>  	return cpufreq_set_policy(policy, &new_policy);

What about something like this instead ?

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b8ff617d449d..5dbdd261aa73 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1184,6 +1184,9 @@ static int cpufreq_online(unsigned int cpu)
                for_each_cpu(j, policy->related_cpus)
                        per_cpu(cpufreq_cpu_data, j) = policy;
                write_unlock_irqrestore(&cpufreq_driver_lock, flags);
+       } else {
+               policy->min = policy->user_policy.min;
+               policy->max = policy->user_policy.max;
        }
 
        if (cpufreq_driver->get && !cpufreq_driver->setpolicy) {


-- 
viresh

  reply	other threads:[~2017-03-17  3:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-16 22:42 [PATCH] cpufreq: Restore policy min/max limits on CPU online Rafael J. Wysocki
2017-03-17  3:20 ` Viresh Kumar [this message]
2017-03-17 16:31   ` Rafael J. Wysocki
2017-03-17 16:43     ` Viresh Kumar
2017-03-17 17:40       ` Rafael J. Wysocki
2017-03-20  3:21         ` Viresh Kumar
2017-03-20 12:30           ` Rafael J. Wysocki
2017-03-17 17:44       ` [PATCH v2] " 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=20170317032016.GC31040@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=srinivas.pandruvada@linux.intel.com \
    /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