From: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
To: Pierre Gondois <pierre.gondois@arm.com>, linux-kernel@vger.kernel.org
Cc: Jie Zhan <zhanjie9@hisilicon.com>,
Lifeng Zheng <zhenglifeng1@huawei.com>,
Ionela Voinescu <ionela.voinescu@arm.com>,
Sumit Gupta <sumitg@nvidia.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Huang Rui <ray.huang@amd.com>,
Mario Limonciello <mario.limonciello@amd.com>,
Perry Yuan <perry.yuan@amd.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Len Brown <lenb@kernel.org>,
Saravana Kannan <saravanak@kernel.org>,
linux-pm@vger.kernel.org, linux-doc@vger.kernel.org,
zhongqiu.han@oss.qualcomm.com
Subject: Re: [PATCH v2 1/4] cpufreq: Extract cpufreq_policy_init_qos() function
Date: Tue, 19 May 2026 21:51:11 +0800 [thread overview]
Message-ID: <cbf289b8-19d9-46b2-a80c-f72720686c46@oss.qualcomm.com> (raw)
In-Reply-To: <20260511135538.522653-2-pierre.gondois@arm.com>
On 5/11/2026 9:55 PM, Pierre Gondois wrote:
> Extract the QoS related logic from cpufreq_policy_online()
> to make the function shorter/simpler.
>
> The logic is placed in cpufreq_policy_init_qos() and is
> now executed right after the following calls:
> - cpufreq_driver->init()
> - cpufreq_table_validate_and_sort()
>
> This helps preparing following patches that will,
> in cpufreq_policy_init_qos():
> - treat the policy->min/max values set by drivers as QoS requests.
> - set a default policy->min/max value to all policies.
>
> No functional change.
>
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Looks good to me apart from a minor nit inline.
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
> drivers/cpufreq/cpufreq.c | 53 +++++++++++++++++++++++----------------
> 1 file changed, 32 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 44eb1b7e7fc1b..034603c2af325 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1397,6 +1397,32 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)
> kfree(policy);
> }
>
> +static int cpufreq_policy_init_qos(struct cpufreq_policy *policy)
> +{
> + int ret;
> +
> + if (policy->boost_supported) {
> + ret = freq_qos_add_request(&policy->constraints,
> + &policy->boost_freq_req,
> + FREQ_QOS_MAX,
> + policy->cpuinfo.max_freq);
> + if (ret < 0)
> + return ret;
> + }
> +
> + ret = freq_qos_add_request(&policy->constraints, &policy->min_freq_req,
> + FREQ_QOS_MIN, FREQ_QOS_MIN_DEFAULT_VALUE);
> + if (ret < 0)
> + return ret;
> +
> + ret = freq_qos_add_request(&policy->constraints, &policy->max_freq_req,
> + FREQ_QOS_MAX, FREQ_QOS_MAX_DEFAULT_VALUE);
> + if (ret < 0)
> + return ret;
> +
> + return ret;
Just minor nit: cpufreq_policy_init_qos() could perhaps return 0 on
success.
In the original inline code we only checked 'ret < 0', so positive
return values were not intended to propagate as part of the API
contract. Returning 'ret' here may expose a positive success code (e.g.
1) and make the helper easier to misuse (e.g. 'if (ret)' checks).
Returning 0 would keep the semantics unambiguous.
Alternatively, if this behavior is intentional, it might be helpful to
document it with a kdoc comment (e.g. that the function may return 0 or
1 on success and callers should check 'ret < 0' for errors).
> +}
> +
> static int cpufreq_policy_online(struct cpufreq_policy *policy,
> unsigned int cpu, bool new_policy)
> {
> @@ -1442,6 +1468,12 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
> if (ret)
> goto out_offline_policy;
>
> + if (new_policy) {
> + ret = cpufreq_policy_init_qos(policy);
> + if (ret < 0)
> + goto out_offline_policy;
> + }
> +
> /* related_cpus should at least include policy->cpus. */
> cpumask_copy(policy->related_cpus, policy->cpus);
> }
> @@ -1458,27 +1490,6 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
> add_cpu_dev_symlink(policy, j, get_cpu_device(j));
> }
>
> - if (policy->boost_supported) {
> - ret = freq_qos_add_request(&policy->constraints,
> - &policy->boost_freq_req,
> - FREQ_QOS_MAX,
> - policy->cpuinfo.max_freq);
> - if (ret < 0)
> - goto out_destroy_policy;
> - }
> -
> - ret = freq_qos_add_request(&policy->constraints,
> - &policy->min_freq_req, FREQ_QOS_MIN,
> - FREQ_QOS_MIN_DEFAULT_VALUE);
> - if (ret < 0)
> - goto out_destroy_policy;
> -
> - ret = freq_qos_add_request(&policy->constraints,
> - &policy->max_freq_req, FREQ_QOS_MAX,
> - FREQ_QOS_MAX_DEFAULT_VALUE);
> - if (ret < 0)
> - goto out_destroy_policy;
> -
> blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
> CPUFREQ_CREATE_POLICY, policy);
> }
--
Thx and BRs,
Zhongqiu Han
next prev parent reply other threads:[~2026-05-19 13:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 13:55 [PATCH v2 0/4] cpufreq: Set policy->min and max as real QoS constraints Pierre Gondois
2026-05-11 13:55 ` [PATCH v2 1/4] cpufreq: Extract cpufreq_policy_init_qos() function Pierre Gondois
2026-05-19 13:51 ` Zhongqiu Han [this message]
2026-05-28 8:55 ` Pierre Gondois
2026-05-20 8:10 ` Jie Zhan
2026-05-11 13:55 ` [PATCH v2 2/4] cpufreq: Set default policy->min/max values for all drivers Pierre Gondois
2026-05-20 8:12 ` Jie Zhan
2026-05-22 5:43 ` Viresh Kumar
2026-05-28 8:55 ` Pierre Gondois
2026-05-11 13:55 ` [PATCH v2 3/4] cpufreq: Remove driver default policy->min/max init Pierre Gondois
2026-05-20 8:15 ` Jie Zhan
2026-05-11 13:55 ` [PATCH v2 4/4] cpufreq: Use policy->min/max init as QoS request Pierre Gondois
2026-05-20 8:38 ` Jie Zhan
2026-05-21 11:58 ` Pierre Gondois
2026-05-25 1:05 ` Jie Zhan
2026-05-20 10:03 ` Viresh Kumar
2026-05-21 11:58 ` Pierre Gondois
2026-05-22 5:44 ` Viresh Kumar
2026-05-21 11:26 ` zhenglifeng (A)
2026-05-21 11:58 ` Pierre Gondois
2026-05-22 5:45 ` [PATCH v2 0/4] cpufreq: Set policy->min and max as real QoS constraints Viresh Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cbf289b8-19d9-46b2-a80c-f72720686c46@oss.qualcomm.com \
--to=zhongqiu.han@oss.qualcomm.com \
--cc=corbet@lwn.net \
--cc=ionela.voinescu@arm.com \
--cc=kprateek.nayak@amd.com \
--cc=lenb@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=perry.yuan@amd.com \
--cc=pierre.gondois@arm.com \
--cc=rafael@kernel.org \
--cc=ray.huang@amd.com \
--cc=saravanak@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=sumitg@nvidia.com \
--cc=viresh.kumar@linaro.org \
--cc=zhanjie9@hisilicon.com \
--cc=zhenglifeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®