lib: sbi_domain: Re-work boot-time assignment of HARTs to non-ROOT domains

Assign a non-ROOT domain to a HART on first come first serve basis if the
HART is listed as a possible HART of the non-ROOT domain. If no non-ROOT
domain list a HART as possible HART then the HART is assigned to the ROOT
domain.

This allows us to drop the OpenSBI specific DT property from each CPU DT
node (aka "opensbi-domain" Dt property).

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Reviewed-by: Yu-Chien Peter Lin <peter.lin@sifive.com>
Link: https://lore.kernel.org/r/20260905131748.922920-3-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Anup Patel
2026-09-16 09:21:21 +05:30
committed by Anup Patel
parent 6dc5a896b1
commit 71faf5a307
5 changed files with 42 additions and 142 deletions
+19 -15
View File
@@ -625,16 +625,14 @@ void sbi_domain_dump_all(const char *suffix)
}
}
int sbi_domain_register(struct sbi_domain *dom,
const struct sbi_hartmask *assign_mask)
int sbi_domain_register(struct sbi_domain *dom)
{
u32 i;
int rc;
u32 i, cold_hartid = current_hartid();
struct sbi_domain *tdom;
u32 cold_hartid = current_hartid();
int rc;
/* Sanity checks */
if (!dom || !assign_mask || domain_finalized)
if (!dom || domain_finalized)
return SBI_EINVAL;
/* Check if domain already discovered */
@@ -663,15 +661,21 @@ int sbi_domain_register(struct sbi_domain *dom,
/* Clear assigned HARTs of domain */
sbi_hartmask_clear_all(&dom->assigned_harts);
/* Assign domain to HART if HART is a possible HART */
sbi_hartmask_for_each_hartindex(i, assign_mask) {
if (!sbi_hartmask_test_hartindex(i, dom->possible_harts))
continue;
/*
* Assign a non-ROOT domain to a HART on first come first serve
* basis if the HART is listed as a possible HART of the non-ROOT
* domain. If no non-ROOT domain list a HART as possible HART then
* the HART is assigned to the ROOT domain.
*/
sbi_hartmask_for_each_hartindex(i, dom->possible_harts) {
tdom = sbi_hartindex_to_domain(i);
if (tdom)
sbi_hartmask_clear_hartindex(i,
&tdom->assigned_harts);
if (tdom) {
if (tdom == &root)
sbi_hartmask_clear_hartindex(i, &tdom->assigned_harts);
else
continue;
}
sbi_update_hartindex_to_domain(i, dom);
sbi_hartmask_set_hartindex(i, &dom->assigned_harts);
@@ -975,7 +979,7 @@ int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid)
sbi_hartmask_set_hartindex(i, root_hmask);
/* Finally register the root domain */
rc = sbi_domain_register(&root, root_hmask);
rc = sbi_domain_register(&root);
if (rc)
goto fail_free_root_hmask;