Re: [PATCH V4 2/2] base/drivers/arch_topology: Default dmips-mhz if they are not set in DT

From: Quentin Perret
Date: Mon Nov 26 2018 - 07:48:33 EST


On Monday 26 Nov 2018 at 13:20:43 (+0100), Daniel Lezcano wrote:
> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
> index fd5325b..e0c5b60 100644
> --- a/drivers/base/arch_topology.c
> +++ b/drivers/base/arch_topology.c
> @@ -243,9 +243,20 @@ static int __init register_cpufreq_notifier(void)
> * until we have the necessary code to parse the cpu capacity, so
> * skip registering cpufreq notifier.
> */
> - if (!acpi_disabled || !raw_capacity)
> + if (!acpi_disabled)
> return -EINVAL;
>
> + if (!raw_capacity) {
> +
> + pr_info("cpu_capacity: No capacity defined in DT, set default "
> + "values to %ld\n", SCHED_CAPACITY_SCALE);
> +
> + raw_capacity = kmalloc_array(num_possible_cpus(),
> + sizeof(*raw_capacity), GFP_KERNEL);
> + if (!raw_capacity)
> + return -ENOMEM;
> + }
> +
> if (!alloc_cpumask_var(&cpus_to_visit, GFP_KERNEL)) {
> pr_err("cpu_capacity: failed to allocate memory for cpus_to_visit\n");
> return -ENOMEM;

I just tried on my Juno by removing the capacity-dmips-mhz values from
the DT and got the following:

$ cat /sys/devices/system/cpu/cpufreq/policy*/scaling_available_frequencies
450000 575000 700000 775000 850000
450000 625000 800000 950000 1100000
$ cat /sys/devices/system/cpu/cpu*/cpu_capacity
791
1024
1024
791
791
791

Same thing with a partially-filled DT (which is the expected behaviour
now). So feel free to add:

Tested-by: Quentin Perret <quentin.perret@xxxxxxx>

Thanks,
Quentin