]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpufreq: Use policy->min/max init as QoS request
authorPierre Gondois <pierre.gondois@arm.com>
Thu, 28 May 2026 09:09:06 +0000 (11:09 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 8 Jun 2026 16:42:14 +0000 (18:42 +0200)
Modify cpufreq_policy_init_qos() introduced previously to use
policy->min/max set in the driver .init() callback as the initial
values for the policy min/max frequency QoS requests, respectively,
so long as they are different from 0 (which means that they have
been updated by the driver). Update the documentation in accordance
with that code change.

This only affects the following drivers:

 - gx-suspmod (min)
 - cppc-cpufreq (min)
 - longrun (min/max)

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
[ rjw: Changelog rewrite ]
Link: https://patch.msgid.link/20260528090913.2759118-5-pierre.gondois@arm.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/cpu-freq/cpu-drivers.rst
drivers/cpufreq/cpufreq.c

index c5635ac3de54748791f5de56e4bf943ad7058251..17c69f83691e2aaadf9fb1f92b94b423d6631ac9 100644 (file)
@@ -114,8 +114,13 @@ Then, the driver must fill in the following values:
 |policy->cur                       | The current operating frequency of   |
 |                                  | this CPU (if appropriate)            |
 +-----------------------------------+--------------------------------------+
-|policy->min,                      |                                      |
-|policy->max,                      |                                      |
+|policy->min,                      | The min/max scaling frequency.       |
+|policy->max                       | If set by the driver in ->init(),    |
+|                                  | used as the lower/upper bound for    |
+|                                  | policy frequency QoS requests;       |
+|                                  | otherwise, reflects the min/max      |
+|                                  | frequency the driver can set         |
++-----------------------------------+--------------------------------------+
 |policy->policy and, if necessary,  |                                     |
 |policy->governor                  | must contain the "default policy" for|
 |                                  | this CPU. A few moments later,       |
index 253d3ba4217cc3847049a2e458323e50e2f0259a..a81d40f120293a480652849f08486814e62fa303 100644 (file)
@@ -1399,8 +1399,16 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)
 
 static int cpufreq_policy_init_qos(struct cpufreq_policy *policy)
 {
+       unsigned int min_freq, max_freq;
        int ret;
 
+       /* Use policy->min/max set by the driver as QoS requests. */
+       min_freq = max(FREQ_QOS_MIN_DEFAULT_VALUE, policy->min);
+       if (policy->max)
+               max_freq = min(FREQ_QOS_MAX_DEFAULT_VALUE, policy->max);
+       else
+               max_freq = FREQ_QOS_MAX_DEFAULT_VALUE;
+
        if (policy->boost_supported) {
                ret = freq_qos_add_request(&policy->constraints,
                                                &policy->boost_freq_req,
@@ -1411,12 +1419,12 @@ static int cpufreq_policy_init_qos(struct cpufreq_policy *policy)
        }
 
        ret = freq_qos_add_request(&policy->constraints, &policy->min_freq_req,
-                                  FREQ_QOS_MIN, FREQ_QOS_MIN_DEFAULT_VALUE);
+                                  FREQ_QOS_MIN, min_freq);
        if (ret < 0)
                return ret;
 
        ret = freq_qos_add_request(&policy->constraints, &policy->max_freq_req,
-                                  FREQ_QOS_MAX, FREQ_QOS_MAX_DEFAULT_VALUE);
+                                  FREQ_QOS_MAX, max_freq);
        if (ret < 0)
                return ret;