CPUFreq: Last set of updates for 3.13
Subsystems (2)
Viresh Kumar
maintainercover CPUFreq: Last set of updates for 3.13
Hi Rafael,
I really tried to stop after you asked me to, but still got few more patches.. These are very minor changes and a fairly smaller patchset..
I have rebased this over your linux-next branch
7c218b1 Merge branch 'acpi-bind-next' into linux-next
and tested over my exynos board.. I don't expect them to do any crappy stuff..
You can include these first (if they look fine) and then I will send all other patches that I have queued up for 3.13.. I will send all of them in one lot, with partition numbers mentioned (i.e. patches that should go together) and then you can apply them the way you wish.. Set by set or all at once..
Thanks..
Viresh Kumar (5):
cpufreq: Optimize cpufreq_frequency_table_verify()
cpufreq: rename __cpufreq_set_policy() as cpufreq_set_policy()
cpufreq: rewrite cpufreq_driver->flags using shift operator
cpufreq: use cpufreq_driver->flags to mark
CPUFREQ_HAVE_GOVERNOR_PER_POLICY
cpufreq: add new routine cpufreq_verify_within_cpu_limits()
drivers/cpufreq/arm_big_little.c | 4 ++-- drivers/cpufreq/cpufreq-nforce2.c | 4 +--- drivers/cpufreq/cpufreq.c | 24 ++++++++++------------- drivers/cpufreq/cpufreq_governor.h | 5 ++++- drivers/cpufreq/davinci-cpufreq.c | 4 +--- drivers/cpufreq/freq_table.c | 27 +++++++++++++------------- drivers/cpufreq/integrator-cpufreq.c | 9 ++------- drivers/cpufreq/intel_pstate.c | 4 +--- drivers/cpufreq/longrun.c | 4 +--- drivers/cpufreq/pcc-cpufreq.c | 3 +-- drivers/cpufreq/sh-cpufreq.c | 7 ++----- drivers/cpufreq/unicore2-cpufreq.c | 4 +--- include/linux/cpufreq.h | 37 ++++++++++++++++++++++-------------- 13 files changed, 62 insertions(+), 74 deletions(-)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 1/5 cpufreq: Optimize cpufreq_frequency_table_verify()
cpufreq_frequency_table_verify() is a bit rewritten here to make it more logical and optimal.
- merge multiple lines for variable declarations together.
- quit early if any frequency between min/max is found.
- don't call cpufreq_verify_within_limits() in case any valid freq is found as it is of no use.
- count renamed as found and made a boolean.
--- drivers/cpufreq/freq_table.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
drivers/cpufreq/freq_table.c +13 -12
@@ -54,9 +54,8 @@ EXPORT_SYMBOL_GPL(cpufreq_frequency_table_cpuinfo);int cpufreq_frequency_table_verify (struct cpufreq_policy *policy,struct cpufreq_frequency_table *table) { -unsigned int next_larger = ~0 ; -unsigned int i; -unsigned int count =0 ; +unsigned int next_larger = ~0 , freq, i =0 ; +bool found = false;pr_debug ("request for verification of policy (%u - %u kHz) for cpu %u\n" , policy->min, policy->max, policy->cpu);
@@ -64,21 +63,23 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); -for (i =0 ; (table[i].frequency !=CPUFREQ_TABLE_END ); i++) { -unsigned int freq = table[i].frequency; +for (; freq = table[i].frequency, freq !=CPUFREQ_TABLE_END ; i++) {if (freq ==CPUFREQ_ENTRY_INVALID )continue ; -if ((freq >= policy->min) && (freq <= policy->max)) - count++; -else if ((next_larger > freq) && (freq > policy->max)) +if ((freq >= policy->min) && (freq <= policy->max)) { + found = true; +break ; + } + +if ((next_larger > freq) && (freq > policy->max)) next_larger = freq; } -if (!count) +if (!found) { policy->max = next_larger; - -cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); + }pr_debug ("verification lead to (%u - %u kHz) for cpu %u\n" , policy->min, policy->max, policy->cpu);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 2/5 cpufreq: rename __cpufreq_set_policy() as cpufreq_set_policy()
In reply to Viresh KumarEarlier there used to be two functions named __cpufreq_set_policy() and cpufreq_set_policy(), but now we only have a single routine lets name it cpufreq_set_policy() instead of __cpufreq_set_policy().
This also removes some invalid comments or fixes some incorrect comments.
--- drivers/cpufreq/cpufreq.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/cpufreq/cpufreq.c +9 -13
@@ -414,7 +414,7 @@ show_one(scaling_min_freq, min);show_one (scaling_max_freq, max);show_one (scaling_cur_freq, cur); -static int __cpufreq_set_policy (struct cpufreq_policy *policy, +static int cpufreq_set_policy (struct cpufreq_policy *policy,struct cpufreq_policy *new_policy);/**
@@ -435,7 +435,7 @@ static ssize_t store_##file_name \if (ret !=1 ) \return -EINVAL ; \ \ - ret =__cpufreq_set_policy (policy, &new_policy); \ + ret =cpufreq_set_policy (policy, &new_policy); \ policy->user_policy.object = policy->object; \ \return ret ? ret : count; \
@@ -493,11 +493,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy *policy, &new_policy.governor))return -EINVAL ; -/* -* Do not use cpufreq_set_policy here or the user_policy.max -* will be wrongly overridden -*/ - ret =__cpufreq_set_policy (policy, &new_policy); + ret =cpufreq_set_policy (policy, &new_policy); policy->user_policy.policy = policy->policy; policy->user_policy.governor = policy->governor;
@@ -844,11 +840,11 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy)int ret =0 ;memcpy (&new_policy, policy,sizeof (*policy)); -/* assure that the starting sequence is run in __cpufreq_set_policy */ +/* assure that the starting sequence is run in cpufreq_set_policy */ policy->governor =NULL ;/* set default policy */ - ret =__cpufreq_set_policy (policy, &new_policy); + ret =cpufreq_set_policy (policy, &new_policy); policy->user_policy.policy = policy->policy; policy->user_policy.governor = policy->governor;
@@ -1844,10 +1840,10 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu)EXPORT_SYMBOL (cpufreq_get_policy);/* -* data : current policy. -* policy : policy to be set. +* policy : current policy. +* new_policy: policy to be set. */ -static int __cpufreq_set_policy (struct cpufreq_policy *policy, +static int cpufreq_set_policy (struct cpufreq_policy *policy,struct cpufreq_policy *new_policy) {int ret =0 , failed =1 ;
@@ -1996,7 +1992,7 @@ int cpufreq_update_policy(unsigned int cpu) } } - ret =__cpufreq_set_policy (policy, &new_policy); + ret =cpufreq_set_policy (policy, &new_policy);unlock_policy_rwsem_write (cpu);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 3/5 cpufreq: rewrite cpufreq_driver->flags using shift operator
In reply to Viresh KumarCurrently cpufreq_driver's flags are defined directly using 0x1, 0x2, 0x4, 0x8, etc.. As the list grows it doesn't stays much readable..
Lets use bitwise shift operator << to generate these numbers for respective positions.
--- include/linux/cpufreq.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
include/linux/cpufreq.h +8 -7
@@ -211,13 +211,14 @@ struct cpufreq_driver { };/* flags */ -#define CPUFREQ_STICKY 0x01/* the driver isn't removed even if -* all ->init() calls failed */ -#define CPUFREQ_CONST_LOOPS 0x02/* loops_per_jiffy or other kernel -* "constants" aren't affected by -* frequency transitions */ -#define CPUFREQ_PM_NO_WARN 0x04/* don't warn on suspend/resume speed -* mismatches */ +#define CPUFREQ_STICKY (1 << 0)/* driver isn't removed even if +all ->init() calls failed */ +#define CPUFREQ_CONST_LOOPS (1 << 1)/* loops_per_jiffy or other +kernel "constants" aren't +affected by frequency +transitions */ +#define CPUFREQ_PM_NO_WARN (1 << 2)/* don't warn on suspend/resume +speed mismatches */ int cpufreq_register_driver (struct cpufreq_driver *driver_data);int cpufreq_unregister_driver (struct cpufreq_driver *driver_data);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 4/5 cpufreq: use cpufreq_driver->flags to mark CPUFREQ_HAVE_GOVERNOR_PER_POLICY
In reply to Viresh KumarLets use cpufreq_driver->flags to mark CPUFREQ_HAVE_GOVERNOR_PER_POLICY instead of a separate field within cpufreq_driver. This will save some bytes for us.
--- drivers/cpufreq/arm_big_little.c | 4 ++-- drivers/cpufreq/cpufreq.c | 2 +- drivers/cpufreq/cpufreq_governor.h | 5 ++++- include/linux/cpufreq.h | 15 ++++++++------- 4 files changed, 15 insertions(+), 11 deletions(-)
drivers/cpufreq/arm_big_little.c +2 -2
@@ -214,13 +214,13 @@ static struct freq_attr *bL_cpufreq_attr[] = {static struct cpufreq_driver bL_cpufreq_driver = { .name ="arm-big-little" , - .flags =CPUFREQ_STICKY , + .flags =CPUFREQ_STICKY | +CPUFREQ_HAVE_GOVERNOR_PER_POLICY , .verify = bL_cpufreq_verify_policy, .target = bL_cpufreq_set_target, .get = bL_cpufreq_get, .init = bL_cpufreq_init, .exit = bL_cpufreq_exit, - .have_governor_per_policy = true, .attr = bL_cpufreq_attr, };
drivers/cpufreq/cpufreq.c +1 -1
@@ -135,7 +135,7 @@ static DEFINE_MUTEX(cpufreq_governor_mutex);bool have_governor_per_policy (void ) { -return cpufreq_driver->have_governor_per_policy; +return !!(cpufreq_driver->flags &CPUFREQ_HAVE_GOVERNOR_PER_POLICY ); }EXPORT_SYMBOL_GPL (have_governor_per_policy);
drivers/cpufreq/cpufreq_governor.h +4 -1
@@ -191,7 +191,10 @@ struct common_dbs_data {struct attribute_group *attr_group_gov_sys;/* one governor - system */ struct attribute_group *attr_group_gov_pol;/* one governor - policy */ -/* Common data for platforms that don't set have_governor_per_policy */ +/* +* Common data for platforms that don't set +* CPUFREQ_HAVE_GOVERNOR_PER_POLICY +*/ struct dbs_data *gdbs_data;struct cpu_dbs_common_info *(*get_cpu_cdbs)(int cpu);
include/linux/cpufreq.h +8 -7
@@ -180,13 +180,6 @@ __ATTR(_name, 0644, show_##_name, store_##_name)struct cpufreq_driver {char name[CPUFREQ_NAME_LEN ];u8 flags; -/* -* This should be set by platforms having multiple clock-domains, i.e. -* supporting multiple policies. With this sysfs directories of governor -* would be created in cpu/cpu<num>/cpufreq/ directory and so they can -* use the same governor with different tunables for different clusters. -*/ -bool have_governor_per_policy;/* needed by all drivers */ int (*init) (struct cpufreq_policy *policy);
@@ -220,6 +213,14 @@ struct cpufreq_driver {#define CPUFREQ_PM_NO_WARN (1 << 2)/* don't warn on suspend/resume speed mismatches */ +/* +* This should be set by platforms having multiple clock-domains, i.e. +* supporting multiple policies. With this sysfs directories of governor would +* be created in cpu/cpu<num>/cpufreq/ directory and so they can use the same +* governor with different tunables for different clusters. +*/ +#define CPUFREQ_HAVE_GOVERNOR_PER_POLICY (1 << 3) +int cpufreq_register_driver (struct cpufreq_driver *driver_data);int cpufreq_unregister_driver (struct cpufreq_driver *driver_data);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 5/5 cpufreq: add new routine cpufreq_verify_within_cpu_limits()
In reply to Viresh KumarMost of the users of cpufreq_verify_within_limits() calls it for limiting with min/max from policy->cpuinfo. We can make that code simple by introducing another routine which will do this for them automatically.
This patch adds another routine cpufreq_verify_within_cpu_limits() and updates others to use it.
--- drivers/cpufreq/cpufreq-nforce2.c | 4 +--- drivers/cpufreq/davinci-cpufreq.c | 4 +--- drivers/cpufreq/freq_table.c | 6 ++---- drivers/cpufreq/integrator-cpufreq.c | 9 ++------- drivers/cpufreq/intel_pstate.c | 4 +--- drivers/cpufreq/longrun.c | 4 +--- drivers/cpufreq/pcc-cpufreq.c | 3 +-- drivers/cpufreq/sh-cpufreq.c | 7 ++----- drivers/cpufreq/unicore2-cpufreq.c | 4 +--- include/linux/cpufreq.h | 7 +++++++ 10 files changed, 19 insertions(+), 33 deletions(-)
drivers/cpufreq/cpufreq-nforce2.c +1 -3
@@ -303,9 +303,7 @@ static int nforce2_verify(struct cpufreq_policy *policy)if (policy->min < (fsb_pol_max * fid *100 )) policy->max = (fsb_pol_max +1 ) * fid *100 ; -cpufreq_verify_within_limits (policy, - policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_cpu_limits (policy);return 0 ; }
drivers/cpufreq/davinci-cpufreq.c +1 -3
@@ -50,9 +50,7 @@ static int davinci_verify_speed(struct cpufreq_policy *policy)if (policy->cpu)return -EINVAL ; -cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); - +cpufreq_verify_within_cpu_limits (policy); policy->min =clk_round_rate (armclk, policy->min *1000 ) /1000 ; policy->max =clk_round_rate (armclk, policy->max *1000 ) /1000 ; cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
drivers/cpufreq/freq_table.c +2 -4
@@ -60,8 +60,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,pr_debug ("request for verification of policy (%u - %u kHz) for cpu %u\n" , policy->min, policy->max, policy->cpu); -cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_cpu_limits (policy);for (; freq = table[i].frequency, freq !=CPUFREQ_TABLE_END ; i++) {if (freq ==CPUFREQ_ENTRY_INVALID )
@@ -77,8 +76,7 @@ int cpufreq_frequency_table_verify(struct cpufreq_policy *policy,if (!found) { policy->max = next_larger; -cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_cpu_limits (policy); } pr_debug("verification lead to (%u - %u kHz) for cpu %u\n",
drivers/cpufreq/integrator-cpufreq.c +2 -7
@@ -59,9 +59,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy) {struct icst_vco vco; -cpufreq_verify_within_limits (policy, - policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_cpu_limits (policy); vco =icst_hz_to_vco (&cclk_params, policy->max *1000 ); policy->max =icst_hz (&cclk_params, vco) /1000 ;
@@ -69,10 +67,7 @@ static int integrator_verify_policy(struct cpufreq_policy *policy) vco =icst_hz_to_vco (&cclk_params, policy->min *1000 ); policy->min =icst_hz (&cclk_params, vco) /1000 ; -cpufreq_verify_within_limits (policy, - policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); - +cpufreq_verify_within_cpu_limits (policy);return 0 ; }
drivers/cpufreq/intel_pstate.c +1 -3
@@ -611,9 +611,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)static int intel_pstate_verify_policy (struct cpufreq_policy *policy) { -cpufreq_verify_within_limits (policy, - policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_cpu_limits (policy);if ((policy->policy !=CPUFREQ_POLICY_POWERSAVE ) && (policy->policy !=CPUFREQ_POLICY_PERFORMANCE ))
drivers/cpufreq/longrun.c +1 -3
@@ -129,9 +129,7 @@ static int longrun_verify_policy(struct cpufreq_policy *policy)return -EINVAL ; policy->cpu =0 ; -cpufreq_verify_within_limits (policy, - policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_cpu_limits (policy);if ((policy->policy !=CPUFREQ_POLICY_POWERSAVE ) && (policy->policy !=CPUFREQ_POLICY_PERFORMANCE ))
drivers/cpufreq/pcc-cpufreq.c +1 -2
@@ -111,8 +111,7 @@ static struct pcc_cpu __percpu *pcc_cpu_info;static int pcc_cpufreq_verify (struct cpufreq_policy *policy) { -cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_cpu_limits (policy);return 0 ; }
drivers/cpufreq/sh-cpufreq.c +2 -5
@@ -87,15 +87,12 @@ static int sh_cpufreq_verify(struct cpufreq_policy *policy)if (freq_table)return cpufreq_frequency_table_verify (policy, freq_table); -cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); +cpufreq_verify_within_cpu_limits (policy); policy->min = (clk_round_rate (cpuclk,1 ) +500 ) /1000 ; policy->max = (clk_round_rate (cpuclk, ~0UL ) +500 ) /1000 ; -cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, - policy->cpuinfo.max_freq); - +cpufreq_verify_within_cpu_limits (policy);return 0 ; }
drivers/cpufreq/unicore2-cpufreq.c +1 -3
@@ -29,9 +29,7 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy)if (policy->cpu)return -EINVAL ; -cpufreq_verify_within_limits (policy, - policy->cpuinfo.min_freq, policy->cpuinfo.max_freq); - +cpufreq_verify_within_cpu_limits (policy);return 0 ; }
include/linux/cpufreq.h +7 -0
@@ -242,6 +242,13 @@ static inline void cpufreq_verify_within_limits(struct cpufreq_policy *policy,return ; } +static inline void +cpufreq_verify_within_cpu_limits (struct cpufreq_policy *policy) +{ +cpufreq_verify_within_limits (policy, policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); +} +/********************************************************************* * CPUFREQ NOTIFIER INTERFACE * *********************************************************************/
Signature · 1 line
1.7.12.rc2.18.g61b472e
Quoted 9 lines · Viresh Kumar
Hi Rafael,
I really tried to stop after you asked me to, but still got few more patches.. These are very minor changes and a fairly smaller patchset..
I have rebased this over your linux-next branch
7c218b1 Merge branch 'acpi-bind-next' into linux-next
Quoted 8 lines
and tested over my exynos board.. I don't expect them to do any crappy stuff..
You can include these first (if they look fine) and then I will send all other patches that I have queued up for 3.13.. I will send all of them in one lot, with partition numbers mentioned (i.e. patches that should go together) and then you can apply them the way you wish.. Set by set or all at once..
Thanks..
Viresh,
Thanks for the great work cleaning up all the drivers. IIUC, you have ~200 patches lined up for the 3.13 merge window. That causes some worries.
Can we quickly do the following to get more confidence that there won't be wide-spread breakage:
1. Get all of these into linux-next quickly
2. Set up a LAVA[1] job to get linux-next kernels running on boards in our farm
3. Run cpufreq functional tests, e.g. PM-QA[2] test suite from Linaro with these kernels
Regards,
Amit
[1] An automated test harness used by Linaro
[2] https://git.linaro.org/gitweb?p=tools/pm-qa.git;a=tree;f=cpufreq;h=b53f7ad0fe778011d75e94ec7bd2b2fc1fc4cfd7;hb=HEAD
Viresh Kumar
maintainerQuoted 2 lines · Amit Kucheria
Thanks for the great work cleaning up all the drivers. IIUC, you have ~200 patches lined up for the 3.13 merge window.
227 to be precise :)
Quoted 6 lines
That causes some worries.
Can we quickly do the following to get more confidence that there won't be wide-spread breakage:
1. Get all of these into linux-next quickly
Yes, even Myself and Rafael wanted to do that.. And were waiting for pull request to go for 3.12-rc1..
I am mostly ready with my patches, wouldn't take long time for me to review those completely before sending them..
Quoted 3 lines
2. Set up a LAVA[1] job to get linux-next kernels running on boards in our farm
3. Run cpufreq functional tests, e.g. PM-QA[2] test suite from Linaro with these kernels
That would be nice actually.. Anyway some people would test it on linux-next, but doing that for few boards by Linaro would be Awesome..
--
viresh