lib: sbi_domain: Introduce domain intialization order

Currently, the domain initialization order is implied by the order
in which domains are populated by sbi_platform_domains_init() from
sbi_domain_finalize(). This is not documented anywhere and forces
unecessary ordering between domain DT nodes.

To address the above, introduce per-domain 32-bit integer to represent
intialization order (aka "init_order") where domain with a lower
initialization order will be booted first and two domains must not
have same initialization order. For DT based domain creation, new
"init-order" DT property can be used in domain DT node to specify
the initialization order. The ROOT domain is assumed to have lowest
initialization order (aka 0xffffffff).

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-4-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 71faf5a307
commit 55b6b73435
5 changed files with 41 additions and 15 deletions
+9 -8
View File
@@ -291,28 +291,29 @@ int sbi_domain_context_exit(void)
}
dom_ctx = ctx->prev_ctx;
ctx->prev_ctx = NULL;
/* If no previous caller context */
if (!dom_ctx) {
/* Try to find next uninitialized user-defined domain's context */
/* Try to find next uninitialized domain with least initialization order */
dom_ctx = NULL;
sbi_domain_for_each(dom) {
if (dom == &root || dom == sbi_domain_thishart_ptr())
if (dom == sbi_domain_thishart_ptr())
continue;
if (!sbi_hartmask_test_hartindex(hartindex, dom->possible_harts))
continue;
tmp = hart_context_get(dom, hartindex);
if (tmp && !tmp->initialized) {
if (tmp && tmp->initialized)
continue;
if (!dom_ctx || tmp->dom->init_order < dom_ctx->dom->init_order)
dom_ctx = tmp;
break;
}
}
}
/* Take the root domain context if fail to find */
if (!dom_ctx)
dom_ctx = hart_context_get(&root, hartindex);
return SBI_ENOENT;
return switch_to_next_domain_context(ctx, dom_ctx);
}