Skip to content

Commit abe8bd0

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: Disallow ->resolve_freq() for drivers providing ->target_index()
The handlers provided by cpufreq core are sufficient for resolving the frequency for drivers providing ->target_index(), as the core already has the frequency table and so ->resolve_freq() isn't required for such platforms. This patch disallows drivers with ->target_index() callback to use the ->resolve_freq() callback. Also, it fixes a potential kernel crash for drivers providing ->target() but no ->resolve_freq(). Fixes: e3c0623 "cpufreq: add cpufreq_driver_resolve_freq()" Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 5b6667c commit abe8bd0

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎drivers/cpufreq/cpufreq.c‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,20 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
507507
{
508508
target_freq = clamp_val(target_freq, policy->min, policy->max);
509509
policy->cached_target_freq = target_freq;
510+
511+
if (cpufreq_driver->target_index) {
512+
int idx;
513+
514+
idx = cpufreq_frequency_table_target(policy, target_freq,
515+
CPUFREQ_RELATION_L);
516+
policy->cached_resolved_idx = idx;
517+
return policy->freq_table[idx].frequency;
518+
}
519+
510520
if (cpufreq_driver->resolve_freq)
511521
return cpufreq_driver->resolve_freq(policy, target_freq);
512-
policy->cached_resolved_idx =
513-
cpufreq_frequency_table_target(policy, target_freq,
514-
CPUFREQ_RELATION_L);
515-
return policy->freq_table[policy->cached_resolved_idx].frequency;
522+
523+
return target_freq;
516524
}
517525

518526
/*********************************************************************

0 commit comments

Comments
 (0)