Skip to contentSkip to conversation

lib: fdt_domain: Default boot-hart to coldboot HART for multi-domain boot

PATCH Applied Yu-Chien Peter Lin 2 participants 3 messages Mar 27 – May 11

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: fdt_domain: Default boot-hart to coldboot HART for multi-domain boot

When "boot-hart" is not specified, dom->boot_hartid was left as -1U, causing domain context switching to fail. Default it to the coldboot HART to enable SMP boot in multi-domain setups, consistent with how next-arg1 is handled.

Also update its description in domain_support.md.

---
 docs/domain_support.md     | 6 +++---
 lib/utils/fdt/fdt_domain.c | 5 +----
 2 files changed, 4 insertions(+), 7 deletions(-)
docs/domain_support.md +3 -3
index 93186c4a..c01e445f 100644
@@ -173,9 +173,9 @@ The DT properties of a domain instance DT node are as follows:
   Any region of a domain defined in DT node cannot have only M-bits set
   in access permissions i.e. it cannot be an m-mode only accessible region.
 * **boot-hart** (Optional) - The DT node phandle of the HART booting the
-  domain instance. If coldboot HART is assigned to the domain instance then
-  this DT property is ignored and the coldboot HART is assumed to be the
-  boot HART of the domain instance.
+  domain instance. If not specified, defaults to the coldboot HART. Note that
+  if the coldboot HART is assigned to this domain, it will be forced as
+  the boot HART regardless of this property.
 * **next-arg1** (Optional) - The 64 bit next booting stage arg1 for the
   domain instance. If this DT property is not available and coldboot HART
   is not assigned to the domain instance then **next booting stage arg1 of coldboot HART**
lib/utils/fdt/fdt_domain.c +1 -4
index b2fa8633..1b039533 100644
@@ -396,16 +396,13 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque)
 	dom->fw_region_inited = root.fw_region_inited;
 
 	/* Read "boot-hart" DT property */
-	val32 = -1U;
+	val32 = current_hartid();
 	val = fdt_getprop(fdt, domain_offset, "boot-hart", &len);
 	if (val && len >= 4) {
 		cpu_offset = fdt_node_offset_by_phandle(fdt,
 							 fdt32_to_cpu(*val));
 		if (cpu_offset >= 0 && fdt_node_is_enabled(fdt, cpu_offset))
 			fdt_parse_hart_id(fdt, cpu_offset, &val32);
-	} else {
-		if (domain_offset == *cold_domain_offset)
-			val32 = current_hartid();
 	}
 	dom->boot_hartid = val32;
 
Signature · 7 lines
2.48.0


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Yu-Chien Peter Lin

When "boot-hart" is not specified, dom->boot_hartid was left as -1U, causing domain context switching to fail. Default it to the coldboot HART to enable SMP boot in multi-domain setups, consistent with how next-arg1 is handled.

Also update its description in domain_support.md.

LGTM.

Regards,
Anup

Quoted 52 lines
---
 docs/domain_support.md     | 6 +++---
 lib/utils/fdt/fdt_domain.c | 5 +----
 2 files changed, 4 insertions(+), 7 deletions(-)
docs/domain_support.md +3 -3
index 93186c4a..c01e445f 100644
@@ -173,9 +173,9 @@ The DT properties of a domain instance DT node are as follows:
   Any region of a domain defined in DT node cannot have only M-bits set
   in access permissions i.e. it cannot be an m-mode only accessible region.
 * **boot-hart** (Optional) - The DT node phandle of the HART booting the
-  domain instance. If coldboot HART is assigned to the domain instance then
-  this DT property is ignored and the coldboot HART is assumed to be the
-  boot HART of the domain instance.
+  domain instance. If not specified, defaults to the coldboot HART. Note that
+  if the coldboot HART is assigned to this domain, it will be forced as
+  the boot HART regardless of this property.
 * **next-arg1** (Optional) - The 64 bit next booting stage arg1 for the
   domain instance. If this DT property is not available and coldboot HART
   is not assigned to the domain instance then **next booting stage arg1 of coldboot HART**
lib/utils/fdt/fdt_domain.c +1 -5
index b2fa8633..1b039533 100644
@@ -396,16 +396,13 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque)
        dom->fw_region_inited = root.fw_region_inited;
 
        /* Read "boot-hart" DT property */
-       val32 = -1U;
+       val32 = current_hartid();
        val = fdt_getprop(fdt, domain_offset, "boot-hart", &len);
        if (val && len >= 4) {
                cpu_offset = fdt_node_offset_by_phandle(fdt,
                                                         fdt32_to_cpu(*val));
                if (cpu_offset >= 0 && fdt_node_is_enabled(fdt, cpu_offset))
                        fdt_parse_hart_id(fdt, cpu_offset, &val32);
-       } else {
-               if (domain_offset == *cold_domain_offset)
-                       val32 = current_hartid();
        }
        dom->boot_hartid = val32;
 
--

2.48.0

--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Applied
#2 lore raw
In reply to Yu-Chien Peter Lin
Quoted 9 lines · Yu-Chien Peter Lin

When "boot-hart" is not specified, dom->boot_hartid was left as -1U, causing domain context switching to fail. Default it to the coldboot HART to enable SMP boot in multi-domain setups, consistent with how next-arg1 is handled.

Also update its description in domain_support.md.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 52 lines
---
 docs/domain_support.md     | 6 +++---
 lib/utils/fdt/fdt_domain.c | 5 +----
 2 files changed, 4 insertions(+), 7 deletions(-)
docs/domain_support.md +3 -3
index 93186c4a..c01e445f 100644
@@ -173,9 +173,9 @@ The DT properties of a domain instance DT node are as follows:
   Any region of a domain defined in DT node cannot have only M-bits set
   in access permissions i.e. it cannot be an m-mode only accessible region.
 * **boot-hart** (Optional) - The DT node phandle of the HART booting the
-  domain instance. If coldboot HART is assigned to the domain instance then
-  this DT property is ignored and the coldboot HART is assumed to be the
-  boot HART of the domain instance.
+  domain instance. If not specified, defaults to the coldboot HART. Note that
+  if the coldboot HART is assigned to this domain, it will be forced as
+  the boot HART regardless of this property.
 * **next-arg1** (Optional) - The 64 bit next booting stage arg1 for the
   domain instance. If this DT property is not available and coldboot HART
   is not assigned to the domain instance then **next booting stage arg1 of coldboot HART**
lib/utils/fdt/fdt_domain.c +1 -5
index b2fa8633..1b039533 100644
@@ -396,16 +396,13 @@ static int __fdt_parse_domain(const void *fdt, int domain_offset, void *opaque)
        dom->fw_region_inited = root.fw_region_inited;
 
        /* Read "boot-hart" DT property */
-       val32 = -1U;
+       val32 = current_hartid();
        val = fdt_getprop(fdt, domain_offset, "boot-hart", &len);
        if (val && len >= 4) {
                cpu_offset = fdt_node_offset_by_phandle(fdt,
                                                         fdt32_to_cpu(*val));
                if (cpu_offset >= 0 && fdt_node_is_enabled(fdt, cpu_offset))
                        fdt_parse_hart_id(fdt, cpu_offset, &val32);
-       } else {
-               if (domain_offset == *cold_domain_offset)
-                       val32 = current_hartid();
        }
        dom->boot_hartid = val32;
 
--

2.48.0

--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi