|
20 | 20 | #include <linux/spinlock.h> |
21 | 21 | #include <linux/msi.h> |
22 | 22 |
|
| 23 | +#include <asm/debugfs.h> |
23 | 24 | #include <asm/prom.h> |
24 | 25 | #include <asm/io.h> |
25 | 26 | #include <asm/smp.h> |
@@ -1555,3 +1556,107 @@ static int __init xive_off(char *arg) |
1555 | 1556 | return 0; |
1556 | 1557 | } |
1557 | 1558 | __setup("xive=off", xive_off); |
| 1559 | + |
| 1560 | +void xive_debug_show_cpu(struct seq_file *m, int cpu) |
| 1561 | +{ |
| 1562 | + struct xive_cpu *xc = per_cpu(xive_cpu, cpu); |
| 1563 | + |
| 1564 | + seq_printf(m, "CPU %d:", cpu); |
| 1565 | + if (xc) { |
| 1566 | + seq_printf(m, "pp=%02x CPPR=%02x ", xc->pending_prio, xc->cppr); |
| 1567 | + |
| 1568 | +#ifdef CONFIG_SMP |
| 1569 | + { |
| 1570 | + u64 val = xive_esb_read(&xc->ipi_data, XIVE_ESB_GET); |
| 1571 | + |
| 1572 | + seq_printf(m, "IPI=0x%08x PQ=%c%c ", xc->hw_ipi, |
| 1573 | + val & XIVE_ESB_VAL_P ? 'P' : '-', |
| 1574 | + val & XIVE_ESB_VAL_Q ? 'Q' : '-'); |
| 1575 | + } |
| 1576 | +#endif |
| 1577 | + { |
| 1578 | + struct xive_q *q = &xc->queue[xive_irq_priority]; |
| 1579 | + u32 i0, i1, idx; |
| 1580 | + |
| 1581 | + if (q->qpage) { |
| 1582 | + idx = q->idx; |
| 1583 | + i0 = be32_to_cpup(q->qpage + idx); |
| 1584 | + idx = (idx + 1) & q->msk; |
| 1585 | + i1 = be32_to_cpup(q->qpage + idx); |
| 1586 | + seq_printf(m, "EQ idx=%d T=%d %08x %08x ...", |
| 1587 | + q->idx, q->toggle, i0, i1); |
| 1588 | + } |
| 1589 | + } |
| 1590 | + } |
| 1591 | + seq_puts(m, "\n"); |
| 1592 | +} |
| 1593 | + |
| 1594 | +void xive_debug_show_irq(struct seq_file *m, u32 hw_irq, struct irq_data *d) |
| 1595 | +{ |
| 1596 | + struct irq_chip *chip = irq_data_get_irq_chip(d); |
| 1597 | + int rc; |
| 1598 | + u32 target; |
| 1599 | + u8 prio; |
| 1600 | + u32 lirq; |
| 1601 | + |
| 1602 | + if (!is_xive_irq(chip)) |
| 1603 | + return; |
| 1604 | + |
| 1605 | + rc = xive_ops->get_irq_config(hw_irq, &target, &prio, &lirq); |
| 1606 | + if (rc) { |
| 1607 | + seq_printf(m, "IRQ 0x%08x : no config rc=%d\n", hw_irq, rc); |
| 1608 | + return; |
| 1609 | + } |
| 1610 | + |
| 1611 | + seq_printf(m, "IRQ 0x%08x : target=0x%x prio=%02x lirq=0x%x ", |
| 1612 | + hw_irq, target, prio, lirq); |
| 1613 | + |
| 1614 | + if (d) { |
| 1615 | + struct xive_irq_data *xd = irq_data_get_irq_handler_data(d); |
| 1616 | + u64 val = xive_esb_read(xd, XIVE_ESB_GET); |
| 1617 | + |
| 1618 | + seq_printf(m, "flags=%c%c%c PQ=%c%c", |
| 1619 | + xd->flags & XIVE_IRQ_FLAG_STORE_EOI ? 'S' : ' ', |
| 1620 | + xd->flags & XIVE_IRQ_FLAG_LSI ? 'L' : ' ', |
| 1621 | + xd->flags & XIVE_IRQ_FLAG_H_INT_ESB ? 'H' : ' ', |
| 1622 | + val & XIVE_ESB_VAL_P ? 'P' : '-', |
| 1623 | + val & XIVE_ESB_VAL_Q ? 'Q' : '-'); |
| 1624 | + } |
| 1625 | + seq_puts(m, "\n"); |
| 1626 | +} |
| 1627 | + |
| 1628 | +static int xive_core_debug_show(struct seq_file *m, void *private) |
| 1629 | +{ |
| 1630 | + unsigned int i; |
| 1631 | + struct irq_desc *desc; |
| 1632 | + int cpu; |
| 1633 | + |
| 1634 | + if (xive_ops->debug_show) |
| 1635 | + xive_ops->debug_show(m, private); |
| 1636 | + |
| 1637 | + for_each_possible_cpu(cpu) |
| 1638 | + xive_debug_show_cpu(m, cpu); |
| 1639 | + |
| 1640 | + for_each_irq_desc(i, desc) { |
| 1641 | + struct irq_data *d = irq_desc_get_irq_data(desc); |
| 1642 | + unsigned int hw_irq; |
| 1643 | + |
| 1644 | + if (!d) |
| 1645 | + continue; |
| 1646 | + |
| 1647 | + hw_irq = (unsigned int)irqd_to_hwirq(d); |
| 1648 | + |
| 1649 | + /* IPIs are special (HW number 0) */ |
| 1650 | + if (hw_irq) |
| 1651 | + xive_debug_show_irq(m, hw_irq, d); |
| 1652 | + } |
| 1653 | + return 0; |
| 1654 | +} |
| 1655 | +DEFINE_SHOW_ATTRIBUTE(xive_core_debug); |
| 1656 | + |
| 1657 | +int xive_core_debug_init(void) |
| 1658 | +{ |
| 1659 | + debugfs_create_file("xive", 0400, powerpc_debugfs_root, |
| 1660 | + NULL, &xive_core_debug_fops); |
| 1661 | + return 0; |
| 1662 | +} |
0 commit comments