* Re: [PATCH v2] cpufreq: apple-soc: Calculate frequency as a 64-bit value
2026-07-20 7:25 [PATCH v2] cpufreq: apple-soc: Calculate frequency as a 64-bit value Sasha Finkelstein
@ 2026-07-20 8:23 ` Zhongqiu Han
2026-07-20 16:05 ` Joshua Peisach
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Zhongqiu Han @ 2026-07-20 8:23 UTC (permalink / raw)
To: Sasha Finkelstein, Sven Peter, Janne Grunau, Neal Gompa,
Rafael J. Wysocki, Viresh Kumar
Cc: asahi, linux-arm-kernel, linux-pm, linux-kernel, zhongqiu.han
On 7/20/2026 3:25 PM, Sasha Finkelstein 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. Ideally, we
> should use a true u64 instead of unsigned long and "knowning" that this
> only runs on 64 bit machines, but the core code uses ulong everywhere,
> so this should be good enough.
>
> Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
> ---
> Changes in v2:
> - Minor style fixes
> - Link to v1: https://patch.msgid.link/20260703-cpufreq-64-v1-1-c406c705319a@chaosmail.tech
Looks good to me.
Reviewed-by: Zhongqiu Han <zhongqiu.han@oss.qualcomm.com>
> ---
> 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..5ad274a1e6ae 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 + 999;
> 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>
>
>
--
Thx and BRs,
Zhongqiu Han
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] cpufreq: apple-soc: Calculate frequency as a 64-bit value
2026-07-20 7:25 [PATCH v2] cpufreq: apple-soc: Calculate frequency as a 64-bit value Sasha Finkelstein
2026-07-20 8:23 ` Zhongqiu Han
@ 2026-07-20 16:05 ` Joshua Peisach
2026-07-21 4:58 ` Viresh Kumar
2026-07-22 10:24 ` Janne Grunau
3 siblings, 0 replies; 5+ messages in thread
From: Joshua Peisach @ 2026-07-20 16:05 UTC (permalink / raw)
To: Sasha Finkelstein, Sven Peter, Janne Grunau, Neal Gompa,
Rafael J. Wysocki, Viresh Kumar
Cc: asahi, linux-arm-kernel, linux-pm, linux-kernel
On Mon Jul 20, 2026 at 3:25 AM EDT, Sasha Finkelstein 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. Ideally, we
> should use a true u64 instead of unsigned long and "knowning" that this
> only runs on 64 bit machines, but the core code uses ulong everywhere,
> so this should be good enough.
>
> Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
> ---
> Changes in v2:
> - Minor style fixes
> - Link to v1: https://patch.msgid.link/20260703-cpufreq-64-v1-1-c406c705319a@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..5ad274a1e6ae 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 + 999;
> 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>
Reviewed-by: Joshua Peisach <jpeisach@ubuntu.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] cpufreq: apple-soc: Calculate frequency as a 64-bit value
2026-07-20 7:25 [PATCH v2] cpufreq: apple-soc: Calculate frequency as a 64-bit value Sasha Finkelstein
2026-07-20 8:23 ` Zhongqiu Han
2026-07-20 16:05 ` Joshua Peisach
@ 2026-07-21 4:58 ` Viresh Kumar
2026-07-22 10:24 ` Janne Grunau
3 siblings, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2026-07-21 4:58 UTC (permalink / raw)
To: Sasha Finkelstein
Cc: Sven Peter, Janne Grunau, Neal Gompa, Rafael J. Wysocki, asahi,
linux-arm-kernel, linux-pm, linux-kernel
On 20-07-26, 09:25, Sasha Finkelstein 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. Ideally, we
> should use a true u64 instead of unsigned long and "knowning" that this
> only runs on 64 bit machines, but the core code uses ulong everywhere,
> so this should be good enough.
>
> Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
> ---
> Changes in v2:
> - Minor style fixes
> - Link to v1: https://patch.msgid.link/20260703-cpufreq-64-v1-1-c406c705319a@chaosmail.tech
> ---
> drivers/cpufreq/apple-soc-cpufreq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied. Thanks.
--
viresh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] cpufreq: apple-soc: Calculate frequency as a 64-bit value
2026-07-20 7:25 [PATCH v2] cpufreq: apple-soc: Calculate frequency as a 64-bit value Sasha Finkelstein
` (2 preceding siblings ...)
2026-07-21 4:58 ` Viresh Kumar
@ 2026-07-22 10:24 ` Janne Grunau
3 siblings, 0 replies; 5+ messages in thread
From: Janne Grunau @ 2026-07-22 10:24 UTC (permalink / raw)
To: Sasha Finkelstein
Cc: Sven Peter, Neal Gompa, Rafael J. Wysocki, Viresh Kumar, asahi,
linux-arm-kernel, linux-pm, linux-kernel
On Mon, Jul 20, 2026 at 09:25:10AM +0200, Sasha Finkelstein 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. Ideally, we
> should use a true u64 instead of unsigned long and "knowning" that this
> only runs on 64 bit machines, but the core code uses ulong everywhere,
> so this should be good enough.
It depends on 'ARCH_APPLE || (COMPILE_TEST && 64BIT)' so it only gets
built for 64-bit architectures so the unsigned long won't cause compiler
warnings/errors.
> Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
> ---
> Changes in v2:
> - Minor style fixes
> - Link to v1: https://patch.msgid.link/20260703-cpufreq-64-v1-1-c406c705319a@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..5ad274a1e6ae 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 + 999;
> struct dev_pm_opp *opp = dev_pm_opp_find_freq_floor(cpu_dev, &rate);
>
> if (IS_ERR(opp)) {
>
Reviewed-by: Janne Grunau <j@jannau.net>
Janne
^ permalink raw reply [flat|nested] 5+ messages in thread