[PATCH 1/7] cpufreq: Disable cpufreq-based invariance when fail to register driver

Lifeng Zheng posted 7 patches 7 months, 3 weeks ago
[PATCH 1/7] cpufreq: Disable cpufreq-based invariance when fail to register driver
Posted by Lifeng Zheng 7 months, 3 weeks ago
The cpufreq-based invariance is enabled in cpufreq_register_driver(), but
never disabled after that when fail. Add a
static_branch_disable_cpuslocked() to do that as
cpufreq_unregister_driver() does.

Fixes: 874f63531064 ("cpufreq: report whether cpufreq supports Frequency Invariance (FI)")
Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
---
 drivers/cpufreq/cpufreq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d7426e1d8bdd..1bc665b5bba8 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2991,6 +2991,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
 err_boost_unreg:
 	remove_boost_sysfs_file();
 err_null_driver:
+	static_branch_disable_cpuslocked(&cpufreq_freq_invariance);
 	write_lock_irqsave(&cpufreq_driver_lock, flags);
 	cpufreq_driver = NULL;
 	write_unlock_irqrestore(&cpufreq_driver_lock, flags);
-- 
2.33.0
Re: [PATCH 1/7] cpufreq: Disable cpufreq-based invariance when fail to register driver
Posted by Rafael J. Wysocki 7 months, 3 weeks ago
On Mon, Jun 23, 2025 at 3:34 PM Lifeng Zheng <zhenglifeng1@huawei.com> wrote:
>
> The cpufreq-based invariance is enabled in cpufreq_register_driver(), but
> never disabled after that when fail. Add a
> static_branch_disable_cpuslocked() to do that as
> cpufreq_unregister_driver() does.

What about moving the invariance initialization to the point when 0 is
going to be returned?

> Fixes: 874f63531064 ("cpufreq: report whether cpufreq supports Frequency Invariance (FI)")
> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
> ---
>  drivers/cpufreq/cpufreq.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index d7426e1d8bdd..1bc665b5bba8 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2991,6 +2991,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>  err_boost_unreg:
>         remove_boost_sysfs_file();
>  err_null_driver:
> +       static_branch_disable_cpuslocked(&cpufreq_freq_invariance);
>         write_lock_irqsave(&cpufreq_driver_lock, flags);
>         cpufreq_driver = NULL;
>         write_unlock_irqrestore(&cpufreq_driver_lock, flags);
> --
Re: [PATCH 1/7] cpufreq: Disable cpufreq-based invariance when fail to register driver
Posted by zhenglifeng (A) 7 months, 1 week ago
On 2025/6/23 23:27, Rafael J. Wysocki wrote:

> On Mon, Jun 23, 2025 at 3:34 PM Lifeng Zheng <zhenglifeng1@huawei.com> wrote:
>>
>> The cpufreq-based invariance is enabled in cpufreq_register_driver(), but
>> never disabled after that when fail. Add a
>> static_branch_disable_cpuslocked() to do that as
>> cpufreq_unregister_driver() does.
> 
> What about moving the invariance initialization to the point when 0 is
> going to be returned?

Yes, that'll do it, too, thank you.

> 
>> Fixes: 874f63531064 ("cpufreq: report whether cpufreq supports Frequency Invariance (FI)")
>> Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
>> ---
>>  drivers/cpufreq/cpufreq.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index d7426e1d8bdd..1bc665b5bba8 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -2991,6 +2991,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
>>  err_boost_unreg:
>>         remove_boost_sysfs_file();
>>  err_null_driver:
>> +       static_branch_disable_cpuslocked(&cpufreq_freq_invariance);
>>         write_lock_irqsave(&cpufreq_driver_lock, flags);
>>         cpufreq_driver = NULL;
>>         write_unlock_irqrestore(&cpufreq_driver_lock, flags);
>> --