aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/irq.h160
-rw-r--r--kernel/irq/autoprobe.c9
-rw-r--r--kernel/irq/handle.c10
-rw-r--r--kernel/irq/internals.h6
-rw-r--r--kernel/irq/manage.c14
-rw-r--r--kernel/irq/resend.c4
-rw-r--r--kernel/irq/spurious.c1
7 files changed, 182 insertions, 22 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 14d7e94048dd..437f2c635db6 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -43,20 +43,36 @@
43#define IRQ_NOPROBE 512 /* IRQ is not valid for probing */ 43#define IRQ_NOPROBE 512 /* IRQ is not valid for probing */
44#define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */ 44#define IRQ_NOREQUEST 1024 /* IRQ cannot be requested */
45#define IRQ_NOAUTOEN 2048 /* IRQ will not be enabled on request irq */ 45#define IRQ_NOAUTOEN 2048 /* IRQ will not be enabled on request irq */
46#define IRQ_DELAYED_DISABLE \
47 4096 /* IRQ disable (masking) happens delayed. */
48
49/*
50 * IRQ types, see also include/linux/interrupt.h
51 */
52#define IRQ_TYPE_NONE 0x0000 /* Default, unspecified type */
53#define IRQ_TYPE_EDGE_RISING 0x0001 /* Edge rising type */
54#define IRQ_TYPE_EDGE_FALLING 0x0002 /* Edge falling type */
55#define IRQ_TYPE_EDGE_BOTH (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
56#define IRQ_TYPE_LEVEL_HIGH 0x0004 /* Level high type */
57#define IRQ_TYPE_LEVEL_LOW 0x0008 /* Level low type */
58#define IRQ_TYPE_SIMPLE 0x0010 /* Simple type */
59#define IRQ_TYPE_PERCPU 0x0020 /* Per CPU type */
60#define IRQ_TYPE_PROBE 0x0040 /* Probing in progress */
61
62struct proc_dir_entry;
63
46/** 64/**
47 * struct hw_interrupt_type - hardware interrupt type descriptor 65 * struct irq_chip - hardware interrupt chip descriptor
48 * 66 *
49 * @name: name for /proc/interrupts 67 * @name: name for /proc/interrupts
50 * @startup: start up the interrupt (defaults to ->enable if NULL) 68 * @startup: start up the interrupt (defaults to ->enable if NULL)
51 * @shutdown: shut down the interrupt (defaults to ->disable if NULL) 69 * @shutdown: shut down the interrupt (defaults to ->disable if NULL)
52 * @enable: enable the interrupt (defaults to chip->unmask if NULL) 70 * @enable: enable the interrupt (defaults to chip->unmask if NULL)
53 * @disable: disable the interrupt (defaults to chip->mask if NULL) 71 * @disable: disable the interrupt (defaults to chip->mask if NULL)
54 * @handle_irq: irq flow handler called from the arch IRQ glue code
55 * @ack: start of a new interrupt 72 * @ack: start of a new interrupt
56 * @mask: mask an interrupt source 73 * @mask: mask an interrupt source
57 * @mask_ack: ack and mask an interrupt source 74 * @mask_ack: ack and mask an interrupt source
58 * @unmask: unmask an interrupt source 75 * @unmask: unmask an interrupt source
59 * @hold: same interrupt while the handler is running
60 * @end: end of interrupt 76 * @end: end of interrupt
61 * @set_affinity: set the CPU affinity on SMP machines 77 * @set_affinity: set the CPU affinity on SMP machines
62 * @retrigger: resend an IRQ to the CPU 78 * @retrigger: resend an IRQ to the CPU
@@ -64,33 +80,45 @@
64 * @set_wake: enable/disable power-management wake-on of an IRQ 80 * @set_wake: enable/disable power-management wake-on of an IRQ
65 * 81 *
66 * @release: release function solely used by UML 82 * @release: release function solely used by UML
83 * @typename: obsoleted by name, kept as migration helper
67 */ 84 */
68struct hw_interrupt_type { 85struct irq_chip {
69 const char *typename; 86 const char *name;
70 unsigned int (*startup)(unsigned int irq); 87 unsigned int (*startup)(unsigned int irq);
71 void (*shutdown)(unsigned int irq); 88 void (*shutdown)(unsigned int irq);
72 void (*enable)(unsigned int irq); 89 void (*enable)(unsigned int irq);
73 void (*disable)(unsigned int irq); 90 void (*disable)(unsigned int irq);
91
74 void (*ack)(unsigned int irq); 92 void (*ack)(unsigned int irq);
93 void (*mask)(unsigned int irq);
94 void (*mask_ack)(unsigned int irq);
95 void (*unmask)(unsigned int irq);
96
75 void (*end)(unsigned int irq); 97 void (*end)(unsigned int irq);
76 void (*set_affinity)(unsigned int irq, cpumask_t dest); 98 void (*set_affinity)(unsigned int irq, cpumask_t dest);
77 int (*retrigger)(unsigned int irq); 99 int (*retrigger)(unsigned int irq);
100 int (*set_type)(unsigned int irq, unsigned int flow_type);
101 int (*set_wake)(unsigned int irq, unsigned int on);
78 102
79 /* Currently used only by UML, might disappear one day.*/ 103 /* Currently used only by UML, might disappear one day.*/
80#ifdef CONFIG_IRQ_RELEASE_METHOD 104#ifdef CONFIG_IRQ_RELEASE_METHOD
81 void (*release)(unsigned int irq, void *dev_id); 105 void (*release)(unsigned int irq, void *dev_id);
82#endif 106#endif
107 /*
108 * For compatibility, ->typename is copied into ->name.
109 * Will disappear.
110 */
111 const char *typename;
83}; 112};
84 113
85typedef struct hw_interrupt_type hw_irq_controller;
86
87struct proc_dir_entry;
88
89/** 114/**
90 * struct irq_desc - interrupt descriptor 115 * struct irq_desc - interrupt descriptor
91 * 116 *
92 * @handler: interrupt type dependent handler functions 117 * @handle_irq: highlevel irq-events handler [if NULL, __do_IRQ()]
93 * @handler_data: data for the type handlers 118 * @chip: low level interrupt hardware access
119 * @handler_data: per-IRQ data for the irq_chip methods
120 * @chip_data: platform-specific per-chip private data for the chip
121 * methods, to allow shared chip implementations
94 * @action: the irq action chain 122 * @action: the irq action chain
95 * @status: status information 123 * @status: status information
96 * @depth: disable-depth, for nested irq_disable() calls 124 * @depth: disable-depth, for nested irq_disable() calls
@@ -98,6 +126,7 @@ struct proc_dir_entry;
98 * @irqs_unhandled: stats field for spurious unhandled interrupts 126 * @irqs_unhandled: stats field for spurious unhandled interrupts
99 * @lock: locking for SMP 127 * @lock: locking for SMP
100 * @affinity: IRQ affinity on SMP 128 * @affinity: IRQ affinity on SMP
129 * @cpu: cpu index useful for balancing
101 * @pending_mask: pending rebalanced interrupts 130 * @pending_mask: pending rebalanced interrupts
102 * @move_irq: need to re-target IRQ destination 131 * @move_irq: need to re-target IRQ destination
103 * @dir: /proc/irq/ procfs entry 132 * @dir: /proc/irq/ procfs entry
@@ -106,16 +135,22 @@ struct proc_dir_entry;
106 * Pad this out to 32 bytes for cache and indexing reasons. 135 * Pad this out to 32 bytes for cache and indexing reasons.
107 */ 136 */
108struct irq_desc { 137struct irq_desc {
109 hw_irq_controller *chip; 138 void fastcall (*handle_irq)(unsigned int irq,
139 struct irq_desc *desc,
140 struct pt_regs *regs);
141 struct irq_chip *chip;
142 void *handler_data;
110 void *chip_data; 143 void *chip_data;
111 struct irqaction *action; /* IRQ action list */ 144 struct irqaction *action; /* IRQ action list */
112 unsigned int status; /* IRQ status */ 145 unsigned int status; /* IRQ status */
146
113 unsigned int depth; /* nested irq disables */ 147 unsigned int depth; /* nested irq disables */
114 unsigned int irq_count; /* For detecting broken IRQs */ 148 unsigned int irq_count; /* For detecting broken IRQs */
115 unsigned int irqs_unhandled; 149 unsigned int irqs_unhandled;
116 spinlock_t lock; 150 spinlock_t lock;
117#ifdef CONFIG_SMP 151#ifdef CONFIG_SMP
118 cpumask_t affinity; 152 cpumask_t affinity;
153 unsigned int cpu;
119#endif 154#endif
120#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE) 155#if defined(CONFIG_GENERIC_PENDING_IRQ) || defined(CONFIG_IRQBALANCE)
121 cpumask_t pending_mask; 156 cpumask_t pending_mask;
@@ -131,6 +166,9 @@ extern struct irq_desc irq_desc[NR_IRQS];
131/* 166/*
132 * Migration helpers for obsolete names, they will go away: 167 * Migration helpers for obsolete names, they will go away:
133 */ 168 */
169#define hw_interrupt_type irq_chip
170typedef struct irq_chip hw_irq_controller;
171#define no_irq_type no_irq_chip
134typedef struct irq_desc irq_desc_t; 172typedef struct irq_desc irq_desc_t;
135 173
136/* 174/*
@@ -138,6 +176,17 @@ typedef struct irq_desc irq_desc_t;
138 */ 176 */
139#include <asm/hw_irq.h> 177#include <asm/hw_irq.h>
140 178
179/*
180 * Architectures call this to let the generic IRQ layer
181 * handle an interrupt:
182 */
183static inline void generic_handle_irq(unsigned int irq, struct pt_regs *regs)
184{
185 struct irq_desc *desc = irq_desc + irq;
186
187 desc->handle_irq(irq, desc, regs);
188}
189
141extern int setup_irq(unsigned int irq, struct irqaction *new); 190extern int setup_irq(unsigned int irq, struct irqaction *new);
142 191
143#ifdef CONFIG_GENERIC_HARDIRQS 192#ifdef CONFIG_GENERIC_HARDIRQS
@@ -236,27 +285,100 @@ static inline int select_smp_affinity(unsigned int irq)
236#endif 285#endif
237 286
238extern int no_irq_affinity; 287extern int no_irq_affinity;
239extern int noirqdebug_setup(char *str);
240 288
241extern irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, 289/* Handle irq action chains: */
242 struct irqaction *action); 290extern int handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
291 struct irqaction *action);
292
293/*
294 * Built-in IRQ handlers for various IRQ types,
295 * callable via desc->chip->handle_irq()
296 */
297extern void fastcall
298handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs);
299extern void fastcall
300handle_fastack_irq(unsigned int irq, struct irq_desc *desc,
301 struct pt_regs *regs);
302extern void fastcall
303handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs);
304extern void fastcall
305handle_simple_irq(unsigned int irq, struct irq_desc *desc,
306 struct pt_regs *regs);
307extern void fastcall
308handle_percpu_irq(unsigned int irq, struct irq_desc *desc,
309 struct pt_regs *regs);
310extern void fastcall
311handle_bad_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs);
312
313/*
314 * Get a descriptive string for the highlevel handler, for
315 * /proc/interrupts output:
316 */
317extern const char *
318handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *,
319 struct pt_regs *));
320
243/* 321/*
244 * Explicit fastcall, because i386 4KSTACKS calls it from assembly: 322 * Monolithic do_IRQ implementation.
323 * (is an explicit fastcall, because i386 4KSTACKS calls it from assembly)
245 */ 324 */
246extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs); 325extern fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs);
247 326
327/* Handling of unhandled and spurious interrupts: */
248extern void note_interrupt(unsigned int irq, struct irq_desc *desc, 328extern void note_interrupt(unsigned int irq, struct irq_desc *desc,
249 int action_ret, struct pt_regs *regs); 329 int action_ret, struct pt_regs *regs);
250extern int can_request_irq(unsigned int irq, unsigned long irqflags);
251 330
252/* Resending of interrupts :*/ 331/* Resending of interrupts :*/
253void check_irq_resend(struct irq_desc *desc, unsigned int irq); 332void check_irq_resend(struct irq_desc *desc, unsigned int irq);
254 333
334/* Initialize /proc/irq/ */
255extern void init_irq_proc(void); 335extern void init_irq_proc(void);
256 336
257#endif /* CONFIG_GENERIC_HARDIRQS */ 337/* Enable/disable irq debugging output: */
338extern int noirqdebug_setup(char *str);
339
340/* Checks whether the interrupt can be requested by request_irq(): */
341extern int can_request_irq(unsigned int irq, unsigned long irqflags);
342
343/* Dummy irq-chip implementation: */
344extern struct irq_chip no_irq_chip;
345
346extern void
347set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
348 void fastcall (*handle)(unsigned int,
349 struct irq_desc *,
350 struct pt_regs *));
351extern void
352__set_irq_handler(unsigned int irq,
353 void fastcall (*handle)(unsigned int, struct irq_desc *,
354 struct pt_regs *),
355 int is_chained);
258 356
259extern hw_irq_controller no_irq_type; /* needed in every arch ? */ 357/*
358 * Set a highlevel flow handler for a given IRQ:
359 */
360static inline void
361set_irq_handler(unsigned int irq,
362 void fastcall (*handle)(unsigned int, struct irq_desc *,
363 struct pt_regs *))
364{
365 __set_irq_handler(irq, handle, 0);
366}
367
368/*
369 * Set a highlevel chained flow handler for a given IRQ.
370 * (a chained handler is automatically enabled and set to
371 * IRQ_NOREQUEST and IRQ_NOPROBE)
372 */
373static inline void
374set_irq_chained_handler(unsigned int irq,
375 void fastcall (*handle)(unsigned int, struct irq_desc *,
376 struct pt_regs *))
377{
378 __set_irq_handler(irq, handle, 1);
379}
380
381#endif /* CONFIG_GENERIC_HARDIRQS */
260 382
261#endif /* !CONFIG_S390 */ 383#endif /* !CONFIG_S390 */
262 384
diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c
index ed98c7d46cf2..cfdb63eb5c94 100644
--- a/kernel/irq/autoprobe.c
+++ b/kernel/irq/autoprobe.c
@@ -40,8 +40,15 @@ unsigned long probe_irq_on(void)
40 desc = irq_desc + i; 40 desc = irq_desc + i;
41 41
42 spin_lock_irq(&desc->lock); 42 spin_lock_irq(&desc->lock);
43 if (!desc->action && !(desc->status & IRQ_NOPROBE)) 43 if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
44 /*
45 * Some chips need to know about probing in
46 * progress:
47 */
48 if (desc->chip->set_type)
49 desc->chip->set_type(i, IRQ_TYPE_PROBE);
44 desc->chip->startup(i); 50 desc->chip->startup(i);
51 }
45 spin_unlock_irq(&desc->lock); 52 spin_unlock_irq(&desc->lock);
46 } 53 }
47 54
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index bddcb8f5fea4..a04b516afa59 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -18,6 +18,16 @@
18 18
19#include "internals.h" 19#include "internals.h"
20 20
21/**
22 * handle_bad_irq - handle spurious and unhandled irqs
23 */
24void fastcall
25handle_bad_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
26{
27 kstat_this_cpu.irqs[irq]++;
28 ack_bad_irq(irq);
29}
30
21/* 31/*
22 * Linux has a controller-independent interrupt architecture. 32 * Linux has a controller-independent interrupt architecture.
23 * Every controller has a 'controller-template', that is used 33 * Every controller has a 'controller-template', that is used
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index 46feba630266..2ba8ae3c8e96 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -4,6 +4,12 @@
4 4
5extern int noirqdebug; 5extern int noirqdebug;
6 6
7/* Set default functions for irq_chip structures: */
8extern void irq_chip_set_defaults(struct irq_chip *chip);
9
10/* Set default handler: */
11extern void compat_irq_chip_set_default_handler(struct irq_desc *desc);
12
7#ifdef CONFIG_PROC_FS 13#ifdef CONFIG_PROC_FS
8extern void register_irq_proc(unsigned int irq); 14extern void register_irq_proc(unsigned int irq);
9extern void register_handler_proc(unsigned int irq, struct irqaction *action); 15extern void register_handler_proc(unsigned int irq, struct irqaction *action);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 1a2e7663096a..b61784ee78b2 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -153,6 +153,17 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
153 return !action; 153 return !action;
154} 154}
155 155
156void compat_irq_chip_set_default_handler(struct irq_desc *desc)
157{
158 /*
159 * If the architecture still has not overriden
160 * the flow handler then zap the default. This
161 * should catch incorrect flow-type setting.
162 */
163 if (desc->handle_irq == &handle_bad_irq)
164 desc->handle_irq = NULL;
165}
166
156/* 167/*
157 * Internal function to register an irqaction - typically used to 168 * Internal function to register an irqaction - typically used to
158 * allocate special interrupts that are part of the architecture. 169 * allocate special interrupts that are part of the architecture.
@@ -217,6 +228,9 @@ int setup_irq(unsigned int irq, struct irqaction *new)
217 desc->status |= IRQ_PER_CPU; 228 desc->status |= IRQ_PER_CPU;
218#endif 229#endif
219 if (!shared) { 230 if (!shared) {
231 irq_chip_set_defaults(desc->chip);
232 compat_irq_chip_set_default_handler(desc);
233
220 desc->status &= ~(IRQ_AUTODETECT | IRQ_WAITING | 234 desc->status &= ~(IRQ_AUTODETECT | IRQ_WAITING |
221 IRQ_INPROGRESS); 235 IRQ_INPROGRESS);
222 236
diff --git a/kernel/irq/resend.c b/kernel/irq/resend.c
index 096b102fb392..872f91ba2ce8 100644
--- a/kernel/irq/resend.c
+++ b/kernel/irq/resend.c
@@ -37,9 +37,9 @@ static void resend_irqs(unsigned long arg)
37 irq = find_first_bit(irqs_resend, NR_IRQS); 37 irq = find_first_bit(irqs_resend, NR_IRQS);
38 clear_bit(irq, irqs_resend); 38 clear_bit(irq, irqs_resend);
39 desc = irq_desc + irq; 39 desc = irq_desc + irq;
40 spin_lock_irqsave(&desc->lock, flags); 40 local_irq_disable();
41 desc->handle_irq(irq, desc, NULL); 41 desc->handle_irq(irq, desc, NULL);
42 spin_unlock_irqrestore(&desc->lock, flags); 42 local_irq_enable();
43 } 43 }
44} 44}
45 45
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 3a0a62123301..ca187b83f897 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -168,6 +168,7 @@ void note_interrupt(unsigned int irq, struct irq_desc *desc,
168 */ 168 */
169 printk(KERN_EMERG "Disabling IRQ #%d\n", irq); 169 printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
170 desc->status |= IRQ_DISABLED; 170 desc->status |= IRQ_DISABLED;
171 desc->depth = 1;
171 desc->chip->disable(irq); 172 desc->chip->disable(irq);
172 } 173 }
173 desc->irqs_unhandled = 0; 174 desc->irqs_unhandled = 0;