diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2009-03-23 13:28:15 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-03-24 07:15:23 -0400 |
commit | 3aa551c9b4c40018f0e261a178e3d25478dc04a9 (patch) | |
tree | 2a696109273fcc421d774cc8fefa4180331a85ad /include/linux/interrupt.h | |
parent | 80c5520811d3805adcb15c570ea5e2d489fa5d0b (diff) |
genirq: add threaded interrupt handler support
Add support for threaded interrupt handlers:
A device driver can request that its main interrupt handler runs in a
thread. To achive this the device driver requests the interrupt with
request_threaded_irq() and provides additionally to the handler a
thread function. The handler function is called in hard interrupt
context and needs to check whether the interrupt originated from the
device. If the interrupt originated from the device then the handler
can either return IRQ_HANDLED or IRQ_WAKE_THREAD. IRQ_HANDLED is
returned when no further action is required. IRQ_WAKE_THREAD causes
the genirq code to invoke the threaded (main) handler. When
IRQ_WAKE_THREAD is returned handler must have disabled the interrupt
on the device level. This is mandatory for shared interrupt handlers,
but we need to do it as well for obscure x86 hardware where disabling
an interrupt on the IO_APIC level redirects the interrupt to the
legacy PIC interrupt lines.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/interrupt.h')
-rw-r--r-- | include/linux/interrupt.h | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h index 0c9cb63e6895..6fc2b720c231 100644 --- a/include/linux/interrupt.h +++ b/include/linux/interrupt.h | |||
@@ -59,6 +59,16 @@ | |||
59 | #define IRQF_NOBALANCING 0x00000800 | 59 | #define IRQF_NOBALANCING 0x00000800 |
60 | #define IRQF_IRQPOLL 0x00001000 | 60 | #define IRQF_IRQPOLL 0x00001000 |
61 | 61 | ||
62 | /* | ||
63 | * Bits used by threaded handlers: | ||
64 | * IRQTF_RUNTHREAD - signals that the interrupt handler thread should run | ||
65 | * IRQTF_DIED - handler thread died | ||
66 | */ | ||
67 | enum { | ||
68 | IRQTF_RUNTHREAD, | ||
69 | IRQTF_DIED, | ||
70 | }; | ||
71 | |||
62 | typedef irqreturn_t (*irq_handler_t)(int, void *); | 72 | typedef irqreturn_t (*irq_handler_t)(int, void *); |
63 | 73 | ||
64 | /** | 74 | /** |
@@ -71,6 +81,9 @@ typedef irqreturn_t (*irq_handler_t)(int, void *); | |||
71 | * @next: pointer to the next irqaction for shared interrupts | 81 | * @next: pointer to the next irqaction for shared interrupts |
72 | * @irq: interrupt number | 82 | * @irq: interrupt number |
73 | * @dir: pointer to the proc/irq/NN/name entry | 83 | * @dir: pointer to the proc/irq/NN/name entry |
84 | * @thread_fn: interupt handler function for threaded interrupts | ||
85 | * @thread: thread pointer for threaded interrupts | ||
86 | * @thread_flags: flags related to @thread | ||
74 | */ | 87 | */ |
75 | struct irqaction { | 88 | struct irqaction { |
76 | irq_handler_t handler; | 89 | irq_handler_t handler; |
@@ -81,11 +94,31 @@ struct irqaction { | |||
81 | struct irqaction *next; | 94 | struct irqaction *next; |
82 | int irq; | 95 | int irq; |
83 | struct proc_dir_entry *dir; | 96 | struct proc_dir_entry *dir; |
97 | irq_handler_t thread_fn; | ||
98 | struct task_struct *thread; | ||
99 | unsigned long thread_flags; | ||
84 | }; | 100 | }; |
85 | 101 | ||
86 | extern irqreturn_t no_action(int cpl, void *dev_id); | 102 | extern irqreturn_t no_action(int cpl, void *dev_id); |
87 | extern int __must_check request_irq(unsigned int, irq_handler_t handler, | 103 | |
88 | unsigned long, const char *, void *); | 104 | extern int __must_check |
105 | request_threaded_irq(unsigned int irq, irq_handler_t handler, | ||
106 | irq_handler_t thread_fn, | ||
107 | unsigned long flags, const char *name, void *dev); | ||
108 | |||
109 | static inline int __must_check | ||
110 | request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, | ||
111 | const char *name, void *dev) | ||
112 | { | ||
113 | return request_threaded_irq(irq, handler, NULL, flags, name, dev); | ||
114 | } | ||
115 | |||
116 | #ifdef CONFIG_GENERIC_HARDIRQS | ||
117 | extern void exit_irq_thread(void); | ||
118 | #else | ||
119 | static inline void exit_irq_thread(void) { } | ||
120 | #endif | ||
121 | |||
89 | extern void free_irq(unsigned int, void *); | 122 | extern void free_irq(unsigned int, void *); |
90 | 123 | ||
91 | struct device; | 124 | struct device; |