[Skiboot] [PATCH 5/7] hw/prd: Expose prd ranges via device tree

Jeremy Kerr jk at ozlabs.org
Tue May 19 15:20:15 AEST 2015


Currently, the prd reserved ranges are present in the reserved-ranges
nodes in the device tree. While this works, it's difficult to filter the
actual PRD ranges from general reserved memory.

This change adds a prd node to the ibm,opal node, with a node to
describe each reservation.

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

---
 core/init.c                              |    2 +
 doc/device-tree/ibm,opal/diagnostics.txt |   10 +++++
 doc/device-tree/reserved-memory.txt      |    3 +
 hw/prd.c                                 |   39 +++++++++++++++++++++++
 include/skiboot.h                        |    1 
 5 files changed, 55 insertions(+)

diff --git a/core/init.c b/core/init.c
index 0e28f95..8cb89b5 100644
--- a/core/init.c
+++ b/core/init.c
@@ -770,6 +770,8 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu)
 	/* ... and add remaining reservations to the DT */
 	mem_region_add_dt_reserved();
 
+	prd_register_reserved_memory();
+
 	load_and_boot_kernel(false);
 }
 
diff --git a/doc/device-tree/ibm,opal/diagnostics.txt b/doc/device-tree/ibm,opal/diagnostics.txt
new file mode 100644
index 0000000..14da91c
--- /dev/null
+++ b/doc/device-tree/ibm,opal/diagnostics.txt
@@ -0,0 +1,10 @@
+
+ibm,opal/diagnostics device tree entries
+----------------------------------
+
+The diagnostics node under ibm,opal describes a userspace-to-firmware
+interface, supporting the runtime processor recovery diagnostics functions.
+
+The properties of a prd node are:
+
+ compatible = "ibm,opal-prd"
diff --git a/doc/device-tree/reserved-memory.txt b/doc/device-tree/reserved-memory.txt
index 0f6002d..ff0d6a4 100644
--- a/doc/device-tree/reserved-memory.txt
+++ b/doc/device-tree/reserved-memory.txt
@@ -25,3 +25,6 @@ The sub-nodes under the /reserved-memory node contain:
     and size values are two cells each, as signified by the top-level
     #{address,size}-cells
 
+ ibm,prd-label = "string"
+  - a string token for use by the prd system. Specific ranges may be
+    used by prd - those will be referenced by this label.
diff --git a/hw/prd.c b/hw/prd.c
index 4862213..2943904 100644
--- a/hw/prd.c
+++ b/hw/prd.c
@@ -21,6 +21,7 @@
 #include <chip.h>
 #include <opal-msg.h>
 #include <fsp.h>
+#include <mem_region.h>
 
 enum events {
 	EVENT_ATTN	= 1 << 0,
@@ -32,6 +33,7 @@ static uint8_t events[MAX_CHIPS];
 static uint64_t ipoll_status[MAX_CHIPS];
 static struct opal_prd_msg prd_msg;
 static bool prd_msg_inuse, prd_active;
+struct dt_node *prd_node;
 
 /* Locking:
  *
@@ -358,4 +360,41 @@ void prd_init(void)
 		queue_prd_msg = queue_prd_msg_hbrt;
 		opal_register(OPAL_PRD_MSG, opal_prd_msg, 1);
 	}
+
+	prd_node = dt_new(opal_node, "diagnostics");
+	dt_add_property_strings(prd_node, "compatible", "ibm,opal-prd");
+}
+
+void prd_register_reserved_memory(void)
+{
+	struct mem_region *region;
+	uint32_t *phandles = NULL;
+	int n = 0;
+
+	if (!prd_node)
+		return;
+
+	lock(&mem_region_lock);
+	for (region = mem_region_next(NULL); region;
+			region = mem_region_next(region)) {
+
+		if (region->type != REGION_HW_RESERVED)
+			continue;
+
+		if (!region->node)
+			continue;
+
+		if (!dt_find_property(region->node, "ibm,prd-label")) {
+			dt_add_property_string(region->node, "ibm,prd-label",
+					region->name);
+		}
+
+		phandles = realloc(phandles, ++n * sizeof(*phandles));
+		phandles[n-1] = region->node->phandle;
+	}
+	unlock(&mem_region_lock);
+
+	dt_add_property(prd_node, "prd-ranges",
+			phandles, n * sizeof(*phandles));
+	free(phandles);
 }
diff --git a/include/skiboot.h b/include/skiboot.h
index e92d38e..5aa0c85 100644
--- a/include/skiboot.h
+++ b/include/skiboot.h
@@ -253,6 +253,7 @@ extern void prd_psi_interrupt(uint32_t proc);
 extern void prd_tmgt_interrupt(uint32_t proc);
 extern void prd_occ_reset(uint32_t proc);
 extern void prd_init(void);
+extern void prd_register_reserved_memory(void);
 
 /* Flatten device-tree */
 extern void *create_dtb(const struct dt_node *root);


More information about the Skiboot mailing list