Skip to content

Commit 14be098

Browse files
legoatermpe
authored andcommitted
powerpc/xive: Add support for IRQ domain hierarchy
This adds handlers to allocate/free IRQs in a domain hierarchy. We could try to use xive_irq_domain_map() in xive_irq_domain_alloc() but we rely on xive_irq_alloc_data() to set the IRQ handler data and duplicating the code is simpler. xive_irq_free_data() needs to be called when IRQ are freed to clear the MMIO mappings and free the XIVE handler data, xive_irq_data structure. This is going to be a problem with MSI domains which we will address later. Signed-off-by: Cédric Le Goater <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e812020 commit 14be098

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

arch/powerpc/sysdev/xive/common.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,71 @@ static void xive_irq_domain_debug_show(struct seq_file *m, struct irq_domain *d,
13661366
}
13671367
#endif
13681368

1369+
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
1370+
static int xive_irq_domain_translate(struct irq_domain *d,
1371+
struct irq_fwspec *fwspec,
1372+
unsigned long *hwirq,
1373+
unsigned int *type)
1374+
{
1375+
return xive_irq_domain_xlate(d, to_of_node(fwspec->fwnode),
1376+
fwspec->param, fwspec->param_count,
1377+
hwirq, type);
1378+
}
1379+
1380+
static int xive_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
1381+
unsigned int nr_irqs, void *arg)
1382+
{
1383+
struct irq_fwspec *fwspec = arg;
1384+
irq_hw_number_t hwirq;
1385+
unsigned int type = IRQ_TYPE_NONE;
1386+
int i, rc;
1387+
1388+
rc = xive_irq_domain_translate(domain, fwspec, &hwirq, &type);
1389+
if (rc)
1390+
return rc;
1391+
1392+
pr_debug("%s %d/%lx #%d\n", __func__, virq, hwirq, nr_irqs);
1393+
1394+
for (i = 0; i < nr_irqs; i++) {
1395+
/* TODO: call xive_irq_domain_map() */
1396+
1397+
/*
1398+
* Mark interrupts as edge sensitive by default so that resend
1399+
* actually works. Will fix that up below if needed.
1400+
*/
1401+
irq_clear_status_flags(virq, IRQ_LEVEL);
1402+
1403+
/* allocates and sets handler data */
1404+
rc = xive_irq_alloc_data(virq + i, hwirq + i);
1405+
if (rc)
1406+
return rc;
1407+
1408+
irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
1409+
&xive_irq_chip, domain->host_data);
1410+
irq_set_handler(virq + i, handle_fasteoi_irq);
1411+
}
1412+
1413+
return 0;
1414+
}
1415+
1416+
static void xive_irq_domain_free(struct irq_domain *domain,
1417+
unsigned int virq, unsigned int nr_irqs)
1418+
{
1419+
int i;
1420+
1421+
pr_debug("%s %d #%d\n", __func__, virq, nr_irqs);
1422+
1423+
for (i = 0; i < nr_irqs; i++)
1424+
xive_irq_free_data(virq + i);
1425+
}
1426+
#endif
1427+
13691428
static const struct irq_domain_ops xive_irq_domain_ops = {
1429+
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
1430+
.alloc = xive_irq_domain_alloc,
1431+
.free = xive_irq_domain_free,
1432+
.translate = xive_irq_domain_translate,
1433+
#endif
13701434
.match = xive_irq_domain_match,
13711435
.map = xive_irq_domain_map,
13721436
.unmap = xive_irq_domain_unmap,

0 commit comments

Comments
 (0)