From 94f94856621c7f4476d347140d2592d82f5fdbb4 Mon Sep 17 00:00:00 2001 From: Park Bumgyu Date: Thu, 5 Apr 2018 15:33:08 +0900 Subject: [PATCH] sched: ems: parsing energy data to build energy table To build energy table, parse the mips and coefficient from device tree. Change-Id: If7db3c4d67cb62a983cccd452ce2546feabe5e27 Signed-off-by: Park Bumgyu --- kernel/sched/ems/core.c | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/kernel/sched/ems/core.c b/kernel/sched/ems/core.c index b24d3f76db63..f75c9b2a96c0 100644 --- a/kernel/sched/ems/core.c +++ b/kernel/sched/ems/core.c @@ -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, }; -- 2.20.1