Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip: mips-cpu: Prepare for non-legacy IRQ domains

The various struct irq_chip callbacks in the MIPS CPU interrupt
controller driver have been calculating the hardware interrupt number by
subtracting MIPS_CPU_IRQ_BASE from the virq number. This presumes a
linear mapping beginning from MIPS_CPU_IRQ_BASE, and this will not hold
once an IPI IRQ domain is introduced. Switch to using the hwirq field of
struct irq_data which already contains the hardware interrupt number
instead of attempting to calculate it.

Similarly, plat_irq_dispatch calculated the virq number by adding
MIPS_CPU_IRQ_BASE to the hardware interrupt number. Ready this for the
introduction of an IPI IRQ domain by instead using irq_linear_revmap.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/15835/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Paul Burton and committed by
Ralf Baechle
131735af c0cfbe69

+13 -10
+13 -10
drivers/irqchip/irq-mips-cpu.c
··· 39 39 #include <asm/mipsmtregs.h> 40 40 #include <asm/setup.h> 41 41 42 + static struct irq_domain *irq_domain; 43 + 42 44 static inline void unmask_mips_irq(struct irq_data *d) 43 45 { 44 - set_c0_status(IE_SW0 << (d->irq - MIPS_CPU_IRQ_BASE)); 46 + set_c0_status(IE_SW0 << d->hwirq); 45 47 irq_enable_hazard(); 46 48 } 47 49 48 50 static inline void mask_mips_irq(struct irq_data *d) 49 51 { 50 - clear_c0_status(IE_SW0 << (d->irq - MIPS_CPU_IRQ_BASE)); 52 + clear_c0_status(IE_SW0 << d->hwirq); 51 53 irq_disable_hazard(); 52 54 } 53 55 ··· 72 70 { 73 71 unsigned int vpflags = dvpe(); 74 72 75 - clear_c0_cause(C_SW0 << (d->irq - MIPS_CPU_IRQ_BASE)); 73 + clear_c0_cause(C_SW0 << d->hwirq); 76 74 evpe(vpflags); 77 75 unmask_mips_irq(d); 78 76 return 0; ··· 85 83 static void mips_mt_cpu_irq_ack(struct irq_data *d) 86 84 { 87 85 unsigned int vpflags = dvpe(); 88 - clear_c0_cause(C_SW0 << (d->irq - MIPS_CPU_IRQ_BASE)); 86 + clear_c0_cause(C_SW0 << d->hwirq); 89 87 evpe(vpflags); 90 88 mask_mips_irq(d); 91 89 } ··· 105 103 asmlinkage void __weak plat_irq_dispatch(void) 106 104 { 107 105 unsigned long pending = read_c0_cause() & read_c0_status() & ST0_IM; 106 + unsigned int virq; 108 107 int irq; 109 108 110 109 if (!pending) { ··· 116 113 pending >>= CAUSEB_IP; 117 114 while (pending) { 118 115 irq = fls(pending) - 1; 119 - do_IRQ(MIPS_CPU_IRQ_BASE + irq); 116 + virq = irq_linear_revmap(irq_domain, irq); 117 + do_IRQ(virq); 120 118 pending &= ~BIT(irq); 121 119 } 122 120 } ··· 149 145 150 146 static void __init __mips_cpu_irq_init(struct device_node *of_node) 151 147 { 152 - struct irq_domain *domain; 153 - 154 148 /* Mask interrupts. */ 155 149 clear_c0_status(ST0_IM); 156 150 clear_c0_cause(CAUSEF_IP); 157 151 158 - domain = irq_domain_add_legacy(of_node, 8, MIPS_CPU_IRQ_BASE, 0, 159 - &mips_cpu_intc_irq_domain_ops, NULL); 160 - if (!domain) 152 + irq_domain = irq_domain_add_legacy(of_node, 8, MIPS_CPU_IRQ_BASE, 0, 153 + &mips_cpu_intc_irq_domain_ops, 154 + NULL); 155 + if (!irq_domain) 161 156 panic("Failed to add irqdomain for MIPS CPU"); 162 157 } 163 158