mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Karl Mehltretter <kmehltretter@gmail.com>
To: Jonas Bonn <jonas@southpole.se>,
	Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>,
	Stafford Horne <shorne@gmail.com>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
	Sahil Siddiq <sahilcdq0@gmail.com>,
	linux-openrisc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] openrisc: cacheinfo: Index cpuinfo_or1k by target cpu
Date: Sat,  7 Nov 2026 20:53:25 +0100	[thread overview]
Message-ID: <20261107195325.70635-1-kmehltretter@gmail.com> (raw)

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)


                 reply	other threads:[~2026-11-07 19:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261107195325.70635-1-kmehltretter@gmail.com \
    --to=kmehltretter@gmail.com \
    --cc=jonas@southpole.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-openrisc@vger.kernel.org \
    --cc=sahilcdq0@gmail.com \
    --cc=shorne@gmail.com \
    --cc=stefan.kristiansson@saunalahti.fi \
    /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

all inboxes | Powered by JetHome®