blob: 710db0ec97e3b4bd99c97c966bdacee503d61640 [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>
18
19#include "internals.h"
20
Yinghai Lu08678b02008-08-19 20:50:05 -070021/*
22 * lockdep: we want to handle all irq_desc locks as a single lock-class:
23 */
24static struct lock_class_key irq_desc_lock_class;
Yinghai Lu08678b02008-08-19 20:50:05 -070025
Thomas Gleixner6a6de9e2006-06-29 02:24:51 -070026/**
27 * handle_bad_irq - handle spurious and unhandled irqs
Henrik Kretzschmar43a1dd52006-08-31 21:27:44 -070028 * @irq: the interrupt number
29 * @desc: description of the interrupt
Henrik Kretzschmar43a1dd52006-08-31 21:27:44 -070030 *
31 * Handles spurious and unhandled IRQ's. It also prints a debugmessage.
Thomas Gleixner6a6de9e2006-06-29 02:24:51 -070032 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -080033void
David Howells7d12e782006-10-05 14:55:46 +010034handle_bad_irq(unsigned int irq, struct irq_desc *desc)
Thomas Gleixner6a6de9e2006-06-29 02:24:51 -070035{
Ingo Molnar43f77752006-06-29 02:24:58 -070036 print_irq_desc(irq, desc);
Yinghai Lu8c464a42008-08-25 12:41:19 -070037#ifdef CONFIG_HAVE_DYN_ARRAY
Yinghai Lu7f95ec92008-08-19 20:50:09 -070038 kstat_irqs_this_cpu(desc)++;
Yinghai Lu8c464a42008-08-25 12:41:19 -070039#else
40 kstat_irqs_this_cpu(irq)++;
41#endif
Thomas Gleixner6a6de9e2006-06-29 02:24:51 -070042 ack_bad_irq(irq);
43}
44
Linus Torvalds1da177e2005-04-16 15:20:36 -070045/*
46 * Linux has a controller-independent interrupt architecture.
47 * Every controller has a 'controller-template', that is used
48 * by the main code to do the right thing. Each driver-visible
Ingo Molnar06fcb0c2006-06-29 02:24:40 -070049 * interrupt source is transparently wired to the appropriate
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 * controller. Thus drivers need not be aware of the
51 * interrupt-controller.
52 *
53 * The code is designed to be easily extended with new/different
54 * interrupt controllers, without having to do assembly magic or
55 * having to touch the generic code.
56 *
57 * Controller mappings for all interrupt sources:
58 */
Yinghai Lu85c0f902008-08-19 20:49:47 -070059int nr_irqs = NR_IRQS;
Ingo Molnarfa42d102008-08-19 20:50:30 -070060EXPORT_SYMBOL_GPL(nr_irqs);
Yinghai Lud60458b2008-08-19 20:50:00 -070061
62#ifdef CONFIG_HAVE_DYN_ARRAY
Yinghai Lu08678b02008-08-19 20:50:05 -070063static struct irq_desc irq_desc_init = {
64 .irq = -1U,
Yinghai Lud60458b2008-08-19 20:50:00 -070065 .status = IRQ_DISABLED,
66 .chip = &no_irq_chip,
67 .handle_irq = handle_bad_irq,
68 .depth = 1,
69 .lock = __SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
70#ifdef CONFIG_SMP
71 .affinity = CPU_MASK_ALL
72#endif
73};
74
Yinghai Lu08678b02008-08-19 20:50:05 -070075
76static void init_one_irq_desc(struct irq_desc *desc)
77{
78 memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
Yinghai Lu08678b02008-08-19 20:50:05 -070079 lockdep_set_class(&desc->lock, &irq_desc_lock_class);
Yinghai Lu08678b02008-08-19 20:50:05 -070080}
81
Yinghai Lu7f95ec92008-08-19 20:50:09 -070082extern int after_bootmem;
83extern void *__alloc_bootmem_nopanic(unsigned long size,
84 unsigned long align,
85 unsigned long goal);
86
87static void init_kstat_irqs(struct irq_desc *desc, int nr_desc, int nr)
88{
89 unsigned long bytes, total_bytes;
90 char *ptr;
91 int i;
92 unsigned long phys;
93
94 /* Compute how many bytes we need per irq and allocate them */
95 bytes = nr * sizeof(unsigned int);
96 total_bytes = bytes * nr_desc;
97 if (after_bootmem)
98 ptr = kzalloc(total_bytes, GFP_ATOMIC);
99 else
100 ptr = __alloc_bootmem_nopanic(total_bytes, PAGE_SIZE, 0);
101
102 if (!ptr)
103 panic(" can not allocate kstat_irqs\n");
104
105 phys = __pa(ptr);
106 printk(KERN_DEBUG "kstat_irqs ==> [%#lx - %#lx]\n", phys, phys + total_bytes);
107
108 for (i = 0; i < nr_desc; i++) {
109 desc[i].kstat_irqs = (unsigned int *)ptr;
110 ptr += bytes;
111 }
112}
113
Yinghai Lue89eb432008-08-20 20:46:25 -0700114/*
115 * Protect the sparse_irqs_free freelist:
116 */
117static DEFINE_SPINLOCK(sparse_irq_lock);
118
Yinghai Lu67fb2832008-08-19 20:50:18 -0700119#ifdef CONFIG_HAVE_SPARSE_IRQ
120static struct irq_desc *sparse_irqs_free;
121struct irq_desc *sparse_irqs;
122#endif
123
Yinghai Lu7f95ec92008-08-19 20:50:09 -0700124static void __init init_work(void *data)
125{
126 struct dyn_array *da = data;
127 int i;
128 struct irq_desc *desc;
129
130 desc = *da->name;
131
132 for (i = 0; i < *da->nr; i++) {
133 init_one_irq_desc(&desc[i]);
134#ifndef CONFIG_HAVE_SPARSE_IRQ
135 desc[i].irq = i;
136#endif
137 }
138
Yinghai Lu67fb2832008-08-19 20:50:18 -0700139 /* init kstat_irqs, nr_cpu_ids is ready already */
140 init_kstat_irqs(desc, *da->nr, nr_cpu_ids);
141
Yinghai Lu7f95ec92008-08-19 20:50:09 -0700142#ifdef CONFIG_HAVE_SPARSE_IRQ
143 for (i = 1; i < *da->nr; i++)
144 desc[i-1].next = &desc[i];
Yinghai Lu7f95ec92008-08-19 20:50:09 -0700145
Yinghai Lu67fb2832008-08-19 20:50:18 -0700146 sparse_irqs_free = sparse_irqs;
147 sparse_irqs = NULL;
148#endif
Yinghai Lu7f95ec92008-08-19 20:50:09 -0700149}
150
Yinghai Lu08678b02008-08-19 20:50:05 -0700151#ifdef CONFIG_HAVE_SPARSE_IRQ
152static int nr_irq_desc = 32;
153
154static int __init parse_nr_irq_desc(char *arg)
155{
156 if (arg)
157 nr_irq_desc = simple_strtoul(arg, NULL, 0);
158 return 0;
159}
160
161early_param("nr_irq_desc", parse_nr_irq_desc);
162
Yinghai Lu08678b02008-08-19 20:50:05 -0700163DEFINE_DYN_ARRAY(sparse_irqs, sizeof(struct irq_desc), nr_irq_desc, PAGE_SIZE, init_work);
164
Yinghai Lucb5bc832008-08-19 20:50:17 -0700165struct irq_desc *irq_to_desc(unsigned int irq)
Yinghai Lu9059d8f2008-08-19 20:50:10 -0700166{
167 struct irq_desc *desc;
168
Yinghai Lu67fb2832008-08-19 20:50:18 -0700169 desc = sparse_irqs;
Yinghai Lu9059d8f2008-08-19 20:50:10 -0700170 while (desc) {
171 if (desc->irq == irq)
172 return desc;
173
Yinghai Lu9059d8f2008-08-19 20:50:10 -0700174 desc = desc->next;
175 }
176 return NULL;
177}
Yinghai Lue89eb432008-08-20 20:46:25 -0700178
Yinghai Lucb5bc832008-08-19 20:50:17 -0700179struct irq_desc *irq_to_desc_alloc(unsigned int irq)
Yinghai Lu08678b02008-08-19 20:50:05 -0700180{
181 struct irq_desc *desc, *desc_pri;
Yinghai Lue89eb432008-08-20 20:46:25 -0700182 unsigned long flags;
Yinghai Lu08678b02008-08-19 20:50:05 -0700183 int count = 0;
Yinghai Lue89eb432008-08-20 20:46:25 -0700184 int i;
Yinghai Lu08678b02008-08-19 20:50:05 -0700185
Yinghai Lu67fb2832008-08-19 20:50:18 -0700186 desc_pri = desc = sparse_irqs;
Yinghai Lu08678b02008-08-19 20:50:05 -0700187 while (desc) {
188 if (desc->irq == irq)
189 return desc;
190
Yinghai Lu08678b02008-08-19 20:50:05 -0700191 desc_pri = desc;
192 desc = desc->next;
193 count++;
194 }
195
Yinghai Lue89eb432008-08-20 20:46:25 -0700196 spin_lock_irqsave(&sparse_irq_lock, flags);
Yinghai Lu08678b02008-08-19 20:50:05 -0700197 /*
198 * we run out of pre-allocate ones, allocate more
199 */
Yinghai Lu67fb2832008-08-19 20:50:18 -0700200 if (!sparse_irqs_free) {
201 unsigned long phys;
202 unsigned long total_bytes;
Yinghai Lu46926b62008-08-19 20:50:15 -0700203
Yinghai Lu67fb2832008-08-19 20:50:18 -0700204 printk(KERN_DEBUG "try to get more irq_desc %d\n", nr_irq_desc);
205
206 total_bytes = sizeof(struct irq_desc) * nr_irq_desc;
207 if (after_bootmem)
208 desc = kzalloc(total_bytes, GFP_ATOMIC);
209 else
210 desc = __alloc_bootmem_nopanic(total_bytes, PAGE_SIZE, 0);
211
212 if (!desc)
213 panic("please boot with nr_irq_desc= %d\n", count * 2);
214
215 phys = __pa(desc);
216 printk(KERN_DEBUG "irq_desc ==> [%#lx - %#lx]\n", phys, phys + total_bytes);
217
218 for (i = 0; i < nr_irq_desc; i++)
219 init_one_irq_desc(&desc[i]);
220
221 for (i = 1; i < nr_irq_desc; i++)
222 desc[i-1].next = &desc[i];
223
224 /* init kstat_irqs, nr_cpu_ids is ready already */
225 init_kstat_irqs(desc, nr_irq_desc, nr_cpu_ids);
226
227 sparse_irqs_free = desc;
Yinghai Lu46926b62008-08-19 20:50:15 -0700228 }
Yinghai Lu08678b02008-08-19 20:50:05 -0700229
Yinghai Lu67fb2832008-08-19 20:50:18 -0700230 desc = sparse_irqs_free;
231 sparse_irqs_free = sparse_irqs_free->next;
232 desc->next = NULL;
233 if (desc_pri)
234 desc_pri->next = desc;
Yinghai Lu08678b02008-08-19 20:50:05 -0700235 else
Yinghai Lu67fb2832008-08-19 20:50:18 -0700236 sparse_irqs = desc;
Yinghai Lu08678b02008-08-19 20:50:05 -0700237 desc->irq = irq;
Yinghai Lue89eb432008-08-20 20:46:25 -0700238
239 spin_unlock_irqrestore(&sparse_irq_lock, flags);
240
Yinghai Lu08678b02008-08-19 20:50:05 -0700241 return desc;
242}
243#else
Yinghai Lu9059d8f2008-08-19 20:50:10 -0700244struct irq_desc *irq_desc;
Yinghai Lud60458b2008-08-19 20:50:00 -0700245DEFINE_DYN_ARRAY(irq_desc, sizeof(struct irq_desc), nr_irqs, PAGE_SIZE, init_work);
246
Yinghai Lu08678b02008-08-19 20:50:05 -0700247#endif
248
Yinghai Lud60458b2008-08-19 20:50:00 -0700249#else
250
Ravikiran G Thirumalaie729aa12007-05-08 00:29:13 -0700251struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 [0 ... NR_IRQS-1] = {
Zhang, Yanmin4f167fb2005-05-16 21:53:43 -0700253 .status = IRQ_DISABLED,
Ingo Molnarf1c26622006-06-29 02:24:57 -0700254 .chip = &no_irq_chip,
Ingo Molnar7a557132006-06-29 02:24:54 -0700255 .handle_irq = handle_bad_irq,
Thomas Gleixner94d39e12006-06-29 02:24:50 -0700256 .depth = 1,
Yinghai Lu08678b02008-08-19 20:50:05 -0700257 .lock = __SPIN_LOCK_UNLOCKED(sparse_irqs->lock),
Ingo Molnara53da522006-06-29 02:24:38 -0700258#ifdef CONFIG_SMP
259 .affinity = CPU_MASK_ALL
260#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 }
262};
Yinghai Lu08678b02008-08-19 20:50:05 -0700263
264#endif
265
266#ifndef CONFIG_HAVE_SPARSE_IRQ
267struct irq_desc *irq_to_desc(unsigned int irq)
268{
269 if (irq < nr_irqs)
270 return &irq_desc[irq];
271
272 return NULL;
273}
Yinghai Lucb5bc832008-08-19 20:50:17 -0700274struct irq_desc *irq_to_desc_alloc(unsigned int irq)
Yinghai Lu9059d8f2008-08-19 20:50:10 -0700275{
276 return irq_to_desc(irq);
277}
Yinghai Lud60458b2008-08-19 20:50:00 -0700278#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
280/*
Ingo Molnar77a5afe2006-06-29 02:24:46 -0700281 * What should we do if we get a hw irq event on an illegal vector?
282 * Each architecture has to answer this themself.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 */
Ingo Molnar77a5afe2006-06-29 02:24:46 -0700284static void ack_bad(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285{
Yinghai Lu08678b02008-08-19 20:50:05 -0700286 struct irq_desc *desc;
287
288 desc = irq_to_desc(irq);
289 print_irq_desc(irq, desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 ack_bad_irq(irq);
291}
292
Ingo Molnar77a5afe2006-06-29 02:24:46 -0700293/*
294 * NOP functions
295 */
296static void noop(unsigned int irq)
297{
298}
299
300static unsigned int noop_ret(unsigned int irq)
301{
302 return 0;
303}
304
305/*
306 * Generic no controller implementation
307 */
Ingo Molnarf1c26622006-06-29 02:24:57 -0700308struct irq_chip no_irq_chip = {
309 .name = "none",
Ingo Molnar77a5afe2006-06-29 02:24:46 -0700310 .startup = noop_ret,
311 .shutdown = noop,
312 .enable = noop,
313 .disable = noop,
314 .ack = ack_bad,
315 .end = noop,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316};
317
318/*
Thomas Gleixnerf8b54732006-07-01 22:30:08 +0100319 * Generic dummy implementation which can be used for
320 * real dumb interrupt sources
321 */
322struct irq_chip dummy_irq_chip = {
323 .name = "dummy",
324 .startup = noop_ret,
325 .shutdown = noop,
326 .enable = noop,
327 .disable = noop,
328 .ack = noop,
329 .mask = noop,
330 .unmask = noop,
331 .end = noop,
332};
333
334/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 * Special, empty irq handler:
336 */
David Howells7d12e782006-10-05 14:55:46 +0100337irqreturn_t no_action(int cpl, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338{
339 return IRQ_NONE;
340}
341
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700342/**
343 * handle_IRQ_event - irq action chain handler
344 * @irq: the interrupt number
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700345 * @action: the interrupt action chain for this irq
346 *
347 * Handles the action chain of an irq event
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 */
David Howells7d12e782006-10-05 14:55:46 +0100349irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350{
Jan Beulich908dcec2006-06-23 02:06:00 -0700351 irqreturn_t ret, retval = IRQ_NONE;
352 unsigned int status = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
Thomas Gleixner3cca53b2006-07-01 19:29:31 -0700354 if (!(action->flags & IRQF_DISABLED))
Ingo Molnar366c7f52006-07-03 00:25:25 -0700355 local_irq_enable_in_hardirq();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
357 do {
David Howells7d12e782006-10-05 14:55:46 +0100358 ret = action->handler(irq, action->dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 if (ret == IRQ_HANDLED)
360 status |= action->flags;
361 retval |= ret;
362 action = action->next;
363 } while (action);
364
Thomas Gleixner3cca53b2006-07-01 19:29:31 -0700365 if (status & IRQF_SAMPLE_RANDOM)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 add_interrupt_randomness(irq);
367 local_irq_disable();
368
369 return retval;
370}
371
David Howellsaf8c65b2006-09-25 23:32:07 -0700372#ifndef CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700373/**
374 * __do_IRQ - original all in one highlevel IRQ handler
375 * @irq: the interrupt number
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700376 *
377 * __do_IRQ handles all normal device IRQ's (the special
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 * SMP cross-CPU interrupts have their own specific
379 * handlers).
Ingo Molnar8d28bc72006-06-29 02:24:46 -0700380 *
381 * This is the original x86 implementation which is used for every
382 * interrupt type.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 */
Harvey Harrison7ad5b3a2008-02-08 04:19:53 -0800384unsigned int __do_IRQ(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385{
Yinghai Lu08678b02008-08-19 20:50:05 -0700386 struct irq_desc *desc = irq_to_desc(irq);
Ingo Molnar06fcb0c2006-06-29 02:24:40 -0700387 struct irqaction *action;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 unsigned int status;
389
Yinghai Lu8c464a42008-08-25 12:41:19 -0700390#ifdef CONFIG_HAVE_DYN_ARRAY
Yinghai Lu7f95ec92008-08-19 20:50:09 -0700391 kstat_irqs_this_cpu(desc)++;
Yinghai Lu8c464a42008-08-25 12:41:19 -0700392#else
393 kstat_irqs_this_cpu(irq)++;
394#endif
Karsten Wiesef26fdd52005-09-06 15:17:25 -0700395 if (CHECK_IRQ_PER_CPU(desc->status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 irqreturn_t action_ret;
397
398 /*
399 * No locking required for CPU-local interrupts:
400 */
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700401 if (desc->chip->ack)
402 desc->chip->ack(irq);
Russ Andersonc642b832007-11-14 17:00:15 -0800403 if (likely(!(desc->status & IRQ_DISABLED))) {
404 action_ret = handle_IRQ_event(irq, desc->action);
405 if (!noirqdebug)
406 note_interrupt(irq, desc, action_ret);
407 }
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700408 desc->chip->end(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 return 1;
410 }
411
412 spin_lock(&desc->lock);
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700413 if (desc->chip->ack)
414 desc->chip->ack(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 /*
416 * REPLAY is when Linux resends an IRQ that was dropped earlier
417 * WAITING is used by probe to mark irqs that are being tested
418 */
419 status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
420 status |= IRQ_PENDING; /* we _want_ to handle it */
421
422 /*
423 * If the IRQ is disabled for whatever reason, we cannot
424 * use the action we have.
425 */
426 action = NULL;
427 if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
428 action = desc->action;
429 status &= ~IRQ_PENDING; /* we commit to handling */
430 status |= IRQ_INPROGRESS; /* we are handling it */
431 }
432 desc->status = status;
433
434 /*
435 * If there is no IRQ handler or it was disabled, exit early.
436 * Since we set PENDING, if another processor is handling
437 * a different instance of this same irq, the other processor
438 * will take care of it.
439 */
440 if (unlikely(!action))
441 goto out;
442
443 /*
444 * Edge triggered interrupts need to remember
445 * pending events.
446 * This applies to any hw interrupts that allow a second
447 * instance of the same irq to arrive while we are in do_IRQ
448 * or in the handler. But the code here only handles the _second_
449 * instance of the irq, not the third or fourth. So it is mostly
450 * useful for irq hardware that does not mask cleanly in an
451 * SMP environment.
452 */
453 for (;;) {
454 irqreturn_t action_ret;
455
456 spin_unlock(&desc->lock);
457
David Howells7d12e782006-10-05 14:55:46 +0100458 action_ret = handle_IRQ_event(irq, action);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 if (!noirqdebug)
David Howells7d12e782006-10-05 14:55:46 +0100460 note_interrupt(irq, desc, action_ret);
Linus Torvaldsb42172f2006-11-22 09:32:06 -0800461
462 spin_lock(&desc->lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 if (likely(!(desc->status & IRQ_PENDING)))
464 break;
465 desc->status &= ~IRQ_PENDING;
466 }
467 desc->status &= ~IRQ_INPROGRESS;
468
469out:
470 /*
471 * The ->end() handler has to deal with interrupts which got
472 * disabled while the handler was running.
473 */
Ingo Molnard1bef4e2006-06-29 02:24:36 -0700474 desc->chip->end(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 spin_unlock(&desc->lock);
476
477 return 1;
478}
David Howellsaf8c65b2006-09-25 23:32:07 -0700479#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
Yinghai Lu08678b02008-08-19 20:50:05 -0700481
Ingo Molnar243c7622006-07-03 00:25:06 -0700482#ifdef CONFIG_TRACE_IRQFLAGS
Ingo Molnar243c7622006-07-03 00:25:06 -0700483void early_init_irq_lock_class(void)
484{
Yinghai Lu08678b02008-08-19 20:50:05 -0700485#ifndef CONFIG_HAVE_DYN_ARRAY
Ingo Molnar243c7622006-07-03 00:25:06 -0700486 int i;
487
Yinghai Lu85c0f902008-08-19 20:49:47 -0700488 for (i = 0; i < nr_irqs; i++)
Ingo Molnar243c7622006-07-03 00:25:06 -0700489 lockdep_set_class(&irq_desc[i].lock, &irq_desc_lock_class);
Ingo Molnar243c7622006-07-03 00:25:06 -0700490#endif
Yinghai Lu08678b02008-08-19 20:50:05 -0700491}
492#endif
493
Yinghai Lu8c464a42008-08-25 12:41:19 -0700494#ifdef CONFIG_HAVE_DYN_ARRAY
Yinghai Lu7f95ec92008-08-19 20:50:09 -0700495unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
496{
497 struct irq_desc *desc = irq_to_desc(irq);
498 return desc->kstat_irqs[cpu];
499}
Yinghai Lu8c464a42008-08-25 12:41:19 -0700500#endif
Yinghai Lu7f95ec92008-08-19 20:50:09 -0700501EXPORT_SYMBOL(kstat_irqs_cpu);
502