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

Commit fda5258f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "arm: topology: Export arch_get_cpu_efficiency API"

parents 702eba00 b10a8a84
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ extern struct cputopo_arm cpu_topology[NR_CPUS];
void init_cpu_topology(void);
void store_cpu_topology(unsigned int cpuid);
const struct cpumask *cpu_coregroup_mask(int cpu);
unsigned long arch_get_cpu_efficiency(int cpu);

#ifdef CONFIG_CPU_FREQ
#define arch_scale_freq_capacity cpufreq_scale_freq_capacity
+29 −6
Original line number Diff line number Diff line
@@ -196,6 +196,14 @@ static int __init parse_cluster(struct device_node *cluster, int depth)
	return 0;
}

static DEFINE_PER_CPU(unsigned long, cpu_efficiency) = SCHED_CAPACITY_SCALE;

unsigned long arch_get_cpu_efficiency(int cpu)
{
	return per_cpu(cpu_efficiency, cpu);
}
EXPORT_SYMBOL(arch_get_cpu_efficiency);

#ifdef CONFIG_OF
struct cpu_efficiency {
	const char *compatible;
@@ -272,6 +280,7 @@ static int __init parse_dt_topology(void)
	for_each_possible_cpu(cpu) {
		const u32 *rate;
		int len;
		u32 efficiency;

		/* too early to use cpu->of_node */
		cn = of_get_cpu_node(cpu, NULL);
@@ -280,13 +289,27 @@ static int __init parse_dt_topology(void)
			continue;
		}

		for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++)
			if (of_device_is_compatible(cn, cpu_eff->compatible))
		/*
		 * The CPU efficiency value passed from the device tree
		 * overrides the value defined in the table_efficiency[]
		 */
		if (of_property_read_u32(cn, "efficiency", &efficiency) < 0) {

			for (cpu_eff = table_efficiency;
					cpu_eff->compatible; cpu_eff++)

				if (of_device_is_compatible(cn,
						cpu_eff->compatible))
					break;

			if (cpu_eff->compatible == NULL)
				continue;

			efficiency = cpu_eff->efficiency;
		}

		per_cpu(cpu_efficiency, cpu) = efficiency;

		rate = of_get_property(cn, "clock-frequency", &len);
		if (!rate || len != 4) {
			pr_err("%s missing clock-frequency property\n",
@@ -294,7 +317,7 @@ static int __init parse_dt_topology(void)
			continue;
		}

		capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
		capacity = ((be32_to_cpup(rate)) >> 20) * efficiency;

		/* Save min capacity of the system */
		if (capacity < min_capacity)