[PATCH -next v2 2/3] cacheinfo: Make default acpi_get_cache_info() return an error

Conor Dooley conor at kernel.org
Tue Jan 24 09:15:18 PST 2023


On Tue, Jan 24, 2023 at 04:40:47PM +0100, Pierre Gondois wrote:
> commit bd500361a937 ("ACPI: PPTT: Update acpi_find_last_cache_level()
> to acpi_get_cache_info()")
> updates the prototype of acpi_get_cache_info(). The cache 'levels'
> is update through a pointer and not the return value of the function.
> 
> If CONFIG_ACPI_PPTT is not defined, acpi_get_cache_info() doesn't
> update its *levels and *split_levels parameters and returns 0.
> This can lead to a faulty behaviour.
> 
> Make acpi_get_cache_info() return an error code if CONFIG_ACPI_PPTT
> is not defined.
> Also,
> 
> In init_cache_level(), if no PPTT is present or CONFIG_ACPI_PPTT is
> not defined, instead of aborting if acpi_get_cache_info() returns an
> error code, just continue. This allows to try fetching the cache
> information from clidr_el1.

Again, dunno jack about clidr_el1. But the change here seems sane once
more? I was going to suggest throwing away ret entirely and just
initialising fw_level to zero, since the function inside
acpi_get_cache_level() that actually modifies it comes after the last
error return anyway - but that probably would just leave you exposed to
a change in the core code that doesn't also update the callsites.
Plus this looks more deliberate IMO. On that basis, LGTM.

> Signed-off-by: Pierre Gondois <pierre.gondois at arm.com>
> ---
>  arch/arm64/kernel/cacheinfo.c | 2 +-
>  include/linux/cacheinfo.h     | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/kernel/cacheinfo.c b/arch/arm64/kernel/cacheinfo.c
> index d3fe9542c370..bf348b8d321f 100644
> --- a/arch/arm64/kernel/cacheinfo.c
> +++ b/arch/arm64/kernel/cacheinfo.c
> @@ -59,7 +59,7 @@ int init_cache_level(unsigned int cpu)
>  	} else {
>  		ret = acpi_get_cache_info(cpu, &fw_level, NULL);
>  		if (ret < 0)
> -			return ret;
> +			fw_level = 0;
>  	}
>  
>  	if (fw_level < 0)
> diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h
> index dfef57077cd0..908e19d17f49 100644
> --- a/include/linux/cacheinfo.h
> +++ b/include/linux/cacheinfo.h
> @@ -100,7 +100,7 @@ static inline
>  int acpi_get_cache_info(unsigned int cpu,
>  			unsigned int *levels, unsigned int *split_levels)
>  {
> -	return 0;
> +	return -ENOENT;
>  }
>  #else
>  int acpi_get_cache_info(unsigned int cpu,
> -- 
> 2.25.1
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20230124/2e3c0b54/attachment.sig>


More information about the linux-arm-kernel mailing list