[Skiboot] [PATCH] core/interrupts.c: change IC unit addr in devtree

Maxim Polyakov m.polyakov at yadro.com
Tue Apr 23 02:13:37 AEST 2019


This patch changes the unit address of the interrupt controller node
from 0 to the last - 0xffffffffffffffff, because address 0 is
reserved for memory at 0 node. In the device tree, it looks like this:

interrupt-controller at 0xffffffffffffffff {
	#address-cells = < 0x00 >;
	device_type = "PowerPC-Interrupt-Source-Controller";
	compatible = "IBM,ppc-xics\0IBM,opal-xics";
	#interrupt-cells = < 0x02 >;
	reg = < 0xffffffff 0xffffffff 0x00 0x00 >;
	phandle = < 0x10000454 >;
	interrupt-controller;
};

This solves the duplicate unit-address problem:
https://github.com/open-power/skiboot/issues/237

Signed-off-by: Maxim Polyakov <m.polyakov at yadro.com>
---
 core/interrupts.c    | 17 +++++++++++++----
 doc/xive.rst         |  4 ++++
 include/interrupts.h |  7 +++++++
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/core/interrupts.c b/core/interrupts.c
index 5d7a68c..dd39ce0 100644
--- a/core/interrupts.c
+++ b/core/interrupts.c
@@ -173,18 +173,21 @@ uint32_t get_psi_interrupt(uint32_t chip_id)
 	return irq;
 }
 
-
 struct dt_node *add_ics_node(void)
 {
-	struct dt_node *ics = dt_new_addr(dt_root, "interrupt-controller", 0);
+	struct dt_node *ics;
 	bool has_xive;
 
+	ics = dt_new_addr(dt_root, "interrupt-controller", ICS_NODE_UNIT_ADDR);
 	if (!ics)
 		return NULL;
 
 	has_xive = proc_gen >= proc_gen_p9;
 
-	dt_add_property_cells(ics, "reg", 0, 0, 0, 0);
+	dt_add_property_cells(ics, "reg",
+			      (uint32_t) (ICS_NODE_UNIT_ADDR >> 32),
+			      (uint32_t) (ICS_NODE_UNIT_ADDR & 0xffffffff),
+			      0, 0);
 	dt_add_property_strings(ics, "compatible",
 				has_xive ? "ibm,opal-xive-vc" : "IBM,ppc-xics",
 				"IBM,opal-xics");
@@ -200,9 +203,15 @@ struct dt_node *add_ics_node(void)
 uint32_t get_ics_phandle(void)
 {
 	struct dt_node *i;
+	char ics_node_name[ICS_NAME_BUF_SIZE];
+
+	snprintf(ics_node_name,
+		 ICS_NAME_BUF_SIZE,
+		 "interrupt-controller@%lx",
+		 ICS_NODE_UNIT_ADDR);
 
 	for (i = dt_first(dt_root); i; i = dt_next(dt_root, i)) {
-		if (streq(i->name, "interrupt-controller at 0")) {
+		if (streq(i->name, ics_node_name)) {
 			return i->phandle;
 		}
 	}
diff --git a/doc/xive.rst b/doc/xive.rst
index 42a6090..d4bfbba 100644
--- a/doc/xive.rst
+++ b/doc/xive.rst
@@ -18,6 +18,10 @@ I - Device-tree updates
 
     - ``compatible`` : This is extended with a new value ``ibm,opal-xive-vc``
 
+    - The unit-address has been changed to ``0xffffffffffffffff``, because
+      unit-address 0 is reserved for ``memory at 0`` node. In the device-tree,
+      it looks like this:
+        ``/interrupt-controller at 0xffffffffffffffff``
 
  2) The new ``/interrupt-controller@<addr>`` node
 
diff --git a/include/interrupts.h b/include/interrupts.h
index 2c4fa7e..10a56b4 100644
--- a/include/interrupts.h
+++ b/include/interrupts.h
@@ -219,6 +219,13 @@ uint32_t p8_irq_to_phb(uint32_t irq);
 /* TBD: NX, AS, ...
  */
 
+/*
+ * Unit address of the parent interrupt controller node
+ * in the device-tree. See doc/xive.rst
+ */
+#define ICS_NODE_UNIT_ADDR	0xffffffffffffffff
+#define ICS_NAME_BUF_SIZE	40
+
 /* Note about interrupt numbers on P9
  * ==================================
  *
-- 
2.7.4



More information about the Skiboot mailing list