Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: Replace "max_transition_latency" with "dynamic_switching"

There is no limitation in the ondemand or conservative governors which
disallow the transition_latency to be greater than 10 ms.

The max_transition_latency field is rather used to disallow automatic
dynamic frequency switching for platforms which didn't wanted these
governors to run.

Replace max_transition_latency with a boolean (dynamic_switching) and
check for transition_latency == CPUFREQ_ETERNAL along with that. This
makes it pretty straight forward to read/understand now.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Viresh Kumar and committed by
Rafael J. Wysocki
ed4676e2 768608a5

+7 -12
+4 -4
drivers/cpufreq/cpufreq.c
··· 2003 2003 if (!policy->governor) 2004 2004 return -EINVAL; 2005 2005 2006 - if (policy->governor->max_transition_latency && 2007 - policy->cpuinfo.transition_latency > 2008 - policy->governor->max_transition_latency) { 2006 + /* Platform doesn't want dynamic frequency switching ? */ 2007 + if (policy->governor->dynamic_switching && 2008 + policy->cpuinfo.transition_latency == CPUFREQ_ETERNAL) { 2009 2009 struct cpufreq_governor *gov = cpufreq_fallback_governor(); 2010 2010 2011 2011 if (gov) { 2012 - pr_warn("%s governor failed, too long transition latency of HW, fallback to %s governor\n", 2012 + pr_warn("Transition latency set to CPUFREQ_ETERNAL, can't use %s governor. Fallback to %s governor\n", 2013 2013 policy->governor->name, gov->name); 2014 2014 policy->governor = gov; 2015 2015 } else {
+1 -1
drivers/cpufreq/cpufreq_governor.h
··· 159 159 #define CPUFREQ_DBS_GOVERNOR_INITIALIZER(_name_) \ 160 160 { \ 161 161 .name = _name_, \ 162 - .max_transition_latency = TRANSITION_LATENCY_LIMIT, \ 162 + .dynamic_switching = true, \ 163 163 .owner = THIS_MODULE, \ 164 164 .init = cpufreq_dbs_governor_init, \ 165 165 .exit = cpufreq_dbs_governor_exit, \
+2 -7
include/linux/cpufreq.h
··· 487 487 * polling frequency is 1000 times the transition latency of the processor. The 488 488 * ondemand governor will work on any processor with transition latency <= 10ms, 489 489 * using appropriate sampling rate. 490 - * 491 - * For CPUs with transition latency > 10ms (mostly drivers with CPUFREQ_ETERNAL) 492 - * the ondemand governor will not work. All times here are in us (microseconds). 493 490 */ 494 491 #define LATENCY_MULTIPLIER (1000) 495 - #define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000) 496 492 497 493 struct cpufreq_governor { 498 494 char name[CPUFREQ_NAME_LEN]; ··· 501 505 char *buf); 502 506 int (*store_setspeed) (struct cpufreq_policy *policy, 503 507 unsigned int freq); 504 - unsigned int max_transition_latency; /* HW must be able to switch to 505 - next freq faster than this value in nano secs or we 506 - will fallback to performance governor */ 508 + /* For governors which change frequency dynamically by themselves */ 509 + bool dynamic_switching; 507 510 struct list_head governor_list; 508 511 struct module *owner; 509 512 };