Skip to content

Commit e1c0549

Browse files
author
Marc Zyngier
committed
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 <[email protected]>
1 parent 8240ef5 commit e1c0549

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

arch/arm/kernel/irq.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,27 @@ int arch_show_interrupts(struct seq_file *p, int prec)
6363
*/
6464
void handle_IRQ(unsigned int irq, struct pt_regs *regs)
6565
{
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);
6787
}
6888

6989
/*

include/linux/irqdesc.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,24 +161,18 @@ static inline void generic_handle_irq_desc(struct irq_desc *desc)
161161
int handle_irq_desc(struct irq_desc *desc);
162162
int generic_handle_irq(unsigned int irq);
163163

164-
#ifdef CONFIG_HANDLE_DOMAIN_IRQ
164+
#ifdef CONFIG_IRQ_DOMAIN
165165
/*
166166
* Convert a HW interrupt number to a logical one using a IRQ domain,
167167
* and handle the result interrupt number. Return -EINVAL if
168168
* conversion failed.
169169
*/
170-
int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq,
171-
bool lookup, struct pt_regs *regs);
172-
173170
int generic_handle_domain_irq(struct irq_domain *domain, unsigned int hwirq);
174171

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);
180175

181-
#ifdef CONFIG_IRQ_DOMAIN
182176
int handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq,
183177
struct pt_regs *regs);
184178
#endif

kernel/irq/irqdesc.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ int generic_handle_irq(unsigned int irq)
659659
}
660660
EXPORT_SYMBOL_GPL(generic_handle_irq);
661661

662-
#ifdef CONFIG_HANDLE_DOMAIN_IRQ
662+
#ifdef CONFIG_IRQ_DOMAIN
663663
/**
664664
* generic_handle_domain_irq - Invoke the handler for a HW irq belonging
665665
* to a domain, usually for a non-root interrupt
@@ -676,41 +676,28 @@ int generic_handle_domain_irq(struct irq_domain *domain, unsigned int hwirq)
676676
}
677677
EXPORT_SYMBOL_GPL(generic_handle_domain_irq);
678678

679+
#ifdef CONFIG_HANDLE_DOMAIN_IRQ
679680
/**
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
682683
* @domain: The domain where to perform the lookup
683684
* @hwirq: The HW irq number to convert to a logical one
684685
* @lookup: Whether to perform the domain lookup or not
685686
* @regs: Register file coming from the low-level handling code
686687
*
687688
* Returns: 0 on success, or -EINVAL if conversion has failed
688689
*/
689-
int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq,
690-
bool lookup, struct pt_regs *regs)
690+
int handle_domain_irq(struct irq_domain *domain,
691+
unsigned int hwirq, struct pt_regs *regs)
691692
{
692693
struct pt_regs *old_regs = set_irq_regs(regs);
693694
struct irq_desc *desc;
694695
int ret = 0;
695696

696697
irq_enter();
697698

698-
if (likely(IS_ENABLED(CONFIG_IRQ_DOMAIN) && lookup)) {
699-
/* The irqdomain code provides boundary checks */
700-
desc = irq_resolve_mapping(domain, hwirq);
701-
} else {
702-
/*
703-
* Some hardware gives randomly wrong interrupts. Rather
704-
* than crashing, do something sensible.
705-
*/
706-
if (unlikely(!hwirq || hwirq >= nr_irqs)) {
707-
ack_bad_irq(hwirq);
708-
desc = NULL;
709-
} else {
710-
desc = irq_to_desc(hwirq);
711-
}
712-
}
713-
699+
/* The irqdomain code provides boundary checks */
700+
desc = irq_resolve_mapping(domain, hwirq);
714701
if (likely(desc))
715702
handle_irq_desc(desc);
716703
else
@@ -721,7 +708,6 @@ int __handle_domain_irq(struct irq_domain *domain, unsigned int hwirq,
721708
return ret;
722709
}
723710

724-
#ifdef CONFIG_IRQ_DOMAIN
725711
/**
726712
* handle_domain_nmi - Invoke the handler for a HW irq belonging to a domain
727713
* @domain: The domain where to perform the lookup

0 commit comments

Comments
 (0)