Skip to content

Commit 5210864

Browse files
ericmiaoRussell King
authored andcommitted
ARM: 6532/1: Allow machine to specify it's own IRQ handlers at run-time
Normally different ARM platform has different way to decode the IRQ hardware status and demultiplex to the corresponding IRQ handler. This is highly optimized by macro irq_handler in entry-armv.S, and each machine defines their own macro to decode the IRQ number. However, this prevents multiple machine classes to be built into a single kernel. By allowing each machine to specify thier own handler, and making function pointer 'handle_arch_irq' to point to it at run time, this can be solved. And introduce CONFIG_MULTI_IRQ_HANDLER to allow both solutions to work. Comparing with the highly optimized macro of irq_handler, the new function must be written with care not to lose too much performance. And the IPI stuff on SMP is expected to move to the provided arch IRQ handler as well. The assembly code to invoke handle_arch_irq is optimized by Russell King. Signed-off-by: Eric Miao <eric.miao@canonical.com> Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 4a50bfe commit 5210864

5 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎arch/arm/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,11 @@ config CPU_HAS_PMU
10221022
default y
10231023
bool
10241024

1025+
config MULTI_IRQ_HANDLER
1026+
bool
1027+
help
1028+
Allow each machine to specify it's own IRQ handler at run time.
1029+
10251030
if !MMU
10261031
source "arch/arm/Kconfig-nommu"
10271032
endif

‎arch/arm/include/asm/mach/arch.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ struct machine_desc {
4040
void (*init_irq)(void);
4141
struct sys_timer *timer; /* system tick timer */
4242
void (*init_machine)(void);
43+
#ifdef CONFIG_MULTI_IRQ_HANDLER
44+
void (*handle_irq)(struct pt_regs *);
45+
#endif
4346
};
4447

4548
/*

‎arch/arm/include/asm/mach/irq.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ extern void (*init_arch_irq)(void);
2222
extern void init_FIQ(void);
2323
extern int show_fiq_list(struct seq_file *, void *);
2424

25+
#ifdef CONFIG_MULTI_IRQ_HANDLER
26+
extern void (*handle_arch_irq)(struct pt_regs *);
27+
#endif
28+
2529
/*
2630
* This is for easy migration, but should be changed in the source
2731
*/

‎arch/arm/kernel/entry-armv.S‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
* Interrupt handling. Preserves r7, r8, r9
3131
*/
3232
.macro irq_handler
33+
#ifdef CONFIG_MULTI_IRQ_HANDLER
34+
ldr r5, =handle_arch_irq
35+
mov r0, sp
36+
ldr r5, [r5]
37+
adr lr, BSYM(9997f)
38+
teq r5, #0
39+
movne pc, r5
40+
#endif
3341
get_irqnr_preamble r5, lr
3442
1: get_irqnr_and_base r0, r6, r5, lr
3543
movne r1, sp
@@ -58,9 +66,8 @@
5866
adrne lr, BSYM(1b)
5967
bne do_local_timer
6068
#endif
61-
9997:
6269
#endif
63-
70+
9997:
6471
.endm
6572

6673
#ifdef CONFIG_KPROBES
@@ -1245,3 +1252,9 @@ cr_alignment:
12451252
.space 4
12461253
cr_no_alignment:
12471254
.space 4
1255+
1256+
#ifdef CONFIG_MULTI_IRQ_HANDLER
1257+
.globl handle_arch_irq
1258+
handle_arch_irq:
1259+
.space 4
1260+
#endif

‎arch/arm/kernel/setup.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,9 @@ void __init setup_arch(char **cmdline_p)
875875
init_arch_irq = mdesc->init_irq;
876876
system_timer = mdesc->timer;
877877
init_machine = mdesc->init_machine;
878+
#ifdef CONFIG_MULTI_IRQ_HANDLER
879+
handle_arch_irq = mdesc->handle_irq;
880+
#endif
878881

879882
#ifdef CONFIG_VT
880883
#if defined(CONFIG_VGA_CONSOLE)

0 commit comments

Comments
 (0)