* [PATCH v2 0/2] cpufreq: Return -EOPNOTSUPP if no policy is boost supported
@ 2025-11-28 9:13 Lifeng Zheng
2025-11-28 9:13 ` [PATCH v2 1/2] " Lifeng Zheng
2025-11-28 9:13 ` [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization Lifeng Zheng
0 siblings, 2 replies; 9+ messages in thread
From: Lifeng Zheng @ 2025-11-28 9:13 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, linuxarm, jonathan.cameron, zhanjie9,
lihuisong, yubowen8, zhangpengjie2, wangzhi12, linhongye,
zhenglifeng1
Make cpufreq_boost_trigger_state() return error when boost isn't supported
by any policy.
Changelog:
v2:
- change the error to -EOPNOTSUPP
- remove the comment and blank line
- split the optimization into another patch
---
Discussions of previous version:
v1: https://lore.kernel.org/all/20251126031916.3641176-1-zhenglifeng1@huawei.com/
Lifeng Zheng (2):
cpufreq: Return -EOPNOTSUPP if no policy is boost supported
cpufreq: cpufreq_boost_trigger_state() optimization
drivers/cpufreq/cpufreq.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/2] cpufreq: Return -EOPNOTSUPP if no policy is boost supported
2025-11-28 9:13 [PATCH v2 0/2] cpufreq: Return -EOPNOTSUPP if no policy is boost supported Lifeng Zheng
@ 2025-11-28 9:13 ` Lifeng Zheng
2025-12-01 3:43 ` Viresh Kumar
2025-11-28 9:13 ` [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization Lifeng Zheng
1 sibling, 1 reply; 9+ messages in thread
From: Lifeng Zheng @ 2025-11-28 9:13 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, linuxarm, jonathan.cameron, zhanjie9,
lihuisong, yubowen8, zhangpengjie2, wangzhi12, linhongye,
zhenglifeng1
In cpufreq_boost_trigger_state(), if all the policies are boost
unsupported, policy_set_boost() will not be called and this function will
return 0. But it is better to return an error to indicate that the platform
doesn't support boost.
Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
---
drivers/cpufreq/cpufreq.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index e8d7544b77b8..a4399e5490da 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2806,7 +2806,7 @@ static int cpufreq_boost_trigger_state(int state)
{
struct cpufreq_policy *policy;
unsigned long flags;
- int ret = 0;
+ int ret = -EOPNOTSUPP;
/*
* Don't compare 'cpufreq_driver->boost_enabled' with 'state' here to
@@ -2826,6 +2826,10 @@ static int cpufreq_boost_trigger_state(int state)
if (ret)
goto err_reset_state;
}
+
+ if (ret)
+ goto err_reset_state;
+
cpus_read_unlock();
return 0;
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization
2025-11-28 9:13 [PATCH v2 0/2] cpufreq: Return -EOPNOTSUPP if no policy is boost supported Lifeng Zheng
2025-11-28 9:13 ` [PATCH v2 1/2] " Lifeng Zheng
@ 2025-11-28 9:13 ` Lifeng Zheng
2025-12-01 3:42 ` Viresh Kumar
1 sibling, 1 reply; 9+ messages in thread
From: Lifeng Zheng @ 2025-11-28 9:13 UTC (permalink / raw)
To: rafael, viresh.kumar
Cc: linux-pm, linux-kernel, linuxarm, jonathan.cameron, zhanjie9,
lihuisong, yubowen8, zhangpengjie2, wangzhi12, linhongye,
zhenglifeng1
Simplify the error handling branch code in cpufreq_boost_trigger_state().
Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
---
drivers/cpufreq/cpufreq.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index a4399e5490da..a725747572c9 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2824,18 +2824,13 @@ static int cpufreq_boost_trigger_state(int state)
ret = policy_set_boost(policy, state);
if (ret)
- goto err_reset_state;
+ break;
}
- if (ret)
- goto err_reset_state;
-
cpus_read_unlock();
- return 0;
-
-err_reset_state:
- cpus_read_unlock();
+ if (!ret)
+ return 0;
write_lock_irqsave(&cpufreq_driver_lock, flags);
cpufreq_driver->boost_enabled = !state;
--
2.33.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization
2025-11-28 9:13 ` [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization Lifeng Zheng
@ 2025-12-01 3:42 ` Viresh Kumar
2025-12-02 1:32 ` zhenglifeng (A)
0 siblings, 1 reply; 9+ messages in thread
From: Viresh Kumar @ 2025-12-01 3:42 UTC (permalink / raw)
To: Lifeng Zheng
Cc: rafael, linux-pm, linux-kernel, linuxarm, jonathan.cameron,
zhanjie9, lihuisong, yubowen8, zhangpengjie2, wangzhi12,
linhongye
On 28-11-25, 17:13, Lifeng Zheng wrote:
> Simplify the error handling branch code in cpufreq_boost_trigger_state().
>
> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> ---
> drivers/cpufreq/cpufreq.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index a4399e5490da..a725747572c9 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2824,18 +2824,13 @@ static int cpufreq_boost_trigger_state(int state)
>
> ret = policy_set_boost(policy, state);
> if (ret)
> - goto err_reset_state;
> + break;
> }
>
> - if (ret)
> - goto err_reset_state;
> -
> cpus_read_unlock();
>
> - return 0;
> -
> -err_reset_state:
> - cpus_read_unlock();
> + if (!ret)
Maybe we can make this `if (likely(!ret))`
> + return 0;
>
> write_lock_irqsave(&cpufreq_driver_lock, flags);
> cpufreq_driver->boost_enabled = !state;
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] cpufreq: Return -EOPNOTSUPP if no policy is boost supported
2025-11-28 9:13 ` [PATCH v2 1/2] " Lifeng Zheng
@ 2025-12-01 3:43 ` Viresh Kumar
0 siblings, 0 replies; 9+ messages in thread
From: Viresh Kumar @ 2025-12-01 3:43 UTC (permalink / raw)
To: Lifeng Zheng
Cc: rafael, linux-pm, linux-kernel, linuxarm, jonathan.cameron,
zhanjie9, lihuisong, yubowen8, zhangpengjie2, wangzhi12,
linhongye
On 28-11-25, 17:13, Lifeng Zheng wrote:
> In cpufreq_boost_trigger_state(), if all the policies are boost
> unsupported, policy_set_boost() will not be called and this function will
> return 0. But it is better to return an error to indicate that the platform
> doesn't support boost.
>
> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> ---
> drivers/cpufreq/cpufreq.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index e8d7544b77b8..a4399e5490da 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2806,7 +2806,7 @@ static int cpufreq_boost_trigger_state(int state)
> {
> struct cpufreq_policy *policy;
> unsigned long flags;
> - int ret = 0;
> + int ret = -EOPNOTSUPP;
>
> /*
> * Don't compare 'cpufreq_driver->boost_enabled' with 'state' here to
> @@ -2826,6 +2826,10 @@ static int cpufreq_boost_trigger_state(int state)
> if (ret)
> goto err_reset_state;
> }
> +
> + if (ret)
> + goto err_reset_state;
> +
> cpus_read_unlock();
>
> return 0;
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
--
viresh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization
2025-12-01 3:42 ` Viresh Kumar
@ 2025-12-02 1:32 ` zhenglifeng (A)
2025-12-02 4:58 ` Viresh Kumar
0 siblings, 1 reply; 9+ messages in thread
From: zhenglifeng (A) @ 2025-12-02 1:32 UTC (permalink / raw)
To: Viresh Kumar
Cc: rafael, linux-pm, linux-kernel, linuxarm, jonathan.cameron,
zhanjie9, lihuisong, yubowen8, zhangpengjie2, wangzhi12,
linhongye
On 2025/12/1 11:42, Viresh Kumar wrote:
> On 28-11-25, 17:13, Lifeng Zheng wrote:
>> Simplify the error handling branch code in cpufreq_boost_trigger_state().
>>
>> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
>> ---
>> drivers/cpufreq/cpufreq.c | 11 +++--------
>> 1 file changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index a4399e5490da..a725747572c9 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -2824,18 +2824,13 @@ static int cpufreq_boost_trigger_state(int state)
>>
>> ret = policy_set_boost(policy, state);
>> if (ret)
>> - goto err_reset_state;
>> + break;
>> }
>>
>> - if (ret)
>> - goto err_reset_state;
>> -
>> cpus_read_unlock();
>>
>> - return 0;
>> -
>> -err_reset_state:
>> - cpus_read_unlock();
>> + if (!ret)
>
> Maybe we can make this `if (likely(!ret))`
For the platforms which are not boost supported, this will never be
matched. Is `likely` OK in this situation?
>
>> + return 0;
>>
>> write_lock_irqsave(&cpufreq_driver_lock, flags);
>> cpufreq_driver->boost_enabled = !state;
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization
2025-12-02 1:32 ` zhenglifeng (A)
@ 2025-12-02 4:58 ` Viresh Kumar
2025-12-02 6:24 ` zhenglifeng (A)
0 siblings, 1 reply; 9+ messages in thread
From: Viresh Kumar @ 2025-12-02 4:58 UTC (permalink / raw)
To: zhenglifeng (A)
Cc: rafael, linux-pm, linux-kernel, linuxarm, jonathan.cameron,
zhanjie9, lihuisong, yubowen8, zhangpengjie2, wangzhi12,
linhongye
On 02-12-25, 09:32, zhenglifeng (A) wrote:
> On 2025/12/1 11:42, Viresh Kumar wrote:
> > On 28-11-25, 17:13, Lifeng Zheng wrote:
> >> Simplify the error handling branch code in cpufreq_boost_trigger_state().
> >>
> >> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> >> ---
> >> drivers/cpufreq/cpufreq.c | 11 +++--------
> >> 1 file changed, 3 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> >> index a4399e5490da..a725747572c9 100644
> >> --- a/drivers/cpufreq/cpufreq.c
> >> +++ b/drivers/cpufreq/cpufreq.c
> >> @@ -2824,18 +2824,13 @@ static int cpufreq_boost_trigger_state(int state)
> >>
> >> ret = policy_set_boost(policy, state);
> >> if (ret)
> >> - goto err_reset_state;
> >> + break;
> >> }
> >>
> >> - if (ret)
> >> - goto err_reset_state;
> >> -
> >> cpus_read_unlock();
> >>
> >> - return 0;
> >> -
> >> -err_reset_state:
> >> - cpus_read_unlock();
> >> + if (!ret)
> >
> > Maybe we can make this `if (likely(!ret))`
>
> For the platforms which are not boost supported, this will never be
> matched. Is `likely` OK in this situation?
Ideally they won't have a `boost` file in sysfs, and if they have it, we don't
really need to optimize the failure case.
--
viresh
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization
2025-12-02 4:58 ` Viresh Kumar
@ 2025-12-02 6:24 ` zhenglifeng (A)
2025-12-02 6:46 ` Viresh Kumar
0 siblings, 1 reply; 9+ messages in thread
From: zhenglifeng (A) @ 2025-12-02 6:24 UTC (permalink / raw)
To: Viresh Kumar
Cc: rafael, linux-pm, linux-kernel, linuxarm, jonathan.cameron,
zhanjie9, lihuisong, yubowen8, zhangpengjie2, wangzhi12,
linhongye
On 2025/12/2 12:58, Viresh Kumar wrote:
> On 02-12-25, 09:32, zhenglifeng (A) wrote:
>> On 2025/12/1 11:42, Viresh Kumar wrote:
>>> On 28-11-25, 17:13, Lifeng Zheng wrote:
>>>> Simplify the error handling branch code in cpufreq_boost_trigger_state().
>>>>
>>>> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
>>>> ---
>>>> drivers/cpufreq/cpufreq.c | 11 +++--------
>>>> 1 file changed, 3 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>>>> index a4399e5490da..a725747572c9 100644
>>>> --- a/drivers/cpufreq/cpufreq.c
>>>> +++ b/drivers/cpufreq/cpufreq.c
>>>> @@ -2824,18 +2824,13 @@ static int cpufreq_boost_trigger_state(int state)
>>>>
>>>> ret = policy_set_boost(policy, state);
>>>> if (ret)
>>>> - goto err_reset_state;
>>>> + break;
>>>> }
>>>>
>>>> - if (ret)
>>>> - goto err_reset_state;
>>>> -
>>>> cpus_read_unlock();
>>>>
>>>> - return 0;
>>>> -
>>>> -err_reset_state:
>>>> - cpus_read_unlock();
>>>> + if (!ret)
>>>
>>> Maybe we can make this `if (likely(!ret))`
>>
>> For the platforms which are not boost supported, this will never be
>> matched. Is `likely` OK in this situation?
>
> Ideally they won't have a `boost` file in sysfs, and if they have it, we don't
> really need to optimize the failure case.
I see. Then I think the `if (ret)` in the loop should be
`if (unlikely(ret))` too.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization
2025-12-02 6:24 ` zhenglifeng (A)
@ 2025-12-02 6:46 ` Viresh Kumar
0 siblings, 0 replies; 9+ messages in thread
From: Viresh Kumar @ 2025-12-02 6:46 UTC (permalink / raw)
To: zhenglifeng (A)
Cc: rafael, linux-pm, linux-kernel, linuxarm, jonathan.cameron,
zhanjie9, lihuisong, yubowen8, zhangpengjie2, wangzhi12,
linhongye
On 02-12-25, 14:24, zhenglifeng (A) wrote:
> On 2025/12/2 12:58, Viresh Kumar wrote:
> > On 02-12-25, 09:32, zhenglifeng (A) wrote:
> >> On 2025/12/1 11:42, Viresh Kumar wrote:
> >>> On 28-11-25, 17:13, Lifeng Zheng wrote:
> >>>> Simplify the error handling branch code in cpufreq_boost_trigger_state().
> >>>>
> >>>> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> >>>> ---
> >>>> drivers/cpufreq/cpufreq.c | 11 +++--------
> >>>> 1 file changed, 3 insertions(+), 8 deletions(-)
> >>>>
> >>>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> >>>> index a4399e5490da..a725747572c9 100644
> >>>> --- a/drivers/cpufreq/cpufreq.c
> >>>> +++ b/drivers/cpufreq/cpufreq.c
> >>>> @@ -2824,18 +2824,13 @@ static int cpufreq_boost_trigger_state(int state)
> >>>>
> >>>> ret = policy_set_boost(policy, state);
> >>>> if (ret)
> >>>> - goto err_reset_state;
> >>>> + break;
> >>>> }
> >>>>
> >>>> - if (ret)
> >>>> - goto err_reset_state;
> >>>> -
> >>>> cpus_read_unlock();
> >>>>
> >>>> - return 0;
> >>>> -
> >>>> -err_reset_state:
> >>>> - cpus_read_unlock();
> >>>> + if (!ret)
> >>>
> >>> Maybe we can make this `if (likely(!ret))`
> >>
> >> For the platforms which are not boost supported, this will never be
> >> matched. Is `likely` OK in this situation?
> >
> > Ideally they won't have a `boost` file in sysfs, and if they have it, we don't
> > really need to optimize the failure case.
>
> I see. Then I think the `if (ret)` in the loop should be
> `if (unlikely(ret))` too.
That can be done too.
--
viresh
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-12-02 6:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28 9:13 [PATCH v2 0/2] cpufreq: Return -EOPNOTSUPP if no policy is boost supported Lifeng Zheng
2025-11-28 9:13 ` [PATCH v2 1/2] " Lifeng Zheng
2025-12-01 3:43 ` Viresh Kumar
2025-11-28 9:13 ` [PATCH v2 2/2] cpufreq: cpufreq_boost_trigger_state() optimization Lifeng Zheng
2025-12-01 3:42 ` Viresh Kumar
2025-12-02 1:32 ` zhenglifeng (A)
2025-12-02 4:58 ` Viresh Kumar
2025-12-02 6:24 ` zhenglifeng (A)
2025-12-02 6:46 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox