* [PATCH] cpufreq: sparc-us2e: fix frequency table index copy-paste error
@ 2026-08-28 7:56 Xueqin Luo
2026-08-28 11:33 ` Zhongqiu Han
0 siblings, 1 reply; 2+ messages in thread
From: Xueqin Luo @ 2026-08-28 7:56 UTC (permalink / raw)
To: rafael, viresh.kumar; +Cc: linux-pm, linux-kernel, Xueqin Luo
In us2e_freq_cpu_init(), the last three writes to the frequency table
all use index [2] instead of [2], [3], [4] respectively. This is a
copy-paste error where the index was not incremented, causing the
divider-6 and divider-8 entries to overwrite the already-written
divider-4 entry.
As a result, only three frequency steps (div 1, 2, and 8) are actually
available to the cpufreq core, while the intended dividers 4 and 6 are
silently lost. The struct us2e_freq_percpu_info::table[6] has room for
5 entries plus a terminator, matching the 5 hardware dividers.
Fix the indices so all five frequency steps are correctly populated:
table[0]=div1, table[1]=div2, table[2]=div4, table[3]=div6,
table[4]=div8, table[5]=TABLE_END.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
---
drivers/cpufreq/sparc-us2e-cpufreq.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
index a68706406b88..5cda391ad03b 100644
--- a/drivers/cpufreq/sparc-us2e-cpufreq.c
+++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
@@ -282,12 +282,11 @@ static int us2e_freq_cpu_init(struct cpufreq_policy *policy)
table[1].frequency = clock_tick / 2;
table[2].driver_data = 2;
table[2].frequency = clock_tick / 4;
- table[2].driver_data = 3;
- table[2].frequency = clock_tick / 6;
- table[2].driver_data = 4;
- table[2].frequency = clock_tick / 8;
- table[2].driver_data = 5;
- table[3].frequency = CPUFREQ_TABLE_END;
+ table[3].driver_data = 3;
+ table[3].frequency = clock_tick / 6;
+ table[4].driver_data = 4;
+ table[4].frequency = clock_tick / 8;
+ table[5].frequency = CPUFREQ_TABLE_END;
policy->cpuinfo.transition_latency = 0;
policy->cur = clock_tick;
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cpufreq: sparc-us2e: fix frequency table index copy-paste error
2026-08-28 7:56 [PATCH] cpufreq: sparc-us2e: fix frequency table index copy-paste error Xueqin Luo
@ 2026-08-28 11:33 ` Zhongqiu Han
0 siblings, 0 replies; 2+ messages in thread
From: Zhongqiu Han @ 2026-08-28 11:33 UTC (permalink / raw)
To: Xueqin Luo, rafael, viresh.kumar; +Cc: linux-pm, linux-kernel, zhongqiu.han
On 8/28/2026 3:56 PM, Xueqin Luo wrote:
> In us2e_freq_cpu_init(), the last three writes to the frequency table
> all use index [2] instead of [2], [3], [4] respectively. This is a
Nit: Should it be that "the last two frequency writes both use index
[2] instead of [3] and [4] respectively, and the terminator uses [3]
instead of [5]." ?
> copy-paste error where the index was not incremented, causing the
> divider-6 and divider-8 entries to overwrite the already-written
> divider-4 entry.
>
> As a result, only three frequency steps (div 1, 2, and 8) are actually
> available to the cpufreq core, while the intended dividers 4 and 6 are
If the core passes the array index (2) to ->target_index(), and
index_to_divisor(2) is 4. so the real available div is 1,2,4?
> silently lost. The struct us2e_freq_percpu_info::table[6] has room for
> 5 entries plus a terminator, matching the 5 hardware dividers.
>
> Fix the indices so all five frequency steps are correctly populated:
> table[0]=div1, table[1]=div2, table[2]=div4, table[3]=div6,
> table[4]=div8, table[5]=TABLE_END.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Xueqin Luo <luoxueqin@kylinos.cn>
> ---
> drivers/cpufreq/sparc-us2e-cpufreq.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cpufreq/sparc-us2e-cpufreq.c b/drivers/cpufreq/sparc-us2e-cpufreq.c
> index a68706406b88..5cda391ad03b 100644
> --- a/drivers/cpufreq/sparc-us2e-cpufreq.c
> +++ b/drivers/cpufreq/sparc-us2e-cpufreq.c
> @@ -282,12 +282,11 @@ static int us2e_freq_cpu_init(struct cpufreq_policy *policy)
> table[1].frequency = clock_tick / 2;
> table[2].driver_data = 2;
> table[2].frequency = clock_tick / 4;
> - table[2].driver_data = 3;
> - table[2].frequency = clock_tick / 6;
> - table[2].driver_data = 4;
> - table[2].frequency = clock_tick / 8;
> - table[2].driver_data = 5;
> - table[3].frequency = CPUFREQ_TABLE_END;
> + table[3].driver_data = 3;
> + table[3].frequency = clock_tick / 6;
> + table[4].driver_data = 4;
> + table[4].frequency = clock_tick / 8;
> + table[5].frequency = CPUFREQ_TABLE_END;
>
> policy->cpuinfo.transition_latency = 0;
> policy->cur = clock_tick;
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-28 11:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-28 7:56 [PATCH] cpufreq: sparc-us2e: fix frequency table index copy-paste error Xueqin Luo
2026-08-28 11:33 ` Zhongqiu Han
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox