Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 298ae469 authored by Puja Gupta's avatar Puja Gupta
Browse files

sched: Use efficiency values from device tree



Even if energy model is available read the efficiency values from device
tree and use those values.

Change-Id: Icf6bf6004bb95b364645c5d945c99e5e85266d55
Signed-off-by: default avatarPuja Gupta <pujag@codeaurora.org>
parent b00992f4
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@
#include <linux/sched_energy.h>
#include <linux/sched_energy.h>


DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE;
DEFINE_PER_CPU(unsigned long, freq_scale) = SCHED_CAPACITY_SCALE;
DEFINE_PER_CPU(unsigned long, efficiency) = SCHED_CAPACITY_SCALE;


void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq,
void arch_set_freq_scale(struct cpumask *cpus, unsigned long cur_freq,
			 unsigned long max_freq)
			 unsigned long max_freq)
@@ -362,6 +363,7 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
	ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz",
	ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz",
				   &cpu_capacity);
				   &cpu_capacity);
	if (!ret) {
	if (!ret) {
		per_cpu(efficiency, cpu) = cpu_capacity;
		if (!raw_capacity) {
		if (!raw_capacity) {
			raw_capacity = kcalloc(num_possible_cpus(),
			raw_capacity = kcalloc(num_possible_cpus(),
					       sizeof(*raw_capacity),
					       sizeof(*raw_capacity),
+7 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,13 @@ unsigned long topology_get_cpu_scale(struct sched_domain *sd, int cpu)


void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);
void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);


DECLARE_PER_CPU(unsigned long, efficiency);
static inline
unsigned long topology_get_cpu_efficiency(int cpu)
{
	return per_cpu(efficiency, cpu);
}

DECLARE_PER_CPU(unsigned long, freq_scale);
DECLARE_PER_CPU(unsigned long, freq_scale);


static inline
static inline
+2 −3
Original line number Original line Diff line number Diff line
@@ -168,7 +168,7 @@ static int sched_energy_probe(struct platform_device *pdev)
	for_each_possible_cpu(cpu) {
	for_each_possible_cpu(cpu) {
		struct device *cpu_dev;
		struct device *cpu_dev;
		struct dev_pm_opp *opp;
		struct dev_pm_opp *opp;
		int efficiency = topology_get_cpu_scale(NULL, cpu);
		int efficiency = topology_get_cpu_efficiency(cpu);


		max_efficiency = max(efficiency, max_efficiency);
		max_efficiency = max(efficiency, max_efficiency);


@@ -202,7 +202,7 @@ static int sched_energy_probe(struct platform_device *pdev)
	for_each_possible_cpu(cpu) {
	for_each_possible_cpu(cpu) {
		unsigned long cpu_max_cap;
		unsigned long cpu_max_cap;
		struct sched_group_energy *sge_l0, *sge;
		struct sched_group_energy *sge_l0, *sge;
		int efficiency = topology_get_cpu_scale(NULL, cpu);
		int efficiency = topology_get_cpu_efficiency(cpu);


		cpu_max_cap = DIV_ROUND_UP(SCHED_CAPACITY_SCALE *
		cpu_max_cap = DIV_ROUND_UP(SCHED_CAPACITY_SCALE *
					   max_frequencies[cpu], max_freq);
					   max_frequencies[cpu], max_freq);
@@ -264,7 +264,6 @@ static int sched_energy_probe(struct platform_device *pdev)
			cpu, efficiency, max_frequencies[cpu], max_efficiency,
			cpu, efficiency, max_frequencies[cpu], max_efficiency,
			cpu_max_cap);
			cpu_max_cap);


		arch_update_cpu_capacity(cpu);
	}
	}


	kfree(max_frequencies);
	kfree(max_frequencies);
+2 −2
Original line number Original line Diff line number Diff line
@@ -1080,11 +1080,11 @@ static void init_sched_groups_energy(int cpu, struct sched_domain *sd,
		if (energy_eff(sge, i) > energy_eff(sge, i+1))
		if (energy_eff(sge, i) > energy_eff(sge, i+1))
			continue;
			continue;
#ifdef CONFIG_SCHED_DEBUG
#ifdef CONFIG_SCHED_DEBUG
		pr_warn("WARN: cpu=%d, domain=%s: incr. energy eff %lu[%d]->%lu[%d]\n",
		pr_debug("WARN: cpu=%d, domain=%s: incr. energy eff %lu[%d]->%lu[%d]\n",
			cpu, sd->name, energy_eff(sge, i), i,
			cpu, sd->name, energy_eff(sge, i), i,
			energy_eff(sge, i+1), i+1);
			energy_eff(sge, i+1), i+1);
#else
#else
		pr_warn("WARN: cpu=%d: incr. energy eff %lu[%d]->%lu[%d]\n",
		pr_debug("WARN: cpu=%d: incr. energy eff %lu[%d]->%lu[%d]\n",
			cpu, energy_eff(sge, i), i, energy_eff(sge, i+1), i+1);
			cpu, energy_eff(sge, i), i, energy_eff(sge, i+1), i+1);
#endif
#endif
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -2070,7 +2070,7 @@ static struct sched_cluster *alloc_new_cluster(const struct cpumask *cpus)


	raw_spin_lock_init(&cluster->load_lock);
	raw_spin_lock_init(&cluster->load_lock);
	cluster->cpus = *cpus;
	cluster->cpus = *cpus;
	cluster->efficiency = topology_get_cpu_scale(NULL, cpumask_first(cpus));
	cluster->efficiency = topology_get_cpu_efficiency(cpumask_first(cpus));


	if (cluster->efficiency > max_possible_efficiency)
	if (cluster->efficiency > max_possible_efficiency)
		max_possible_efficiency = cluster->efficiency;
		max_possible_efficiency = cluster->efficiency;