arm: use cpu scale value derived from energy model
authorDietmar Eggemann <dietmar.eggemann@arm.com>
Tue, 8 Aug 2017 13:22:44 +0000 (14:22 +0100)
committerLukasz Luba <l.luba@partner.samsung.com>
Mon, 10 Sep 2018 08:21:19 +0000 (10:21 +0200)
To make sure that the capacity value of the last element of the capacity
states vector of the energy model (EM) core (MC) level is equal to the
cpu scale value, use this capacity value to overwrite the cpu scale
value preeviously derived from the Cpu Invariant Engine (CIE).

This patch is necessary as long as there is no complete EM support in
device tree.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Lukasz Luba <l.luba@partner.samsung.com>
arch/arm/kernel/topology.c

index 4cbb4e406b7d6e142bc6596d0c740e13724dae38..226dd6256e7cdd05d9512a9575d8383c9eaf24fe 100644 (file)
@@ -290,10 +290,26 @@ static void __init parse_dt_topology(void)
  */
 static void update_cpu_capacity(unsigned int cpu)
 {
-       if (!cpu_capacity(cpu) || cap_from_dt)
-               return;
+       const struct sched_group_energy *sge;
+       unsigned long capacity;
+
+       sge = cpu_core_energy(cpu);
+
+       if (sge) {
+               int max_cap_idx;
+
+               max_cap_idx = sge->nr_cap_states - 1;
+               capacity = sge->cap_states[max_cap_idx].cap;
+
+               printk_deferred("cpu=%d set cpu scale %lu from energy model\n",
+                               cpu, capacity);
+       } else {
+               if (!cpu_capacity(cpu) || cap_from_dt)
+                       return;
+               capacity = cpu_capacity(cpu) / middle_capacity;
+       }
 
-       topology_set_cpu_scale(cpu, cpu_capacity(cpu) / middle_capacity);
+       topology_set_cpu_scale(cpu, capacity);
 
        pr_info("CPU%u: update cpu_capacity %lu\n",
                cpu, topology_get_cpu_scale(NULL, cpu));