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

genirq: Move non-irqdomain handle_domain_irq() handling into ARM's handle_IRQ()

Despite the name, handle_domain_irq() deals with non-irqdomain
handling for the sake of a handful of legacy ARM platforms.

Move such handling into ARM's handle_IRQ(), allowing for better
code generation for everyone else. This allows us get rid of
some complexity, and to rearrange the guards on the various helpers
in a more logical way.

Signed-off-by: Marc Zyngier <maz@kernel.org>

+33 -33
+21 -1
arch/arm/kernel/irq.c
··· 63 63 */ 64 64 void handle_IRQ(unsigned int irq, struct pt_regs *regs) 65 65 { 66 - __handle_domain_irq(NULL, irq, false, regs); 66 + struct pt_regs *old_regs = set_irq_regs(regs); 67 + struct irq_desc *desc; 68 + 69 + irq_enter(); 70 + 71 + /* 72 + * Some hardware gives randomly wrong interrupts. Rather 73 + * than crashing, do something sensible. 74 + */ 75 + if (unlikely(!irq || irq >= nr_irqs)) 76 + desc = NULL; 77 + else 78 + desc = irq_to_desc(irq); 79 + 80 + if (likely(desc)) 81 + handle_irq_desc(desc); 82 + else 83 + ack_bad_irq(irq); 84 + 85 + irq_exit(); 86 + set_irq_regs(old_regs); 67 87 } 68 88 69 89 /*
+4 -10
include/linux/irqdesc.h
··· 161 161 int handle_irq_desc(struct irq_desc *desc); 162 162 int generic_handle_irq(unsigned int irq); 163 163 164 - #ifdef CONFIG_HANDLE_DOMAIN_IRQ 164 + #ifdef CONFIG_IRQ_DOMAIN 165 165 /* 166 166 * Convert a HW interrupt number to a logical one using a IRQ domain, 167 167 * and handle the result interrupt number. Return -EINVAL if 168 168 * conversion failed. 169 169 */ 170 - int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, 171 - bool lookup, struct pt_regs *regs); 172 - 173 170 int generic_handle_domain_irq(struct irq_domain *domain, unsigned int hwirq); 174 171 175 - static inline int handle_domain_irq(struct irq_domain *domain, 176 - unsigned int hwirq, struct pt_regs *regs) 177 - { 178 - return __handle_domain_irq(domain, hwirq, true, regs); 179 - } 172 + #ifdef CONFIG_HANDLE_DOMAIN_IRQ 173 + int handle_domain_irq(struct irq_domain *domain, 174 + unsigned int hwirq, struct pt_regs *regs); 180 175 181 - #ifdef CONFIG_IRQ_DOMAIN 182 176 int handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq, 183 177 struct pt_regs *regs); 184 178 #endif
+8 -22
kernel/irq/irqdesc.c
··· 659 659 } 660 660 EXPORT_SYMBOL_GPL(generic_handle_irq); 661 661 662 - #ifdef CONFIG_HANDLE_DOMAIN_IRQ 662 + #ifdef CONFIG_IRQ_DOMAIN 663 663 /** 664 664 * generic_handle_domain_irq - Invoke the handler for a HW irq belonging 665 665 * to a domain, usually for a non-root interrupt ··· 676 676 } 677 677 EXPORT_SYMBOL_GPL(generic_handle_domain_irq); 678 678 679 + #ifdef CONFIG_HANDLE_DOMAIN_IRQ 679 680 /** 680 - * __handle_domain_irq - Invoke the handler for a HW irq belonging to a domain, 681 - * usually for a root interrupt controller 681 + * handle_domain_irq - Invoke the handler for a HW irq belonging to a domain, 682 + * usually for a root interrupt controller 682 683 * @domain: The domain where to perform the lookup 683 684 * @hwirq: The HW irq number to convert to a logical one 684 685 * @lookup: Whether to perform the domain lookup or not ··· 687 686 * 688 687 * Returns: 0 on success, or -EINVAL if conversion has failed 689 688 */ 690 - int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq, 691 - bool lookup, struct pt_regs *regs) 689 + int handle_domain_irq(struct irq_domain *domain, 690 + unsigned int hwirq, struct pt_regs *regs) 692 691 { 693 692 struct pt_regs *old_regs = set_irq_regs(regs); 694 693 struct irq_desc *desc; ··· 696 695 697 696 irq_enter(); 698 697 699 - if (likely(IS_ENABLED(CONFIG_IRQ_DOMAIN) && lookup)) { 700 - /* The irqdomain code provides boundary checks */ 701 - desc = irq_resolve_mapping(domain, hwirq); 702 - } else { 703 - /* 704 - * Some hardware gives randomly wrong interrupts. Rather 705 - * than crashing, do something sensible. 706 - */ 707 - if (unlikely(!hwirq || hwirq >= nr_irqs)) { 708 - ack_bad_irq(hwirq); 709 - desc = NULL; 710 - } else { 711 - desc = irq_to_desc(hwirq); 712 - } 713 - } 714 - 698 + /* The irqdomain code provides boundary checks */ 699 + desc = irq_resolve_mapping(domain, hwirq); 715 700 if (likely(desc)) 716 701 handle_irq_desc(desc); 717 702 else ··· 708 721 return ret; 709 722 } 710 723 711 - #ifdef CONFIG_IRQ_DOMAIN 712 724 /** 713 725 * handle_domain_nmi - Invoke the handler for a HW irq belonging to a domain 714 726 * @domain: The domain where to perform the lookup