mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pengjie Zhang <zhangpengjie2@huawei.com>
To: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>,
	<rafael@kernel.org>, <viresh.kumar@linaro.org>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<zhongqiu.han@oss.qualcomm.com>, <christian.loehle@arm.com>,
	<ananthu.cv@oss.qualcomm.com>, <pierre.gondois@arm.com>,
	<zhenglifeng1@huawei.com>, <zhanjie9@hisilicon.com>
Subject: Re: [PATCH 1/2] cpufreq: Allow global boost updates with inactive capable policies
Date: Mon, 30 Nov 2026 21:49:28 +0800	[thread overview]
Message-ID: <467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com> (raw)
In-Reply-To: <20261130111348.363810-2-jiangtianfeng@linux.alibaba.com>

Hi Jiangtian,

Thanks for handling the offline case in v5.

With 5785772fe9e6 ("cpufreq: CPPC: Enable boost by default") [1] in
linux-pm/linux-next, the global boost knob can start at 1 on a CPPC
system where no registered policy supports boost. With the v5 core
changes applied on top, writing 0 would still return -EINVAL and
leave the knob at 1.

I understand that 77cf053b041f deliberately made this an error.
Since the global knob controls permission to boost, could we let
userspace write either 0 or 1 and read that value back even when
no policy supports boost? A successful write of 0 must leave boost
disabled on every active policy that supports it.

[1] 
https://lore.kernel.org/all/20261118013558.3075038-1-zhangpengjie2@huawei.com/

Thanks,
Pengjie

On 11/30/2026 7:13 PM, Jiangtian Feng wrote:
> Global boost is a permission to use boost, not a statement that boost is
> currently active on every policy. A boost-capable policy can be inactive or
> offline when the global knob is written. Rejecting the write in that case
> loses the requested global setting and makes the policy list state affect
> the result in a way that is not useful to userspace.
>
> Track boost support across all registered policies under cpus_read_lock,
> but continue to call policy_set_boost() only for active, boost-capable
> policies. An inactive boost-capable policy therefore no longer makes the
> global write fail, and the requested setting can be applied when it becomes
> active again.
>
> Preserve the -EOPNOTSUPP result when no registered policy supports boost,
> as introduced by 77cf053b041f, and leave all real policy_set_boost()
> failures unchanged.
>
> Link: https://lore.kernel.org/all/744b868b-55af-4a12-86a8-f4fd5d132e6a@huawei.com/
> Link: https://lore.kernel.org/all/wnnfdvp3r3bg5wztazoijei2uji5xypl4b4wlvlxuwxaizu6g7@2xxyrk7kdxhf/
>
> Qoder, an AI coding assistant, helped analyze the 77cf history, review the
> policy-list locking/lifetime and draft this change and description. The
> policy state matrix and hardware/hotplug behavior remain subject to final
> review and validation.
>
> Signed-off-by: Jiangtian Feng <jiangtianfeng@linux.alibaba.com>
> ---
>   drivers/cpufreq/cpufreq.c | 13 ++++++++++---
>   1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 4332cb114070..f83fc6e40fbe 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2887,7 +2887,8 @@ static int cpufreq_boost_trigger_state(int state)
>   	struct cpufreq_policy *policy;
>   	unsigned long flags;
>   	bool boost_enabled;
> -	int ret = -EOPNOTSUPP;
> +	bool any_boost_supported = false;
> +	int ret = 0;
>   
>   	guard(mutex)(&cpufreq_boost_mutex);
>   
> @@ -2902,8 +2903,11 @@ static int cpufreq_boost_trigger_state(int state)
>   	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
>   
>   	cpus_read_lock();
> -	for_each_active_policy(policy) {
> -		if (!policy->boost_supported)
> +	/* Track capability across inactive policies, but only update active ones. */
> +	for_each_policy(policy) {
> +		if (policy->boost_supported)
> +			any_boost_supported = true;
> +		if (policy_is_inactive(policy) || !policy->boost_supported)
>   			continue;
>   
>   		guard(cpufreq_policy_write)(policy);
> @@ -2913,6 +2917,9 @@ static int cpufreq_boost_trigger_state(int state)
>   			break;
>   	}
>   
> +	if (!any_boost_supported)
> +		ret = -EOPNOTSUPP;
> +
>   	cpus_read_unlock();
>   
>   	if (likely(!ret))

  reply	other threads:[~2026-11-30 13:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 11:13 [PATCH v5 0/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-11-30 11:13 ` [PATCH 1/2] cpufreq: Allow global boost updates with inactive capable policies Jiangtian Feng
2026-11-30 13:49   ` Pengjie Zhang [this message]
2026-11-30 11:13 ` [PATCH 2/2] cpufreq: Keep global boost enabled after partial enable Jiangtian Feng
2026-11-30 13:51   ` Pengjie Zhang

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=467b9ef5-1fc3-4771-9895-363e815670c7@huawei.com \
    --to=zhangpengjie2@huawei.com \
    --cc=ananthu.cv@oss.qualcomm.com \
    --cc=christian.loehle@arm.com \
    --cc=jiangtianfeng@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pierre.gondois@arm.com \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=zhanjie9@hisilicon.com \
    --cc=zhenglifeng1@huawei.com \
    --cc=zhongqiu.han@oss.qualcomm.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®