* [PATCH] cpufreq: apple-soc: Calculate frequency as a 64-bit value
@ 2026-07-03 18:52 Sasha Finkelstein
2026-07-03 20:52 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Finkelstein @ 2026-07-03 18:52 UTC (permalink / raw)
To: Sven Peter, Janne Grunau, Neal Gompa, Rafael J. Wysocki,
Viresh Kumar
Cc: asahi, linux-arm-kernel, linux-pm, linux-kernel,
Sasha Finkelstein
The current frequency calculation is done in 32 bit, causing problems
if run on a future SoC that can boost higher than 4.2GHz.
Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
---
drivers/cpufreq/apple-soc-cpufreq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/cpufreq/apple-soc-cpufreq.c b/drivers/cpufreq/apple-soc-cpufreq.c
index 638e5bf72185..6a0f1d36578f 100644
--- a/drivers/cpufreq/apple-soc-cpufreq.c
+++ b/drivers/cpufreq/apple-soc-cpufreq.c
@@ -288,7 +288,7 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)
/* Get OPP levels (p-state indexes) and stash them in driver_data */
for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
- unsigned long rate = freq_table[i].frequency * 1000 + 999;
+ unsigned long rate = freq_table[i].frequency * 1000UL + 999UL;
struct dev_pm_opp *opp = dev_pm_opp_find_freq_floor(cpu_dev, &rate);
if (IS_ERR(opp)) {
---
base-commit: 4a50a141f05a8d1737661b19ee22ff8455b94409
change-id: 20260703-cpufreq-64-2a23d7261e09
Best regards,
--
Sasha Finkelstein <k@chaosmail.tech>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] cpufreq: apple-soc: Calculate frequency as a 64-bit value
2026-07-03 18:52 [PATCH] cpufreq: apple-soc: Calculate frequency as a 64-bit value Sasha Finkelstein
@ 2026-07-03 20:52 ` David Laight
2026-07-03 20:59 ` Sasha Finkelstein
0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2026-07-03 20:52 UTC (permalink / raw)
To: Sasha Finkelstein
Cc: Sven Peter, Janne Grunau, Neal Gompa, Rafael J. Wysocki,
Viresh Kumar, asahi, linux-arm-kernel, linux-pm, linux-kernel
On Fri, 03 Jul 2026 20:52:48 +0200
Sasha Finkelstein <k@chaosmail.tech> wrote:
> The current frequency calculation is done in 32 bit, causing problems
> if run on a future SoC that can boost higher than 4.2GHz.
If it matters you need to fix it for 32bit builds as well.
It is pretty much really wrong to use 'unsigned long' for frequencies.
IMHO the should either be 32bit or 64bit.
David
>
> Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
> ---
> drivers/cpufreq/apple-soc-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/cpufreq/apple-soc-cpufreq.c b/drivers/cpufreq/apple-soc-cpufreq.c
> index 638e5bf72185..6a0f1d36578f 100644
> --- a/drivers/cpufreq/apple-soc-cpufreq.c
> +++ b/drivers/cpufreq/apple-soc-cpufreq.c
> @@ -288,7 +288,7 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)
>
> /* Get OPP levels (p-state indexes) and stash them in driver_data */
> for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
> - unsigned long rate = freq_table[i].frequency * 1000 + 999;
> + unsigned long rate = freq_table[i].frequency * 1000UL + 999UL;
> struct dev_pm_opp *opp = dev_pm_opp_find_freq_floor(cpu_dev, &rate);
>
> if (IS_ERR(opp)) {
>
> ---
> base-commit: 4a50a141f05a8d1737661b19ee22ff8455b94409
> change-id: 20260703-cpufreq-64-2a23d7261e09
>
> Best regards,
> --
> Sasha Finkelstein <k@chaosmail.tech>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] cpufreq: apple-soc: Calculate frequency as a 64-bit value
2026-07-03 20:52 ` David Laight
@ 2026-07-03 20:59 ` Sasha Finkelstein
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Finkelstein @ 2026-07-03 20:59 UTC (permalink / raw)
To: David Laight
Cc: Sven Peter, Janne Grunau, Neal Gompa, Rafael J. Wysocki,
Viresh Kumar, asahi, linux-arm-kernel, linux-pm, linux-kernel
On Jul 3, 2026, at 22:52, David Laight <david.laight.linux@gmail.com> wrote:
>
> If it matters you need to fix it for 32bit builds as well.
> It is pretty much really wrong to use 'unsigned long' for frequencies.
> IMHO the should either be 32bit or 64bit.
This module has a 64BIT dep, and is not applicable to 32-bit devices.
In addition, the calculation is passed to dev_pm_opp_find_freq_floor,
which is core code and takes an unsigned long.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-03 20:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 18:52 [PATCH] cpufreq: apple-soc: Calculate frequency as a 64-bit value Sasha Finkelstein
2026-07-03 20:52 ` David Laight
2026-07-03 20:59 ` Sasha Finkelstein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox