From: Pierre Gondois Date: Thu, 28 May 2026 09:09:04 +0000 (+0200) Subject: cpufreq: Set default policy->min/max values for all drivers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=743a3cddb1f0aa45f0a277a494de653097c7a378;p=thirdparty%2Flinux.git cpufreq: Set default policy->min/max values for all drivers Some drivers set policy->min/max in their .init() callback, but cpufreq_set_policy() will ultimately override them through: cpufreq_policy_online() \-cpufreq_init_policy() \-cpufreq_set_policy() \-/* Set policy->min/max */ Thus the policy min/max values set by the drivers are only temporary. There is an exception if CPUFREQ_NEED_INITIAL_FREQ_CHECK is set and cpufreq_policy_online() calls __cpufreq_driver_target() which invokes cpufreq_driver->target(). To prepare for a subsequent change that will remove all initialization of policy->min/max in driver .init() callbacks if the min/max value is equal to the corresponding cpuinfo.min/max_freq, set default policy->min/max values in the core for all drivers. Signed-off-by: Pierre Gondois Reviewed-by: Jie Zhan [ rjw: Edits of the new comment and changelog ] Link: https://patch.msgid.link/20260528090913.2759118-3-pierre.gondois@arm.com Signed-off-by: Rafael J. Wysocki --- diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 584e4fcbf0443..253d3ba4217cc 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1474,6 +1474,13 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy, goto out_offline_policy; } + /* + * If the driver hasn't set policy->min/max, set them as they + * are used for clamping frequency requests. + */ + policy->min = policy->min ? policy->min : policy->cpuinfo.min_freq; + policy->max = policy->max ? policy->max : policy->cpuinfo.max_freq; + /* related_cpus should at least include policy->cpus. */ cpumask_copy(policy->related_cpus, policy->cpus); }