mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] openrisc: cacheinfo: Index cpuinfo_or1k by target cpu
@ 2026-11-07 19:53 Karl Mehltretter
  0 siblings, 0 replies; only message in thread
From: Karl Mehltretter @ 2026-11-07 19:53 UTC (permalink / raw)
  To: Jonas Bonn, Stefan Kristiansson, Stafford Horne
  Cc: Karl Mehltretter, Sahil Siddiq, linux-openrisc, linux-kernel

init_cache_level() and populate_cache_leaves() take a target cpu
parameter, pass it to get_cpu_cacheinfo(), and then index cpuinfo_or1k
with smp_processor_id(). On UP kernels with PREEMPT and DEBUG_PREEMPT
enabled, cacheinfo_sysfs_init() invokes init_cache_level() from the
preemptible swapper/0 thread via cpuhp_setup_state(), triggering a
debug_smp_processor_id() diagnostic.

Index cpuinfo_or1k with cpu in both functions.

Fixes: 4e6d24a309e6 ("openrisc: Add cacheinfo support")
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
Assisted by an LLM.

Tested on v7.4-rc1 (d48723711bae) under QEMU or1k (or1k-sim) with
or1ksim_defconfig plus PREEMPT and DEBUG_PREEMPT. Without this patch,
two consecutive boots emit "BUG: using smp_processor_id() in
preemptible [00000000] code: swapper/0/1" at init_cache_level+0x28/0x1f4.
With this patch, two consecutive boots complete without the
debug_smp_processor_id() diagnostic.

 arch/openrisc/kernel/cacheinfo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/openrisc/kernel/cacheinfo.c b/arch/openrisc/kernel/cacheinfo.c
index 61230545e4ff6..7c2c38beecd99 100644
--- a/arch/openrisc/kernel/cacheinfo.c
+++ b/arch/openrisc/kernel/cacheinfo.c
@@ -28,7 +28,7 @@ static inline void ci_leaf_init(struct cacheinfo *this_leaf, enum cache_type typ
 
 int init_cache_level(unsigned int cpu)
 {
-	struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[smp_processor_id()];
+	struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[cpu];
 	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 	int leaves = 0, levels = 0;
 	unsigned long upr = mfspr(SPR_UPR);
@@ -83,7 +83,7 @@ int init_cache_level(unsigned int cpu)
 
 int populate_cache_leaves(unsigned int cpu)
 {
-	struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[smp_processor_id()];
+	struct cpuinfo_or1k *cpuinfo = &cpuinfo_or1k[cpu];
 	struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 	struct cacheinfo *this_leaf = this_cpu_ci->info_list;
 	int level = 1;
base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee

-- 
2.39.5 (Apple Git-154)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-07 19:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 19:53 [PATCH] openrisc: cacheinfo: Index cpuinfo_or1k by target cpu Karl Mehltretter

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

all inboxes | Powered by JetHome®