diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2016-06-03 01:28:47 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-06-08 18:58:05 -0400 |
commit | f8bfc116cacbdf7e0e655d8a798a242087ed70a5 (patch) | |
tree | 2abbe90962cff00f2dcdac17f2981573e62d105b /drivers/cpufreq/cpufreq.c | |
parent | f0f879ba533ed29ca277c95d529fce703113271e (diff) |
cpufreq: Remove cpufreq_frequency_get_table()
Most of the callers of cpufreq_frequency_get_table() already have the
pointer to a valid 'policy' structure and they don't really need to go
through the per-cpu variable first and then a check to validate the
frequency, in order to find the freq-table for the policy.
Directly use the policy->freq_table field instead for them.
Only one user of that API is left after above changes, cpu_cooling.c and
it accesses the freq_table in a racy way as the policy can get freed in
between.
Fix it by using cpufreq_cpu_get() properly.
Since there are no more users of cpufreq_frequency_get_table() left, get
rid of it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Javi Merino <javi.merino@arm.com> (cpu_cooling.c)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq.c')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index c6a14ba239a2..cc252eecc45a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -126,15 +126,6 @@ struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy) | |||
126 | } | 126 | } |
127 | EXPORT_SYMBOL_GPL(get_governor_parent_kobj); | 127 | EXPORT_SYMBOL_GPL(get_governor_parent_kobj); |
128 | 128 | ||
129 | struct cpufreq_frequency_table *cpufreq_frequency_get_table(unsigned int cpu) | ||
130 | { | ||
131 | struct cpufreq_policy *policy = per_cpu(cpufreq_cpu_data, cpu); | ||
132 | |||
133 | return policy && !policy_is_inactive(policy) ? | ||
134 | policy->freq_table : NULL; | ||
135 | } | ||
136 | EXPORT_SYMBOL_GPL(cpufreq_frequency_get_table); | ||
137 | |||
138 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) | 129 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
139 | { | 130 | { |
140 | u64 idle_time; | 131 | u64 idle_time; |
@@ -1950,7 +1941,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, | |||
1950 | if (!cpufreq_driver->target_index) | 1941 | if (!cpufreq_driver->target_index) |
1951 | return -EINVAL; | 1942 | return -EINVAL; |
1952 | 1943 | ||
1953 | freq_table = cpufreq_frequency_get_table(policy->cpu); | 1944 | freq_table = policy->freq_table; |
1954 | if (unlikely(!freq_table)) { | 1945 | if (unlikely(!freq_table)) { |
1955 | pr_err("%s: Unable to find freq_table\n", __func__); | 1946 | pr_err("%s: Unable to find freq_table\n", __func__); |
1956 | return -EINVAL; | 1947 | return -EINVAL; |
@@ -2345,26 +2336,25 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { | |||
2345 | *********************************************************************/ | 2336 | *********************************************************************/ |
2346 | static int cpufreq_boost_set_sw(int state) | 2337 | static int cpufreq_boost_set_sw(int state) |
2347 | { | 2338 | { |
2348 | struct cpufreq_frequency_table *freq_table; | ||
2349 | struct cpufreq_policy *policy; | 2339 | struct cpufreq_policy *policy; |
2350 | int ret = -EINVAL; | 2340 | int ret = -EINVAL; |
2351 | 2341 | ||
2352 | for_each_active_policy(policy) { | 2342 | for_each_active_policy(policy) { |
2353 | freq_table = cpufreq_frequency_get_table(policy->cpu); | 2343 | if (!policy->freq_table) |
2354 | if (freq_table) { | 2344 | continue; |
2355 | ret = cpufreq_frequency_table_cpuinfo(policy, | ||
2356 | freq_table); | ||
2357 | if (ret) { | ||
2358 | pr_err("%s: Policy frequency update failed\n", | ||
2359 | __func__); | ||
2360 | break; | ||
2361 | } | ||
2362 | 2345 | ||
2363 | down_write(&policy->rwsem); | 2346 | ret = cpufreq_frequency_table_cpuinfo(policy, |
2364 | policy->user_policy.max = policy->max; | 2347 | policy->freq_table); |
2365 | cpufreq_governor_limits(policy); | 2348 | if (ret) { |
2366 | up_write(&policy->rwsem); | 2349 | pr_err("%s: Policy frequency update failed\n", |
2350 | __func__); | ||
2351 | break; | ||
2367 | } | 2352 | } |
2353 | |||
2354 | down_write(&policy->rwsem); | ||
2355 | policy->user_policy.max = policy->max; | ||
2356 | cpufreq_governor_limits(policy); | ||
2357 | up_write(&policy->rwsem); | ||
2368 | } | 2358 | } |
2369 | 2359 | ||
2370 | return ret; | 2360 | return ret; |