arm64: cacheinfo: Simplify init_cache_level()
PATCH 1/1 arm64: cacheinfo: Simplify init_cache_level()
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.
--- arch/arm64/kernel/cacheinfo.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
arch/arm64/kernel/cacheinfo.c +4 -8
@@ -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) {/*
Hi Thorsten,
Quoted 2 lines · Thorsten Blum
acpi_get_cache_info()already setsfw_levelto 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
Quoted 38 lines
Use unsigned int for
fw_levelto match the expected type, and remove the now-unused local ret variable.Signed-off-by Thorsten Blum <[email protected]>--- arch/arm64/kernel/cacheinfo.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)arch/arm64/kernel/cacheinfo.c +4
-8@@ -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) {/*
Hi Ben,
Quoted 8 lines · Ben Horgan
Hi Thorsten,
Quoted 2 lines · Thorsten Blum
acpi_get_cache_info()already setsfw_levelto 0 on failure, so drop the redundant check and the manual assignment.This doesn't seem to be the case when
CONFIG_ACPI_PPTTis not defined. Can the dummy implementation ininclude/linux/cacheinfo.hbe called frominit_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.
Quoted 2 lines
drivers/acpi/pptt.clevels 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
Hi Thorsten,
Quoted 6 lines · Thorsten Blum
Hi Ben,
Quoted 3 lines · Ben Horgan
Hi Thorsten,
On 04/11/2026 08:36, Thorsten Blum wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
acpi_get_cache_info()already setsfw_levelto 0 on failure, so drop the redundant check and the manual assignment.This doesn't seem to be the case when
CONFIG_ACPI_PPTTis not defined. Can the dummy implementation ininclude/linux/cacheinfo.hbe called frominit_cache_level()? For the implementation inOn arm64,
ACPI_PPTTis selected when ACPI is enabled. When ACPI is disabled,acpi_disabled= 1 andinit_cache_level()won't call the stub.
Ok, that's true.
Quoted 8 lines
Quoted 3 lines
drivers/acpi/pptt.clevels 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
Quoted 3 lines
Thanks,
Thorsten