[Skiboot] [PATCH 38/60] interrupts: Add optional name for OPAL interrupts

Benjamin Herrenschmidt benh at kernel.crashing.org
Thu Dec 22 14:16:46 AEDT 2016


This adds the infrastructure for an interrupt source to provide
a name for an interrupt directed toward OPAL. Those names will
be put into an "opal-interrupts-names" property which is a
standard DT string list corresponding 1:1 with the "opal-interrupts"
property.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
 core/interrupts.c    | 17 ++++++++++++++++-
 include/interrupts.h |  4 ++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/core/interrupts.c b/core/interrupts.c
index 6c00138..c01a430 100644
--- a/core/interrupts.c
+++ b/core/interrupts.c
@@ -198,8 +198,9 @@ uint32_t get_ics_phandle(void)
 void add_opal_interrupts(void)
 {
 	struct irq_source *is;
-	unsigned int i, count = 0;
+	unsigned int i, ns, tns = 0, count = 0;
 	uint32_t *irqs = NULL, isn;
+	char *names = NULL;
 
 	lock(&irq_lock);
 	list_for_each(&irq_sources, is, link) {
@@ -211,8 +212,21 @@ void add_opal_interrupts(void)
 			continue;
 		for (isn = is->start; isn < is->end; isn++) {
 			uint64_t attr = is->ops->attributes(is, isn);
+			char *name;
+
 			if (attr & IRQ_ATTR_TARGET_LINUX)
 				continue;
+			name = is->ops->name ? is->ops->name(is, isn) : NULL;
+			ns = name ? strlen(name) : 0;
+			printf("irq %x name: %s (%d/%d)\n",
+			       isn, name ? name : "<null>", ns, tns);
+			names = realloc(names, tns + ns + 1);
+			if (name) {
+				strcpy(names + tns, name);
+				tns += (ns + 1);
+				free(name);
+			} else
+				names[tns++] = 0;
 			i = count++;
 			irqs = realloc(irqs, 4 * count);
 			irqs[i] = isn;
@@ -227,6 +241,7 @@ void add_opal_interrupts(void)
 	 * handling in Linux can cause problems.
 	 */
 	dt_add_property(opal_node, "opal-interrupts", irqs, count * 4);
+	dt_add_property(opal_node, "opal-interrupts-names", names, tns);
 
 	free(irqs);
 }
diff --git a/include/interrupts.h b/include/interrupts.h
index 61149cf..2de1f97 100644
--- a/include/interrupts.h
+++ b/include/interrupts.h
@@ -266,6 +266,9 @@ struct irq_source;
  * though we might expose it at some point in XIVE native mode for
  * interrupts that require special EOI operations such as possibly
  * the LPC interrupts on P9 that need a latch cleared in the LPCHC.
+ *
+ * The "name" callback returns a name for the interrupt in a new
+ * malloc()'ed block. The caller will free() it. NULL is acceptable.
  */
 struct irq_source_ops {
 	int64_t (*set_xive)(struct irq_source *is, uint32_t isn,
@@ -281,6 +284,7 @@ struct irq_source_ops {
 #define IRQ_ATTR_TARGET_FREQUENT	0x2
 	void (*interrupt)(struct irq_source *is, uint32_t isn);
 	void (*eoi)(struct irq_source *is, uint32_t isn);
+	char *(*name)(struct irq_source *is, uint32_t isn);
 };
 
 struct irq_source {
-- 
2.9.3



More information about the Skiboot mailing list