arm64: use cpu scale value derived from energy model
authorDietmar Eggemann <dietmar.eggemann@arm.com>
Mon, 7 Aug 2017 16:53:36 +0000 (17:53 +0100)
committerLukasz Luba <l.luba@partner.samsung.com>
Mon, 10 Sep 2018 08:24:12 +0000 (10:24 +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/arm64/kernel/energy_model.h

index 0a7c13466cdee8c826fddd7bf443ebda693f5d13..fc62ca5816fa2e8d6e59c6e471532d6d8735977d 100644 (file)
@@ -243,7 +243,23 @@ struct sched_group_energy *energy(int cpu, struct sched_group_energy **sge)
 static inline
 const struct sched_group_energy * const cpu_core_energy(int cpu)
 {
-       return core_energy ? energy(cpu, core_energy) : NULL;
+       struct sched_group_energy *sge = NULL;
+
+       if (core_energy) {
+               unsigned long capacity;
+               int max_cap_idx;
+
+               sge = energy(cpu, core_energy);
+               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);
+
+               topology_set_cpu_scale(cpu, capacity);
+       }
+
+       return sge;
 }
 
 static inline