[PATCH 4/4] lib: sbi: sbi_init: Allocate MPXY state for each domain

Alvin Chang alvinga at andestech.com
Mon Feb 17 21:48:37 PST 2025


Each domain need its own shared memory region. Adjust the
sbi_mpxy_init() after sbi_domain_finalize() so OpenSBI
can populate domains from device-tree and allocate their
own MPXY state.

Signed-off-by: Yong Li <yong.li at intel.com>
Tested-by: Yu-Chien Peter Lin <peter.lin at sifive.com>
Reviewed-by: Yu-Chien Peter Lin <peter.lin at sifive.com>
Tested-by: Alvin Chang <alvinga at andestech.com>
Reviewed-by: Alvin Chang <alvinga at andestech.com>
---
 lib/sbi/sbi_init.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/sbi/sbi_init.c b/lib/sbi/sbi_init.c
index b47bc7a..d277b34 100644
--- a/lib/sbi/sbi_init.c
+++ b/lib/sbi/sbi_init.c
@@ -313,11 +313,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
 		sbi_hart_hang();
 	}
 
-	rc = sbi_mpxy_init(scratch);
-	if (rc) {
-		sbi_printf("%s: mpxy init failed (error %d)\n", __func__, rc);
-		sbi_hart_hang();
-	}
 	/*
 	 * Note: Finalize domains after HSM initialization so that we
 	 * can startup non-root domains.
@@ -331,6 +326,16 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)
 		sbi_hart_hang();
 	}
 
+	/*
+	 * Note: Each domain needs its own MPXY shared memory region.
+	 * Note: Initialize the MPXY after sbi_domain_finalize().
+	 */
+	rc = sbi_mpxy_init(scratch);
+	if (rc) {
+		sbi_printf("%s: mpxy init failed (error %d)\n", __func__, rc);
+		sbi_hart_hang();
+	}
+
 	/*
 	 * Note: Platform final initialization should be after finalizing
 	 * domains so that it sees correct domain assignment and PMP
-- 
2.34.1




More information about the opensbi mailing list