sched: ems: parsing energy data to build energy table
authorPark Bumgyu <bumgyu.park@samsung.com>
Thu, 5 Apr 2018 06:33:08 +0000 (15:33 +0900)
committerChungwoo Park <cww.park@samsung.com>
Mon, 21 May 2018 08:35:32 +0000 (17:35 +0900)
To build energy table, parse the mips and coefficient from device tree.

Change-Id: If7db3c4d67cb62a983cccd452ce2546feabe5e27
Signed-off-by: Park Bumgyu <bumgyu.park@samsung.com>
kernel/sched/ems/core.c

index b24d3f76db63062cc71be8538eecd2d8ad0b83aa..f75c9b2a96c094f6626af6f1419ee1608fbeedb8 100644 (file)
@@ -33,6 +33,8 @@ static int cpu_util_wake(int cpu, struct task_struct *p)
 }
 
 struct energy_table {
+       unsigned int mips;
+       unsigned int coefficient;;
        struct capacity_state *states;
        unsigned int nr_states;
 };
@@ -139,6 +141,47 @@ static void find_eco_target(struct eco_env *eenv)
        eenv->backup_cpu = backup_cpu;
 }
 
+static int __init init_sched_energy_data(void)
+{
+       struct device_node *cpu_node, *cpu_phandle;
+       int cpu;
+
+       for_each_possible_cpu(cpu) {
+               struct energy_table *table;
+
+               cpu_node = of_get_cpu_node(cpu, NULL);
+               if (!cpu_node) {
+                       pr_warn("CPU device node missing for CPU %d\n", cpu);
+                       return -ENODATA;
+               }
+
+               cpu_phandle = of_parse_phandle(cpu_node, "sched-energy-data", 0);
+               if (!cpu_phandle) {
+                       pr_warn("CPU device node has no sched-energy-data\n");
+                       return -ENODATA;
+               }
+
+               table = &per_cpu(energy_table, cpu);
+               if (of_property_read_u32(cpu_phandle, "capacity-mips", &table->mips)) {
+                       pr_warn("No capacity-mips data\n");
+                       return -ENODATA;
+               }
+
+               if (of_property_read_u32(cpu_phandle, "power-coefficient", &table->coefficient)) {
+                       pr_warn("No power-coefficient data\n");
+                       return -ENODATA;
+               }
+
+               of_node_put(cpu_phandle);
+               of_node_put(cpu_node);
+
+               pr_info("cpu%d mips=%d, coefficient=%d\n", cpu, table->mips, table->coefficient);
+       }
+
+       return 0;
+}
+pure_initcall(init_sched_energy_data);
+
 static unsigned int calculate_energy(struct task_struct *p, int target_cpu)
 {
        unsigned long util[NR_CPUS] = {0, };