mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-09-20 15:21:42 +01:00
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:
+14
-7
@@ -28,6 +28,7 @@ static bool domain_finalized = false;
|
||||
|
||||
struct sbi_domain root = {
|
||||
.name = "root",
|
||||
.init_order = -1U,
|
||||
.possible_harts = NULL,
|
||||
.regions = NULL,
|
||||
.system_reset_allowed = true,
|
||||
@@ -537,6 +538,9 @@ void sbi_domain_dump(const struct sbi_domain *dom, const char *suffix)
|
||||
sbi_printf("Domain%d Name %s: %s\n",
|
||||
dom->index, suffix, dom->name);
|
||||
|
||||
sbi_printf("Domain%d Init Order %s: 0x%x\n",
|
||||
dom->index, suffix, dom->init_order);
|
||||
|
||||
sbi_printf("Domain%d Boot HART %s: %d\n",
|
||||
dom->index, suffix, dom->boot_hartid);
|
||||
|
||||
@@ -635,9 +639,14 @@ int sbi_domain_register(struct sbi_domain *dom)
|
||||
if (!dom || domain_finalized)
|
||||
return SBI_EINVAL;
|
||||
|
||||
/* Check if domain already discovered */
|
||||
/*
|
||||
* Ensure that:
|
||||
* 1) Domain not already registered
|
||||
* 2) Initialization order is unique
|
||||
*/
|
||||
sbi_domain_for_each(tdom) {
|
||||
if (tdom == dom)
|
||||
if (tdom == dom ||
|
||||
tdom->init_order == dom->init_order)
|
||||
return SBI_EALREADY;
|
||||
}
|
||||
|
||||
@@ -662,15 +671,13 @@ int sbi_domain_register(struct sbi_domain *dom)
|
||||
sbi_hartmask_clear_all(&dom->assigned_harts);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Assign HART to a domain with the least initialization order
|
||||
* where the HART is listed as a possible HART of the domain.
|
||||
*/
|
||||
sbi_hartmask_for_each_hartindex(i, dom->possible_harts) {
|
||||
tdom = sbi_hartindex_to_domain(i);
|
||||
if (tdom) {
|
||||
if (tdom == &root)
|
||||
if (tdom->init_order > dom->init_order)
|
||||
sbi_hartmask_clear_hartindex(i, &tdom->assigned_harts);
|
||||
else
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user