[Skiboot] [RFC, PATCH 3/4] core/mem_region: allow pre-existing reserved-memory nodes

Jeremy Kerr jk at ozlabs.org
Mon Jul 20 19:01:41 AEST 2015


If the HB device tree provides a top-level reserved-memory node, we'll
abort(). We want to be able to handle a pre-populated reserved-memory
node in a future change, so handle this case gracefully.

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>

---
 core/mem_region.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/core/mem_region.c b/core/mem_region.c
index fede263..d7e797e 100644
--- a/core/mem_region.c
+++ b/core/mem_region.c
@@ -1016,10 +1016,13 @@ void mem_region_add_dt_reserved(void)
 	mem_regions_finalised = true;
 
 	/* establish top-level reservation node */
-	node = dt_new(dt_root, "reserved-memory");
-	dt_add_property_cells(node, "#address-cells", 2);
-	dt_add_property_cells(node, "#size-cells", 2);
-	dt_add_property(node, "ranges", NULL, 0);
+	node = dt_find_by_path(dt_root, "reserved-memory");
+	if (!node) {
+		node = dt_new(dt_root, "reserved-memory");
+		dt_add_property_cells(node, "#address-cells", 2);
+		dt_add_property_cells(node, "#size-cells", 2);
+		dt_add_property(node, "ranges", NULL, 0);
+	}
 
 	/* First pass: calculate length of property data */
 	list_for_each(&regions, region, list) {


More information about the Skiboot mailing list