Skip to content

Commit 5a31d59

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: Allow freq_table to be obtained for offline CPUs
Users of freq table may want to access it for any CPU from policy->related_cpus mask. One such user is cpu-cooling layer. It gets a list of 'clip_cpus' (equivalent to policy->related_cpus) during registration and tries to get freq_table for the first CPU of this mask. If the CPU, for which it tries to fetch freq_table, is offline, cpufreq_frequency_get_table() fails. This happens because it relies on cpufreq_cpu_get_raw() for its functioning which returns policy only for online CPUs. The fix is to access the policy data structure for the given CPU directly (which also returns a valid policy for offline CPUs), but the policy itself has to be active (meaning that at least one CPU using it is online) for the frequency table to be returned. Because we will be using 'cpufreq_cpu_data' now, which is internal to the cpufreq core, move cpufreq_frequency_get_table() to cpufreq.c. Reported-and-tested-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 35afd02 commit 5a31d59

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)
169169
}
170170
EXPORT_SYMBOL_GPL(get_governor_parent_kobj);
171171

172+
struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
173+
{
174+
struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu);
175+
176+
return policy && !policy_is_inactive(policy) ?
177+
policy->freq_table : NULL;
178+
}
179+
EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table);
180+
172181
static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall)
173182
{
174183
u64 idle_time;

drivers/cpufreq/freq_table.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,6 @@ int cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
297297
}
298298
EXPORT_SYMBOL_GPL(cpufreq_table_validate_and_show);
299299

300-
struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu);
301-
302-
struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu)
303-
{
304-
struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
305-
return policy ? policy->freq_table : NULL;
306-
}
307-
EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table);
308-
309300
MODULE_AUTHOR("Dominik Brodowski <linux@brodo.de>");
310301
MODULE_DESCRIPTION("CPUfreq frequency table helpers");
311302
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)