From: Finley Xiao Date: Sun, 8 Jan 2017 02:11:55 +0000 (+0800) Subject: PM / AVS: rockchip-cpu-avs: check initial rate early X-Git-Tag: firefly_0821_release~796 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=db7745d6180822a148c11356d98dd92f0dae33d5;p=firefly-linux-kernel-4.4.55.git PM / AVS: rockchip-cpu-avs: check initial rate early As merge the commit 388612baba20 ("cpufreq: Send START policy notification after sending CREATE"), cpufreq stats table is created earlier. In order to get correct table index, check initial rate when receive CREATE and START notification events. Change-Id: I1ccc6d41704ae8c01156103bbd82888e4e37cd0c Signed-off-by: Finley Xiao --- diff --git a/drivers/power/avs/rockchip-cpu-avs.c b/drivers/power/avs/rockchip-cpu-avs.c index 93a1720dc378..0f14d6919a9b 100644 --- a/drivers/power/avs/rockchip-cpu-avs.c +++ b/drivers/power/avs/rockchip-cpu-avs.c @@ -47,6 +47,7 @@ struct cluster_info { unsigned int min_freq; unsigned int min_volt; struct leakage_volt_table *table; + unsigned int adjust_done; }; struct rockchip_cpu_avs { @@ -108,27 +109,19 @@ static int rockchip_cpu_avs_notifier(struct notifier_block *nb, int i, id, cpu = policy->cpu; int ret; - if (event == CPUFREQ_CREATE_POLICY) { - for (id = 0; id < MAX_CLUSTERS; id++) { - if (cpumask_test_cpu(policy->cpu, - &avs->allowed_cpus[id])) - break; - if (cpumask_empty(&avs->allowed_cpus[id])) { - cpumask_copy(&avs->allowed_cpus[id], - policy->related_cpus); - break; - } - } - goto out; - } - - if (event != CPUFREQ_START) + if (event != CPUFREQ_CREATE_POLICY && event != CPUFREQ_START) goto out; for (id = 0; id < MAX_CLUSTERS; id++) { if (cpumask_test_cpu(cpu, &avs->allowed_cpus[id])) break; + if (cpumask_empty(&avs->allowed_cpus[id])) { + cpumask_copy(&avs->allowed_cpus[id], + policy->related_cpus); + break; + } } + if (id == MAX_CLUSTERS) { pr_err("cpu%d invalid cluster id\n", cpu); goto out; @@ -157,7 +150,23 @@ static int rockchip_cpu_avs_notifier(struct notifier_block *nb, goto next; } - rockchip_leakage_adjust_table(cpu_dev, policy->freq_table, cluster); + /* + * First time, CPUFREQ_CREATE_POLICY, adjust talbe + * Second time, CPUFREQ_START, no need to adjust again + * Later, cpu down and up, CPUFREQ_START, adjust table + */ + if (event == CPUFREQ_CREATE_POLICY) { + rockchip_leakage_adjust_table(cpu_dev, policy->freq_table, + cluster); + cluster->adjust_done = 1; + } else if (event == CPUFREQ_START) { + if (cluster->adjust_done == 1) + cluster->adjust_done = 0; + else + rockchip_leakage_adjust_table(cpu_dev, + policy->freq_table, + cluster); + } next: if (avs->check_done[id] == 0) {