All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cacheinfo: don't propagate DT/ACPI error when arch supplies info (arm64)
@ 2026-06-09 16:23 Breno Leitao
  2026-06-11 10:30 ` Pierre Gondois
  0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2026-06-09 16:23 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Sudeep Holla, Pierre Gondois
  Cc: driver-core, linux-kernel, kernel-team, Breno Leitao

cache_setup_properties() sets use_arch_info = true when DT/ACPI
provide no cache nodes and the arch can derive the topology from
CPU registers (e.g. arm64 reading CLIDR_EL1), but still returns the
original -ENOENT. cache_shared_cpu_map_setup() bails on that error
before the new flag can take effect, so the first CPU brought online
always trips a misleading warning:

  cacheinfo: Unable to detect cache hierarchy for CPU 0

Subsequent CPUs skip cache_setup_properties() entirely because
use_arch_info is now true, which is why only CPU0 hits it. This is
reproducible on arm64 with the QEMU 'virt' machine, whose default DT
has no cache nodes.

Clear ret after setting use_arch_info so the caller proceeds and
populates the shared cpu map via the arch-supplied leaves.

Fixes: ef9f643a9f8b ("cacheinfo: Add use_arch[|_cache]_info field/function")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
Cc; hruben@meta.com
---
 drivers/base/cacheinfo.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index 70701d3bc81c..4e11d36f127e 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -401,9 +401,18 @@ static int cache_setup_properties(unsigned int cpu)
 	else if (!acpi_disabled)
 		ret = cache_setup_acpi(cpu);
 
-	// Assume there is no cache information available in DT/ACPI from now.
-	if (ret && use_arch_cache_info())
+	/*
+	 * If DT/ACPI lacks cache nodes but the arch can derive the topology
+	 * from CPU registers (e.g. arm64 reading CLIDR_EL1), fall back to
+	 * that path instead of propagating the error.  Otherwise the very
+	 * first CPU processed trips a misleading "Unable to detect cache
+	 * hierarchy" warning, because use_arch_info is only set after the
+	 * first failure.
+	 */
+	if (ret && use_arch_cache_info()) {
 		use_arch_info = true;
+		ret = 0;
+	}
 
 	return ret;
 }

---
base-commit: a87737435cfa134f9cdcc696ba3080759d04cf72
change-id: 20260609-cacheinfo-b2a8d27a19ce

Best regards,
-- 
Breno Leitao <leitao@debian.org>


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

* Re: [PATCH] cacheinfo: don't propagate DT/ACPI error when arch supplies info (arm64)
  2026-06-09 16:23 [PATCH] cacheinfo: don't propagate DT/ACPI error when arch supplies info (arm64) Breno Leitao
@ 2026-06-11 10:30 ` Pierre Gondois
  2026-06-11 11:05   ` Breno Leitao
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Gondois @ 2026-06-11 10:30 UTC (permalink / raw)
  To: Breno Leitao, Greg Kroah-Hartman, Rafael J. Wysocki,
	Danilo Krummrich, Sudeep Holla
  Cc: driver-core, linux-kernel, kernel-team

On 6/9/26 18:23, Breno Leitao wrote:
> cache_setup_properties() sets use_arch_info = true when DT/ACPI
> provide no cache nodes and the arch can derive the topology from
> CPU registers (e.g. arm64 reading CLIDR_EL1), but still returns the
> original -ENOENT. cache_shared_cpu_map_setup() bails on that error
> before the new flag can take effect, so the first CPU brought online
> always trips a misleading warning:
>
>    cacheinfo: Unable to detect cache hierarchy for CPU 0
>
> Subsequent CPUs skip cache_setup_properties() entirely because
> use_arch_info is now true, which is why only CPU0 hits it. This is
> reproducible on arm64 with the QEMU 'virt' machine, whose default DT
> has no cache nodes.
>
> Clear ret after setting use_arch_info so the caller proceeds and
> populates the shared cpu map via the arch-supplied leaves.
>
> Fixes: ef9f643a9f8b ("cacheinfo: Add use_arch[|_cache]_info field/function")
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> Cc; hruben@meta.com
> ---
>   drivers/base/cacheinfo.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
> index 70701d3bc81c..4e11d36f127e 100644
> --- a/drivers/base/cacheinfo.c
> +++ b/drivers/base/cacheinfo.c
> @@ -401,9 +401,18 @@ static int cache_setup_properties(unsigned int cpu)
>   	else if (!acpi_disabled)
>   		ret = cache_setup_acpi(cpu);
>   
> -	// Assume there is no cache information available in DT/ACPI from now.
> -	if (ret && use_arch_cache_info())
> +	/*
> +	 * If DT/ACPI lacks cache nodes but the arch can derive the topology
> +	 * from CPU registers (e.g. arm64 reading CLIDR_EL1), fall back to
> +	 * that path instead of propagating the error.  Otherwise the very
> +	 * first CPU processed trips a misleading "Unable to detect cache
> +	 * hierarchy" warning, because use_arch_info is only set after the
> +	 * first failure.
> +	 */

NIT: Maybe the comment is a bit long/verbose,
but maybe also not worth a v2

Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>

> +	if (ret && use_arch_cache_info()) {
>   		use_arch_info = true;
> +		ret = 0;
> +	}
>   
>   	return ret;
>   }
>
> ---
> base-commit: a87737435cfa134f9cdcc696ba3080759d04cf72
> change-id: 20260609-cacheinfo-b2a8d27a19ce
>
> Best regards,

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

* Re: [PATCH] cacheinfo: don't propagate DT/ACPI error when arch supplies info (arm64)
  2026-06-11 10:30 ` Pierre Gondois
@ 2026-06-11 11:05   ` Breno Leitao
  0 siblings, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2026-06-11 11:05 UTC (permalink / raw)
  To: Pierre Gondois
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Sudeep Holla, driver-core, linux-kernel, kernel-team

Hello Pierre,

On Thu, Jun 11, 2026 at 12:30:24PM +0200, Pierre Gondois wrote:
> On 6/9/26 18:23, Breno Leitao wrote:
> > cache_setup_properties() sets use_arch_info = true when DT/ACPI
> > provide no cache nodes and the arch can derive the topology from
> > CPU registers (e.g. arm64 reading CLIDR_EL1), but still returns the
> > original -ENOENT. cache_shared_cpu_map_setup() bails on that error
> > before the new flag can take effect, so the first CPU brought online
> > always trips a misleading warning:
> > 
> >    cacheinfo: Unable to detect cache hierarchy for CPU 0
> > 
> > Subsequent CPUs skip cache_setup_properties() entirely because
> > use_arch_info is now true, which is why only CPU0 hits it. This is
> > reproducible on arm64 with the QEMU 'virt' machine, whose default DT
> > has no cache nodes.
> > 
> > Clear ret after setting use_arch_info so the caller proceeds and
> > populates the shared cpu map via the arch-supplied leaves.
> > 
> > Fixes: ef9f643a9f8b ("cacheinfo: Add use_arch[|_cache]_info field/function")
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > ---
> > Cc; hruben@meta.com
> > ---
> >   drivers/base/cacheinfo.c | 13 +++++++++++--
> >   1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
> > index 70701d3bc81c..4e11d36f127e 100644
> > --- a/drivers/base/cacheinfo.c
> > +++ b/drivers/base/cacheinfo.c
> > @@ -401,9 +401,18 @@ static int cache_setup_properties(unsigned int cpu)
> >   	else if (!acpi_disabled)
> >   		ret = cache_setup_acpi(cpu);
> > -	// Assume there is no cache information available in DT/ACPI from now.
> > -	if (ret && use_arch_cache_info())
> > +	/*
> > +	 * If DT/ACPI lacks cache nodes but the arch can derive the topology
> > +	 * from CPU registers (e.g. arm64 reading CLIDR_EL1), fall back to
> > +	 * that path instead of propagating the error.  Otherwise the very
> > +	 * first CPU processed trips a misleading "Unable to detect cache
> > +	 * hierarchy" warning, because use_arch_info is only set after the
> > +	 * first failure.
> > +	 */
> 
> NIT: Maybe the comment is a bit long/verbose,
> but maybe also not worth a v2
> 
> Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>

Thanks for the review, let me shirnk the comment above and send a v2. It
will be painless.

--breno

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

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

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-09 16:23 [PATCH] cacheinfo: don't propagate DT/ACPI error when arch supplies info (arm64) Breno Leitao
2026-06-11 10:30 ` Pierre Gondois
2026-06-11 11:05   ` Breno Leitao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.