From: dave.patel@riscstar.com
To: opensbi@lists.infradead.org
Cc: Scott Bambrough <scott@riscstar.com>,
Robin Randhawa <robin.randhawa@sifive.com>,
Anup Patel <anup.patel@qti.qualcomm.com>,
Samuel Holland <samuel.holland@sifive.com>,
Dave Patel <dave.patel@riscstar.com>,
Ray Mao <raymond.mao@riscstar.com>,
Anup Patel <anuppate@qti.qualcomm.com>,
Dhaval <dhaval@rivosinc.com>, Peter Lin <peter.lin@sifive.com>
Subject: [PATCH 1/4] lib: sbi: domain: ensure boot_hartid is assigned
Date: Fri, 20 Mar 2026 14:23:46 +0000 [thread overview]
Message-ID: <20260320142349.72980-2-dave.patel@riscstar.com> (raw)
In-Reply-To: <20260320142349.72980-1-dave.patel@riscstar.com>
From: Raymond Mao <raymond.mao@riscstar.com>
When boot_hartid points to a hart that is not in the domain's assigned
hartmask (e.g. due to cold boot hart differences), the domain startup
can skip starting the intended boot hart, leading to intermittent Linux
boot failures. Scan the assigned hartmask and pick the first available
hartid to guarantee a valid boot target.
---
lib/sbi/sbi_domain.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
index 4e8d2045..498a1d56 100644
--- a/lib/sbi/sbi_domain.c
+++ b/lib/sbi/sbi_domain.c
@@ -804,6 +804,30 @@ int sbi_domain_startup(struct sbi_scratch *scratch, u32 cold_hartid)
/* Startup boot HART of domains */
sbi_domain_for_each(dom) {
+ u32 boot_hartindex = sbi_hartid_to_hartindex(dom->boot_hartid);
+ bool boot_assigned = false;
+
+ if (sbi_hartindex_valid(boot_hartindex)) {
+ spin_lock(&dom->assigned_harts_lock);
+ boot_assigned = sbi_hartmask_test_hartindex(
+ boot_hartindex, &dom->assigned_harts);
+ spin_unlock(&dom->assigned_harts_lock);
+ }
+
+ if (!boot_assigned) {
+ u32 new_hartid = -1U;
+
+ spin_lock(&dom->assigned_harts_lock);
+ sbi_hartmask_for_each_hartindex(dhart, &dom->assigned_harts) {
+ new_hartid = sbi_hartindex_to_hartid(dhart);
+ break;
+ }
+ spin_unlock(&dom->assigned_harts_lock);
+
+ if (new_hartid != -1U)
+ dom->boot_hartid = new_hartid;
+ }
+
/* Domain boot HART index */
dhart = sbi_hartid_to_hartindex(dom->boot_hartid);
--
2.43.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2026-03-20 14:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 14:23 [PATCH v1 0/4] Add eager FP and RISC-V vector context switching support dave.patel
2026-03-20 14:23 ` dave.patel [this message]
2026-03-20 14:23 ` [PATCH 2/4] lib: sbi: Add RISC-V vector context save/restore support (eager switching) dave.patel
2026-03-20 14:23 ` [PATCH 3/4] lib: sbi: Add floating-point context save/restore support dave.patel
2026-03-20 14:23 ` [PATCH 4/4] include: sbi: scratch: Add per-hart FP and vector context pointers in scratch dave.patel
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=20260320142349.72980-2-dave.patel@riscstar.com \
--to=dave.patel@riscstar.com \
--cc=anup.patel@qti.qualcomm.com \
--cc=anuppate@qti.qualcomm.com \
--cc=dhaval@rivosinc.com \
--cc=opensbi@lists.infradead.org \
--cc=peter.lin@sifive.com \
--cc=raymond.mao@riscstar.com \
--cc=robin.randhawa@sifive.com \
--cc=samuel.holland@sifive.com \
--cc=scott@riscstar.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