Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: cacheinfo: Simplify init_cache_level()
@ 2026-11-04  8:36 Thorsten Blum
  2026-11-04 10:32 ` Ben Horgan
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2026-11-04  8:36 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland
  Cc: Thorsten Blum, linux-arm-kernel, linux-kernel

acpi_get_cache_info() already sets fw_level to 0 on failure, so drop the
redundant check and the manual assignment.

Use unsigned int for fw_level to match the expected type, and remove the
now-unused local ret variable.

Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 arch/arm64/kernel/cacheinfo.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c
index 309942b06c5b..881131fb4934 100644
--- a/arch/arm64/kernel/cacheinfo.c
+++ b/arch/arm64/kernel/cacheinfo.c
@@ -67,19 +67,15 @@ int early_cache_level(unsigned int cpu)
 
 int init_cache_level(unsigned int cpu)
 {
-	unsigned int level, leaves;
-	int fw_level, ret;
+	unsigned int level, leaves, fw_level;
 	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 
 	detect_cache_level(&level, &leaves);
 
-	if (acpi_disabled) {
+	if (acpi_disabled)
 		fw_level = of_find_last_cache_level(cpu);
-	} else {
-		ret = acpi_get_cache_info(cpu, &fw_level, NULL);
-		if (ret < 0)
-			fw_level = 0;
-	}
+	else
+		acpi_get_cache_info(cpu, &fw_level, NULL);
 
 	if (level < fw_level) {
 		/*


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: cacheinfo: Simplify init_cache_level()
  2026-11-04  8:36 [PATCH] arm64: cacheinfo: Simplify init_cache_level() Thorsten Blum
@ 2026-11-04 10:32 ` Ben Horgan
  2026-11-04 11:07   ` Thorsten Blum
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Horgan @ 2026-11-04 10:32 UTC (permalink / raw)
  To: Thorsten Blum, Catalin Marinas, Will Deacon, Mark Rutland
  Cc: linux-arm-kernel, linux-kernel

Hi Thorsten,

On 04/11/2026 08:36, Thorsten Blum wrote:
> acpi_get_cache_info() already sets fw_level to 0 on failure, so drop the
> redundant check and the manual assignment.

This doesn't seem to be the case when CONFIG_ACPI_PPTT is not defined. Can the dummy implementation
in include/linux/cacheinfo.h be called from init_cache_level()? For the implementation in
drivers/acpi/pptt.c levels is documented as "Number of levels if success." and so would be good to
mention what happens in the error case if it needs to be relied on.

Thanks,

Ben

> 
> Use unsigned int for fw_level to match the expected type, and remove the
> now-unused local ret variable.
> 
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
>  arch/arm64/kernel/cacheinfo.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c
> index 309942b06c5b..881131fb4934 100644
> --- a/arch/arm64/kernel/cacheinfo.c
> +++ b/arch/arm64/kernel/cacheinfo.c
> @@ -67,19 +67,15 @@ int early_cache_level(unsigned int cpu)
>  
>  int init_cache_level(unsigned int cpu)
>  {
> -	unsigned int level, leaves;
> -	int fw_level, ret;
> +	unsigned int level, leaves, fw_level;
>  	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
>  
>  	detect_cache_level(&level, &leaves);
>  
> -	if (acpi_disabled) {
> +	if (acpi_disabled)
>  		fw_level = of_find_last_cache_level(cpu);
> -	} else {
> -		ret = acpi_get_cache_info(cpu, &fw_level, NULL);
> -		if (ret < 0)
> -			fw_level = 0;
> -	}
> +	else
> +		acpi_get_cache_info(cpu, &fw_level, NULL);
>  
>  	if (level < fw_level) {
>  		/*
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: cacheinfo: Simplify init_cache_level()
  2026-11-04 10:32 ` Ben Horgan
@ 2026-11-04 11:07   ` Thorsten Blum
  2026-11-04 11:19     ` Ben Horgan
  0 siblings, 1 reply; 4+ messages in thread
From: Thorsten Blum @ 2026-11-04 11:07 UTC (permalink / raw)
  To: Ben Horgan
  Cc: Catalin Marinas, Will Deacon, Mark Rutland, linux-arm-kernel,
	linux-kernel

Hi Ben,

On Wed, Nov 04, 2026 at 10:32:58AM +0000, Ben Horgan wrote:
> Hi Thorsten,
> 
> On 04/11/2026 08:36, Thorsten Blum wrote:
> > acpi_get_cache_info() already sets fw_level to 0 on failure, so drop the
> > redundant check and the manual assignment.
> 
> This doesn't seem to be the case when CONFIG_ACPI_PPTT is not defined. Can the dummy implementation
> in include/linux/cacheinfo.h be called from init_cache_level()? For the implementation in

On arm64, ACPI_PPTT is selected when ACPI is enabled. When ACPI is
disabled, acpi_disabled = 1 and init_cache_level() won't call the stub.

> drivers/acpi/pptt.c levels is documented as "Number of levels if success." and so would be good to
> mention what happens in the error case if it needs to be relied on.

Below the parameter descriptions, it already says:

  "Errors caused by lack of a PPTT table, or otherwise, return 0
   indicating we didn't find any cache levels."

Thanks,
Thorsten


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: cacheinfo: Simplify init_cache_level()
  2026-11-04 11:07   ` Thorsten Blum
@ 2026-11-04 11:19     ` Ben Horgan
  0 siblings, 0 replies; 4+ messages in thread
From: Ben Horgan @ 2026-11-04 11:19 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Catalin Marinas, Will Deacon, Mark Rutland, linux-arm-kernel,
	linux-kernel

Hi Thorsten,

On 04/11/2026 11:07, Thorsten Blum wrote:
> Hi Ben,
> 
> On Wed, Nov 04, 2026 at 10:32:58AM +0000, Ben Horgan wrote:
>> Hi Thorsten,
>>
>> On 04/11/2026 08:36, Thorsten Blum wrote:
>>> acpi_get_cache_info() already sets fw_level to 0 on failure, so drop the
>>> redundant check and the manual assignment.
>>
>> This doesn't seem to be the case when CONFIG_ACPI_PPTT is not defined. Can the dummy implementation
>> in include/linux/cacheinfo.h be called from init_cache_level()? For the implementation in
> 
> On arm64, ACPI_PPTT is selected when ACPI is enabled. When ACPI is
> disabled, acpi_disabled = 1 and init_cache_level() won't call the stub.

Ok, that's true.

> 
>> drivers/acpi/pptt.c levels is documented as "Number of levels if success." and so would be good to
>> mention what happens in the error case if it needs to be relied on.
> 
> Below the parameter descriptions, it already says:
> 
>   "Errors caused by lack of a PPTT table, or otherwise, return 0
>    indicating we didn't find any cache levels."

Ah yes, I should have read on.

Thanks,

Ben

> 
> Thanks,
> Thorsten



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-04 11:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  8:36 [PATCH] arm64: cacheinfo: Simplify init_cache_level() Thorsten Blum
2026-11-04 10:32 ` Ben Horgan
2026-11-04 11:07   ` Thorsten Blum
2026-11-04 11:19     ` Ben Horgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox