On Thu, 2013-08-08 at 08:39 +0100, Jon Medhurst (Tixy) wrote:
On Wed, 2013-08-07 at 18:52 +0530, Viresh Kumar wrote:
While getting support for In-Kernel-Switcher in big LITTLE cpufreq driver we introduced cpu_last_req_freq per-cpu variable that stores the last frequency requested for a cpu. It was important for IKS as CPUs in the same cluster can have separate struct cpufreq_policy associated with them and so cpufreq core may try to set different frequencies on both CPUs of same cluster.
But for non-IKS solution or MP we don't need to cache last requested frequency. Currently there is a bug in code where if cpufreq_driver->get() is called for any cpu other than policy->cpu, we are returning 0, because we set cpu_last_req_freq only for policy->cpu and not for others.
Do you know what the observable symptoms of this are?
As this is a fix which needs to get into LSK I've added the linaro-kernel list to the cc so it has more public visibility.
Tixy
This problem could have been fixed by setting cpu_last_req_freq for all CPUs in policy->cpus, but that wouldn't be the best solution. Purpose of cpufreq_driver->get() is to get exact frequency from the hardware instead of returning cached frequency that was last requested as that is already present with the core.
Hence, this patch forces only IKS to use cpu_last_req_freq and not MP. We will get the frequency from hardware when ->get() is called for MP.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org
drivers/cpufreq/arm_big_little.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index f589b6c..c8de71f 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c @@ -91,9 +91,14 @@ static unsigned int clk_get_cpu_rate(unsigned int cpu) static unsigned int bL_cpufreq_get_rate(unsigned int cpu) {
- pr_debug("%s: freq: %d\n", __func__, per_cpu(cpu_last_req_freq, cpu));
- if (is_bL_switching_enabled()) {
pr_debug("%s: freq: %d\n", __func__, per_cpu(cpu_last_req_freq,
cpu));
- return per_cpu(cpu_last_req_freq, cpu);
return per_cpu(cpu_last_req_freq, cpu);
- } else {
return clk_get_cpu_rate(cpu);
- }
} static unsigned int @@ -104,11 +109,11 @@ bL_cpufreq_set_rate(u32 cpu, u32 old_cluster, u32 new_cluster, u32 rate) mutex_lock(&cluster_lock[new_cluster]);
- prev_rate = per_cpu(cpu_last_req_freq, cpu);
- per_cpu(cpu_last_req_freq, cpu) = rate;
- per_cpu(physical_cluster, cpu) = new_cluster;
- if (is_bL_switching_enabled()) {
prev_rate = per_cpu(cpu_last_req_freq, cpu);
per_cpu(cpu_last_req_freq, cpu) = rate;
per_cpu(physical_cluster, cpu) = new_cluster;
- new_rate = find_cluster_maxfreq(new_cluster); new_rate = ACTUAL_FREQ(new_cluster, new_rate); } else {
@@ -122,8 +127,10 @@ bL_cpufreq_set_rate(u32 cpu, u32 old_cluster, u32 new_cluster, u32 rate) if (WARN_ON(ret)) { pr_err("clk_set_rate failed: %d, new cluster: %d\n", ret, new_cluster);
per_cpu(cpu_last_req_freq, cpu) = prev_rate;
per_cpu(physical_cluster, cpu) = old_cluster;
if (is_bL_switching_enabled()) {
per_cpu(cpu_last_req_freq, cpu) = prev_rate;
This causes the warnings below.
drivers/cpufreq/arm_big_little.c: In function 'bL_cpufreq_set_target': drivers/cpufreq/arm_big_little.c:131:36: warning: 'prev_rate' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/cpufreq/arm_big_little.c:107:16: note: 'prev_rate' was declared here
How about we add
bool bLs = is_bL_switching_enabled();
and use "if (bLs)" rather than "if (is_bL_switching_enabled())"?
per_cpu(physical_cluster, cpu) = old_cluster;
}
mutex_unlock(&cluster_lock[new_cluster]); @@ -461,7 +468,9 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy) policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; policy->cur = clk_get_cpu_rate(policy->cpu);
- per_cpu(cpu_last_req_freq, policy->cpu) = policy->cur;
- if (is_bL_switching_enabled())
per_cpu(cpu_last_req_freq, policy->cpu) = policy->cur;
dev_info(cpu_dev, "%s: CPU %d initialized\n", __func__, policy->cpu); return 0;