qcom-cpufreq: Cache the resolved frequency index
This driver implements resolved_freq and target methods. Since target method does not know the resolved frequency index, the frequency table look up is needed again. We can optimize this by caching the resolved frequency index in the resolved_freq method. Change-Id: Ib303ef57c51ce50de52b759728bc8c162a90dc29 Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org> Signed-off-by: Rohit Gupta <rohgup@codeaurora.org> [avilaj@codeaurora.org: Fix some merge conflicts] Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
This commit is contained in:
committed by
Jonathan Avila
parent
2d7062186f
commit
fdfe60b6de
@@ -34,6 +34,8 @@ struct cpufreq_suspend_t {
|
||||
};
|
||||
|
||||
static DEFINE_PER_CPU(struct cpufreq_suspend_t, suspend_data);
|
||||
static DEFINE_PER_CPU(int, cached_resolve_idx);
|
||||
static DEFINE_PER_CPU(unsigned int, cached_resolve_freq);
|
||||
|
||||
static int set_cpu_freq(struct cpufreq_policy *policy, unsigned int new_freq,
|
||||
unsigned int index)
|
||||
@@ -66,6 +68,7 @@ static int msm_cpufreq_target(struct cpufreq_policy *policy,
|
||||
int ret = 0;
|
||||
int index;
|
||||
struct cpufreq_frequency_table *table;
|
||||
int first_cpu = cpumask_first(policy->related_cpus);
|
||||
|
||||
mutex_lock(&per_cpu(suspend_data, policy->cpu).suspend_mutex);
|
||||
|
||||
@@ -80,7 +83,11 @@ static int msm_cpufreq_target(struct cpufreq_policy *policy,
|
||||
}
|
||||
|
||||
table = policy->freq_table;
|
||||
index = cpufreq_frequency_table_target(policy, target_freq, relation);
|
||||
if (per_cpu(cached_resolve_freq, first_cpu) == target_freq)
|
||||
index = per_cpu(cached_resolve_idx, first_cpu);
|
||||
else
|
||||
index = cpufreq_frequency_table_target(policy, target_freq,
|
||||
relation);
|
||||
|
||||
pr_debug("CPU[%d] target %d relation %d (%d-%d) selected %d\n",
|
||||
policy->cpu, target_freq, relation,
|
||||
@@ -97,10 +104,17 @@ static unsigned int msm_cpufreq_resolve_freq(struct cpufreq_policy *policy,
|
||||
unsigned int target_freq)
|
||||
{
|
||||
int index;
|
||||
int first_cpu = cpumask_first(policy->related_cpus);
|
||||
unsigned int freq;
|
||||
|
||||
index = cpufreq_frequency_table_target(policy, target_freq,
|
||||
CPUFREQ_RELATION_L);
|
||||
return policy->freq_table[index].frequency;
|
||||
freq = policy->freq_table[index].frequency;
|
||||
|
||||
per_cpu(cached_resolve_idx, first_cpu) = index;
|
||||
per_cpu(cached_resolve_freq, first_cpu) = freq;
|
||||
|
||||
return freq;
|
||||
}
|
||||
|
||||
static int msm_cpufreq_verify(struct cpufreq_policy *policy)
|
||||
@@ -455,6 +469,7 @@ static int __init msm_cpufreq_register(void)
|
||||
for_each_possible_cpu(cpu) {
|
||||
mutex_init(&(per_cpu(suspend_data, cpu).suspend_mutex));
|
||||
per_cpu(suspend_data, cpu).device_suspended = 0;
|
||||
per_cpu(cached_resolve_freq, cpu) = UINT_MAX;
|
||||
}
|
||||
|
||||
rc = platform_driver_register(&msm_cpufreq_plat_driver);
|
||||
|
||||
Reference in New Issue
Block a user