OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Troy Mitchell <troy.mitchell@linux.spacemit.com>
To: opensbi@lists.infradead.org
Cc: Xianbin Zhu <xianbin.zhu@linux.spacemit.com>,
	 Anup Patel <anup@brainfault.org>, Bo Gan <ganboing@gmail.com>,
	 Samuel Holland <samuel.holland@sifive.com>,
	 Heinrich Schuchardt <heinrich.schuchardt@canonical.com>,
	 Kevin Zhang <zhangmeng.kevin@linux.spacemit.com>,
	 Troy Mitchell <troy.mitchell@linux.spacemit.com>
Subject: [PATCH v5 3/6] platform: generic: spacemit: k1: move hart init to nascent hook
Date: Fri, 23 Oct 2026 11:44:43 +0800	[thread overview]
Message-ID: <20261023-spacemit-k3-v5-3-c5ddfc72caa4@linux.spacemit.com> (raw)
In-Reply-To: <20261023-spacemit-k3-v5-0-c5ddfc72caa4@linux.spacemit.com>

cold_boot_allowed() is a policy query and should not modify per-hart
state. The K1 callback currently programs ML2SETUP as a side effect.

Move the ML2SETUP programming to nascent_init(), which runs on every
hart before common initialization. Chain generic_nascent_init() to keep
the generic per-hart setup intact.

Fixes: 1f84ec2ac22e ("platform: generic: spacemit: add K1")
Reported-by: Bo Gan <ganboing@gmail.com>
Link: https://lore.kernel.org/r/56220293-88e3-451f-833e-8251656a83d9@gmail.com
Reviewed-by: Bo Gan <ganboing@gmail.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
---
 platform/generic/spacemit/k1.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/platform/generic/spacemit/k1.c b/platform/generic/spacemit/k1.c
index 7ee5f17a..5e699f8e 100644
--- a/platform/generic/spacemit/k1.c
+++ b/platform/generic/spacemit/k1.c
@@ -8,6 +8,7 @@
  */
 
 #include <platform_override.h>
+#include <sbi/riscv_asm.h>
 #include <sbi/riscv_io.h>
 #include <sbi/sbi_hsm.h>
 #include <spacemit/k1.h>
@@ -86,16 +87,23 @@ static int spacemit_k1_early_init(bool cold_boot)
 	return 0;
 }
 
-static bool spacemit_cold_boot_allowed(u32 hartid)
+static int spacemit_k1_nascent_init(void)
 {
-	csr_set(CSR_ML2SETUP, 1 << (hartid % PLATFORM_MAX_CPUS_PER_CLUSTER));
+	csr_set(CSR_ML2SETUP,
+		BIT(current_hartid() % PLATFORM_MAX_CPUS_PER_CLUSTER));
+
+	return generic_nascent_init();
+}
 
+static bool spacemit_cold_boot_allowed(u32 hartid)
+{
 	return !hartid;
 }
 
 static int spacemit_k1_platform_init(const void *fdt, int nodeoff,
 				     const struct fdt_match *match)
 {
+	generic_platform_ops.nascent_init = spacemit_k1_nascent_init;
 	generic_platform_ops.early_init = spacemit_k1_early_init;
 	generic_platform_ops.cold_boot_allowed = spacemit_cold_boot_allowed;
 

-- 
2.55.0


-- 
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

  parent reply	other threads:[~2026-10-23  3:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23  3:44 [PATCH v5 0/6] platform: generic: spacemit: add K3 platform support Troy Mitchell
2026-10-23  3:44 ` [PATCH v5 1/6] lib: sbi: select expected trap handler per hart Troy Mitchell
2026-10-23  4:08   ` Anup Patel
2026-10-23  6:14     ` Troy Mitchell
2026-10-23  3:44 ` [PATCH v5 2/6] platform: generic: spacemit: k1: rename cache flush operation Troy Mitchell
2026-10-23  3:44 ` Troy Mitchell [this message]
2026-10-23  3:44 ` [PATCH v5 4/6] platform: generic: spacemit: k1: refactor platform support Troy Mitchell
2026-10-23  3:44 ` [PATCH v5 5/6] platform: generic: spacemit: k3: add " Troy Mitchell
2026-10-23  3:44 ` [PATCH v5 6/6] platform: generic: spacemit: k3: override cold_boot_allowed for hart 0 only Troy Mitchell

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=20261023-spacemit-k3-v5-3-c5ddfc72caa4@linux.spacemit.com \
    --to=troy.mitchell@linux.spacemit.com \
    --cc=anup@brainfault.org \
    --cc=ganboing@gmail.com \
    --cc=heinrich.schuchardt@canonical.com \
    --cc=opensbi@lists.infradead.org \
    --cc=samuel.holland@sifive.com \
    --cc=xianbin.zhu@linux.spacemit.com \
    --cc=zhangmeng.kevin@linux.spacemit.com \
    /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