diff options
author | Ruchi Kandoi <kandoiruchi@google.com> | 2015-06-05 18:21:56 -0700 |
---|---|---|
committer | Ruchi Kandoi <kandoiruchi@google.com> | 2015-06-08 17:53:22 +0000 |
commit | 5862c50d1970886b5b5a57b5b52ecfd6feb95ebd (patch) | |
tree | aa24b669fb7293eb861b0831f570986f7331472d | |
parent | 5371356ed838799125b1379fa38cdddfd1d189fd (diff) | |
download | edison-v3.10-5862c50d1970886b5b5a57b5b52ecfd6feb95ebd.tar.gz |
cpufreq: Iterate over all the possible cpus to create powerstats.
For architectures which support a single policy for multiple cpus,
powerstats will not be initalized for all the cores. This change will
make sure powerstats is initialized for all the cores.
Also minor changes to increase code readability.
Bug: 21498425
Change-Id: I938f45e92ff6d5371c32c4d0e37274e6de66769c
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index c441758e01a..74cd3df8a52 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -597,7 +597,7 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb, int ret, count = 0, i; struct cpufreq_policy *policy = data; struct cpufreq_frequency_table *table; - unsigned int cpu = policy->cpu; + unsigned int cpu_num, cpu = policy->cpu; if (val == CPUFREQ_UPDATE_POLICY_CPU) { cpufreq_stats_update_policy_cpu(policy); @@ -621,8 +621,10 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb, if (!per_cpu(all_cpufreq_stats, cpu)) cpufreq_allstats_create(cpu, table, count); - if (!per_cpu(cpufreq_power_stats, cpu)) - cpufreq_powerstats_create(cpu, table, count); + for_each_possible_cpu(cpu_num) { + if (!per_cpu(cpufreq_power_stats, cpu_num)) + cpufreq_powerstats_create(cpu_num, table, count); + } ret = cpufreq_stats_create_table(policy, table, count); if (ret) @@ -670,7 +672,7 @@ static int cpufreq_stats_create_table_cpu(unsigned int cpu) { struct cpufreq_policy *policy; struct cpufreq_frequency_table *table; - int ret = -ENODEV, i, count = 0; + int i, count, cpu_num, ret = -ENODEV; policy = cpufreq_cpu_get(cpu); if (!policy) @@ -680,19 +682,21 @@ static int cpufreq_stats_create_table_cpu(unsigned int cpu) if (!table) goto out; + count = 0; for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) { unsigned int freq = table[i].frequency; - if (freq == CPUFREQ_ENTRY_INVALID) - continue; - count++; + if (freq != CPUFREQ_ENTRY_INVALID) + count++; } if (!per_cpu(all_cpufreq_stats, cpu)) cpufreq_allstats_create(cpu, table, count); - if (!per_cpu(cpufreq_power_stats, cpu)) - cpufreq_powerstats_create(cpu, table, count); + for_each_possible_cpu(cpu_num) { + if (!per_cpu(cpufreq_power_stats, cpu_num)) + cpufreq_powerstats_create(cpu_num, table, count); + } ret = cpufreq_stats_create_table(policy, table, count); |