From: Pengjie Zhang <zhangpengjie2@huawei.com>
To: Christian Loehle <christian.loehle@arm.com>,
"Rafael J . Wysocki" <rafael@kernel.org>,
<viresh.kumar@linaro.org>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<sumit.gupta@nvidia.com>, <zhanjie9@hisilicon.com>,
<superm1@kernel.org>
Subject: Re: [PATCH] cpufreq: Preserve global boost state on failed updates
Date: Thu, 5 Nov 2026 11:09:53 +0800 [thread overview]
Message-ID: <0eec150c-b8e6-45ee-b6b2-30fd97f72539@huawei.com> (raw)
In-Reply-To: <20261104161657.546370-1-christian.loehle@arm.com>
On 11/5/2026 12:16 AM, Christian Loehle wrote:
> cpufreq_boost_trigger_state() restores the opposite of the requested
> state when updating policy boost state fails. For example, a failed
> write of 0 when global boost is already disabled enables the global
> flag without enabling any policies.
>
> Save the original global boost state using a mutex and restore it on
> failure.
>
> Fixes: 121baab7b88e ("cpufreq: Force sync policy boost with global boost on sysfs update")
> Fixes: 6f19efc0a1ca ("cpufreq: Add boost frequency support in core")
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
> ---
> On a platform without boost_supported the unfixed behaviour is:
> # cat /sys/devices/system/cpu/cpufreq/boost
> 0
> # echo 1 > /sys/devices/system/cpu/cpufreq/boost
> echo: write error: invalid argument
> # cat /sys/devices/system/cpu/cpufreq/boost
> 0
> # echo 0 > /sys/devices/system/cpu/cpufreq/boost
> echo: write error: invalid argument
> # cat /sys/devices/system/cpu/cpufreq/boost
> 1
>
> drivers/cpufreq/cpufreq.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 54dde8419bdc..d95c849f79c5 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2810,18 +2810,24 @@ int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
> }
> EXPORT_SYMBOL_GPL(cpufreq_boost_set_sw);
>
> +static DEFINE_MUTEX(cpufreq_boost_mutex);
> +
> static int cpufreq_boost_trigger_state(int state)
> {
> struct cpufreq_policy *policy;
> unsigned long flags;
> + bool boost_enabled;
> int ret = -EOPNOTSUPP;
>
> + guard(mutex)(&cpufreq_boost_mutex);
> +
> /*
> * Don't compare 'cpufreq_driver->boost_enabled' with 'state' here to
> * make sure all policies are in sync with global boost flag.
> */
>
> write_lock_irqsave(&cpufreq_driver_lock, flags);
> + boost_enabled = cpufreq_driver->boost_enabled;
> cpufreq_driver->boost_enabled = state;
> write_unlock_irqrestore(&cpufreq_driver_lock, flags);
>
> @@ -2841,7 +2847,7 @@ static int cpufreq_boost_trigger_state(int state)
> return 0;
>
> write_lock_irqsave(&cpufreq_driver_lock, flags);
> - cpufreq_driver->boost_enabled = !state;
> + cpufreq_driver->boost_enabled = boost_enabled;
> write_unlock_irqrestore(&cpufreq_driver_lock, flags);
>
> pr_err("%s: Cannot %s BOOST\n",
Reviewed-by: Pengjie Zhang <zhangpengjie2@huawei.com>
next prev parent reply other threads:[~2026-11-05 3:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 16:16 Christian Loehle
2026-11-05 3:09 ` Pengjie Zhang [this message]
2026-11-05 8:41 ` Zhongqiu Han
2026-11-05 8:45 ` Christian Loehle
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=0eec150c-b8e6-45ee-b6b2-30fd97f72539@huawei.com \
--to=zhangpengjie2@huawei.com \
--cc=christian.loehle@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sumit.gupta@nvidia.com \
--cc=superm1@kernel.org \
--cc=viresh.kumar@linaro.org \
--cc=zhanjie9@hisilicon.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®