Skip to contentSkip to conversation

cpufreq: query regarding policy->min/max & policy->cpuinfo.min_freq/max_freq

DISCUSSION Rahul Pathak 1 participant 1 message Mar 10, 2023

lore
Share & tools
lore
#0 lore raw

Hi

Sorry for the long email.

I have a query on the use case where the platform driver during initialization can choose to configure policy->min/max with a range which is a subset of policy->cpuinfo.min_freq/max_freq. I am trying to understand if choosing a subset of range should be preserved until any governor or explicit change from userspace changes the
range.

Let me take an example -
From cppc_cpufreq.c which does this exactly -

/*
* Set min to lowest nonlinear perf to avoid any efficiency penalty (see
* Section 8.4.7.1.1.5 of ACPI 6.1 spec)
*/
policy->min = cppc_cpufreq_perf_to_khz(cpu_data,

       caps->lowest_nonlinear_perf);
policy->max = cppc_cpufreq_perf_to_khz(cpu_data,
       caps->nominal_perf);

/*
* Set cpuinfo.min_freq to Lowest to make the full range of performance
* available if userspace wants to use any perf between lowest & lowest
* nonlinear perf
*/
policy->cpuinfo.min_freq = cppc_cpufreq_perf_to_khz(cpu_data,

    caps->lowest_perf);
policy->cpuinfo.max_freq = cppc_cpufreq_perf_to_khz(cpu_data,
    caps->nominal_perf);

During initialization when cpufreq core calls the cpufreq_init_policy() and later cpufreq_set_policy(), inside that the new_data.min/max are not there as valid values since there is no user input during initialization.

new_data.min = freq_qos_read_value(&policy->constraints, FREQ_QOS_MIN); new_data.max = freq_qos_read_value(&policy->constraints, FREQ_QOS_MAX);

So, only taking the case of new_data.min which is set to 0 at this time.

When subsequent cpufreq_driver->verify() compares the new_data.min with cpuinfo->min_freq inside cpufreq_verify_within_cpu_limits() it extends the policy->min to policy->cpuinfo.min_freq. Which ultimately becomes the new effective minimum possible.

This means that setting the initial policy->min/max different from full range policy->cpuinfo.min_freq/max_freq has no effect and it will always be extended in the initialization only. And the driver should always set policy->min/max same as policy->cpuinfo.min_freq/max_freq. Is this the right understanding?

Thanks
Rahul