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

Commit 59316b8f authored by Puja Gupta's avatar Puja Gupta
Browse files

ANDROID: Separate cpu_scale and energy model setup



Keep the cpu_scale calculation in the arch_topology driver the way it is
done in mainline. This will require appropriate capacity-dmips-mhz
properties in the dt file.

Do the energy model setup completely separate in kernel/sched/energy.c.

This will allow to adapt the non-mainline energy model code more easily.

Change-Id: I51af46e0f588e82512417fd168e25cec90dc9319
Signed-off-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
Git-commit: 70b670cc0c97ff350f260b827ca2e18799a57972
Git-repo: https://android.googlesource.com/kernel/common/


Signed-off-by: default avatarPuja Gupta <pujag@codeaurora.org>
parent be49c613
Loading
Loading
Loading
Loading
+3 −29
Original line number Diff line number Diff line
@@ -36,22 +36,12 @@ static inline
const struct sched_group_energy * const cpu_core_energy(int cpu)
{
	struct sched_group_energy *sge = sge_array[cpu][SD_LEVEL0];
	unsigned long capacity;
	int max_cap_idx;

	if (sched_is_energy_aware() && !sge) {
		pr_warn("Invalid sched_group_energy for CPU%d\n", cpu);
		return NULL;
	}

	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;
}

@@ -207,26 +197,10 @@ static void __init parse_dt_topology(void)
 */
static void update_cpu_capacity(unsigned int cpu)
{
	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, capacity);
	topology_set_cpu_scale(cpu, cpu_capacity(cpu) / middle_capacity);

	pr_info("CPU%u: update cpu_capacity %lu\n",
		cpu, topology_get_cpu_scale(NULL, cpu));
+0 −10
Original line number Diff line number Diff line
@@ -309,22 +309,12 @@ static inline
const struct sched_group_energy * const cpu_core_energy(int cpu)
{
	struct sched_group_energy *sge = sge_array[cpu][SD_LEVEL0];
	unsigned long capacity;
	int max_cap_idx;

	if (sched_is_energy_aware() && !sge) {
		pr_warn("Invalid sched_group_energy for CPU%d\n", cpu);
		return NULL;
	}

	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;
}

+2 −11
Original line number Diff line number Diff line
@@ -73,10 +73,6 @@ static ssize_t cpu_capacity_store(struct device *dev,
	if (!count)
		return 0;

	/* don't allow changes if sched-group-energy is installed */
	if(sched_energy_installed(this_cpu))
		return -EINVAL;

	ret = kstrtoul(buf, 0, &new_capacity);
	if (ret)
		return ret;
@@ -357,19 +353,14 @@ void topology_normalize_cpu_scale(void)
bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
{
	static bool cap_parsing_failed;
	int ret = 0;
	int ret;
	u32 cpu_capacity;

	if (cap_parsing_failed)
		return false;

	/* override capacity-dmips-mhz if we have sched-energy-costs */
	if (of_find_property(cpu_node, "sched-energy-costs", NULL))
		cpu_capacity = topology_get_cpu_scale(NULL, cpu);
	else
	ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz",
				   &cpu_capacity);

	if (!ret) {
		if (!raw_capacity) {
			raw_capacity = kcalloc(num_possible_cpus(),
+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ extern struct sched_group_energy *sge_array[NR_CPUS][NR_SD_LEVELS];

#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
void init_sched_energy_costs(void);
int sched_energy_installed(int cpu);
#else
void init_sched_energy_costs(void) {}
#endif
+0 −19
Original line number Diff line number Diff line
@@ -49,21 +49,6 @@ static void free_resources(void)
	}
}

static inline unsigned long cpu_max_capacity(int cpu)
{
	if (!sge_array[cpu][0]->cap_states)
		return 1024;
	if (!sge_array[cpu][0]->nr_cap_states)
		return 1024;

	return sge_array[cpu][0]->cap_states[sge_array[cpu][0]->nr_cap_states-1].cap;
}

int sched_energy_installed(int cpu)
{
	return (sge_array[cpu][0]->cap_states != NULL);
}

void init_sched_energy_costs(void)
{
	struct device_node *cn, *cp;
@@ -148,10 +133,6 @@ void init_sched_energy_costs(void)
			sge->idle_states = idle_states;

			sge_array[cpu][sd_level] = sge;

			/* populate cpu scale so that flags get set correctly */
			if (sd_level == 0)
				topology_set_cpu_scale(cpu, cpu_max_capacity(cpu));
		}
	}