aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/irq/Makefile2
-rw-r--r--kernel/irq/autoprobe.c56
-rw-r--r--kernel/irq/chip.c525
-rw-r--r--kernel/irq/handle.c118
-rw-r--r--kernel/irq/internals.h46
-rw-r--r--kernel/irq/manage.c156
-rw-r--r--kernel/irq/migration.c20
-rw-r--r--kernel/irq/proc.c30
-rw-r--r--kernel/irq/resend.c78
-rw-r--r--kernel/irq/spurious.c33
-rw-r--r--kernel/kexec.c6
-rw-r--r--kernel/resource.c52
12 files changed, 937 insertions, 185 deletions
diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile
index 9f77f50d8143..1dab0ac3f797 100644
--- a/kernel/irq/Makefile
+++ b/kernel/irq/Makefile
@@ -1,5 +1,5 @@
1 1
2obj-y := handle.o manage.o spurious.o 2obj-y := handle.o manage.o spurious.o resend.o chip.o
3obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o 3obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o
4obj-$(CONFIG_PROC_FS) += proc.o 4obj-$(CONFIG_PROC_FS) += proc.o
5obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o 5obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o
diff --git a/kernel/irq/autoprobe.c b/kernel/irq/autoprobe.c
index 3467097ca61a..533068cfb607 100644
--- a/kernel/irq/autoprobe.c
+++ b/kernel/irq/autoprobe.c
@@ -11,12 +11,14 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/delay.h> 12#include <linux/delay.h>
13 13
14#include "internals.h"
15
14/* 16/*
15 * Autodetection depends on the fact that any interrupt that 17 * Autodetection depends on the fact that any interrupt that
16 * comes in on to an unassigned handler will get stuck with 18 * comes in on to an unassigned handler will get stuck with
17 * "IRQ_WAITING" cleared and the interrupt disabled. 19 * "IRQ_WAITING" cleared and the interrupt disabled.
18 */ 20 */
19static DECLARE_MUTEX(probe_sem); 21static DEFINE_MUTEX(probing_active);
20 22
21/** 23/**
22 * probe_irq_on - begin an interrupt autodetect 24 * probe_irq_on - begin an interrupt autodetect
@@ -27,11 +29,11 @@ static DECLARE_MUTEX(probe_sem);
27 */ 29 */
28unsigned long probe_irq_on(void) 30unsigned long probe_irq_on(void)
29{ 31{
30 unsigned long val; 32 struct irq_desc *desc;
31 irq_desc_t *desc; 33 unsigned long mask;
32 unsigned int i; 34 unsigned int i;
33 35
34 down(&probe_sem); 36 mutex_lock(&probing_active);
35 /* 37 /*
36 * something may have generated an irq long ago and we want to 38 * something may have generated an irq long ago and we want to
37 * flush such a longstanding irq before considering it as spurious. 39 * flush such a longstanding irq before considering it as spurious.
@@ -40,8 +42,21 @@ unsigned long probe_irq_on(void)
40 desc = irq_desc + i; 42 desc = irq_desc + i;
41 43
42 spin_lock_irq(&desc->lock); 44 spin_lock_irq(&desc->lock);
43 if (!irq_desc[i].action) 45 if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
44 irq_desc[i].handler->startup(i); 46 /*
47 * An old-style architecture might still have
48 * the handle_bad_irq handler there:
49 */
50 compat_irq_chip_set_default_handler(desc);
51
52 /*
53 * Some chips need to know about probing in
54 * progress:
55 */
56 if (desc->chip->set_type)
57 desc->chip->set_type(i, IRQ_TYPE_PROBE);
58 desc->chip->startup(i);
59 }
45 spin_unlock_irq(&desc->lock); 60 spin_unlock_irq(&desc->lock);
46 } 61 }
47 62
@@ -57,9 +72,9 @@ unsigned long probe_irq_on(void)
57 desc = irq_desc + i; 72 desc = irq_desc + i;
58 73
59 spin_lock_irq(&desc->lock); 74 spin_lock_irq(&desc->lock);
60 if (!desc->action) { 75 if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
61 desc->status |= IRQ_AUTODETECT | IRQ_WAITING; 76 desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
62 if (desc->handler->startup(i)) 77 if (desc->chip->startup(i))
63 desc->status |= IRQ_PENDING; 78 desc->status |= IRQ_PENDING;
64 } 79 }
65 spin_unlock_irq(&desc->lock); 80 spin_unlock_irq(&desc->lock);
@@ -73,11 +88,11 @@ unsigned long probe_irq_on(void)
73 /* 88 /*
74 * Now filter out any obviously spurious interrupts 89 * Now filter out any obviously spurious interrupts
75 */ 90 */
76 val = 0; 91 mask = 0;
77 for (i = 0; i < NR_IRQS; i++) { 92 for (i = 0; i < NR_IRQS; i++) {
78 irq_desc_t *desc = irq_desc + i;
79 unsigned int status; 93 unsigned int status;
80 94
95 desc = irq_desc + i;
81 spin_lock_irq(&desc->lock); 96 spin_lock_irq(&desc->lock);
82 status = desc->status; 97 status = desc->status;
83 98
@@ -85,17 +100,16 @@ unsigned long probe_irq_on(void)
85 /* It triggered already - consider it spurious. */ 100 /* It triggered already - consider it spurious. */
86 if (!(status & IRQ_WAITING)) { 101 if (!(status & IRQ_WAITING)) {
87 desc->status = status & ~IRQ_AUTODETECT; 102 desc->status = status & ~IRQ_AUTODETECT;
88 desc->handler->shutdown(i); 103 desc->chip->shutdown(i);
89 } else 104 } else
90 if (i < 32) 105 if (i < 32)
91 val |= 1 << i; 106 mask |= 1 << i;
92 } 107 }
93 spin_unlock_irq(&desc->lock); 108 spin_unlock_irq(&desc->lock);
94 } 109 }
95 110
96 return val; 111 return mask;
97} 112}
98
99EXPORT_SYMBOL(probe_irq_on); 113EXPORT_SYMBOL(probe_irq_on);
100 114
101/** 115/**
@@ -117,7 +131,7 @@ unsigned int probe_irq_mask(unsigned long val)
117 131
118 mask = 0; 132 mask = 0;
119 for (i = 0; i < NR_IRQS; i++) { 133 for (i = 0; i < NR_IRQS; i++) {
120 irq_desc_t *desc = irq_desc + i; 134 struct irq_desc *desc = irq_desc + i;
121 unsigned int status; 135 unsigned int status;
122 136
123 spin_lock_irq(&desc->lock); 137 spin_lock_irq(&desc->lock);
@@ -128,11 +142,11 @@ unsigned int probe_irq_mask(unsigned long val)
128 mask |= 1 << i; 142 mask |= 1 << i;
129 143
130 desc->status = status & ~IRQ_AUTODETECT; 144 desc->status = status & ~IRQ_AUTODETECT;
131 desc->handler->shutdown(i); 145 desc->chip->shutdown(i);
132 } 146 }
133 spin_unlock_irq(&desc->lock); 147 spin_unlock_irq(&desc->lock);
134 } 148 }
135 up(&probe_sem); 149 mutex_unlock(&probing_active);
136 150
137 return mask & val; 151 return mask & val;
138} 152}
@@ -160,7 +174,7 @@ int probe_irq_off(unsigned long val)
160 int i, irq_found = 0, nr_irqs = 0; 174 int i, irq_found = 0, nr_irqs = 0;
161 175
162 for (i = 0; i < NR_IRQS; i++) { 176 for (i = 0; i < NR_IRQS; i++) {
163 irq_desc_t *desc = irq_desc + i; 177 struct irq_desc *desc = irq_desc + i;
164 unsigned int status; 178 unsigned int status;
165 179
166 spin_lock_irq(&desc->lock); 180 spin_lock_irq(&desc->lock);
@@ -173,16 +187,16 @@ int probe_irq_off(unsigned long val)
173 nr_irqs++; 187 nr_irqs++;
174 } 188 }
175 desc->status = status & ~IRQ_AUTODETECT; 189 desc->status = status & ~IRQ_AUTODETECT;
176 desc->handler->shutdown(i); 190 desc->chip->shutdown(i);
177 } 191 }
178 spin_unlock_irq(&desc->lock); 192 spin_unlock_irq(&desc->lock);
179 } 193 }
180 up(&probe_sem); 194 mutex_unlock(&probing_active);
181 195
182 if (nr_irqs > 1) 196 if (nr_irqs > 1)
183 irq_found = -irq_found; 197 irq_found = -irq_found;
198
184 return irq_found; 199 return irq_found;
185} 200}
186
187EXPORT_SYMBOL(probe_irq_off); 201EXPORT_SYMBOL(probe_irq_off);
188 202
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
new file mode 100644
index 000000000000..4a0952d9458b
--- /dev/null
+++ b/kernel/irq/chip.c
@@ -0,0 +1,525 @@
1/*
2 * linux/kernel/irq/chip.c
3 *
4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
6 *
7 * This file contains the core interrupt handling code, for irq-chip
8 * based architectures.
9 *
10 * Detailed information is available in Documentation/DocBook/genericirq
11 */
12
13#include <linux/irq.h>
14#include <linux/module.h>
15#include <linux/interrupt.h>
16#include <linux/kernel_stat.h>
17
18#include "internals.h"
19
20/**
21 * set_irq_chip - set the irq chip for an irq
22 * @irq: irq number
23 * @chip: pointer to irq chip description structure
24 */
25int set_irq_chip(unsigned int irq, struct irq_chip *chip)
26{
27 struct irq_desc *desc;
28 unsigned long flags;
29
30 if (irq >= NR_IRQS) {
31 printk(KERN_ERR "Trying to install chip for IRQ%d\n", irq);
32 WARN_ON(1);
33 return -EINVAL;
34 }
35
36 if (!chip)
37 chip = &no_irq_chip;
38
39 desc = irq_desc + irq;
40 spin_lock_irqsave(&desc->lock, flags);
41 irq_chip_set_defaults(chip);
42 desc->chip = chip;
43 /*
44 * For compatibility only:
45 */
46 desc->chip = chip;
47 spin_unlock_irqrestore(&desc->lock, flags);
48
49 return 0;
50}
51EXPORT_SYMBOL(set_irq_chip);
52
53/**
54 * set_irq_type - set the irq type for an irq
55 * @irq: irq number
56 * @type: interrupt type - see include/linux/interrupt.h
57 */
58int set_irq_type(unsigned int irq, unsigned int type)
59{
60 struct irq_desc *desc;
61 unsigned long flags;
62 int ret = -ENXIO;
63
64 if (irq >= NR_IRQS) {
65 printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
66 return -ENODEV;
67 }
68
69 desc = irq_desc + irq;
70 if (desc->chip->set_type) {
71 spin_lock_irqsave(&desc->lock, flags);
72 ret = desc->chip->set_type(irq, type);
73 spin_unlock_irqrestore(&desc->lock, flags);
74 }
75 return ret;
76}
77EXPORT_SYMBOL(set_irq_type);
78
79/**
80 * set_irq_data - set irq type data for an irq
81 * @irq: Interrupt number
82 * @data: Pointer to interrupt specific data
83 *
84 * Set the hardware irq controller data for an irq
85 */
86int set_irq_data(unsigned int irq, void *data)
87{
88 struct irq_desc *desc;
89 unsigned long flags;
90
91 if (irq >= NR_IRQS) {
92 printk(KERN_ERR
93 "Trying to install controller data for IRQ%d\n", irq);
94 return -EINVAL;
95 }
96
97 desc = irq_desc + irq;
98 spin_lock_irqsave(&desc->lock, flags);
99 desc->handler_data = data;
100 spin_unlock_irqrestore(&desc->lock, flags);
101 return 0;
102}
103EXPORT_SYMBOL(set_irq_data);
104
105/**
106 * set_irq_chip_data - set irq chip data for an irq
107 * @irq: Interrupt number
108 * @data: Pointer to chip specific data
109 *
110 * Set the hardware irq chip data for an irq
111 */
112int set_irq_chip_data(unsigned int irq, void *data)
113{
114 struct irq_desc *desc = irq_desc + irq;
115 unsigned long flags;
116
117 if (irq >= NR_IRQS || !desc->chip) {
118 printk(KERN_ERR "BUG: bad set_irq_chip_data(IRQ#%d)\n", irq);
119 return -EINVAL;
120 }
121
122 spin_lock_irqsave(&desc->lock, flags);
123 desc->chip_data = data;
124 spin_unlock_irqrestore(&desc->lock, flags);
125
126 return 0;
127}
128EXPORT_SYMBOL(set_irq_chip_data);
129
130/*
131 * default enable function
132 */
133static void default_enable(unsigned int irq)
134{
135 struct irq_desc *desc = irq_desc + irq;
136
137 desc->chip->unmask(irq);
138 desc->status &= ~IRQ_MASKED;
139}
140
141/*
142 * default disable function
143 */
144static void default_disable(unsigned int irq)
145{
146 struct irq_desc *desc = irq_desc + irq;
147
148 if (!(desc->status & IRQ_DELAYED_DISABLE))
149 irq_desc[irq].chip->mask(irq);
150}
151
152/*
153 * default startup function
154 */
155static unsigned int default_startup(unsigned int irq)
156{
157 irq_desc[irq].chip->enable(irq);
158
159 return 0;
160}
161
162/*
163 * Fixup enable/disable function pointers
164 */
165void irq_chip_set_defaults(struct irq_chip *chip)
166{
167 if (!chip->enable)
168 chip->enable = default_enable;
169 if (!chip->disable)
170 chip->disable = default_disable;
171 if (!chip->startup)
172 chip->startup = default_startup;
173 if (!chip->shutdown)
174 chip->shutdown = chip->disable;
175 if (!chip->name)
176 chip->name = chip->typename;
177}
178
179static inline void mask_ack_irq(struct irq_desc *desc, int irq)
180{
181 if (desc->chip->mask_ack)
182 desc->chip->mask_ack(irq);
183 else {
184 desc->chip->mask(irq);
185 desc->chip->ack(irq);
186 }
187}
188
189/**
190 * handle_simple_irq - Simple and software-decoded IRQs.
191 * @irq: the interrupt number
192 * @desc: the interrupt description structure for this irq
193 * @regs: pointer to a register structure
194 *
195 * Simple interrupts are either sent from a demultiplexing interrupt
196 * handler or come from hardware, where no interrupt hardware control
197 * is necessary.
198 *
199 * Note: The caller is expected to handle the ack, clear, mask and
200 * unmask issues if necessary.
201 */
202void fastcall
203handle_simple_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
204{
205 struct irqaction *action;
206 irqreturn_t action_ret;
207 const unsigned int cpu = smp_processor_id();
208
209 spin_lock(&desc->lock);
210
211 if (unlikely(desc->status & IRQ_INPROGRESS))
212 goto out_unlock;
213 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
214 kstat_cpu(cpu).irqs[irq]++;
215
216 action = desc->action;
217 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
218 goto out_unlock;
219
220 desc->status |= IRQ_INPROGRESS;
221 spin_unlock(&desc->lock);
222
223 action_ret = handle_IRQ_event(irq, regs, action);
224 if (!noirqdebug)
225 note_interrupt(irq, desc, action_ret, regs);
226
227 spin_lock(&desc->lock);
228 desc->status &= ~IRQ_INPROGRESS;
229out_unlock:
230 spin_unlock(&desc->lock);
231}
232
233/**
234 * handle_level_irq - Level type irq handler
235 * @irq: the interrupt number
236 * @desc: the interrupt description structure for this irq
237 * @regs: pointer to a register structure
238 *
239 * Level type interrupts are active as long as the hardware line has
240 * the active level. This may require to mask the interrupt and unmask
241 * it after the associated handler has acknowledged the device, so the
242 * interrupt line is back to inactive.
243 */
244void fastcall
245handle_level_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
246{
247 unsigned int cpu = smp_processor_id();
248 struct irqaction *action;
249 irqreturn_t action_ret;
250
251 spin_lock(&desc->lock);
252 mask_ack_irq(desc, irq);
253
254 if (unlikely(desc->status & IRQ_INPROGRESS))
255 goto out;
256 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
257 kstat_cpu(cpu).irqs[irq]++;
258
259 /*
260 * If its disabled or no action available
261 * keep it masked and get out of here
262 */
263 action = desc->action;
264 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
265 goto out;
266
267 desc->status |= IRQ_INPROGRESS;
268 spin_unlock(&desc->lock);
269
270 action_ret = handle_IRQ_event(irq, regs, action);
271 if (!noirqdebug)
272 note_interrupt(irq, desc, action_ret, regs);
273
274 spin_lock(&desc->lock);
275 desc->status &= ~IRQ_INPROGRESS;
276out:
277 if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask)
278 desc->chip->unmask(irq);
279 spin_unlock(&desc->lock);
280}
281
282/**
283 * handle_fasteoi_irq - irq handler for transparent controllers
284 * @irq: the interrupt number
285 * @desc: the interrupt description structure for this irq
286 * @regs: pointer to a register structure
287 *
288 * Only a single callback will be issued to the chip: an ->eoi()
289 * call when the interrupt has been serviced. This enables support
290 * for modern forms of interrupt handlers, which handle the flow
291 * details in hardware, transparently.
292 */
293void fastcall
294handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc,
295 struct pt_regs *regs)
296{
297 unsigned int cpu = smp_processor_id();
298 struct irqaction *action;
299 irqreturn_t action_ret;
300
301 spin_lock(&desc->lock);
302
303 if (unlikely(desc->status & IRQ_INPROGRESS))
304 goto out;
305
306 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
307 kstat_cpu(cpu).irqs[irq]++;
308
309 /*
310 * If its disabled or no action available
311 * keep it masked and get out of here
312 */
313 action = desc->action;
314 if (unlikely(!action || (desc->status & IRQ_DISABLED))) {
315 desc->status |= IRQ_PENDING;
316 goto out;
317 }
318
319 desc->status |= IRQ_INPROGRESS;
320 desc->status &= ~IRQ_PENDING;
321 spin_unlock(&desc->lock);
322
323 action_ret = handle_IRQ_event(irq, regs, action);
324 if (!noirqdebug)
325 note_interrupt(irq, desc, action_ret, regs);
326
327 spin_lock(&desc->lock);
328 desc->status &= ~IRQ_INPROGRESS;
329out:
330 desc->chip->eoi(irq);
331
332 spin_unlock(&desc->lock);
333}
334
335/**
336 * handle_edge_irq - edge type IRQ handler
337 * @irq: the interrupt number
338 * @desc: the interrupt description structure for this irq
339 * @regs: pointer to a register structure
340 *
341 * Interrupt occures on the falling and/or rising edge of a hardware
342 * signal. The occurence is latched into the irq controller hardware
343 * and must be acked in order to be reenabled. After the ack another
344 * interrupt can happen on the same source even before the first one
345 * is handled by the assosiacted event handler. If this happens it
346 * might be necessary to disable (mask) the interrupt depending on the
347 * controller hardware. This requires to reenable the interrupt inside
348 * of the loop which handles the interrupts which have arrived while
349 * the handler was running. If all pending interrupts are handled, the
350 * loop is left.
351 */
352void fastcall
353handle_edge_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
354{
355 const unsigned int cpu = smp_processor_id();
356
357 spin_lock(&desc->lock);
358
359 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
360
361 /*
362 * If we're currently running this IRQ, or its disabled,
363 * we shouldn't process the IRQ. Mark it pending, handle
364 * the necessary masking and go out
365 */
366 if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) ||
367 !desc->action)) {
368 desc->status |= (IRQ_PENDING | IRQ_MASKED);
369 mask_ack_irq(desc, irq);
370 goto out_unlock;
371 }
372
373 kstat_cpu(cpu).irqs[irq]++;
374
375 /* Start handling the irq */
376 desc->chip->ack(irq);
377
378 /* Mark the IRQ currently in progress.*/
379 desc->status |= IRQ_INPROGRESS;
380
381 do {
382 struct irqaction *action = desc->action;
383 irqreturn_t action_ret;
384
385 if (unlikely(!action)) {
386 desc->chip->mask(irq);
387 goto out_unlock;
388 }
389
390 /*
391 * When another irq arrived while we were handling
392 * one, we could have masked the irq.
393 * Renable it, if it was not disabled in meantime.
394 */
395 if (unlikely((desc->status &
396 (IRQ_PENDING | IRQ_MASKED | IRQ_DISABLED)) ==
397 (IRQ_PENDING | IRQ_MASKED))) {
398 desc->chip->unmask(irq);
399 desc->status &= ~IRQ_MASKED;
400 }
401
402 desc->status &= ~IRQ_PENDING;
403 spin_unlock(&desc->lock);
404 action_ret = handle_IRQ_event(irq, regs, action);
405 if (!noirqdebug)
406 note_interrupt(irq, desc, action_ret, regs);
407 spin_lock(&desc->lock);
408
409 } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
410
411 desc->status &= ~IRQ_INPROGRESS;
412out_unlock:
413 spin_unlock(&desc->lock);
414}
415
416#ifdef CONFIG_SMP
417/**
418 * handle_percpu_IRQ - Per CPU local irq handler
419 * @irq: the interrupt number
420 * @desc: the interrupt description structure for this irq
421 * @regs: pointer to a register structure
422 *
423 * Per CPU interrupts on SMP machines without locking requirements
424 */
425void fastcall
426handle_percpu_irq(unsigned int irq, struct irq_desc *desc, struct pt_regs *regs)
427{
428 irqreturn_t action_ret;
429
430 kstat_this_cpu.irqs[irq]++;
431
432 if (desc->chip->ack)
433 desc->chip->ack(irq);
434
435 action_ret = handle_IRQ_event(irq, regs, desc->action);
436 if (!noirqdebug)
437 note_interrupt(irq, desc, action_ret, regs);
438
439 if (desc->chip->eoi)
440 desc->chip->eoi(irq);
441}
442
443#endif /* CONFIG_SMP */
444
445void
446__set_irq_handler(unsigned int irq,
447 void fastcall (*handle)(unsigned int, irq_desc_t *,
448 struct pt_regs *),
449 int is_chained)
450{
451 struct irq_desc *desc;
452 unsigned long flags;
453
454 if (irq >= NR_IRQS) {
455 printk(KERN_ERR
456 "Trying to install type control for IRQ%d\n", irq);
457 return;
458 }
459
460 desc = irq_desc + irq;
461
462 if (!handle)
463 handle = handle_bad_irq;
464
465 if (is_chained && desc->chip == &no_irq_chip)
466 printk(KERN_WARNING "Trying to install "
467 "chained interrupt type for IRQ%d\n", irq);
468
469 spin_lock_irqsave(&desc->lock, flags);
470
471 /* Uninstall? */
472 if (handle == handle_bad_irq) {
473 if (desc->chip != &no_irq_chip) {
474 desc->chip->mask(irq);
475 desc->chip->ack(irq);
476 }
477 desc->status |= IRQ_DISABLED;
478 desc->depth = 1;
479 }
480 desc->handle_irq = handle;
481
482 if (handle != handle_bad_irq && is_chained) {
483 desc->status &= ~IRQ_DISABLED;
484 desc->status |= IRQ_NOREQUEST | IRQ_NOPROBE;
485 desc->depth = 0;
486 desc->chip->unmask(irq);
487 }
488 spin_unlock_irqrestore(&desc->lock, flags);
489}
490
491void
492set_irq_chip_and_handler(unsigned int irq, struct irq_chip *chip,
493 void fastcall (*handle)(unsigned int,
494 struct irq_desc *,
495 struct pt_regs *))
496{
497 set_irq_chip(irq, chip);
498 __set_irq_handler(irq, handle, 0);
499}
500
501/*
502 * Get a descriptive string for the highlevel handler, for
503 * /proc/interrupts output:
504 */
505const char *
506handle_irq_name(void fastcall (*handle)(unsigned int, struct irq_desc *,
507 struct pt_regs *))
508{
509 if (handle == handle_level_irq)
510 return "level ";
511 if (handle == handle_fasteoi_irq)
512 return "fasteoi";
513 if (handle == handle_edge_irq)
514 return "edge ";
515 if (handle == handle_simple_irq)
516 return "simple ";
517#ifdef CONFIG_SMP
518 if (handle == handle_percpu_irq)
519 return "percpu ";
520#endif
521 if (handle == handle_bad_irq)
522 return "bad ";
523
524 return NULL;
525}
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index 0f6530117105..5a360dd4331b 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -1,9 +1,13 @@
1/* 1/*
2 * linux/kernel/irq/handle.c 2 * linux/kernel/irq/handle.c
3 * 3 *
4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar 4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
5 * 6 *
6 * This file contains the core interrupt handling code. 7 * This file contains the core interrupt handling code.
8 *
9 * Detailed information is available in Documentation/DocBook/genericirq
10 *
7 */ 11 */
8 12
9#include <linux/irq.h> 13#include <linux/irq.h>
@@ -14,11 +18,22 @@
14 18
15#include "internals.h" 19#include "internals.h"
16 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 print_irq_desc(irq, desc);
28 kstat_this_cpu.irqs[irq]++;
29 ack_bad_irq(irq);
30}
31
17/* 32/*
18 * Linux has a controller-independent interrupt architecture. 33 * Linux has a controller-independent interrupt architecture.
19 * Every controller has a 'controller-template', that is used 34 * Every controller has a 'controller-template', that is used
20 * by the main code to do the right thing. Each driver-visible 35 * by the main code to do the right thing. Each driver-visible
21 * interrupt source is transparently wired to the apropriate 36 * interrupt source is transparently wired to the appropriate
22 * controller. Thus drivers need not be aware of the 37 * controller. Thus drivers need not be aware of the
23 * interrupt-controller. 38 * interrupt-controller.
24 * 39 *
@@ -28,41 +43,52 @@
28 * 43 *
29 * Controller mappings for all interrupt sources: 44 * Controller mappings for all interrupt sources:
30 */ 45 */
31irq_desc_t irq_desc[NR_IRQS] __cacheline_aligned = { 46struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned = {
32 [0 ... NR_IRQS-1] = { 47 [0 ... NR_IRQS-1] = {
33 .status = IRQ_DISABLED, 48 .status = IRQ_DISABLED,
34 .handler = &no_irq_type, 49 .chip = &no_irq_chip,
35 .lock = SPIN_LOCK_UNLOCKED 50 .handle_irq = handle_bad_irq,
51 .depth = 1,
52 .lock = SPIN_LOCK_UNLOCKED,
53#ifdef CONFIG_SMP
54 .affinity = CPU_MASK_ALL
55#endif
36 } 56 }
37}; 57};
38 58
39/* 59/*
40 * Generic 'no controller' code 60 * What should we do if we get a hw irq event on an illegal vector?
61 * Each architecture has to answer this themself.
41 */ 62 */
42static void end_none(unsigned int irq) { } 63static void ack_bad(unsigned int irq)
43static void enable_none(unsigned int irq) { }
44static void disable_none(unsigned int irq) { }
45static void shutdown_none(unsigned int irq) { }
46static unsigned int startup_none(unsigned int irq) { return 0; }
47
48static void ack_none(unsigned int irq)
49{ 64{
50 /* 65 print_irq_desc(irq, irq_desc + irq);
51 * 'what should we do if we get a hw irq event on an illegal vector'.
52 * each architecture has to answer this themself.
53 */
54 ack_bad_irq(irq); 66 ack_bad_irq(irq);
55} 67}
56 68
57struct hw_interrupt_type no_irq_type = { 69/*
58 .typename = "none", 70 * NOP functions
59 .startup = startup_none, 71 */
60 .shutdown = shutdown_none, 72static void noop(unsigned int irq)
61 .enable = enable_none, 73{
62 .disable = disable_none, 74}
63 .ack = ack_none, 75
64 .end = end_none, 76static unsigned int noop_ret(unsigned int irq)
65 .set_affinity = NULL 77{
78 return 0;
79}
80
81/*
82 * Generic no controller implementation
83 */
84struct irq_chip no_irq_chip = {
85 .name = "none",
86 .startup = noop_ret,
87 .shutdown = noop,
88 .enable = noop,
89 .disable = noop,
90 .ack = ack_bad,
91 .end = noop,
66}; 92};
67 93
68/* 94/*
@@ -73,11 +99,16 @@ irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs)
73 return IRQ_NONE; 99 return IRQ_NONE;
74} 100}
75 101
76/* 102/**
77 * Have got an event to handle: 103 * handle_IRQ_event - irq action chain handler
104 * @irq: the interrupt number
105 * @regs: pointer to a register structure
106 * @action: the interrupt action chain for this irq
107 *
108 * Handles the action chain of an irq event
78 */ 109 */
79fastcall irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs, 110irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
80 struct irqaction *action) 111 struct irqaction *action)
81{ 112{
82 irqreturn_t ret, retval = IRQ_NONE; 113 irqreturn_t ret, retval = IRQ_NONE;
83 unsigned int status = 0; 114 unsigned int status = 0;
@@ -100,15 +131,22 @@ fastcall irqreturn_t handle_IRQ_event(unsigned int irq, struct pt_regs *regs,
100 return retval; 131 return retval;
101} 132}
102 133
103/* 134/**
104 * do_IRQ handles all normal device IRQ's (the special 135 * __do_IRQ - original all in one highlevel IRQ handler
136 * @irq: the interrupt number
137 * @regs: pointer to a register structure
138 *
139 * __do_IRQ handles all normal device IRQ's (the special
105 * SMP cross-CPU interrupts have their own specific 140 * SMP cross-CPU interrupts have their own specific
106 * handlers). 141 * handlers).
142 *
143 * This is the original x86 implementation which is used for every
144 * interrupt type.
107 */ 145 */
108fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs) 146fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs)
109{ 147{
110 irq_desc_t *desc = irq_desc + irq; 148 struct irq_desc *desc = irq_desc + irq;
111 struct irqaction * action; 149 struct irqaction *action;
112 unsigned int status; 150 unsigned int status;
113 151
114 kstat_this_cpu.irqs[irq]++; 152 kstat_this_cpu.irqs[irq]++;
@@ -118,16 +156,16 @@ fastcall unsigned int __do_IRQ(unsigned int irq, struct pt_regs *regs)
118 /* 156 /*
119 * No locking required for CPU-local interrupts: 157 * No locking required for CPU-local interrupts:
120 */ 158 */
121 if (desc->handler->ack) 159 if (desc->chip->ack)
122 desc->handler->ack(irq); 160 desc->chip->ack(irq);
123 action_ret = handle_IRQ_event(irq, regs, desc->action); 161 action_ret = handle_IRQ_event(irq, regs, desc->action);
124 desc->handler->end(irq); 162 desc->chip->end(irq);
125 return 1; 163 return 1;
126 } 164 }
127 165
128 spin_lock(&desc->lock); 166 spin_lock(&desc->lock);
129 if (desc->handler->ack) 167 if (desc->chip->ack)
130 desc->handler->ack(irq); 168 desc->chip->ack(irq);
131 /* 169 /*
132 * REPLAY is when Linux resends an IRQ that was dropped earlier 170 * REPLAY is when Linux resends an IRQ that was dropped earlier
133 * WAITING is used by probe to mark irqs that are being tested 171 * WAITING is used by probe to mark irqs that are being tested
@@ -187,7 +225,7 @@ out:
187 * The ->end() handler has to deal with interrupts which got 225 * The ->end() handler has to deal with interrupts which got
188 * disabled while the handler was running. 226 * disabled while the handler was running.
189 */ 227 */
190 desc->handler->end(irq); 228 desc->chip->end(irq);
191 spin_unlock(&desc->lock); 229 spin_unlock(&desc->lock);
192 230
193 return 1; 231 return 1;
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index 46feba630266..08a849a22447 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);
@@ -16,3 +22,43 @@ static inline void unregister_handler_proc(unsigned int irq,
16 struct irqaction *action) { } 22 struct irqaction *action) { }
17#endif 23#endif
18 24
25/*
26 * Debugging printout:
27 */
28
29#include <linux/kallsyms.h>
30
31#define P(f) if (desc->status & f) printk("%14s set\n", #f)
32
33static inline void print_irq_desc(unsigned int irq, struct irq_desc *desc)
34{
35 printk("irq %d, desc: %p, depth: %d, count: %d, unhandled: %d\n",
36 irq, desc, desc->depth, desc->irq_count, desc->irqs_unhandled);
37 printk("->handle_irq(): %p, ", desc->handle_irq);
38 print_symbol("%s\n", (unsigned long)desc->handle_irq);
39 printk("->chip(): %p, ", desc->chip);
40 print_symbol("%s\n", (unsigned long)desc->chip);
41 printk("->action(): %p\n", desc->action);
42 if (desc->action) {
43 printk("->action->handler(): %p, ", desc->action->handler);
44 print_symbol("%s\n", (unsigned long)desc->action->handler);
45 }
46
47 P(IRQ_INPROGRESS);
48 P(IRQ_DISABLED);
49 P(IRQ_PENDING);
50 P(IRQ_REPLAY);
51 P(IRQ_AUTODETECT);
52 P(IRQ_WAITING);
53 P(IRQ_LEVEL);
54 P(IRQ_MASKED);
55#ifdef CONFIG_IRQ_PER_CPU
56 P(IRQ_PER_CPU);
57#endif
58 P(IRQ_NOPROBE);
59 P(IRQ_NOREQUEST);
60 P(IRQ_NOAUTOEN);
61}
62
63#undef P
64
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 1279e3499534..9eb1d518ee1c 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * linux/kernel/irq/manage.c 2 * linux/kernel/irq/manage.c
3 * 3 *
4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar 4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006 Thomas Gleixner
5 * 6 *
6 * This file contains driver APIs to the irq subsystem. 7 * This file contains driver APIs to the irq subsystem.
7 */ 8 */
@@ -16,12 +17,6 @@
16 17
17#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
18 19
19cpumask_t irq_affinity[NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
20
21#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
22cpumask_t __cacheline_aligned pending_irq_cpumask[NR_IRQS];
23#endif
24
25/** 20/**
26 * synchronize_irq - wait for pending IRQ handlers (on other CPUs) 21 * synchronize_irq - wait for pending IRQ handlers (on other CPUs)
27 * @irq: interrupt number to wait for 22 * @irq: interrupt number to wait for
@@ -42,7 +37,6 @@ void synchronize_irq(unsigned int irq)
42 while (desc->status & IRQ_INPROGRESS) 37 while (desc->status & IRQ_INPROGRESS)
43 cpu_relax(); 38 cpu_relax();
44} 39}
45
46EXPORT_SYMBOL(synchronize_irq); 40EXPORT_SYMBOL(synchronize_irq);
47 41
48#endif 42#endif
@@ -60,7 +54,7 @@ EXPORT_SYMBOL(synchronize_irq);
60 */ 54 */
61void disable_irq_nosync(unsigned int irq) 55void disable_irq_nosync(unsigned int irq)
62{ 56{
63 irq_desc_t *desc = irq_desc + irq; 57 struct irq_desc *desc = irq_desc + irq;
64 unsigned long flags; 58 unsigned long flags;
65 59
66 if (irq >= NR_IRQS) 60 if (irq >= NR_IRQS)
@@ -69,11 +63,10 @@ void disable_irq_nosync(unsigned int irq)
69 spin_lock_irqsave(&desc->lock, flags); 63 spin_lock_irqsave(&desc->lock, flags);
70 if (!desc->depth++) { 64 if (!desc->depth++) {
71 desc->status |= IRQ_DISABLED; 65 desc->status |= IRQ_DISABLED;
72 desc->handler->disable(irq); 66 desc->chip->disable(irq);
73 } 67 }
74 spin_unlock_irqrestore(&desc->lock, flags); 68 spin_unlock_irqrestore(&desc->lock, flags);
75} 69}
76
77EXPORT_SYMBOL(disable_irq_nosync); 70EXPORT_SYMBOL(disable_irq_nosync);
78 71
79/** 72/**
@@ -90,7 +83,7 @@ EXPORT_SYMBOL(disable_irq_nosync);
90 */ 83 */
91void disable_irq(unsigned int irq) 84void disable_irq(unsigned int irq)
92{ 85{
93 irq_desc_t *desc = irq_desc + irq; 86 struct irq_desc *desc = irq_desc + irq;
94 87
95 if (irq >= NR_IRQS) 88 if (irq >= NR_IRQS)
96 return; 89 return;
@@ -99,7 +92,6 @@ void disable_irq(unsigned int irq)
99 if (desc->action) 92 if (desc->action)
100 synchronize_irq(irq); 93 synchronize_irq(irq);
101} 94}
102
103EXPORT_SYMBOL(disable_irq); 95EXPORT_SYMBOL(disable_irq);
104 96
105/** 97/**
@@ -114,7 +106,7 @@ EXPORT_SYMBOL(disable_irq);
114 */ 106 */
115void enable_irq(unsigned int irq) 107void enable_irq(unsigned int irq)
116{ 108{
117 irq_desc_t *desc = irq_desc + irq; 109 struct irq_desc *desc = irq_desc + irq;
118 unsigned long flags; 110 unsigned long flags;
119 111
120 if (irq >= NR_IRQS) 112 if (irq >= NR_IRQS)
@@ -123,17 +115,15 @@ void enable_irq(unsigned int irq)
123 spin_lock_irqsave(&desc->lock, flags); 115 spin_lock_irqsave(&desc->lock, flags);
124 switch (desc->depth) { 116 switch (desc->depth) {
125 case 0: 117 case 0:
118 printk(KERN_WARNING "Unablanced enable_irq(%d)\n", irq);
126 WARN_ON(1); 119 WARN_ON(1);
127 break; 120 break;
128 case 1: { 121 case 1: {
129 unsigned int status = desc->status & ~IRQ_DISABLED; 122 unsigned int status = desc->status & ~IRQ_DISABLED;
130 123
131 desc->status = status; 124 /* Prevent probing on this irq: */
132 if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) { 125 desc->status = status | IRQ_NOPROBE;
133 desc->status = status | IRQ_REPLAY; 126 check_irq_resend(desc, irq);
134 hw_resend_irq(desc->handler,irq);
135 }
136 desc->handler->enable(irq);
137 /* fall-through */ 127 /* fall-through */
138 } 128 }
139 default: 129 default:
@@ -141,9 +131,29 @@ void enable_irq(unsigned int irq)
141 } 131 }
142 spin_unlock_irqrestore(&desc->lock, flags); 132 spin_unlock_irqrestore(&desc->lock, flags);
143} 133}
144
145EXPORT_SYMBOL(enable_irq); 134EXPORT_SYMBOL(enable_irq);
146 135
136/**
137 * set_irq_wake - control irq power management wakeup
138 * @irq: interrupt to control
139 * @on: enable/disable power management wakeup
140 *
141 * Enable/disable power management wakeup mode
142 */
143int set_irq_wake(unsigned int irq, unsigned int on)
144{
145 struct irq_desc *desc = irq_desc + irq;
146 unsigned long flags;
147 int ret = -ENXIO;
148
149 spin_lock_irqsave(&desc->lock, flags);
150 if (desc->chip->set_wake)
151 ret = desc->chip->set_wake(irq, on);
152 spin_unlock_irqrestore(&desc->lock, flags);
153 return ret;
154}
155EXPORT_SYMBOL(set_irq_wake);
156
147/* 157/*
148 * Internal function that tells the architecture code whether a 158 * Internal function that tells the architecture code whether a
149 * particular irq has been exclusively allocated or is available 159 * particular irq has been exclusively allocated or is available
@@ -153,7 +163,7 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
153{ 163{
154 struct irqaction *action; 164 struct irqaction *action;
155 165
156 if (irq >= NR_IRQS) 166 if (irq >= NR_IRQS || irq_desc[irq].status & IRQ_NOREQUEST)
157 return 0; 167 return 0;
158 168
159 action = irq_desc[irq].action; 169 action = irq_desc[irq].action;
@@ -164,11 +174,22 @@ int can_request_irq(unsigned int irq, unsigned long irqflags)
164 return !action; 174 return !action;
165} 175}
166 176
177void compat_irq_chip_set_default_handler(struct irq_desc *desc)
178{
179 /*
180 * If the architecture still has not overriden
181 * the flow handler then zap the default. This
182 * should catch incorrect flow-type setting.
183 */
184 if (desc->handle_irq == &handle_bad_irq)
185 desc->handle_irq = NULL;
186}
187
167/* 188/*
168 * Internal function to register an irqaction - typically used to 189 * Internal function to register an irqaction - typically used to
169 * allocate special interrupts that are part of the architecture. 190 * allocate special interrupts that are part of the architecture.
170 */ 191 */
171int setup_irq(unsigned int irq, struct irqaction * new) 192int setup_irq(unsigned int irq, struct irqaction *new)
172{ 193{
173 struct irq_desc *desc = irq_desc + irq; 194 struct irq_desc *desc = irq_desc + irq;
174 struct irqaction *old, **p; 195 struct irqaction *old, **p;
@@ -178,7 +199,7 @@ int setup_irq(unsigned int irq, struct irqaction * new)
178 if (irq >= NR_IRQS) 199 if (irq >= NR_IRQS)
179 return -EINVAL; 200 return -EINVAL;
180 201
181 if (desc->handler == &no_irq_type) 202 if (desc->chip == &no_irq_chip)
182 return -ENOSYS; 203 return -ENOSYS;
183 /* 204 /*
184 * Some drivers like serial.c use request_irq() heavily, 205 * Some drivers like serial.c use request_irq() heavily,
@@ -200,14 +221,21 @@ int setup_irq(unsigned int irq, struct irqaction * new)
200 /* 221 /*
201 * The following block of code has to be executed atomically 222 * The following block of code has to be executed atomically
202 */ 223 */
203 spin_lock_irqsave(&desc->lock,flags); 224 spin_lock_irqsave(&desc->lock, flags);
204 p = &desc->action; 225 p = &desc->action;
205 if ((old = *p) != NULL) { 226 old = *p;
206 /* Can't share interrupts unless both agree to */ 227 if (old) {
207 if (!(old->flags & new->flags & SA_SHIRQ)) 228 /*
229 * Can't share interrupts unless both agree to and are
230 * the same type (level, edge, polarity). So both flag
231 * fields must have SA_SHIRQ set and the bits which
232 * set the trigger type must match.
233 */
234 if (!((old->flags & new->flags) & SA_SHIRQ) ||
235 ((old->flags ^ new->flags) & SA_TRIGGER_MASK))
208 goto mismatch; 236 goto mismatch;
209 237
210#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ) 238#if defined(CONFIG_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
211 /* All handlers must agree on per-cpuness */ 239 /* All handlers must agree on per-cpuness */
212 if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU)) 240 if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU))
213 goto mismatch; 241 goto mismatch;
@@ -222,20 +250,44 @@ int setup_irq(unsigned int irq, struct irqaction * new)
222 } 250 }
223 251
224 *p = new; 252 *p = new;
225#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ) 253#if defined(CONFIG_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
226 if (new->flags & SA_PERCPU_IRQ) 254 if (new->flags & SA_PERCPU_IRQ)
227 desc->status |= IRQ_PER_CPU; 255 desc->status |= IRQ_PER_CPU;
228#endif 256#endif
229 if (!shared) { 257 if (!shared) {
230 desc->depth = 0; 258 irq_chip_set_defaults(desc->chip);
231 desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | 259
232 IRQ_WAITING | IRQ_INPROGRESS); 260 /* Setup the type (level, edge polarity) if configured: */
233 if (desc->handler->startup) 261 if (new->flags & SA_TRIGGER_MASK) {
234 desc->handler->startup(irq); 262 if (desc->chip && desc->chip->set_type)
235 else 263 desc->chip->set_type(irq,
236 desc->handler->enable(irq); 264 new->flags & SA_TRIGGER_MASK);
265 else
266 /*
267 * SA_TRIGGER_* but the PIC does not support
268 * multiple flow-types?
269 */
270 printk(KERN_WARNING "setup_irq(%d) SA_TRIGGER"
271 "set. No set_type function available\n",
272 irq);
273 } else
274 compat_irq_chip_set_default_handler(desc);
275
276 desc->status &= ~(IRQ_AUTODETECT | IRQ_WAITING |
277 IRQ_INPROGRESS);
278
279 if (!(desc->status & IRQ_NOAUTOEN)) {
280 desc->depth = 0;
281 desc->status &= ~IRQ_DISABLED;
282 if (desc->chip->startup)
283 desc->chip->startup(irq);
284 else
285 desc->chip->enable(irq);
286 } else
287 /* Undo nested disables: */
288 desc->depth = 1;
237 } 289 }
238 spin_unlock_irqrestore(&desc->lock,flags); 290 spin_unlock_irqrestore(&desc->lock, flags);
239 291
240 new->irq = irq; 292 new->irq = irq;
241 register_irq_proc(irq); 293 register_irq_proc(irq);
@@ -278,10 +330,10 @@ void free_irq(unsigned int irq, void *dev_id)
278 return; 330 return;
279 331
280 desc = irq_desc + irq; 332 desc = irq_desc + irq;
281 spin_lock_irqsave(&desc->lock,flags); 333 spin_lock_irqsave(&desc->lock, flags);
282 p = &desc->action; 334 p = &desc->action;
283 for (;;) { 335 for (;;) {
284 struct irqaction * action = *p; 336 struct irqaction *action = *p;
285 337
286 if (action) { 338 if (action) {
287 struct irqaction **pp = p; 339 struct irqaction **pp = p;
@@ -295,18 +347,18 @@ void free_irq(unsigned int irq, void *dev_id)
295 347
296 /* Currently used only by UML, might disappear one day.*/ 348 /* Currently used only by UML, might disappear one day.*/
297#ifdef CONFIG_IRQ_RELEASE_METHOD 349#ifdef CONFIG_IRQ_RELEASE_METHOD
298 if (desc->handler->release) 350 if (desc->chip->release)
299 desc->handler->release(irq, dev_id); 351 desc->chip->release(irq, dev_id);
300#endif 352#endif
301 353
302 if (!desc->action) { 354 if (!desc->action) {
303 desc->status |= IRQ_DISABLED; 355 desc->status |= IRQ_DISABLED;
304 if (desc->handler->shutdown) 356 if (desc->chip->shutdown)
305 desc->handler->shutdown(irq); 357 desc->chip->shutdown(irq);
306 else 358 else
307 desc->handler->disable(irq); 359 desc->chip->disable(irq);
308 } 360 }
309 spin_unlock_irqrestore(&desc->lock,flags); 361 spin_unlock_irqrestore(&desc->lock, flags);
310 unregister_handler_proc(irq, action); 362 unregister_handler_proc(irq, action);
311 363
312 /* Make sure it's not being used on another CPU */ 364 /* Make sure it's not being used on another CPU */
@@ -314,12 +366,11 @@ void free_irq(unsigned int irq, void *dev_id)
314 kfree(action); 366 kfree(action);
315 return; 367 return;
316 } 368 }
317 printk(KERN_ERR "Trying to free free IRQ%d\n",irq); 369 printk(KERN_ERR "Trying to free free IRQ%d\n", irq);
318 spin_unlock_irqrestore(&desc->lock,flags); 370 spin_unlock_irqrestore(&desc->lock, flags);
319 return; 371 return;
320 } 372 }
321} 373}
322
323EXPORT_SYMBOL(free_irq); 374EXPORT_SYMBOL(free_irq);
324 375
325/** 376/**
@@ -353,9 +404,9 @@ EXPORT_SYMBOL(free_irq);
353 */ 404 */
354int request_irq(unsigned int irq, 405int request_irq(unsigned int irq,
355 irqreturn_t (*handler)(int, void *, struct pt_regs *), 406 irqreturn_t (*handler)(int, void *, struct pt_regs *),
356 unsigned long irqflags, const char * devname, void *dev_id) 407 unsigned long irqflags, const char *devname, void *dev_id)
357{ 408{
358 struct irqaction * action; 409 struct irqaction *action;
359 int retval; 410 int retval;
360 411
361 /* 412 /*
@@ -368,6 +419,8 @@ int request_irq(unsigned int irq,
368 return -EINVAL; 419 return -EINVAL;
369 if (irq >= NR_IRQS) 420 if (irq >= NR_IRQS)
370 return -EINVAL; 421 return -EINVAL;
422 if (irq_desc[irq].status & IRQ_NOREQUEST)
423 return -EINVAL;
371 if (!handler) 424 if (!handler)
372 return -EINVAL; 425 return -EINVAL;
373 426
@@ -390,6 +443,5 @@ int request_irq(unsigned int irq,
390 443
391 return retval; 444 return retval;
392} 445}
393
394EXPORT_SYMBOL(request_irq); 446EXPORT_SYMBOL(request_irq);
395 447
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
index a12d00eb5e7c..a57ebe9fa6f6 100644
--- a/kernel/irq/migration.c
+++ b/kernel/irq/migration.c
@@ -3,19 +3,19 @@
3 3
4void set_pending_irq(unsigned int irq, cpumask_t mask) 4void set_pending_irq(unsigned int irq, cpumask_t mask)
5{ 5{
6 irq_desc_t *desc = irq_desc + irq; 6 struct irq_desc *desc = irq_desc + irq;
7 unsigned long flags; 7 unsigned long flags;
8 8
9 spin_lock_irqsave(&desc->lock, flags); 9 spin_lock_irqsave(&desc->lock, flags);
10 desc->move_irq = 1; 10 desc->move_irq = 1;
11 pending_irq_cpumask[irq] = mask; 11 irq_desc[irq].pending_mask = mask;
12 spin_unlock_irqrestore(&desc->lock, flags); 12 spin_unlock_irqrestore(&desc->lock, flags);
13} 13}
14 14
15void move_native_irq(int irq) 15void move_native_irq(int irq)
16{ 16{
17 struct irq_desc *desc = irq_desc + irq;
17 cpumask_t tmp; 18 cpumask_t tmp;
18 irq_desc_t *desc = irq_descp(irq);
19 19
20 if (likely(!desc->move_irq)) 20 if (likely(!desc->move_irq))
21 return; 21 return;
@@ -30,15 +30,15 @@ void move_native_irq(int irq)
30 30
31 desc->move_irq = 0; 31 desc->move_irq = 0;
32 32
33 if (unlikely(cpus_empty(pending_irq_cpumask[irq]))) 33 if (unlikely(cpus_empty(irq_desc[irq].pending_mask)))
34 return; 34 return;
35 35
36 if (!desc->handler->set_affinity) 36 if (!desc->chip->set_affinity)
37 return; 37 return;
38 38
39 assert_spin_locked(&desc->lock); 39 assert_spin_locked(&desc->lock);
40 40
41 cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map); 41 cpus_and(tmp, irq_desc[irq].pending_mask, cpu_online_map);
42 42
43 /* 43 /*
44 * If there was a valid mask to work with, please 44 * If there was a valid mask to work with, please
@@ -51,12 +51,12 @@ void move_native_irq(int irq)
51 */ 51 */
52 if (likely(!cpus_empty(tmp))) { 52 if (likely(!cpus_empty(tmp))) {
53 if (likely(!(desc->status & IRQ_DISABLED))) 53 if (likely(!(desc->status & IRQ_DISABLED)))
54 desc->handler->disable(irq); 54 desc->chip->disable(irq);
55 55
56 desc->handler->set_affinity(irq,tmp); 56 desc->chip->set_affinity(irq,tmp);
57 57
58 if (likely(!(desc->status & IRQ_DISABLED))) 58 if (likely(!(desc->status & IRQ_DISABLED)))
59 desc->handler->enable(irq); 59 desc->chip->enable(irq);
60 } 60 }
61 cpus_clear(pending_irq_cpumask[irq]); 61 cpus_clear(irq_desc[irq].pending_mask);
62} 62}
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index afacd6f585fa..607c7809ad01 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -12,15 +12,10 @@
12 12
13#include "internals.h" 13#include "internals.h"
14 14
15static struct proc_dir_entry *root_irq_dir, *irq_dir[NR_IRQS]; 15static struct proc_dir_entry *root_irq_dir;
16 16
17#ifdef CONFIG_SMP 17#ifdef CONFIG_SMP
18 18
19/*
20 * The /proc/irq/<irq>/smp_affinity values:
21 */
22static struct proc_dir_entry *smp_affinity_entry[NR_IRQS];
23
24#ifdef CONFIG_GENERIC_PENDING_IRQ 19#ifdef CONFIG_GENERIC_PENDING_IRQ
25void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) 20void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
26{ 21{
@@ -36,15 +31,15 @@ void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
36void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val) 31void proc_set_irq_affinity(unsigned int irq, cpumask_t mask_val)
37{ 32{
38 set_balance_irq_affinity(irq, mask_val); 33 set_balance_irq_affinity(irq, mask_val);
39 irq_affinity[irq] = mask_val; 34 irq_desc[irq].affinity = mask_val;
40 irq_desc[irq].handler->set_affinity(irq, mask_val); 35 irq_desc[irq].chip->set_affinity(irq, mask_val);
41} 36}
42#endif 37#endif
43 38
44static int irq_affinity_read_proc(char *page, char **start, off_t off, 39static int irq_affinity_read_proc(char *page, char **start, off_t off,
45 int count, int *eof, void *data) 40 int count, int *eof, void *data)
46{ 41{
47 int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]); 42 int len = cpumask_scnprintf(page, count, irq_desc[(long)data].affinity);
48 43
49 if (count - len < 2) 44 if (count - len < 2)
50 return -EINVAL; 45 return -EINVAL;
@@ -59,7 +54,7 @@ static int irq_affinity_write_proc(struct file *file, const char __user *buffer,
59 unsigned int irq = (int)(long)data, full_count = count, err; 54 unsigned int irq = (int)(long)data, full_count = count, err;
60 cpumask_t new_value, tmp; 55 cpumask_t new_value, tmp;
61 56
62 if (!irq_desc[irq].handler->set_affinity || no_irq_affinity) 57 if (!irq_desc[irq].chip->set_affinity || no_irq_affinity)
63 return -EIO; 58 return -EIO;
64 59
65 err = cpumask_parse(buffer, count, new_value); 60 err = cpumask_parse(buffer, count, new_value);
@@ -102,7 +97,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
102{ 97{
103 char name [MAX_NAMELEN]; 98 char name [MAX_NAMELEN];
104 99
105 if (!irq_dir[irq] || action->dir || !action->name || 100 if (!irq_desc[irq].dir || action->dir || !action->name ||
106 !name_unique(irq, action)) 101 !name_unique(irq, action))
107 return; 102 return;
108 103
@@ -110,7 +105,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
110 snprintf(name, MAX_NAMELEN, "%s", action->name); 105 snprintf(name, MAX_NAMELEN, "%s", action->name);
111 106
112 /* create /proc/irq/1234/handler/ */ 107 /* create /proc/irq/1234/handler/ */
113 action->dir = proc_mkdir(name, irq_dir[irq]); 108 action->dir = proc_mkdir(name, irq_desc[irq].dir);
114} 109}
115 110
116#undef MAX_NAMELEN 111#undef MAX_NAMELEN
@@ -122,22 +117,22 @@ void register_irq_proc(unsigned int irq)
122 char name [MAX_NAMELEN]; 117 char name [MAX_NAMELEN];
123 118
124 if (!root_irq_dir || 119 if (!root_irq_dir ||
125 (irq_desc[irq].handler == &no_irq_type) || 120 (irq_desc[irq].chip == &no_irq_chip) ||
126 irq_dir[irq]) 121 irq_desc[irq].dir)
127 return; 122 return;
128 123
129 memset(name, 0, MAX_NAMELEN); 124 memset(name, 0, MAX_NAMELEN);
130 sprintf(name, "%d", irq); 125 sprintf(name, "%d", irq);
131 126
132 /* create /proc/irq/1234 */ 127 /* create /proc/irq/1234 */
133 irq_dir[irq] = proc_mkdir(name, root_irq_dir); 128 irq_desc[irq].dir = proc_mkdir(name, root_irq_dir);
134 129
135#ifdef CONFIG_SMP 130#ifdef CONFIG_SMP
136 { 131 {
137 struct proc_dir_entry *entry; 132 struct proc_dir_entry *entry;
138 133
139 /* create /proc/irq/<irq>/smp_affinity */ 134 /* create /proc/irq/<irq>/smp_affinity */
140 entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]); 135 entry = create_proc_entry("smp_affinity", 0600, irq_desc[irq].dir);
141 136
142 if (entry) { 137 if (entry) {
143 entry->nlink = 1; 138 entry->nlink = 1;
@@ -145,7 +140,6 @@ void register_irq_proc(unsigned int irq)
145 entry->read_proc = irq_affinity_read_proc; 140 entry->read_proc = irq_affinity_read_proc;
146 entry->write_proc = irq_affinity_write_proc; 141 entry->write_proc = irq_affinity_write_proc;
147 } 142 }
148 smp_affinity_entry[irq] = entry;
149 } 143 }
150#endif 144#endif
151} 145}
@@ -155,7 +149,7 @@ void register_irq_proc(unsigned int irq)
155void unregister_handler_proc(unsigned int irq, struct irqaction *action) 149void unregister_handler_proc(unsigned int irq, struct irqaction *action)
156{ 150{
157 if (action->dir) 151 if (action->dir)
158 remove_proc_entry(action->dir->name, irq_dir[irq]); 152 remove_proc_entry(action->dir->name, irq_desc[irq].dir);
159} 153}
160 154
161void init_irq_proc(void) 155void init_irq_proc(void)
diff --git a/kernel/irq/resend.c b/kernel/irq/resend.c
new file mode 100644
index 000000000000..872f91ba2ce8
--- /dev/null
+++ b/kernel/irq/resend.c
@@ -0,0 +1,78 @@
1/*
2 * linux/kernel/irq/resend.c
3 *
4 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner
6 *
7 * This file contains the IRQ-resend code
8 *
9 * If the interrupt is waiting to be processed, we try to re-run it.
10 * We can't directly run it from here since the caller might be in an
11 * interrupt-protected region. Not all irq controller chips can
12 * retrigger interrupts at the hardware level, so in those cases
13 * we allow the resending of IRQs via a tasklet.
14 */
15
16#include <linux/irq.h>
17#include <linux/module.h>
18#include <linux/random.h>
19#include <linux/interrupt.h>
20
21#include "internals.h"
22
23#ifdef CONFIG_HARDIRQS_SW_RESEND
24
25/* Bitmap to handle software resend of interrupts: */
26static DECLARE_BITMAP(irqs_resend, NR_IRQS);
27
28/*
29 * Run software resends of IRQ's
30 */
31static void resend_irqs(unsigned long arg)
32{
33 struct irq_desc *desc;
34 int irq;
35
36 while (!bitmap_empty(irqs_resend, NR_IRQS)) {
37 irq = find_first_bit(irqs_resend, NR_IRQS);
38 clear_bit(irq, irqs_resend);
39 desc = irq_desc + irq;
40 local_irq_disable();
41 desc->handle_irq(irq, desc, NULL);
42 local_irq_enable();
43 }
44}
45
46/* Tasklet to handle resend: */
47static DECLARE_TASKLET(resend_tasklet, resend_irqs, 0);
48
49#endif
50
51/*
52 * IRQ resend
53 *
54 * Is called with interrupts disabled and desc->lock held.
55 */
56void check_irq_resend(struct irq_desc *desc, unsigned int irq)
57{
58 unsigned int status = desc->status;
59
60 /*
61 * Make sure the interrupt is enabled, before resending it:
62 */
63 desc->chip->enable(irq);
64
65 if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
66 desc->status &= ~IRQ_PENDING;
67 desc->status = status | IRQ_REPLAY;
68
69 if (!desc->chip || !desc->chip->retrigger ||
70 !desc->chip->retrigger(irq)) {
71#ifdef CONFIG_HARDIRQS_SW_RESEND
72 /* Set it pending and activate the softirq: */
73 set_bit(irq, irqs_resend);
74 tasklet_schedule(&resend_tasklet);
75#endif
76 }
77 }
78}
diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index b2fb3c18d06b..b483deed311c 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -16,22 +16,20 @@ static int irqfixup __read_mostly;
16/* 16/*
17 * Recovery handler for misrouted interrupts. 17 * Recovery handler for misrouted interrupts.
18 */ 18 */
19
20static int misrouted_irq(int irq, struct pt_regs *regs) 19static int misrouted_irq(int irq, struct pt_regs *regs)
21{ 20{
22 int i; 21 int i;
23 irq_desc_t *desc;
24 int ok = 0; 22 int ok = 0;
25 int work = 0; /* Did we do work for a real IRQ */ 23 int work = 0; /* Did we do work for a real IRQ */
26 24
27 for(i = 1; i < NR_IRQS; i++) { 25 for (i = 1; i < NR_IRQS; i++) {
26 struct irq_desc *desc = irq_desc + i;
28 struct irqaction *action; 27 struct irqaction *action;
29 28
30 if (i == irq) /* Already tried */ 29 if (i == irq) /* Already tried */
31 continue; 30 continue;
32 desc = &irq_desc[i]; 31
33 spin_lock(&desc->lock); 32 spin_lock(&desc->lock);
34 action = desc->action;
35 /* Already running on another processor */ 33 /* Already running on another processor */
36 if (desc->status & IRQ_INPROGRESS) { 34 if (desc->status & IRQ_INPROGRESS) {
37 /* 35 /*
@@ -45,7 +43,9 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
45 } 43 }
46 /* Honour the normal IRQ locking */ 44 /* Honour the normal IRQ locking */
47 desc->status |= IRQ_INPROGRESS; 45 desc->status |= IRQ_INPROGRESS;
46 action = desc->action;
48 spin_unlock(&desc->lock); 47 spin_unlock(&desc->lock);
48
49 while (action) { 49 while (action) {
50 /* Only shared IRQ handlers are safe to call */ 50 /* Only shared IRQ handlers are safe to call */
51 if (action->flags & SA_SHIRQ) { 51 if (action->flags & SA_SHIRQ) {
@@ -62,9 +62,8 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
62 62
63 /* 63 /*
64 * While we were looking for a fixup someone queued a real 64 * While we were looking for a fixup someone queued a real
65 * IRQ clashing with our walk 65 * IRQ clashing with our walk:
66 */ 66 */
67
68 while ((desc->status & IRQ_PENDING) && action) { 67 while ((desc->status & IRQ_PENDING) && action) {
69 /* 68 /*
70 * Perform real IRQ processing for the IRQ we deferred 69 * Perform real IRQ processing for the IRQ we deferred
@@ -80,8 +79,8 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
80 * If we did actual work for the real IRQ line we must let the 79 * If we did actual work for the real IRQ line we must let the
81 * IRQ controller clean up too 80 * IRQ controller clean up too
82 */ 81 */
83 if(work) 82 if (work && desc->chip && desc->chip->end)
84 desc->handler->end(i); 83 desc->chip->end(i);
85 spin_unlock(&desc->lock); 84 spin_unlock(&desc->lock);
86 } 85 }
87 /* So the caller can adjust the irq error counts */ 86 /* So the caller can adjust the irq error counts */
@@ -100,7 +99,8 @@ static int misrouted_irq(int irq, struct pt_regs *regs)
100 */ 99 */
101 100
102static void 101static void
103__report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) 102__report_bad_irq(unsigned int irq, struct irq_desc *desc,
103 irqreturn_t action_ret)
104{ 104{
105 struct irqaction *action; 105 struct irqaction *action;
106 106
@@ -113,6 +113,7 @@ __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
113 } 113 }
114 dump_stack(); 114 dump_stack();
115 printk(KERN_ERR "handlers:\n"); 115 printk(KERN_ERR "handlers:\n");
116
116 action = desc->action; 117 action = desc->action;
117 while (action) { 118 while (action) {
118 printk(KERN_ERR "[<%p>]", action->handler); 119 printk(KERN_ERR "[<%p>]", action->handler);
@@ -123,7 +124,8 @@ __report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret)
123 } 124 }
124} 125}
125 126
126static void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret) 127static void
128report_bad_irq(unsigned int irq, struct irq_desc *desc, irqreturn_t action_ret)
127{ 129{
128 static int count = 100; 130 static int count = 100;
129 131
@@ -133,8 +135,8 @@ static void report_bad_irq(unsigned int irq, irq_desc_t *desc, irqreturn_t actio
133 } 135 }
134} 136}
135 137
136void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret, 138void note_interrupt(unsigned int irq, struct irq_desc *desc,
137 struct pt_regs *regs) 139 irqreturn_t action_ret, struct pt_regs *regs)
138{ 140{
139 if (unlikely(action_ret != IRQ_HANDLED)) { 141 if (unlikely(action_ret != IRQ_HANDLED)) {
140 desc->irqs_unhandled++; 142 desc->irqs_unhandled++;
@@ -166,7 +168,8 @@ void note_interrupt(unsigned int irq, irq_desc_t *desc, irqreturn_t action_ret,
166 */ 168 */
167 printk(KERN_EMERG "Disabling IRQ #%d\n", irq); 169 printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
168 desc->status |= IRQ_DISABLED; 170 desc->status |= IRQ_DISABLED;
169 desc->handler->disable(irq); 171 desc->depth = 1;
172 desc->chip->disable(irq);
170 } 173 }
171 desc->irqs_unhandled = 0; 174 desc->irqs_unhandled = 0;
172} 175}
@@ -177,6 +180,7 @@ int __init noirqdebug_setup(char *str)
177{ 180{
178 noirqdebug = 1; 181 noirqdebug = 1;
179 printk(KERN_INFO "IRQ lockup detection disabled\n"); 182 printk(KERN_INFO "IRQ lockup detection disabled\n");
183
180 return 1; 184 return 1;
181} 185}
182 186
@@ -187,6 +191,7 @@ static int __init irqfixup_setup(char *str)
187 irqfixup = 1; 191 irqfixup = 1;
188 printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n"); 192 printk(KERN_WARNING "Misrouted IRQ fixup support enabled.\n");
189 printk(KERN_WARNING "This may impact system performance.\n"); 193 printk(KERN_WARNING "This may impact system performance.\n");
194
190 return 1; 195 return 1;
191} 196}
192 197
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 58f0f382597c..50087ecf337e 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -1042,7 +1042,6 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
1042 1042
1043void crash_kexec(struct pt_regs *regs) 1043void crash_kexec(struct pt_regs *regs)
1044{ 1044{
1045 struct kimage *image;
1046 int locked; 1045 int locked;
1047 1046
1048 1047
@@ -1056,12 +1055,11 @@ void crash_kexec(struct pt_regs *regs)
1056 */ 1055 */
1057 locked = xchg(&kexec_lock, 1); 1056 locked = xchg(&kexec_lock, 1);
1058 if (!locked) { 1057 if (!locked) {
1059 image = xchg(&kexec_crash_image, NULL); 1058 if (kexec_crash_image) {
1060 if (image) {
1061 struct pt_regs fixed_regs; 1059 struct pt_regs fixed_regs;
1062 crash_setup_regs(&fixed_regs, regs); 1060 crash_setup_regs(&fixed_regs, regs);
1063 machine_crash_shutdown(&fixed_regs); 1061 machine_crash_shutdown(&fixed_regs);
1064 machine_kexec(image); 1062 machine_kexec(kexec_crash_image);
1065 } 1063 }
1066 xchg(&kexec_lock, 0); 1064 xchg(&kexec_lock, 0);
1067 } 1065 }
diff --git a/kernel/resource.c b/kernel/resource.c
index 2404f9b0bc47..bf1130d81b7f 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -23,20 +23,18 @@
23 23
24struct resource ioport_resource = { 24struct resource ioport_resource = {
25 .name = "PCI IO", 25 .name = "PCI IO",
26 .start = 0x0000, 26 .start = 0,
27 .end = IO_SPACE_LIMIT, 27 .end = IO_SPACE_LIMIT,
28 .flags = IORESOURCE_IO, 28 .flags = IORESOURCE_IO,
29}; 29};
30
31EXPORT_SYMBOL(ioport_resource); 30EXPORT_SYMBOL(ioport_resource);
32 31
33struct resource iomem_resource = { 32struct resource iomem_resource = {
34 .name = "PCI mem", 33 .name = "PCI mem",
35 .start = 0UL, 34 .start = 0,
36 .end = ~0UL, 35 .end = -1,
37 .flags = IORESOURCE_MEM, 36 .flags = IORESOURCE_MEM,
38}; 37};
39
40EXPORT_SYMBOL(iomem_resource); 38EXPORT_SYMBOL(iomem_resource);
41 39
42static DEFINE_RWLOCK(resource_lock); 40static DEFINE_RWLOCK(resource_lock);
@@ -83,10 +81,10 @@ static int r_show(struct seq_file *m, void *v)
83 for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent) 81 for (depth = 0, p = r; depth < MAX_IORES_LEVEL; depth++, p = p->parent)
84 if (p->parent == root) 82 if (p->parent == root)
85 break; 83 break;
86 seq_printf(m, "%*s%0*lx-%0*lx : %s\n", 84 seq_printf(m, "%*s%0*llx-%0*llx : %s\n",
87 depth * 2, "", 85 depth * 2, "",
88 width, r->start, 86 width, (unsigned long long) r->start,
89 width, r->end, 87 width, (unsigned long long) r->end,
90 r->name ? r->name : "<BAD>"); 88 r->name ? r->name : "<BAD>");
91 return 0; 89 return 0;
92} 90}
@@ -151,8 +149,8 @@ __initcall(ioresources_init);
151/* Return the conflict entry if you can't request it */ 149/* Return the conflict entry if you can't request it */
152static struct resource * __request_resource(struct resource *root, struct resource *new) 150static struct resource * __request_resource(struct resource *root, struct resource *new)
153{ 151{
154 unsigned long start = new->start; 152 resource_size_t start = new->start;
155 unsigned long end = new->end; 153 resource_size_t end = new->end;
156 struct resource *tmp, **p; 154 struct resource *tmp, **p;
157 155
158 if (end < start) 156 if (end < start)
@@ -274,11 +272,10 @@ int find_next_system_ram(struct resource *res)
274 * Find empty slot in the resource tree given range and alignment. 272 * Find empty slot in the resource tree given range and alignment.
275 */ 273 */
276static int find_resource(struct resource *root, struct resource *new, 274static int find_resource(struct resource *root, struct resource *new,
277 unsigned long size, 275 resource_size_t size, resource_size_t min,
278 unsigned long min, unsigned long max, 276 resource_size_t max, resource_size_t align,
279 unsigned long align,
280 void (*alignf)(void *, struct resource *, 277 void (*alignf)(void *, struct resource *,
281 unsigned long, unsigned long), 278 resource_size_t, resource_size_t),
282 void *alignf_data) 279 void *alignf_data)
283{ 280{
284 struct resource *this = root->child; 281 struct resource *this = root->child;
@@ -320,11 +317,10 @@ static int find_resource(struct resource *root, struct resource *new,
320 * Allocate empty slot in the resource tree given range and alignment. 317 * Allocate empty slot in the resource tree given range and alignment.
321 */ 318 */
322int allocate_resource(struct resource *root, struct resource *new, 319int allocate_resource(struct resource *root, struct resource *new,
323 unsigned long size, 320 resource_size_t size, resource_size_t min,
324 unsigned long min, unsigned long max, 321 resource_size_t max, resource_size_t align,
325 unsigned long align,
326 void (*alignf)(void *, struct resource *, 322 void (*alignf)(void *, struct resource *,
327 unsigned long, unsigned long), 323 resource_size_t, resource_size_t),
328 void *alignf_data) 324 void *alignf_data)
329{ 325{
330 int err; 326 int err;
@@ -416,10 +412,10 @@ EXPORT_SYMBOL(insert_resource);
416 * arguments. Returns -EBUSY if it can't fit. Existing children of 412 * arguments. Returns -EBUSY if it can't fit. Existing children of
417 * the resource are assumed to be immutable. 413 * the resource are assumed to be immutable.
418 */ 414 */
419int adjust_resource(struct resource *res, unsigned long start, unsigned long size) 415int adjust_resource(struct resource *res, resource_size_t start, resource_size_t size)
420{ 416{
421 struct resource *tmp, *parent = res->parent; 417 struct resource *tmp, *parent = res->parent;
422 unsigned long end = start + size - 1; 418 resource_size_t end = start + size - 1;
423 int result = -EBUSY; 419 int result = -EBUSY;
424 420
425 write_lock(&resource_lock); 421 write_lock(&resource_lock);
@@ -466,7 +462,9 @@ EXPORT_SYMBOL(adjust_resource);
466 * 462 *
467 * Release-region releases a matching busy region. 463 * Release-region releases a matching busy region.
468 */ 464 */
469struct resource * __request_region(struct resource *parent, unsigned long start, unsigned long n, const char *name) 465struct resource * __request_region(struct resource *parent,
466 resource_size_t start, resource_size_t n,
467 const char *name)
470{ 468{
471 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); 469 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
472 470
@@ -502,7 +500,8 @@ struct resource * __request_region(struct resource *parent, unsigned long start,
502 500
503EXPORT_SYMBOL(__request_region); 501EXPORT_SYMBOL(__request_region);
504 502
505int __check_region(struct resource *parent, unsigned long start, unsigned long n) 503int __check_region(struct resource *parent, resource_size_t start,
504 resource_size_t n)
506{ 505{
507 struct resource * res; 506 struct resource * res;
508 507
@@ -517,10 +516,11 @@ int __check_region(struct resource *parent, unsigned long start, unsigned long n
517 516
518EXPORT_SYMBOL(__check_region); 517EXPORT_SYMBOL(__check_region);
519 518
520void __release_region(struct resource *parent, unsigned long start, unsigned long n) 519void __release_region(struct resource *parent, resource_size_t start,
520 resource_size_t n)
521{ 521{
522 struct resource **p; 522 struct resource **p;
523 unsigned long end; 523 resource_size_t end;
524 524
525 p = &parent->child; 525 p = &parent->child;
526 end = start + n - 1; 526 end = start + n - 1;
@@ -549,7 +549,9 @@ void __release_region(struct resource *parent, unsigned long start, unsigned lon
549 549
550 write_unlock(&resource_lock); 550 write_unlock(&resource_lock);
551 551
552 printk(KERN_WARNING "Trying to free nonexistent resource <%08lx-%08lx>\n", start, end); 552 printk(KERN_WARNING "Trying to free nonexistent resource "
553 "<%016llx-%016llx>\n", (unsigned long long)start,
554 (unsigned long long)end);
553} 555}
554 556
555EXPORT_SYMBOL(__release_region); 557EXPORT_SYMBOL(__release_region);