blob: f51eaee921b603b202bf184cdfdaee3a8da2ca08 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/kernel/irq/handle.c
3 *
Ingo Molnara34db9b2006-06-29 02:24:50 -07004 * Copyright (C) 1992, 1998-2006 Linus Torvalds, Ingo Molnar
5 * Copyright (C) 2005-2006, Thomas Gleixner, Russell King
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * This file contains the core interrupt handling code.
Ingo Molnara34db9b2006-06-29 02:24:50 -07008 *
9 * Detailed information is available in Documentation/DocBook/genericirq
10 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 */
12
13#include <linux/irq.h>
14#include <linux/module.h>
15#include <linux/random.h>
16#include <linux/interrupt.h>
17#include <linux/kernel_stat.h>
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -080018#include <linux/rculist.h>
19#include <linux/hash.h>
Mike Travis0fa0ebb2009-01-10 22:24:06 -080020#include <linux/bootmem.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22#include "internals.h"
23
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -080024/*
25 * lockdep: we want to handle all irq_desc locks as a single lock-class:
26 */
Yinghai Lu48a1b102008-12-11 00:15:01 -080027struct lock_class_key irq_desc_lock_class;
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -080028
Thomas Gleixner6a6de9e2006-06-29 02:24:51 -070029/**
30 * handle_bad_irq - handle spurious and unhandled irqs
Henrik Kretzschmar43a1dd52006-08-31 21:27:44 -070031 * @irq: the interrupt number
32 * @desc: description of the interrupt
Henrik Kretzschmar43a1dd52006-08-31 21:27:44 -070033 *
34 * Handles spurious and unhandled IRQ's. It also prints a debugmessage.
Thomas Gleixner6a6de9e2006-06-29 02:24:51 -070035 */
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +020036void handle_bad_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixner6a6de9e2006-06-29 02:24:51 -070037{
Ingo Molnar43f77752006-06-29 02:24:58 -070038 print_irq_desc(irq, desc);
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +020039 kstat_incr_irqs_this_cpu(irq, desc);
Thomas Gleixner6a6de9e2006-06-29 02:24:51 -070040 ack_bad_irq(irq);
41}
42
David Daney97179fd2009-01-27 09:53:22 -080043#if defined(CONFIG_SMP) && defined(CONFIG_GENERIC_HARDIRQS)
44static void __init init_irq_default_affinity(void)
45{
46 alloc_bootmem_cpumask_var(&irq_default_affinity);
47 cpumask_setall(irq_default_affinity);
48}
49#else
50static void __init init_irq_default_affinity(void)
51{
52}
53#endif
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055/*
56 * Linux has a controller-independent interrupt architecture.
57 * Every controller has a 'controller-template', that is used
58 * by the main code to do the right thing. Each driver-visible
Ingo Molnar06fcb0c2006-06-29 02:24:40 -070059 * interrupt source is transparently wired to the appropriate
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 * controller. Thus drivers need not be aware of the
61 * interrupt-controller.
62 *
63 * The code is designed to be easily extended with new/different
64 * interrupt controllers, without having to do assembly magic or
65 * having to touch the generic code.
66 *
67 * Controller mappings for all interrupt sources:
68 */
Yinghai Lu85c0f902008-08-19 20:49:47 -070069int nr_irqs = NR_IRQS;
Ingo Molnarfa42d102008-08-19 20:50:30 -070070EXPORT_SYMBOL_GPL(nr_irqs);
Yinghai Lud60458b2008-08-19 20:50:00 -070071
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -080072#ifdef CONFIG_SPARSE_IRQ
Mike Travis92296c62009-01-11 09:22:58 -080073
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -080074static struct irq_desc irq_desc_init = {
75 .irq = -1,
76 .status = IRQ_DISABLED,
77 .chip = &no_irq_chip,
78 .handle_irq = handle_bad_irq,
79 .depth = 1,
80 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -080081};
82
Yinghai Lu48a1b102008-12-11 00:15:01 -080083void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -080084{
85 unsigned long bytes;
86 char *ptr;
87 int node;
88
89 /* Compute how many bytes we need per irq and allocate them */
90 bytes = nr * sizeof(unsigned int);
91
92 node = cpu_to_node(cpu);
93 ptr = kzalloc_node(bytes, GFP_ATOMIC, node);
94 printk(KERN_DEBUG " alloc kstat_irqs on cpu %d node %d\n", cpu, node);
95
96 if (ptr)
97 desc->kstat_irqs = (unsigned int *)ptr;
98}
99
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800100static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
101{
102 memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
Ingo Molnar793f7b12008-12-26 19:02:20 +0100103
104 spin_lock_init(&desc->lock);
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800105 desc->irq = irq;
106#ifdef CONFIG_SMP
107 desc->cpu = cpu;
108#endif
109 lockdep_set_class(&desc->lock, &irq_desc_lock_class);
110 init_kstat_irqs(desc, cpu, nr_cpu_ids);
111 if (!desc->kstat_irqs) {
112 printk(KERN_ERR "can not alloc kstat_irqs\n");
113 BUG_ON(1);
114 }
Mike Travis802bf932009-01-10 21:58:09 -0800115 if (!init_alloc_desc_masks(desc, cpu, false)) {
Mike Travis7f7ace02009-01-10 21:58:08 -0800116 printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
117 BUG_ON(1);
118 }
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800119 arch_init_chip_data(desc, cpu);
120}
121
122/*
123 * Protect the sparse_irqs:
124 */
Yinghai Lu48a1b102008-12-11 00:15:01 -0800125DEFINE_SPINLOCK(sparse_irq_lock);
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800126
Mike Travis0fa0ebb2009-01-10 22:24:06 -0800127struct irq_desc **irq_desc_ptrs __read_mostly;
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800128
Yinghai Lu99d093d2008-12-05 18:58:32 -0800129static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = {
130 [0 ... NR_IRQS_LEGACY-1] = {
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800131 .irq = -1,
132 .status = IRQ_DISABLED,
133 .chip = &no_irq_chip,
134 .handle_irq = handle_bad_irq,
135 .depth = 1,
136 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800137 }
138};
139
Mike Travis542d8652009-01-10 22:24:07 -0800140static unsigned int *kstat_irqs_legacy;
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800141
Yinghai Lu13a0c3c2008-12-26 02:05:47 -0800142int __init early_irq_init(void)
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800143{
144 struct irq_desc *desc;
145 int legacy_count;
146 int i;
147
David Daney97179fd2009-01-27 09:53:22 -0800148 init_irq_default_affinity();
149
Yinghai Lu4a046d12009-01-12 17:39:24 -0800150 /* initialize nr_irqs based on nr_cpu_ids */
151 arch_probe_nr_irqs();
Mike Travis95949492009-01-10 22:24:06 -0800152 printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs);
153
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800154 desc = irq_desc_legacy;
155 legacy_count = ARRAY_SIZE(irq_desc_legacy);
156
Mike Travis0fa0ebb2009-01-10 22:24:06 -0800157 /* allocate irq_desc_ptrs array based on nr_irqs */
158 irq_desc_ptrs = alloc_bootmem(nr_irqs * sizeof(void *));
159
Mike Travis542d8652009-01-10 22:24:07 -0800160 /* allocate based on nr_cpu_ids */
161 /* FIXME: invert kstat_irgs, and it'd be a per_cpu_alloc'd thing */
162 kstat_irqs_legacy = alloc_bootmem(NR_IRQS_LEGACY * nr_cpu_ids *
163 sizeof(int));
164
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800165 for (i = 0; i < legacy_count; i++) {
166 desc[i].irq = i;
Mike Travis542d8652009-01-10 22:24:07 -0800167 desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids;
Yinghai Lufa6beb32008-12-22 20:24:09 -0800168 lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
Mike Travis7f7ace02009-01-10 21:58:08 -0800169 init_alloc_desc_masks(&desc[i], 0, true);
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800170 irq_desc_ptrs[i] = desc + i;
171 }
172
Mike Travis95949492009-01-10 22:24:06 -0800173 for (i = legacy_count; i < nr_irqs; i++)
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800174 irq_desc_ptrs[i] = NULL;
175
Yinghai Lu13a0c3c2008-12-26 02:05:47 -0800176 return arch_early_irq_init();
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800177}
178
179struct irq_desc *irq_to_desc(unsigned int irq)
180{
Mike Travis0fa0ebb2009-01-10 22:24:06 -0800181 if (irq_desc_ptrs && irq < nr_irqs)
182 return irq_desc_ptrs[irq];
183
184 return NULL;
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800185}
186
187struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
188{
189 struct irq_desc *desc;
190 unsigned long flags;
191 int node;
192
Mike Travis95949492009-01-10 22:24:06 -0800193 if (irq >= nr_irqs) {
Mike Travise2f4d062009-01-10 22:24:06 -0800194 WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n",
195 irq, nr_irqs);
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800196 return NULL;
197 }
198
199 desc = irq_desc_ptrs[irq];
200 if (desc)
201 return desc;
202
203 spin_lock_irqsave(&sparse_irq_lock, flags);
204
205 /* We have to check it to avoid races with another CPU */
206 desc = irq_desc_ptrs[irq];
207 if (desc)
208 goto out_unlock;
209
210 node = cpu_to_node(cpu);
211 desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
212 printk(KERN_DEBUG " alloc irq_desc for %d on cpu %d node %d\n",
213 irq, cpu, node);
214 if (!desc) {
215 printk(KERN_ERR "can not alloc irq_desc\n");
216 BUG_ON(1);
217 }
218 init_one_irq_desc(irq, desc, cpu);
219
220 irq_desc_ptrs[irq] = desc;
221
222out_unlock:
223 spin_unlock_irqrestore(&sparse_irq_lock, flags);
224
225 return desc;
226}
227
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +0900228#else /* !CONFIG_SPARSE_IRQ */
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800229
Ravikiran G Thirumalaie729aa12007-05-08 00:29:13 -0700230struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 [0 ... NR_IRQS-1] = {
Zhang, Yanmin4f167fb2005-05-16 21:53:43 -0700232 .status = IRQ_DISABLED,
Ingo Molnarf1c26622006-06-29 02:24:57 -0700233 .chip = &no_irq_chip,
Ingo Molnar7a557132006-06-29 02:24:54 -0700234 .handle_irq = handle_bad_irq,
Thomas Gleixner94d39e12006-06-29 02:24:50 -0700235 .depth = 1,
Yinghai Luaac3f2b2008-09-24 19:04:35 -0700236 .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 }
238};
Yinghai Lu08678b02008-08-19 20:50:05 -0700239
Yinghai Lu12026ea2008-12-26 22:38:15 -0800240int __init early_irq_init(void)
241{
242 struct irq_desc *desc;
243 int count;
244 int i;
245
David Daney97179fd2009-01-27 09:53:22 -0800246 init_irq_default_affinity();
247
Mike Travis95949492009-01-10 22:24:06 -0800248 printk(KERN_INFO "NR_IRQS:%d\n", NR_IRQS);
249
Yinghai Lu12026ea2008-12-26 22:38:15 -0800250 desc = irq_desc;
251 count = ARRAY_SIZE(irq_desc);
252
Mike Travis7f7ace02009-01-10 21:58:08 -0800253 for (i = 0; i < count; i++) {
Yinghai Lu12026ea2008-12-26 22:38:15 -0800254 desc[i].irq = i;
Mike Travis7f7ace02009-01-10 21:58:08 -0800255 init_alloc_desc_masks(&desc[i], 0, true);
256 }
Yinghai Lu12026ea2008-12-26 22:38:15 -0800257 return arch_early_irq_init();
258}
259
KOSAKI Motohirof9af0e72008-12-26 12:24:24 +0900260struct irq_desc *irq_to_desc(unsigned int irq)
261{
262 return (irq < NR_IRQS) ? irq_desc + irq : NULL;
263}
264
265struct irq_desc *irq_to_desc_alloc_cpu(unsigned int irq, int cpu)
266{
267 return irq_to_desc(irq);
268}
269#endif /* !CONFIG_SPARSE_IRQ */
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800270
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271/*
Ingo Molnar77a5afe2006-06-29 02:24:46 -0700272 * What should we do if we get a hw irq event on an illegal vector?
273 * Each architecture has to answer this themself.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 */
Ingo Molnar77a5afe2006-06-29 02:24:46 -0700275static void ack_bad(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276{
Thomas Gleixnerd3c60042008-10-16 09:55:00 +0200277 struct irq_desc *desc = irq_to_desc(irq);
Yinghai Lu08678b02008-08-19 20:50:05 -0700278
Yinghai Lu08678b02008-08-19 20:50:05 -0700279 print_irq_desc(irq, desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 ack_bad_irq(irq);
281}
282
Ingo Molnar77a5afe2006-06-29 02:24:46 -0700283/*
284 * NOP functions
285 */
286static void noop(unsigned int irq)
287{
288}
289
290static unsigned int noop_ret(unsigned int irq)
291{
292 return 0;
293}
294
295/*
296 * Generic no controller implementation
297 */
Ingo Molnarf1c26622006-06-29 02:24:57 -0700298struct irq_chip no_irq_chip = {
299 .name = "none",
Ingo Molnar77a5afe2006-06-29 02:24:46 -0700300 .startup = noop_ret,
301 .shutdown = noop,
302 .enable = noop,
303 .disable = noop,
304 .ack = ack_bad,
305 .end = noop,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306};
307
308/*
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100309 * Generic dummy implementation which can be used for
310 * real dumb interrupt sources
311 */
312struct irq_chip dummy_irq_chip = {
313 .name = "dummy",
314 .startup = noop_ret,
315 .shutdown = noop,
316 .enable = noop,
317 .disable = noop,
318 .ack = noop,
319 .mask = noop,
320 .unmask = noop,
321 .end = noop,
322};
323
324/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 * Special, empty irq handler:
326 */
David Howells7d12e782006-10-05 14:55:46 +0100327irqreturn_t no_action(int cpl, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328{
329 return IRQ_NONE;
330}
331
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700332/**
333 * handle_IRQ_event - irq action chain handler
334 * @irq: the interrupt number
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700335 * @action: the interrupt action chain for this irq
336 *
337 * Handles the action chain of an irq event
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 */
David Howells7d12e782006-10-05 14:55:46 +0100339irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340{
Jan Beulich908dcec2006-06-23 02:06:00 -0700341 irqreturn_t ret, retval = IRQ_NONE;
342 unsigned int status = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Thomas Gleixner3cca53b2006-07-01 19:29:31 -0700344 if (!(action->flags & IRQF_DISABLED))
Ingo Molnar366c7f52006-07-03 00:25:25 -0700345 local_irq_enable_in_hardirq();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347 do {
David Howells7d12e782006-10-05 14:55:46 +0100348 ret = action->handler(irq, action->dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 if (ret == IRQ_HANDLED)
350 status |= action->flags;
351 retval |= ret;
352 action = action->next;
353 } while (action);
354
Thomas Gleixner3cca53b2006-07-01 19:29:31 -0700355 if (status & IRQF_SAMPLE_RANDOM)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 add_interrupt_randomness(irq);
357 local_irq_disable();
358
359 return retval;
360}
361
David Howellsaf8c65b2006-09-25 23:32:07 -0700362#ifndef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700363/**
364 * __do_IRQ - original all in one highlevel IRQ handler
365 * @irq: the interrupt number
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700366 *
367 * __do_IRQ handles all normal device IRQ's (the special
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 * SMP cross-CPU interrupts have their own specific
369 * handlers).
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700370 *
371 * This is the original x86 implementation which is used for every
372 * interrupt type.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800374unsigned int __do_IRQ(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375{
Yinghai Lu08678b02008-08-19 20:50:05 -0700376 struct irq_desc *desc = irq_to_desc(irq);
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700377 struct irqaction *action;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 unsigned int status;
379
Thomas Gleixnerd6c88a52008-10-15 15:27:23 +0200380 kstat_incr_irqs_this_cpu(irq, desc);
381
Karsten Wiesef26fdd52005-09-06 15:17:25 -0700382 if (CHECK_IRQ_PER_CPU(desc->status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 irqreturn_t action_ret;
384
385 /*
386 * No locking required for CPU-local interrupts:
387 */
Yinghai Lu48a1b102008-12-11 00:15:01 -0800388 if (desc->chip->ack) {
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700389 desc->chip->ack(irq);
Yinghai Lu48a1b102008-12-11 00:15:01 -0800390 /* get new one */
391 desc = irq_remap_to_desc(irq, desc);
392 }
Russ Andersonc642b832007-11-14 17:00:15 -0800393 if (likely(!(desc->status & IRQ_DISABLED))) {
394 action_ret = handle_IRQ_event(irq, desc->action);
395 if (!noirqdebug)
396 note_interrupt(irq, desc, action_ret);
397 }
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700398 desc->chip->end(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 return 1;
400 }
401
402 spin_lock(&desc->lock);
Yinghai Lu48a1b102008-12-11 00:15:01 -0800403 if (desc->chip->ack) {
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700404 desc->chip->ack(irq);
Yinghai Lu48a1b102008-12-11 00:15:01 -0800405 desc = irq_remap_to_desc(irq, desc);
406 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 /*
408 * REPLAY is when Linux resends an IRQ that was dropped earlier
409 * WAITING is used by probe to mark irqs that are being tested
410 */
411 status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
412 status |= IRQ_PENDING; /* we _want_ to handle it */
413
414 /*
415 * If the IRQ is disabled for whatever reason, we cannot
416 * use the action we have.
417 */
418 action = NULL;
419 if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
420 action = desc->action;
421 status &= ~IRQ_PENDING; /* we commit to handling */
422 status |= IRQ_INPROGRESS; /* we are handling it */
423 }
424 desc->status = status;
425
426 /*
427 * If there is no IRQ handler or it was disabled, exit early.
428 * Since we set PENDING, if another processor is handling
429 * a different instance of this same irq, the other processor
430 * will take care of it.
431 */
432 if (unlikely(!action))
433 goto out;
434
435 /*
436 * Edge triggered interrupts need to remember
437 * pending events.
438 * This applies to any hw interrupts that allow a second
439 * instance of the same irq to arrive while we are in do_IRQ
440 * or in the handler. But the code here only handles the _second_
441 * instance of the irq, not the third or fourth. So it is mostly
442 * useful for irq hardware that does not mask cleanly in an
443 * SMP environment.
444 */
445 for (;;) {
446 irqreturn_t action_ret;
447
448 spin_unlock(&desc->lock);
449
David Howells7d12e782006-10-05 14:55:46 +0100450 action_ret = handle_IRQ_event(irq, action);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100452 note_interrupt(irq, desc, action_ret);
Linus Torvaldsb42172f2006-11-22 09:32:06 -0800453
454 spin_lock(&desc->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 if (likely(!(desc->status & IRQ_PENDING)))
456 break;
457 desc->status &= ~IRQ_PENDING;
458 }
459 desc->status &= ~IRQ_INPROGRESS;
460
461out:
462 /*
463 * The ->end() handler has to deal with interrupts which got
464 * disabled while the handler was running.
465 */
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700466 desc->chip->end(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 spin_unlock(&desc->lock);
468
469 return 1;
470}
David Howellsaf8c65b2006-09-25 23:32:07 -0700471#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472
Ingo Molnar243c7622006-07-03 00:25:06 -0700473void early_init_irq_lock_class(void)
474{
Thomas Gleixner10e58082008-10-16 14:19:04 +0200475 struct irq_desc *desc;
Ingo Molnar243c7622006-07-03 00:25:06 -0700476 int i;
477
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800478 for_each_irq_desc(i, desc) {
Thomas Gleixner10e58082008-10-16 14:19:04 +0200479 lockdep_set_class(&desc->lock, &irq_desc_lock_class);
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800480 }
Yinghai Lu08678b02008-08-19 20:50:05 -0700481}
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800482
483#ifdef CONFIG_SPARSE_IRQ
484unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
485{
486 struct irq_desc *desc = irq_to_desc(irq);
KOSAKI Motohiro26ddd8d2008-12-26 14:24:10 +0900487 return desc ? desc->kstat_irqs[cpu] : 0;
Yinghai Lu0b8f1ef2008-12-05 18:58:31 -0800488}
489#endif
490EXPORT_SYMBOL(kstat_irqs_cpu);
491