Skip to content

Commit

Permalink
interrupts: Add optional name for OPAL interrupts
Browse files Browse the repository at this point in the history
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@kernel.crashing.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
ozbenh authored and stewartsmith committed Jan 5, 2017
1 parent 0bc9d38 commit f3e34ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion core/interrupts.c
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions include/interrupts.h
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit f3e34ce

Please sign in to comment.