* [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers
@ 2025-09-01 11:25 Zihuan Zhang
2025-09-01 11:25 ` [PATCH v1 1/3] cpufreq: Drop redundant freq_table parameter Zihuan Zhang
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Zihuan Zhang @ 2025-09-01 11:25 UTC (permalink / raw)
To: Rafael J . wysocki, Viresh Kumar
Cc: zhenglifeng, linux-pm, linux-kernel, Zihuan Zhang
This patchset updates the cpufreq core and drivers to fully adopt
the new policy->freq_table approach introduced in commit
e0b3165ba521 ("cpufreq: add 'freq_table' in struct cpufreq_policy").
Motivation:
- The frequency table is per-policy, not per-CPU, so redundant
freq_table arguments in core helpers and drivers are no longer needed.
- Removing the extra argument reduces confusion and potential mistakes.
Patch details:
1. cpufreq: core: drop redundant freq_table argument in helpers
- Remove freq_table parameters in core helper functions.
- All helper functions now use policy directly.
2. cpufreq: drivers: remove redundant freq_table argument
- Update cpufreq drivers to match the new core API.
- Calls that previously passed a separate freq_table argument
- No behavior changes, only API consistency.
Zihuan Zhang (3):
cpufreq: Drop redundant freq_table parameter
cpufreq: sh: drop redundant freq_table argument
cpufreq: virtual: drop redundant freq_table argument
drivers/cpufreq/cpufreq.c | 2 +-
drivers/cpufreq/freq_table.c | 14 ++++++--------
drivers/cpufreq/sh-cpufreq.c | 2 +-
drivers/cpufreq/virtual-cpufreq.c | 2 +-
include/linux/cpufreq.h | 7 +++----
5 files changed, 12 insertions(+), 15 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v1 1/3] cpufreq: Drop redundant freq_table parameter
2025-09-01 11:25 [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Zihuan Zhang
@ 2025-09-01 11:25 ` Zihuan Zhang
2025-09-01 11:25 ` [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument Zihuan Zhang
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Zihuan Zhang @ 2025-09-01 11:25 UTC (permalink / raw)
To: Rafael J . wysocki, Viresh Kumar
Cc: zhenglifeng, linux-pm, linux-kernel, Zihuan Zhang
Since commit e0b3165ba521 ("cpufreq: add 'freq_table' in struct
cpufreq_policy"),
freq_table has been stored in struct cpufreq_policy instead of being
maintained separately.
However, several helpers in freq_table.c still take both policy and
freq_table as parameters, even though policy->freq_table can always be
used. This leads to redundant function arguments and increases the chance
of inconsistencies.
This patch removes the unnecessary freq_table argument from these functions
and updates their callers to only pass policy. This makes the code simpler,
more consistent, and avoids duplication.
Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
drivers/cpufreq/cpufreq.c | 2 +-
drivers/cpufreq/freq_table.c | 14 ++++++--------
include/linux/cpufreq.h | 7 +++----
3 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index fc7eace8b65b..76ef82d75ba2 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2792,7 +2792,7 @@ int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
if (!policy->freq_table)
return -ENXIO;
- ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table);
+ ret = cpufreq_frequency_table_cpuinfo(policy);
if (ret) {
pr_err("%s: Policy frequency update failed\n", __func__);
return ret;
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 35de513af6c9..d5111ee56e38 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -28,10 +28,9 @@ static bool policy_has_boost_freq(struct cpufreq_policy *policy)
return false;
}
-int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
- struct cpufreq_frequency_table *table)
+int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy)
{
- struct cpufreq_frequency_table *pos;
+ struct cpufreq_frequency_table *pos, *table = policy->freq_table;
unsigned int min_freq = ~0;
unsigned int max_freq = 0;
unsigned int freq;
@@ -65,10 +64,9 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
return 0;
}
-int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy,
- struct cpufreq_frequency_table *table)
+int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy)
{
- struct cpufreq_frequency_table *pos;
+ struct cpufreq_frequency_table *pos, *table = policy->freq_table;
unsigned int freq, prev_smaller = 0;
bool found = false;
@@ -110,7 +108,7 @@ int cpufreq_generic_frequency_table_verify(struct cpufreq_policy_data *policy)
if (!policy->freq_table)
return -ENODEV;
- return cpufreq_frequency_table_verify(policy, policy->freq_table);
+ return cpufreq_frequency_table_verify(policy);
}
EXPORT_SYMBOL_GPL(cpufreq_generic_frequency_table_verify);
@@ -354,7 +352,7 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy)
return 0;
}
- ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table);
+ ret = cpufreq_frequency_table_cpuinfo(policy);
if (ret)
return ret;
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 95f3807c8c55..40966512ea18 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -780,11 +780,10 @@ struct cpufreq_frequency_table {
else
-int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
- struct cpufreq_frequency_table *table);
+int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy);
+
+int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy);
-int cpufreq_frequency_table_verify(struct cpufreq_policy_data *policy,
- struct cpufreq_frequency_table *table);
int cpufreq_generic_frequency_table_verify(struct cpufreq_policy_data *policy);
int cpufreq_table_index_unsorted(struct cpufreq_policy *policy,
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument
2025-09-01 11:25 [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Zihuan Zhang
2025-09-01 11:25 ` [PATCH v1 1/3] cpufreq: Drop redundant freq_table parameter Zihuan Zhang
@ 2025-09-01 11:25 ` Zihuan Zhang
2025-09-02 5:40 ` Viresh Kumar
2025-09-01 11:25 ` [PATCH v1 3/3] cpufreq: virtual: " Zihuan Zhang
2025-09-02 5:42 ` [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Viresh Kumar
3 siblings, 1 reply; 10+ messages in thread
From: Zihuan Zhang @ 2025-09-01 11:25 UTC (permalink / raw)
To: Rafael J . wysocki, Viresh Kumar
Cc: zhenglifeng, linux-pm, linux-kernel, Zihuan Zhang
Previously, some cpufreq core helper functions accepted a separate
'freq_table' argument even though the frequency table is now stored
inside struct cpufreq_policy.
This patch updates all cpufreq core calls to remove the redundant
argument and use policy directly.
Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
drivers/cpufreq/sh-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
index 9c0b01e00508..75d224ba56ba 100644
--- a/drivers/cpufreq/sh-cpufreq.c
+++ b/drivers/cpufreq/sh-cpufreq.c
@@ -93,7 +93,7 @@ static int sh_cpufreq_verify(struct cpufreq_policy_data *policy)
freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL;
if (freq_table)
- return cpufreq_frequency_table_verify(policy, freq_table);
+ return cpufreq_frequency_table_verify(policy);
cpufreq_verify_within_cpu_limits(policy);
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v1 3/3] cpufreq: virtual: drop redundant freq_table argument
2025-09-01 11:25 [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Zihuan Zhang
2025-09-01 11:25 ` [PATCH v1 1/3] cpufreq: Drop redundant freq_table parameter Zihuan Zhang
2025-09-01 11:25 ` [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument Zihuan Zhang
@ 2025-09-01 11:25 ` Zihuan Zhang
2025-09-02 5:42 ` [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Viresh Kumar
3 siblings, 0 replies; 10+ messages in thread
From: Zihuan Zhang @ 2025-09-01 11:25 UTC (permalink / raw)
To: Rafael J . wysocki, Viresh Kumar
Cc: zhenglifeng, linux-pm, linux-kernel, Zihuan Zhang
Previously, some cpufreq core helper functions accepted a separate
'freq_table' argument even though the frequency table is now stored
inside struct cpufreq_policy.
This patch updates all cpufreq core calls to remove the redundant
argument and use policy directly.
Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
drivers/cpufreq/virtual-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/virtual-cpufreq.c b/drivers/cpufreq/virtual-cpufreq.c
index 7dd1b0c263c7..6ffa16d239b2 100644
--- a/drivers/cpufreq/virtual-cpufreq.c
+++ b/drivers/cpufreq/virtual-cpufreq.c
@@ -250,7 +250,7 @@ static int virt_cpufreq_offline(struct cpufreq_policy *policy)
static int virt_cpufreq_verify_policy(struct cpufreq_policy_data *policy)
{
if (policy->freq_table)
- return cpufreq_frequency_table_verify(policy, policy->freq_table);
+ return cpufreq_frequency_table_verify(policy);
cpufreq_verify_within_cpu_limits(policy);
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument
2025-09-01 11:25 ` [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument Zihuan Zhang
@ 2025-09-02 5:40 ` Viresh Kumar
2025-09-02 6:06 ` Zihuan Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2025-09-02 5:40 UTC (permalink / raw)
To: Zihuan Zhang; +Cc: Rafael J . wysocki, zhenglifeng, linux-pm, linux-kernel
On 01-09-25, 19:25, Zihuan Zhang wrote:
> Previously, some cpufreq core helper functions accepted a separate
> 'freq_table' argument even though the frequency table is now stored
> inside struct cpufreq_policy.
>
> This patch updates all cpufreq core calls to remove the redundant
> argument and use policy directly.
>
> Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
> ---
> drivers/cpufreq/sh-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
> index 9c0b01e00508..75d224ba56ba 100644
> --- a/drivers/cpufreq/sh-cpufreq.c
> +++ b/drivers/cpufreq/sh-cpufreq.c
> @@ -93,7 +93,7 @@ static int sh_cpufreq_verify(struct cpufreq_policy_data *policy)
>
> freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL;
> if (freq_table)
Instead of above, you can now simply check if policy->freq_table is
valid or not.
> - return cpufreq_frequency_table_verify(policy, freq_table);
> + return cpufreq_frequency_table_verify(policy);
>
> cpufreq_verify_within_cpu_limits(policy);
>
> --
> 2.25.1
--
viresh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers
2025-09-01 11:25 [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Zihuan Zhang
` (2 preceding siblings ...)
2025-09-01 11:25 ` [PATCH v1 3/3] cpufreq: virtual: " Zihuan Zhang
@ 2025-09-02 5:42 ` Viresh Kumar
2025-09-02 5:54 ` Zihuan Zhang
3 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2025-09-02 5:42 UTC (permalink / raw)
To: Zihuan Zhang; +Cc: Rafael J . wysocki, zhenglifeng, linux-pm, linux-kernel
On 01-09-25, 19:25, Zihuan Zhang wrote:
> This patchset updates the cpufreq core and drivers to fully adopt
> the new policy->freq_table approach introduced in commit
> e0b3165ba521 ("cpufreq: add 'freq_table' in struct cpufreq_policy").
>
> Motivation:
> - The frequency table is per-policy, not per-CPU, so redundant
> freq_table arguments in core helpers and drivers are no longer needed.
> - Removing the extra argument reduces confusion and potential mistakes.
>
> Patch details:
>
> 1. cpufreq: core: drop redundant freq_table argument in helpers
> - Remove freq_table parameters in core helper functions.
> - All helper functions now use policy directly.
>
> 2. cpufreq: drivers: remove redundant freq_table argument
> - Update cpufreq drivers to match the new core API.
> - Calls that previously passed a separate freq_table argument
> - No behavior changes, only API consistency.
>
> Zihuan Zhang (3):
> cpufreq: Drop redundant freq_table parameter
> cpufreq: sh: drop redundant freq_table argument
> cpufreq: virtual: drop redundant freq_table argument
Individual patches must not break kernel compilation, but compilation
breaks after the first patch itself in your series as you have not
updated all the users.
Merge all three into a single patch.
--
viresh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers
2025-09-02 5:42 ` [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Viresh Kumar
@ 2025-09-02 5:54 ` Zihuan Zhang
0 siblings, 0 replies; 10+ messages in thread
From: Zihuan Zhang @ 2025-09-02 5:54 UTC (permalink / raw)
To: Viresh Kumar; +Cc: Rafael J . wysocki, zhenglifeng, linux-pm, linux-kernel
在 2025/9/2 13:42, Viresh Kumar 写道:
> On 01-09-25, 19:25, Zihuan Zhang wrote:
>> This patchset updates the cpufreq core and drivers to fully adopt
>> the new policy->freq_table approach introduced in commit
>> e0b3165ba521 ("cpufreq: add 'freq_table' in struct cpufreq_policy").
>>
>> Motivation:
>> - The frequency table is per-policy, not per-CPU, so redundant
>> freq_table arguments in core helpers and drivers are no longer needed.
>> - Removing the extra argument reduces confusion and potential mistakes.
>>
>> Patch details:
>>
>> 1. cpufreq: core: drop redundant freq_table argument in helpers
>> - Remove freq_table parameters in core helper functions.
>> - All helper functions now use policy directly.
>>
>> 2. cpufreq: drivers: remove redundant freq_table argument
>> - Update cpufreq drivers to match the new core API.
>> - Calls that previously passed a separate freq_table argument
>> - No behavior changes, only API consistency.
>>
>> Zihuan Zhang (3):
>> cpufreq: Drop redundant freq_table parameter
>> cpufreq: sh: drop redundant freq_table argument
>> cpufreq: virtual: drop redundant freq_table argument
> Individual patches must not break kernel compilation, but compilation
> breaks after the first patch itself in your series as you have not
> updated all the users.
>
> Merge all three into a single patch.
>
Got it. I wasn’t sure if core and driver changes should be split, but
yes, merging them into a single patch is better.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument
2025-09-02 5:40 ` Viresh Kumar
@ 2025-09-02 6:06 ` Zihuan Zhang
2025-09-02 6:23 ` Viresh Kumar
0 siblings, 1 reply; 10+ messages in thread
From: Zihuan Zhang @ 2025-09-02 6:06 UTC (permalink / raw)
To: Viresh Kumar; +Cc: Rafael J . wysocki, zhenglifeng, linux-pm, linux-kernel
在 2025/9/2 13:40, Viresh Kumar 写道:
> On 01-09-25, 19:25, Zihuan Zhang wrote:
>> Previously, some cpufreq core helper functions accepted a separate
>> 'freq_table' argument even though the frequency table is now stored
>> inside struct cpufreq_policy.
>>
>> This patch updates all cpufreq core calls to remove the redundant
>> argument and use policy directly.
>>
>> Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
>> ---
>> drivers/cpufreq/sh-cpufreq.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/cpufreq/sh-cpufreq.c b/drivers/cpufreq/sh-cpufreq.c
>> index 9c0b01e00508..75d224ba56ba 100644
>> --- a/drivers/cpufreq/sh-cpufreq.c
>> +++ b/drivers/cpufreq/sh-cpufreq.c
>> @@ -93,7 +93,7 @@ static int sh_cpufreq_verify(struct cpufreq_policy_data *policy)
>>
>> freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL;
>> if (freq_table)
> Instead of above, you can now simply check if policy->freq_table is
> valid or not.
I also noticed that in some drivers like acpi-cpufreq.c, if freq_table
allocation fails, the driver won’t be registered at all.
In such cases,
should the NULL check be done inside the core helper functions, or
should it be left to the drivers?
>> - return cpufreq_frequency_table_verify(policy, freq_table);
>> + return cpufreq_frequency_table_verify(policy);
>>
>> cpufreq_verify_within_cpu_limits(policy);
>>
>> --
>> 2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument
2025-09-02 6:06 ` Zihuan Zhang
@ 2025-09-02 6:23 ` Viresh Kumar
2025-09-02 6:43 ` Zihuan Zhang
0 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2025-09-02 6:23 UTC (permalink / raw)
To: Zihuan Zhang; +Cc: Rafael J . wysocki, zhenglifeng, linux-pm, linux-kernel
On 02-09-25, 14:06, Zihuan Zhang wrote:
> I also noticed that in some drivers like acpi-cpufreq.c, if freq_table
> allocation fails, the driver won’t be registered at all.
>
> In such cases,
>
> should the NULL check be done inside the core helper functions, or should it
> be left to the drivers?
Not all drivers need a freq-table and so it is fine for them to not
have one. This driver looks like can work without a freq table too.
--
viresh
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument
2025-09-02 6:23 ` Viresh Kumar
@ 2025-09-02 6:43 ` Zihuan Zhang
0 siblings, 0 replies; 10+ messages in thread
From: Zihuan Zhang @ 2025-09-02 6:43 UTC (permalink / raw)
To: Viresh Kumar; +Cc: Rafael J . wysocki, zhenglifeng, linux-pm, linux-kernel
在 2025/9/2 14:23, Viresh Kumar 写道:
> On 02-09-25, 14:06, Zihuan Zhang wrote:
>> I also noticed that in some drivers like acpi-cpufreq.c, if freq_table
>> allocation fails, the driver won’t be registered at all.
>>
>> In such cases,
>>
>> should the NULL check be done inside the core helper functions, or should it
>> be left to the drivers?
> Not all drivers need a freq-table and so it is fine for them to not
> have one. This driver looks like can work without a freq table too.
>
Understood, Thanks!
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-09-02 6:43 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 11:25 [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Zihuan Zhang
2025-09-01 11:25 ` [PATCH v1 1/3] cpufreq: Drop redundant freq_table parameter Zihuan Zhang
2025-09-01 11:25 ` [PATCH v1 2/3] cpufreq: sh: drop redundant freq_table argument Zihuan Zhang
2025-09-02 5:40 ` Viresh Kumar
2025-09-02 6:06 ` Zihuan Zhang
2025-09-02 6:23 ` Viresh Kumar
2025-09-02 6:43 ` Zihuan Zhang
2025-09-01 11:25 ` [PATCH v1 3/3] cpufreq: virtual: " Zihuan Zhang
2025-09-02 5:42 ` [PATCH v1 0/3] cpufreq: drop redundant freq_table argument in helpers Viresh Kumar
2025-09-02 5:54 ` Zihuan Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).