Skip to content

Commit 5477fa2

Browse files
vingu-linaroingomolnar
authored andcommitted
cpufreq/cppc: Set the frequency used for computing the capacity
Save the frequency associated to the performance that has been used when initializing the capacity of CPUs. Also, cppc cpufreq driver can register an artificial energy model. In such case, it needs the frequency for this compute capacity. Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Tested-by: Pierre Gondois <pierre.gondois@arm.com> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://lore.kernel.org/r/20231211104855.558096-7-vincent.guittot@linaro.org
1 parent 50b813b commit 5477fa2

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

drivers/base/arch_topology.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
349349

350350
void topology_init_cpu_capacity_cppc(void)
351351
{
352+
u64 capacity, capacity_scale = 0;
352353
struct cppc_perf_caps perf_caps;
353354
int cpu;
354355

@@ -365,6 +366,10 @@ void topology_init_cpu_capacity_cppc(void)
365366
(perf_caps.highest_perf >= perf_caps.nominal_perf) &&
366367
(perf_caps.highest_perf >= perf_caps.lowest_perf)) {
367368
raw_capacity[cpu] = perf_caps.highest_perf;
369+
capacity_scale = max_t(u64, capacity_scale, raw_capacity[cpu]);
370+
371+
per_cpu(capacity_freq_ref, cpu) = cppc_perf_to_khz(&perf_caps, raw_capacity[cpu]);
372+
368373
pr_debug("cpu_capacity: CPU%d cpu_capacity=%u (raw).\n",
369374
cpu, raw_capacity[cpu]);
370375
continue;
@@ -375,7 +380,15 @@ void topology_init_cpu_capacity_cppc(void)
375380
goto exit;
376381
}
377382

378-
topology_normalize_cpu_scale();
383+
for_each_possible_cpu(cpu) {
384+
capacity = raw_capacity[cpu];
385+
capacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT,
386+
capacity_scale);
387+
topology_set_cpu_scale(cpu, capacity);
388+
pr_debug("cpu_capacity: CPU%d cpu_capacity=%lu\n",
389+
cpu, topology_get_cpu_scale(cpu));
390+
}
391+
379392
schedule_work(&update_topology_flags_work);
380393
pr_debug("cpu_capacity: cpu_capacity initialization done\n");
381394

0 commit comments

Comments
 (0)