From: Catalin Marinas <catalin.marinas@arm.com>
To: Thorsten Blum <blum@kernel.org>
Cc: Will Deacon <will@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arm64: cacheinfo: Simplify init_cache_level()
Date: Thu, 26 Nov 2026 16:14:59 +0000 [thread overview]
Message-ID: <awhbA7pxop_WyMTK@arm.com> (raw)
In-Reply-To: <20261104083632.65715-2-blum@kernel.org>
On Wed, Nov 04, 2026 at 09:36:31AM +0100, Thorsten Blum wrote:
> 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);
I wouldn't assume the caller always sets *levels to 0. It may do this
now but the kernel-doc is not entirely clear. It claims that it sets it
only on success with some muddled text about returning 0 on failure,
which I guess may have been intended as setting *levels to 0.
This also relies on ACPI_PPTT being selected which is true for arm64 but
we can't simplify the checks here just because of Kconfig options. It
doesn't cost us anything to check the return value, the patch doesn't
make the code easier to read. So, NAK.
--
Catalin
prev parent reply other threads:[~2026-11-26 16:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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
2026-11-26 16:14 ` Catalin Marinas [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=awhbA7pxop_WyMTK@arm.com \
--to=catalin.marinas@arm.com \
--cc=blum@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).