[PATCH v2 4/4] cpufreq: Use policy->min/max init as QoS request

From: Pierre Gondois

Date: Mon May 11 2026 - 09:57:36 EST


Consider policy->min/max being set in the driver .init()
callback as a QoS request. Impacted driver are:
- gx-suspmod.c (min)
- cppc-cpufreq.c (min)
- longrun.c (min/max)

Update the documentation accordingly.

Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx>
---
Documentation/cpu-freq/cpu-drivers.rst | 10 ++++++++--
drivers/cpufreq/cpufreq.c | 12 ++++++++++--
2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/Documentation/cpu-freq/cpu-drivers.rst b/Documentation/cpu-freq/cpu-drivers.rst
index c5635ac3de547..ab4f3c0f3a89b 100644
--- a/Documentation/cpu-freq/cpu-drivers.rst
+++ b/Documentation/cpu-freq/cpu-drivers.rst
@@ -114,8 +114,14 @@ 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 | If set by the driver in ->init(), |
+| | used as initial minimum frequency |
+| | QoS request. |
++-----------------------------------+--------------------------------------+
+|policy->max | If set by the driver in ->init(), |
+| | used as initial maximum frequency |
+| | QoS request. |
++-----------------------------------+--------------------------------------+
|policy->policy and, if necessary, | |
|policy->governor | must contain the "default policy" for|
| | this CPU. A few moments later, |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 9e2d9d3fc5351..9a005367ed87b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -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 the driver didn't set policy->min/max, set them as
* they are used to clamp frequency requests.
@@ -1418,12 +1426,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;

--
2.43.0