Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1193778
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Viresh Kumar <viresh.kumar@linaro.org> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] cpufreq: Correct a freq check in cpufreq_set_policy |
| Date | Tue, 28 Jul 2015 07:30:04 +0200 |
| Message-ID | <pR5CI-86P-41@gated-at.bofh.it> (permalink) |
| References | <pR3Ud-5vX-1@gated-at.bofh.it> |
| X-Original-To | Pan Xinhui <xinhuix.pan@intel.com> |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=ABQDUhKBfXgTz8fsQ8gn80dt7PNVfwLA04/Zycjzd40=; b=F02YCpY5J9SrhnMI8x9l/qi6ECGtVr3L5F1P/4zP83l0qQVYSfg4abPvJxgSa19fQD s10TK6SRkQv+6pcU46uLqLbyh8r4UVw6MXRwv2EwASpDJPysWuFkxBrOVRvvRIDBkeJ4 1S8/IBr8sfzD+gWUczDFSnG2zuypDBMaumoF3/+/TpgoJ5VRfnCuPUihxFXZ/OBGZL0u dqvyyOUQJLhIzt05j/EZawcCGcSmInW3pen9hZsFjz6kj2OV6yeeZXcG1z03OqqrVMWy 7NTGr9e3wtdAZZlxJ85ZgQJJ6Rkgt3yTF+MU6h9ItmeEc5dlfDQbquaj8NR3XRqDLHPr 5fJw== |
| X-Gm-Message-State | ALoCoQmnLqau+1O9DvIOONE4uUcULn1b9Qog3otqMbvYqpotcurDDTkWrq+of39ivu0cIquPxgLM |
| X-Received | by 10.66.146.132 with SMTP id tc4mr76748927pab.124.1438061102029; Mon, 27 Jul 2015 22:25:02 -0700 (PDT) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 59 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>, "rjw@rjwysocki.net" <rjw@rjwysocki.net>, "mnipxh@163.com" <mnipxh@163.com>, "yanmin_zhang@linux.intel.com" <yanmin_zhang@linux.intel.com> |
| X-Original-Date | Tue, 28 Jul 2015 10:54:57 +0530 |
| X-Original-Message-ID | <20150728052457.GB31364@linux> |
| X-Original-References | <55B6F83D.3040901@intel.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | aioe.org linux.kernel:1193778 |
Show key headers only | View raw
On 28-07-15, 11:34, Pan Xinhui wrote:
> From: Pan Xinhui <xinhuix.pan@intel.com>
>
> This check was originally added by commit 9c9a43ed2734 ("[CPUFREQ]
> return error when failing to set minfreq").It attempt to return an error
> on obviously incorrect limits when we echo xxx >.../scaling_max,min_freq
> Actually we just need check if new_policy->min > new_policy->max.
> Because at least one of max/min is copied from cpufreq_get_policy().
>
> For example, when we echo xxx > .../scaling_min_freq, new_policy is
> copied from policy in cpufreq_get_policy. new_policy->max is same with
> policy->max. new_policy->min is set to a new value.
>
> Let me explain it in deduction method, first statment in if ():
> new_policy->min > policy->max
> policy->max == new_policy->max
> ==> new_policy->min > new_policy->max
>
> second statment in if():
> new_policy->max < policy->min
> policy->max < policy->min
> ==>new_policy->min > new_policy->max (induction method)
>
> So we have proved that we only need check if new_policy->min >
> new_policy->max.
>
> After apply this patch, we can also modify ->min and ->max in same time
> if new freq range is very much different from current freq range. For
> example, if current freq range is 480000-960000, then we want to set
> this range to 1120000-2240000, we would fail in the past because
> new_policy->min > policy->max. As long as the cpufreq range is valid, we
> has no reason to reject the user. So correct the check.
>
> Signed-off-by: Pan Xinhui <xinhuix.pan@intel.com>
> ---
> drivers/cpufreq/cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 6424e05..8772346 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2276,7 +2276,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
>
> memcpy(&new_policy->cpuinfo, &policy->cpuinfo, sizeof(policy->cpuinfo));
>
> - if (new_policy->min > policy->max || new_policy->max < policy->min)
> + if (new_policy->min > new_policy->max)
> return -EINVAL;
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [PATCH] cpufreq: Correct a freq check in cpufreq_set_policy Viresh Kumar <viresh.kumar@linaro.org> - 2015-07-28 07:30 +0200
csiph-web