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

MIPS: SMTC: Cleanup the hook mess and use irq_data

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
To: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/2194/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Thomas Gleixner and committed by
Ralf Baechle
930cd54b 2a2b2212

+38 -38
+30 -28
arch/mips/include/asm/irq.h
··· 57 57 58 58 extern int plat_set_irq_affinity(struct irq_data *d, 59 59 const struct cpumask *affinity, bool force); 60 - extern void smtc_forward_irq(unsigned int irq); 60 + extern void smtc_forward_irq(struct irq_data *d); 61 61 62 62 /* 63 63 * IRQ affinity hook invoked at the beginning of interrupt dispatch ··· 70 70 * cpumask implementations, this version is optimistically assuming 71 71 * that cpumask.h macro overhead is reasonable during interrupt dispatch. 72 72 */ 73 - #define IRQ_AFFINITY_HOOK(irq) \ 74 - do { \ 75 - if (!cpumask_test_cpu(smp_processor_id(), irq_desc[irq].affinity)) {\ 76 - smtc_forward_irq(irq); \ 77 - irq_exit(); \ 78 - return; \ 79 - } \ 80 - } while (0) 73 + static inline int handle_on_other_cpu(unsigned int irq) 74 + { 75 + struct irq_data *d = irq_get_irq_data(irq); 76 + 77 + if (cpumask_test_cpu(smp_processor_id(), d->affinity)) 78 + return 0; 79 + smtc_forward_irq(d); 80 + return 1; 81 + } 81 82 82 83 #else /* Not doing SMTC affinity */ 83 84 84 - #define IRQ_AFFINITY_HOOK(irq) do { } while (0) 85 + static inline int handle_on_other_cpu(unsigned int irq) { return 0; } 85 86 86 87 #endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */ 87 88 88 89 #ifdef CONFIG_MIPS_MT_SMTC_IM_BACKSTOP 90 + 91 + static inline void smtc_im_backstop(unsigned int irq) 92 + { 93 + if (irq_hwmask[irq] & 0x0000ff00) 94 + write_c0_tccontext(read_c0_tccontext() & 95 + ~(irq_hwmask[irq] & 0x0000ff00)); 96 + } 89 97 90 98 /* 91 99 * Clear interrupt mask handling "backstop" if irq_hwmask ··· 101 93 * functions will take over re-enabling the low-level mask. 102 94 * Otherwise it will be done on return from exception. 103 95 */ 104 - #define __DO_IRQ_SMTC_HOOK(irq) \ 105 - do { \ 106 - IRQ_AFFINITY_HOOK(irq); \ 107 - if (irq_hwmask[irq] & 0x0000ff00) \ 108 - write_c0_tccontext(read_c0_tccontext() & \ 109 - ~(irq_hwmask[irq] & 0x0000ff00)); \ 110 - } while (0) 96 + static inline int smtc_handle_on_other_cpu(unsigned int irq) 97 + { 98 + int ret = handle_on_other_cpu(irq); 111 99 112 - #define __NO_AFFINITY_IRQ_SMTC_HOOK(irq) \ 113 - do { \ 114 - if (irq_hwmask[irq] & 0x0000ff00) \ 115 - write_c0_tccontext(read_c0_tccontext() & \ 116 - ~(irq_hwmask[irq] & 0x0000ff00)); \ 117 - } while (0) 100 + if (!ret) 101 + smtc_im_backstop(irq); 102 + return ret; 103 + } 118 104 119 105 #else 120 106 121 - #define __DO_IRQ_SMTC_HOOK(irq) \ 122 - do { \ 123 - IRQ_AFFINITY_HOOK(irq); \ 124 - } while (0) 125 - #define __NO_AFFINITY_IRQ_SMTC_HOOK(irq) do { } while (0) 107 + static inline void smtc_im_backstop(unsigned int irq) { } 108 + static inline int smtc_handle_on_other_cpu(unsigned int irq) 109 + { 110 + return handle_on_other_cpu(irq); 111 + } 126 112 127 113 #endif 128 114
+3 -3
arch/mips/kernel/irq.c
··· 183 183 { 184 184 irq_enter(); 185 185 check_stack_overflow(); 186 - __DO_IRQ_SMTC_HOOK(irq); 187 - generic_handle_irq(irq); 186 + if (!smtc_handle_on_other_cpu(irq)) 187 + generic_handle_irq(irq); 188 188 irq_exit(); 189 189 } 190 190 ··· 197 197 void __irq_entry do_IRQ_no_affinity(unsigned int irq) 198 198 { 199 199 irq_enter(); 200 - __NO_AFFINITY_IRQ_SMTC_HOOK(irq); 200 + smtc_im_backstop(irq); 201 201 generic_handle_irq(irq); 202 202 irq_exit(); 203 203 }
+5 -7
arch/mips/kernel/smtc.c
··· 677 677 */ 678 678 } 679 679 680 - void smtc_forward_irq(unsigned int irq) 680 + void smtc_forward_irq(struct irq_data *d) 681 681 { 682 - struct irq_data *d = irq_get_irq_data(irq); 682 + unsigned int irq = d->irq; 683 683 int target; 684 684 685 685 /* ··· 708 708 */ 709 709 710 710 /* If no one is eligible, service locally */ 711 - if (target >= NR_CPUS) { 711 + if (target >= NR_CPUS) 712 712 do_IRQ_no_affinity(irq); 713 - return; 714 - } 715 - 716 - smtc_send_ipi(target, IRQ_AFFINITY_IPI, irq); 713 + else 714 + smtc_send_ipi(target, IRQ_AFFINITY_IPI, irq); 717 715 } 718 716 719 717 #endif /* CONFIG_MIPS_MT_SMTC_IRQAFF */