[PATCH v2 2/4] cpufreq: Set default policy->min/max values for all drivers

From: Pierre Gondois

Date: Mon May 11 2026 - 09:58:49 EST


Some drivers set policy->min/max in their .init() callback.
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 provided are only temporary.

There is an exception if CPUFREQ_NEED_INITIAL_FREQ_CHECK is set and:
cpufreq_policy_online()
\-__cpufreq_driver_target()
\-cpufreq_driver->target()

To prepare for a following patch that will remove all
policy->min/max initialization in the driver .init() callback
if the min/max value is equal to the cpuinfo.min/max_freq,
set a default policy->min/max value for all drivers.

Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx>
---
drivers/cpufreq/cpufreq.c | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 034603c2af325..9e2d9d3fc5351 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1401,6 +1401,13 @@ static int cpufreq_policy_init_qos(struct cpufreq_policy *policy)
{
int ret;

+ /*
+ * If the driver didn't set policy->min/max, set them as
+ * they are used to clamp frequency requests.
+ */
+ policy->min = policy->min ? policy->min : policy->cpuinfo.min_freq;
+ policy->max = policy->max ? policy->max : policy->cpuinfo.max_freq;
+
if (policy->boost_supported) {
ret = freq_qos_add_request(&policy->constraints,
&policy->boost_freq_req,
--
2.43.0