Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753847AbbHEXps (ORCPT ); Wed, 5 Aug 2015 19:45:48 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:47608 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1753680AbbHEXpd (ORCPT ); Wed, 5 Aug 2015 19:45:33 -0400 From: "Rafael J. Wysocki" To: Pan Xinhui Cc: "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" , Viresh Kumar , "mnipxh@163.com" , "yanmin_zhang@linux.intel.com" Subject: Re: [PATCH V2] cpufreq: Correct a freq check in cpufreq_set_policy Date: Thu, 06 Aug 2015 02:12:40 +0200 Message-ID: <1726260.KtyaKJ80d7@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/4.1.0-rc5+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <55B9F820.9090505@intel.com> References: <55B6F83D.3040901@intel.com> <55B9F820.9090505@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1928 Lines: 47 On Thursday, July 30, 2015 06:10:40 PM Pan Xinhui wrote: > From: Pan Xinhui > > 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 statement in if (): > new_policy->min > policy->max > policy->max == new_policy->max > ==> new_policy->min > new_policy->max > > second statement 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 at 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 to avoid such > case. > > Signed-off-by: Pan Xinhui Queued up for 4.3, thanks! -- I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- 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/