Commit fe829ed8 authored by Viresh Kumar's avatar Viresh Kumar Committed by Rafael J. Wysocki

cpufreq: Add CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING cpufreq driver flag

The policy->transition_latency field is used for multiple purposes
today and its not straight forward at all. This is how it is used:

A. Set the correct transition_latency value.

B. Set it to CPUFREQ_ETERNAL because:
   1. We don't want automatic dynamic switching (with
      ondemand/conservative) to happen at all.
   2. We don't know the transition latency.

This patch handles the B.1. case in a more readable way. A new flag for
the cpufreq drivers is added to disallow use of cpufreq governors which
have dynamic_switching flag set.

All the current cpufreq drivers which are setting transition_latency
unconditionally to CPUFREQ_ETERNAL are updated to use it. They don't
need to set transition_latency anymore.

There shouldn't be any functional change after this patch.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 560c6e45
...@@ -357,7 +357,6 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy) ...@@ -357,7 +357,6 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy)
/* cpuinfo and default policy values */ /* cpuinfo and default policy values */
policy->min = policy->cpuinfo.min_freq = min_fsb * fid * 100; policy->min = policy->cpuinfo.min_freq = min_fsb * fid * 100;
policy->max = policy->cpuinfo.max_freq = max_fsb * fid * 100; policy->max = policy->cpuinfo.max_freq = max_fsb * fid * 100;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
return 0; return 0;
} }
...@@ -369,6 +368,7 @@ static int nforce2_cpu_exit(struct cpufreq_policy *policy) ...@@ -369,6 +368,7 @@ static int nforce2_cpu_exit(struct cpufreq_policy *policy)
static struct cpufreq_driver nforce2_driver = { static struct cpufreq_driver nforce2_driver = {
.name = "nforce2", .name = "nforce2",
.flags = CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.verify = nforce2_verify, .verify = nforce2_verify,
.target = nforce2_target, .target = nforce2_target,
.get = nforce2_get, .get = nforce2_get,
......
...@@ -2005,11 +2005,12 @@ static int cpufreq_init_governor(struct cpufreq_policy *policy) ...@@ -2005,11 +2005,12 @@ static int cpufreq_init_governor(struct cpufreq_policy *policy)
/* Platform doesn't want dynamic frequency switching ? */ /* Platform doesn't want dynamic frequency switching ? */
if (policy->governor->dynamic_switching && if (policy->governor->dynamic_switching &&
policy->cpuinfo.transition_latency == CPUFREQ_ETERNAL) { (cpufreq_driver->flags & CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING ||
policy->cpuinfo.transition_latency == CPUFREQ_ETERNAL)) {
struct cpufreq_governor *gov = cpufreq_fallback_governor(); struct cpufreq_governor *gov = cpufreq_fallback_governor();
if (gov) { if (gov) {
pr_warn("Transition latency set to CPUFREQ_ETERNAL, can't use %s governor. Fallback to %s governor\n", pr_warn("Can't use %s governor as dynamic switching is disallowed. Fallback to %s governor\n",
policy->governor->name, gov->name); policy->governor->name, gov->name);
policy->governor = gov; policy->governor = gov;
} else { } else {
......
...@@ -165,9 +165,6 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy) ...@@ -165,9 +165,6 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
if (pos->frequency > max_freq) if (pos->frequency > max_freq)
pos->frequency = CPUFREQ_ENTRY_INVALID; pos->frequency = CPUFREQ_ENTRY_INVALID;
/* cpuinfo and default policy values */
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
return cpufreq_table_validate_and_show(policy, elanfreq_table); return cpufreq_table_validate_and_show(policy, elanfreq_table);
} }
...@@ -196,6 +193,7 @@ __setup("elanfreq=", elanfreq_setup); ...@@ -196,6 +193,7 @@ __setup("elanfreq=", elanfreq_setup);
static struct cpufreq_driver elanfreq_driver = { static struct cpufreq_driver elanfreq_driver = {
.get = elanfreq_get_cpu_frequency, .get = elanfreq_get_cpu_frequency,
.flags = CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = elanfreq_target, .target_index = elanfreq_target,
.init = elanfreq_cpu_init, .init = elanfreq_cpu_init,
......
...@@ -428,7 +428,6 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy) ...@@ -428,7 +428,6 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
policy->max = maxfreq; policy->max = maxfreq;
policy->cpuinfo.min_freq = maxfreq / max_duration; policy->cpuinfo.min_freq = maxfreq / max_duration;
policy->cpuinfo.max_freq = maxfreq; policy->cpuinfo.max_freq = maxfreq;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
return 0; return 0;
} }
...@@ -438,6 +437,7 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy) ...@@ -438,6 +437,7 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
* MediaGX/Geode GX initialize cpufreq driver * MediaGX/Geode GX initialize cpufreq driver
*/ */
static struct cpufreq_driver gx_suspmod_driver = { static struct cpufreq_driver gx_suspmod_driver = {
.flags = CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.get = gx_get_cpuspeed, .get = gx_get_cpuspeed,
.verify = cpufreq_gx_verify, .verify = cpufreq_gx_verify,
.target = cpufreq_gx_target, .target = cpufreq_gx_target,
......
...@@ -442,7 +442,8 @@ static struct cpufreq_driver pmac_cpufreq_driver = { ...@@ -442,7 +442,8 @@ static struct cpufreq_driver pmac_cpufreq_driver = {
.init = pmac_cpufreq_cpu_init, .init = pmac_cpufreq_cpu_init,
.suspend = pmac_cpufreq_suspend, .suspend = pmac_cpufreq_suspend,
.resume = pmac_cpufreq_resume, .resume = pmac_cpufreq_resume,
.flags = CPUFREQ_PM_NO_WARN, .flags = CPUFREQ_PM_NO_WARN |
CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.attr = cpufreq_generic_attr, .attr = cpufreq_generic_attr,
.name = "powermac", .name = "powermac",
}; };
...@@ -626,14 +627,16 @@ static int __init pmac_cpufreq_setup(void) ...@@ -626,14 +627,16 @@ static int __init pmac_cpufreq_setup(void)
if (!value) if (!value)
goto out; goto out;
cur_freq = (*value) / 1000; cur_freq = (*value) / 1000;
transition_latency = CPUFREQ_ETERNAL;
/* Check for 7447A based MacRISC3 */ /* Check for 7447A based MacRISC3 */
if (of_machine_is_compatible("MacRISC3") && if (of_machine_is_compatible("MacRISC3") &&
of_get_property(cpunode, "dynamic-power-step", NULL) && of_get_property(cpunode, "dynamic-power-step", NULL) &&
PVR_VER(mfspr(SPRN_PVR)) == 0x8003) { PVR_VER(mfspr(SPRN_PVR)) == 0x8003) {
pmac_cpufreq_init_7447A(cpunode); pmac_cpufreq_init_7447A(cpunode);
/* Allow dynamic switching */
transition_latency = 8000000; transition_latency = 8000000;
pmac_cpufreq_driver.flags &= ~CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING;
/* Check for other MacRISC3 machines */ /* Check for other MacRISC3 machines */
} else if (of_machine_is_compatible("PowerBook3,4") || } else if (of_machine_is_compatible("PowerBook3,4") ||
of_machine_is_compatible("PowerBook3,5") || of_machine_is_compatible("PowerBook3,5") ||
......
...@@ -197,11 +197,12 @@ static int sa1100_target(struct cpufreq_policy *policy, unsigned int ppcr) ...@@ -197,11 +197,12 @@ static int sa1100_target(struct cpufreq_policy *policy, unsigned int ppcr)
static int __init sa1100_cpu_init(struct cpufreq_policy *policy) static int __init sa1100_cpu_init(struct cpufreq_policy *policy)
{ {
return cpufreq_generic_init(policy, sa11x0_freq_table, CPUFREQ_ETERNAL); return cpufreq_generic_init(policy, sa11x0_freq_table, 0);
} }
static struct cpufreq_driver sa1100_driver __refdata = { static struct cpufreq_driver sa1100_driver __refdata = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = sa1100_target, .target_index = sa1100_target,
.get = sa11x0_getspeed, .get = sa11x0_getspeed,
......
...@@ -306,13 +306,14 @@ static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr) ...@@ -306,13 +306,14 @@ static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr)
static int __init sa1110_cpu_init(struct cpufreq_policy *policy) static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
{ {
return cpufreq_generic_init(policy, sa11x0_freq_table, CPUFREQ_ETERNAL); return cpufreq_generic_init(policy, sa11x0_freq_table, 0);
} }
/* sa1110_driver needs __refdata because it must remain after init registers /* sa1110_driver needs __refdata because it must remain after init registers
* it with cpufreq_register_driver() */ * it with cpufreq_register_driver() */
static struct cpufreq_driver sa1110_driver __refdata = { static struct cpufreq_driver sa1110_driver __refdata = {
.flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK, .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK |
CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = sa1110_target, .target_index = sa1110_target,
.get = sa11x0_getspeed, .get = sa11x0_getspeed,
......
...@@ -137,8 +137,6 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -137,8 +137,6 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy)
(clk_round_rate(cpuclk, ~0UL) + 500) / 1000; (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
} }
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
dev_info(dev, "CPU Frequencies - Minimum %u.%03u MHz, " dev_info(dev, "CPU Frequencies - Minimum %u.%03u MHz, "
"Maximum %u.%03u MHz.\n", "Maximum %u.%03u MHz.\n",
policy->min / 1000, policy->min % 1000, policy->min / 1000, policy->min % 1000,
...@@ -159,6 +157,7 @@ static int sh_cpufreq_cpu_exit(struct cpufreq_policy *policy) ...@@ -159,6 +157,7 @@ static int sh_cpufreq_cpu_exit(struct cpufreq_policy *policy)
static struct cpufreq_driver sh_cpufreq_driver = { static struct cpufreq_driver sh_cpufreq_driver = {
.name = "sh", .name = "sh",
.flags = CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.get = sh_cpufreq_get, .get = sh_cpufreq_get,
.target = sh_cpufreq_target, .target = sh_cpufreq_target,
.verify = sh_cpufreq_verify, .verify = sh_cpufreq_verify,
......
...@@ -266,7 +266,6 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy) ...@@ -266,7 +266,6 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
pr_debug("workaround worked.\n"); pr_debug("workaround worked.\n");
} }
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
return cpufreq_table_validate_and_show(policy, speedstep_freqs); return cpufreq_table_validate_and_show(policy, speedstep_freqs);
} }
...@@ -290,6 +289,7 @@ static int speedstep_resume(struct cpufreq_policy *policy) ...@@ -290,6 +289,7 @@ static int speedstep_resume(struct cpufreq_policy *policy)
static struct cpufreq_driver speedstep_driver = { static struct cpufreq_driver speedstep_driver = {
.name = "speedstep-smi", .name = "speedstep-smi",
.flags = CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = speedstep_target, .target_index = speedstep_target,
.init = speedstep_cpu_init, .init = speedstep_cpu_init,
......
...@@ -58,13 +58,12 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy) ...@@ -58,13 +58,12 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy)
policy->min = policy->cpuinfo.min_freq = 250000; policy->min = policy->cpuinfo.min_freq = 250000;
policy->max = policy->cpuinfo.max_freq = 1000000; policy->max = policy->cpuinfo.max_freq = 1000000;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->clk = clk_get(NULL, "MAIN_CLK"); policy->clk = clk_get(NULL, "MAIN_CLK");
return PTR_ERR_OR_ZERO(policy->clk); return PTR_ERR_OR_ZERO(policy->clk);
} }
static struct cpufreq_driver ucv2_driver = { static struct cpufreq_driver ucv2_driver = {
.flags = CPUFREQ_STICKY, .flags = CPUFREQ_STICKY | CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING,
.verify = ucv2_verify_speed, .verify = ucv2_verify_speed,
.target = ucv2_target, .target = ucv2_target,
.get = cpufreq_generic_get, .get = cpufreq_generic_get,
......
...@@ -370,6 +370,12 @@ struct cpufreq_driver { ...@@ -370,6 +370,12 @@ struct cpufreq_driver {
*/ */
#define CPUFREQ_NEED_INITIAL_FREQ_CHECK (1 << 5) #define CPUFREQ_NEED_INITIAL_FREQ_CHECK (1 << 5)
/*
* Set by drivers to disallow use of governors with "dynamic_switching" flag
* set.
*/
#define CPUFREQ_NO_AUTO_DYNAMIC_SWITCHING (1 << 6)
int cpufreq_register_driver(struct cpufreq_driver *driver_data); int cpufreq_register_driver(struct cpufreq_driver *driver_data);
int cpufreq_unregister_driver(struct cpufreq_driver *driver_data); int cpufreq_unregister_driver(struct cpufreq_driver *driver_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment