diff options
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 9dd58835456e..5793e1447fb1 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -180,7 +180,7 @@ static void cpufreq_stats_free_table(unsigned int cpu) | |||
180 | cpufreq_cpu_put(policy); | 180 | cpufreq_cpu_put(policy); |
181 | } | 181 | } |
182 | 182 | ||
183 | static int cpufreq_stats_create_table(struct cpufreq_policy *policy, | 183 | static int __cpufreq_stats_create_table(struct cpufreq_policy *policy, |
184 | struct cpufreq_frequency_table *table) | 184 | struct cpufreq_frequency_table *table) |
185 | { | 185 | { |
186 | unsigned int i, j, count = 0, ret = 0; | 186 | unsigned int i, j, count = 0, ret = 0; |
@@ -253,6 +253,26 @@ error_get_fail: | |||
253 | return ret; | 253 | return ret; |
254 | } | 254 | } |
255 | 255 | ||
256 | static void cpufreq_stats_create_table(unsigned int cpu) | ||
257 | { | ||
258 | struct cpufreq_policy *policy; | ||
259 | struct cpufreq_frequency_table *table; | ||
260 | |||
261 | /* | ||
262 | * "likely(!policy)" because normally cpufreq_stats will be registered | ||
263 | * before cpufreq driver | ||
264 | */ | ||
265 | policy = cpufreq_cpu_get(cpu); | ||
266 | if (likely(!policy)) | ||
267 | return; | ||
268 | |||
269 | table = cpufreq_frequency_get_table(policy->cpu); | ||
270 | if (likely(table)) | ||
271 | __cpufreq_stats_create_table(policy, table); | ||
272 | |||
273 | cpufreq_cpu_put(policy); | ||
274 | } | ||
275 | |||
256 | static void cpufreq_stats_update_policy_cpu(struct cpufreq_policy *policy) | 276 | static void cpufreq_stats_update_policy_cpu(struct cpufreq_policy *policy) |
257 | { | 277 | { |
258 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, | 278 | struct cpufreq_stats *stat = per_cpu(cpufreq_stats_table, |
@@ -284,7 +304,7 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb, | |||
284 | return 0; | 304 | return 0; |
285 | 305 | ||
286 | if (val == CPUFREQ_CREATE_POLICY) | 306 | if (val == CPUFREQ_CREATE_POLICY) |
287 | ret = cpufreq_stats_create_table(policy, table); | 307 | ret = __cpufreq_stats_create_table(policy, table); |
288 | else if (val == CPUFREQ_REMOVE_POLICY) | 308 | else if (val == CPUFREQ_REMOVE_POLICY) |
289 | __cpufreq_stats_free_table(policy); | 309 | __cpufreq_stats_free_table(policy); |
290 | 310 | ||
@@ -346,6 +366,9 @@ static int __init cpufreq_stats_init(void) | |||
346 | if (ret) | 366 | if (ret) |
347 | return ret; | 367 | return ret; |
348 | 368 | ||
369 | for_each_online_cpu(cpu) | ||
370 | cpufreq_stats_create_table(cpu); | ||
371 | |||
349 | ret = cpufreq_register_notifier(¬ifier_trans_block, | 372 | ret = cpufreq_register_notifier(¬ifier_trans_block, |
350 | CPUFREQ_TRANSITION_NOTIFIER); | 373 | CPUFREQ_TRANSITION_NOTIFIER); |
351 | if (ret) { | 374 | if (ret) { |