[Skiboot] [PATCH 30/32] xive: Expose exploitation mode DT properties

Benjamin Herrenschmidt benh at kernel.crashing.org
Tue Nov 22 13:13:32 AEDT 2016


Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
 core/interrupts.c |  7 ++++-
 hw/xive.c         | 81 ++++++++++++++++++++++++++++++++++++++++---------------
 2 files changed, 65 insertions(+), 23 deletions(-)

diff --git a/core/interrupts.c b/core/interrupts.c
index d567b30..6c00138 100644
--- a/core/interrupts.c
+++ b/core/interrupts.c
@@ -163,11 +163,16 @@ uint32_t get_psi_interrupt(uint32_t chip_id)
 struct dt_node *add_ics_node(void)
 {
 	struct dt_node *ics = dt_new_addr(dt_root, "interrupt-controller", 0);
+	bool has_xive;
+
 	if (!ics)
 		return NULL;
 
+	has_xive = proc_gen >= proc_gen_p9;
+
 	dt_add_property_cells(ics, "reg", 0, 0, 0, 0);
-	dt_add_property_strings(ics, "compatible", "IBM,ppc-xics",
+	dt_add_property_strings(ics, "compatible",
+				has_xive ? "ibm,opal-xive-vc" : "IBM,ppc-xics",
 				"IBM,opal-xics");
 	dt_add_property_cells(ics, "#address-cells", 0);
 	dt_add_property_cells(ics, "#interrupt-cells", 2);
diff --git a/hw/xive.c b/hw/xive.c
index 0399743..afb7a82 100644
--- a/hw/xive.c
+++ b/hw/xive.c
@@ -277,7 +277,6 @@ struct xive {
 	uint32_t	chip_id;
 	uint32_t	block_id;
 	struct dt_node	*x_node;
-	struct dt_node	*m_node;
 
 	uint64_t	xscom_base;
 
@@ -387,6 +386,9 @@ struct xive {
 	struct xive_src	ipis;
 };
 
+/* Global DT node */
+static struct dt_node *xive_dt_node;
+
 
 /* Block <-> Chip conversions.
  *
@@ -1731,25 +1733,51 @@ static bool xive_prealloc_tables(struct xive *x)
 	return true;
 }
 
+#ifdef USE_INDIRECT
+static void xive_add_provisioning_properties(void)
+{
+	uint32_t chips[XIVE_MAX_CHIPS];
+	uint32_t i, count;
+
+	dt_add_property_cells(xive_dt_node,
+			      "ibm,xive-provision-page-size", 0x10000);
+
+#ifdef USE_BLOCK_GROUP_MODE
+	count = 1 << xive_chips_alloc_bits;
+#else
+	count = xive_block_count;
+#endif
+	for (i = 0; i < count; i++)
+		chips[i] = xive_block_to_chip[i];
+	dt_add_property(xive_dt_node, "ibm,xive-provision-chips",
+			chips, 4 * count);
+}
+#else
+static inline void xive_add_provisioning_properties(void) { }
+#endif
+
 static void xive_create_mmio_dt_node(struct xive *x)
 {
-	x->m_node = dt_new_addr(dt_root, "interrupt-controller",
-				(uint64_t)x->ic_base);
-	assert(x->m_node);
+	uint64_t tb = (uint64_t)x->tm_base;
 
-	dt_add_property_u64s(x->m_node, "reg",
-			     (uint64_t)x->ic_base, x->ic_size,
-			     (uint64_t)x->tm_base, x->tm_size,
-			     (uint64_t)x->pc_base, x->pc_size,
-			     (uint64_t)x->vc_base, x->vc_size);
+	xive_dt_node = dt_new_addr(dt_root, "interrupt-controller", tb);
+	assert(xive_dt_node);
 
-	/* XXX Only put in "ibm,power9-xive" when we support the exploitation
-	 * related APIs and properties
-	 */
-	dt_add_property_strings(x->m_node, "compatible", /*"ibm,power9-xive",*/ "ibm,opal-intc");
+	dt_add_property_u64s(xive_dt_node, "reg",
+			     tb + 0x00000, 0x10000,
+			     tb + 0x10000, 0x10000,
+			     tb + 0x20000, 0x10000,
+			     tb + 0x30000, 0x00000);
+
+	dt_add_property_strings(xive_dt_node, "compatible",
+				"ibm,opal-xive-pe", "ibm,opal-intc");
 
-	dt_add_property_cells(x->m_node, "ibm,xive-max-sources",
-			      MAX_INT_ENTRIES);
+	dt_add_property_cells(xive_dt_node, "ibm,xive-eq-sizes",
+			      12, 16, 21, 24);
+
+	dt_add_property_cells(xive_dt_node, "ibm,xive-#priorities", 8);
+
+	xive_add_provisioning_properties();
 }
 
 static void xive_setup_forward_ports(struct xive *x, struct proc_chip *remote_chip)
@@ -2367,7 +2395,7 @@ void xive_register_ipi_source(uint32_t base, uint32_t count, void *data,
 			       XIVE_SRC_EOI_PAGE1, false, data, ops);
 }
 
-static void init_one_xive(struct dt_node *np)
+static struct xive *init_one_xive(struct dt_node *np)
 {
 	struct xive *x;
 	struct proc_chip *chip;
@@ -2453,15 +2481,13 @@ static void init_one_xive(struct dt_node *np)
 
 	/* XXX Add registration of escalation sources too */
 
-	/* Create a device-tree node for Linux use */
-	xive_create_mmio_dt_node(x);
-
-	return;
+	return x;
  fail:
 	xive_err(x, "Initialization failed...\n");
 
 	/* Should this be fatal ? */
 	//assert(false);
+	return NULL;
 }
 
 /*
@@ -3286,21 +3312,32 @@ void init_xive(void)
 	struct dt_node *np;
 	struct proc_chip *chip;
 	struct cpu_thread *cpu;
+	struct xive *one_xive;
 	bool first = true;
 
 	/* Look for xive nodes and do basic inits */
 	dt_for_each_compatible(dt_root, np, "ibm,power9-xive-x") {
+		struct xive *x;
+
 		/* Initialize some global stuff */
 		if (first)
 			xive_init_globals();
-		first = false;
+
 		/* Create/initialize the xive instance */
-		init_one_xive(np);
+		x = init_one_xive(np);
+		if (first)
+			one_xive = x;
+		first = false;
 	}
+	if (first)
+		return;
 
 	/* Init VP allocator */
 	xive_init_vp_allocator();
 
+	/* Create a device-tree node for Linux use */
+	xive_create_mmio_dt_node(one_xive);
+
 	/* Some inits must be done after all xive have been created
 	 * such as setting up the forwarding ports
 	 */
-- 
2.7.4



More information about the Skiboot mailing list