2 * linux/arch/arm/kernel/irq.c
4 * Copyright (C) 1992 Linus Torvalds
5 * Modifications for ARM processor Copyright (C) 1995-2000 Russell King.
7 * Support for Dynamic Tick Timer Copyright (C) 2004-2005 Nokia Corporation.
8 * Dynamic Tick Timer written by Tony Lindgren <tony@atomide.com> and
9 * Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This file contains the code used by various IRQ handling routines:
16 * asking for different IRQ's should be done through these routines
17 * instead of just grabbing them. Thus setups with different IRQ numbers
18 * shouldn't result in any weird surprises, and installing new handlers
21 * IRQ's are in fact implemented a bit like signal handlers for the kernel.
22 * Naturally it's not a 1:1 relation, but there are similarities.
24 #include <linux/kernel_stat.h>
25 #include <linux/module.h>
26 #include <linux/signal.h>
27 #include <linux/ioport.h>
28 #include <linux/interrupt.h>
29 #include <linux/ptrace.h>
30 #include <linux/slab.h>
31 #include <linux/random.h>
32 #include <linux/smp.h>
33 #include <linux/init.h>
34 #include <linux/seq_file.h>
35 #include <linux/errno.h>
36 #include <linux/list.h>
37 #include <linux/kallsyms.h>
38 #include <linux/proc_fs.h>
41 #include <asm/system.h>
42 #include <asm/mach/irq.h>
43 #include <asm/mach/time.h>
46 * Maximum IRQ count. Currently, this is arbitary. However, it should
47 * not be set too low to prevent false triggering. Conversely, if it
48 * is set too high, then you could miss a stuck IRQ.
50 * Maybe we ought to set a timer and re-enable the IRQ at a later time?
52 #define MAX_IRQ_CNT 100000
54 static int noirqdebug __read_mostly;
55 static volatile unsigned long irq_err_count;
56 static DEFINE_SPINLOCK(irq_controller_lock);
57 static LIST_HEAD(irq_pending);
59 struct irqdesc irq_desc[NR_IRQS];
60 void (*init_arch_irq)(void) __initdata = NULL;
63 * No architecture-specific irq_finish function defined in arm/arch/irqs.h.
66 #define irq_finish(irq) do { } while (0)
70 * Dummy mask/unmask handler
72 void dummy_mask_unmask_irq(unsigned int irq)
76 irqreturn_t no_action(int irq, void *dev_id, struct pt_regs *regs)
81 void do_bad_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
84 printk(KERN_ERR "IRQ: spurious interrupt %d\n", irq);
87 static struct irqchip bad_chip = {
88 .ack = dummy_mask_unmask_irq,
89 .mask = dummy_mask_unmask_irq,
90 .unmask = dummy_mask_unmask_irq,
93 static struct irqdesc bad_irq_desc = {
96 .pend = LIST_HEAD_INIT(bad_irq_desc.pend),
101 void synchronize_irq(unsigned int irq)
103 struct irqdesc *desc = irq_desc + irq;
105 while (desc->running)
108 EXPORT_SYMBOL(synchronize_irq);
110 #define smp_set_running(desc) do { desc->running = 1; } while (0)
111 #define smp_clear_running(desc) do { desc->running = 0; } while (0)
113 #define smp_set_running(desc) do { } while (0)
114 #define smp_clear_running(desc) do { } while (0)
118 * disable_irq_nosync - disable an irq without waiting
119 * @irq: Interrupt to disable
121 * Disable the selected interrupt line. Enables and disables
122 * are nested. We do this lazily.
124 * This function may be called from IRQ context.
126 void disable_irq_nosync(unsigned int irq)
128 struct irqdesc *desc = irq_desc + irq;
131 spin_lock_irqsave(&irq_controller_lock, flags);
132 desc->disable_depth++;
133 list_del_init(&desc->pend);
134 spin_unlock_irqrestore(&irq_controller_lock, flags);
136 EXPORT_SYMBOL(disable_irq_nosync);
139 * disable_irq - disable an irq and wait for completion
140 * @irq: Interrupt to disable
142 * Disable the selected interrupt line. Enables and disables
143 * are nested. This functions waits for any pending IRQ
144 * handlers for this interrupt to complete before returning.
145 * If you use this function while holding a resource the IRQ
146 * handler may need you will deadlock.
148 * This function may be called - with care - from IRQ context.
150 void disable_irq(unsigned int irq)
152 struct irqdesc *desc = irq_desc + irq;
154 disable_irq_nosync(irq);
156 synchronize_irq(irq);
158 EXPORT_SYMBOL(disable_irq);
161 * enable_irq - enable interrupt handling on an irq
162 * @irq: Interrupt to enable
164 * Re-enables the processing of interrupts on this IRQ line.
165 * Note that this may call the interrupt handler, so you may
166 * get unexpected results if you hold IRQs disabled.
168 * This function may be called from IRQ context.
170 void enable_irq(unsigned int irq)
172 struct irqdesc *desc = irq_desc + irq;
175 spin_lock_irqsave(&irq_controller_lock, flags);
176 if (unlikely(!desc->disable_depth)) {
177 printk("enable_irq(%u) unbalanced from %p\n", irq,
178 __builtin_return_address(0));
179 } else if (!--desc->disable_depth) {
181 desc->chip->unmask(irq);
184 * If the interrupt is waiting to be processed,
185 * try to re-run it. We can't directly run it
186 * from here since the caller might be in an
187 * interrupt-protected region.
189 if (desc->pending && list_empty(&desc->pend)) {
191 if (!desc->chip->retrigger ||
192 desc->chip->retrigger(irq))
193 list_add(&desc->pend, &irq_pending);
196 spin_unlock_irqrestore(&irq_controller_lock, flags);
198 EXPORT_SYMBOL(enable_irq);
201 * Enable wake on selected irq
203 void enable_irq_wake(unsigned int irq)
205 struct irqdesc *desc = irq_desc + irq;
208 spin_lock_irqsave(&irq_controller_lock, flags);
209 if (desc->chip->set_wake)
210 desc->chip->set_wake(irq, 1);
211 spin_unlock_irqrestore(&irq_controller_lock, flags);
213 EXPORT_SYMBOL(enable_irq_wake);
215 void disable_irq_wake(unsigned int irq)
217 struct irqdesc *desc = irq_desc + irq;
220 spin_lock_irqsave(&irq_controller_lock, flags);
221 if (desc->chip->set_wake)
222 desc->chip->set_wake(irq, 0);
223 spin_unlock_irqrestore(&irq_controller_lock, flags);
225 EXPORT_SYMBOL(disable_irq_wake);
227 int show_interrupts(struct seq_file *p, void *v)
229 int i = *(loff_t *) v, cpu;
230 struct irqaction * action;
237 for_each_present_cpu(cpu) {
238 sprintf(cpuname, "CPU%d", cpu);
239 seq_printf(p, " %10s", cpuname);
245 spin_lock_irqsave(&irq_controller_lock, flags);
246 action = irq_desc[i].action;
250 seq_printf(p, "%3d: ", i);
251 for_each_present_cpu(cpu)
252 seq_printf(p, "%10u ", kstat_cpu(cpu).irqs[i]);
253 seq_printf(p, " %s", action->name);
254 for (action = action->next; action; action = action->next)
255 seq_printf(p, ", %s", action->name);
259 spin_unlock_irqrestore(&irq_controller_lock, flags);
260 } else if (i == NR_IRQS) {
261 #ifdef CONFIG_ARCH_ACORN
268 seq_printf(p, "Err: %10lu\n", irq_err_count);
274 * IRQ lock detection.
276 * Hopefully, this should get us out of a few locked situations.
277 * However, it may take a while for this to happen, since we need
278 * a large number if IRQs to appear in the same jiffie with the
279 * same instruction pointer (or within 2 instructions).
281 static int check_irq_lock(struct irqdesc *desc, int irq, struct pt_regs *regs)
283 unsigned long instr_ptr = instruction_pointer(regs);
285 if (desc->lck_jif == jiffies &&
286 desc->lck_pc >= instr_ptr && desc->lck_pc < instr_ptr + 8) {
289 if (desc->lck_cnt > MAX_IRQ_CNT) {
290 printk(KERN_ERR "IRQ LOCK: IRQ%d is locking the system, disabled\n", irq);
295 desc->lck_pc = instruction_pointer(regs);
296 desc->lck_jif = jiffies;
302 report_bad_irq(unsigned int irq, struct pt_regs *regs, struct irqdesc *desc, int ret)
304 static int count = 100;
305 struct irqaction *action;
310 if (ret != IRQ_HANDLED && ret != IRQ_NONE) {
314 printk("irq%u: bogus retval mask %x\n", irq, ret);
316 desc->irqs_unhandled++;
317 if (desc->irqs_unhandled <= 99900)
319 desc->irqs_unhandled = 0;
320 printk("irq%u: nobody cared\n", irq);
324 printk(KERN_ERR "handlers:");
325 action = desc->action;
327 printk("\n" KERN_ERR "[<%p>]", action->handler);
328 print_symbol(" (%s)", (unsigned long)action->handler);
329 action = action->next;
335 __do_irq(unsigned int irq, struct irqaction *action, struct pt_regs *regs)
340 spin_unlock(&irq_controller_lock);
342 #ifdef CONFIG_NO_IDLE_HZ
343 if (!(action->flags & SA_TIMER) && system_timer->dyn_tick != NULL) {
344 spin_lock(&system_timer->dyn_tick->lock);
345 if (system_timer->dyn_tick->state & DYN_TICK_ENABLED)
346 system_timer->dyn_tick->handler(irq, 0, regs);
347 spin_unlock(&system_timer->dyn_tick->lock);
351 if (!(action->flags & SA_INTERRUPT))
356 ret = action->handler(irq, action->dev_id, regs);
357 if (ret == IRQ_HANDLED)
358 status |= action->flags;
360 action = action->next;
363 if (status & SA_SAMPLE_RANDOM)
364 add_interrupt_randomness(irq);
366 spin_lock_irq(&irq_controller_lock);
372 * This is for software-decoded IRQs. The caller is expected to
373 * handle the ack, clear, mask and unmask issues.
376 do_simple_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
378 struct irqaction *action;
379 const unsigned int cpu = smp_processor_id();
383 kstat_cpu(cpu).irqs[irq]++;
385 smp_set_running(desc);
387 action = desc->action;
389 int ret = __do_irq(irq, action, regs);
390 if (ret != IRQ_HANDLED)
391 report_bad_irq(irq, regs, desc, ret);
394 smp_clear_running(desc);
398 * Most edge-triggered IRQ implementations seem to take a broken
399 * approach to this. Hence the complexity.
402 do_edge_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
404 const unsigned int cpu = smp_processor_id();
409 * If we're currently running this IRQ, or its disabled,
410 * we shouldn't process the IRQ. Instead, turn on the
413 if (unlikely(desc->running || desc->disable_depth))
417 * Acknowledge and clear the IRQ, but don't mask it.
419 desc->chip->ack(irq);
422 * Mark the IRQ currently in progress.
426 kstat_cpu(cpu).irqs[irq]++;
429 struct irqaction *action;
431 action = desc->action;
435 if (desc->pending && !desc->disable_depth) {
437 desc->chip->unmask(irq);
440 __do_irq(irq, action, regs);
441 } while (desc->pending && !desc->disable_depth);
446 * If we were disabled or freed, shut down the handler.
448 if (likely(desc->action && !check_irq_lock(desc, irq, regs)))
453 * We got another IRQ while this one was masked or
454 * currently running. Delay it.
457 desc->chip->mask(irq);
458 desc->chip->ack(irq);
462 * Level-based IRQ handler. Nice and simple.
465 do_level_IRQ(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
467 struct irqaction *action;
468 const unsigned int cpu = smp_processor_id();
473 * Acknowledge, clear _AND_ disable the interrupt.
475 desc->chip->ack(irq);
477 if (likely(!desc->disable_depth)) {
478 kstat_cpu(cpu).irqs[irq]++;
480 smp_set_running(desc);
483 * Return with this interrupt masked if no action
485 action = desc->action;
487 int ret = __do_irq(irq, desc->action, regs);
489 if (ret != IRQ_HANDLED)
490 report_bad_irq(irq, regs, desc, ret);
492 if (likely(!desc->disable_depth &&
493 !check_irq_lock(desc, irq, regs)))
494 desc->chip->unmask(irq);
497 smp_clear_running(desc);
501 static void do_pending_irqs(struct pt_regs *regs)
503 struct list_head head, *l, *n;
506 struct irqdesc *desc;
509 * First, take the pending interrupts off the list.
510 * The act of calling the handlers may add some IRQs
511 * back onto the list.
514 INIT_LIST_HEAD(&irq_pending);
515 head.next->prev = &head;
516 head.prev->next = &head;
519 * Now run each entry. We must delete it from our
520 * list before calling the handler.
522 list_for_each_safe(l, n, &head) {
523 desc = list_entry(l, struct irqdesc, pend);
524 list_del_init(&desc->pend);
525 desc_handle_irq(desc - irq_desc, desc, regs);
529 * The list must be empty.
531 BUG_ON(!list_empty(&head));
532 } while (!list_empty(&irq_pending));
536 * do_IRQ handles all hardware IRQ's. Decoded IRQs should not
537 * come via this function. Instead, they should provide their
540 asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
542 struct irqdesc *desc = irq_desc + irq;
545 * Some hardware gives randomly wrong interrupts. Rather
546 * than crashing, do something sensible.
549 desc = &bad_irq_desc;
552 spin_lock(&irq_controller_lock);
553 desc_handle_irq(irq, desc, regs);
556 * Now re-run any pending interrupts.
558 if (!list_empty(&irq_pending))
559 do_pending_irqs(regs);
563 spin_unlock(&irq_controller_lock);
567 void __set_irq_handler(unsigned int irq, irq_handler_t handle, int is_chained)
569 struct irqdesc *desc;
572 if (irq >= NR_IRQS) {
573 printk(KERN_ERR "Trying to install handler for IRQ%d\n", irq);
580 desc = irq_desc + irq;
582 if (is_chained && desc->chip == &bad_chip)
583 printk(KERN_WARNING "Trying to install chained handler for IRQ%d\n", irq);
585 spin_lock_irqsave(&irq_controller_lock, flags);
586 if (handle == do_bad_IRQ) {
587 desc->chip->mask(irq);
588 desc->chip->ack(irq);
589 desc->disable_depth = 1;
591 desc->handle = handle;
592 if (handle != do_bad_IRQ && is_chained) {
595 desc->disable_depth = 0;
596 desc->chip->unmask(irq);
598 spin_unlock_irqrestore(&irq_controller_lock, flags);
601 void set_irq_chip(unsigned int irq, struct irqchip *chip)
603 struct irqdesc *desc;
606 if (irq >= NR_IRQS) {
607 printk(KERN_ERR "Trying to install chip for IRQ%d\n", irq);
614 desc = irq_desc + irq;
615 spin_lock_irqsave(&irq_controller_lock, flags);
617 spin_unlock_irqrestore(&irq_controller_lock, flags);
620 int set_irq_type(unsigned int irq, unsigned int type)
622 struct irqdesc *desc;
626 if (irq >= NR_IRQS) {
627 printk(KERN_ERR "Trying to set irq type for IRQ%d\n", irq);
631 desc = irq_desc + irq;
632 if (desc->chip->set_type) {
633 spin_lock_irqsave(&irq_controller_lock, flags);
634 ret = desc->chip->set_type(irq, type);
635 spin_unlock_irqrestore(&irq_controller_lock, flags);
640 EXPORT_SYMBOL(set_irq_type);
642 void set_irq_flags(unsigned int irq, unsigned int iflags)
644 struct irqdesc *desc;
647 if (irq >= NR_IRQS) {
648 printk(KERN_ERR "Trying to set irq flags for IRQ%d\n", irq);
652 desc = irq_desc + irq;
653 spin_lock_irqsave(&irq_controller_lock, flags);
654 desc->valid = (iflags & IRQF_VALID) != 0;
655 desc->probe_ok = (iflags & IRQF_PROBE) != 0;
656 desc->noautoenable = (iflags & IRQF_NOAUTOEN) != 0;
657 spin_unlock_irqrestore(&irq_controller_lock, flags);
660 int setup_irq(unsigned int irq, struct irqaction *new)
663 struct irqaction *old, **p;
665 struct irqdesc *desc;
668 * Some drivers like serial.c use request_irq() heavily,
669 * so we have to be careful not to interfere with a
672 if (new->flags & SA_SAMPLE_RANDOM) {
674 * This function might sleep, we want to call it first,
675 * outside of the atomic block.
676 * Yes, this might clear the entropy pool if the wrong
677 * driver is attempted to be loaded, without actually
678 * installing a new handler, but is this really a problem,
679 * only the sysadmin is able to do this.
681 rand_initialize_irq(irq);
685 * The following block of code has to be executed atomically
687 desc = irq_desc + irq;
688 spin_lock_irqsave(&irq_controller_lock, flags);
690 if ((old = *p) != NULL) {
692 * Can't share interrupts unless both agree to and are
695 if (!(old->flags & new->flags & SA_SHIRQ) ||
696 (~old->flags & new->flags) & SA_TRIGGER_MASK) {
697 spin_unlock_irqrestore(&irq_controller_lock, flags);
701 /* add new interrupt at end of irq queue */
715 desc->disable_depth = 1;
717 if (new->flags & SA_TRIGGER_MASK &&
718 desc->chip->set_type) {
719 unsigned int type = new->flags & SA_TRIGGER_MASK;
720 desc->chip->set_type(irq, type);
723 if (!desc->noautoenable) {
724 desc->disable_depth = 0;
725 desc->chip->unmask(irq);
729 spin_unlock_irqrestore(&irq_controller_lock, flags);
734 * request_irq - allocate an interrupt line
735 * @irq: Interrupt line to allocate
736 * @handler: Function to be called when the IRQ occurs
737 * @irqflags: Interrupt type flags
738 * @devname: An ascii name for the claiming device
739 * @dev_id: A cookie passed back to the handler function
741 * This call allocates interrupt resources and enables the
742 * interrupt line and IRQ handling. From the point this
743 * call is made your handler function may be invoked. Since
744 * your handler function must clear any interrupt the board
745 * raises, you must take care both to initialise your hardware
746 * and to set up the interrupt handler in the right order.
748 * Dev_id must be globally unique. Normally the address of the
749 * device data structure is used as the cookie. Since the handler
750 * receives this value it makes sense to use it.
752 * If your interrupt is shared you must pass a non NULL dev_id
753 * as this is required when freeing the interrupt.
757 * SA_SHIRQ Interrupt is shared
759 * SA_INTERRUPT Disable local interrupts while processing
761 * SA_SAMPLE_RANDOM The interrupt can be used for entropy
764 int request_irq(unsigned int irq, irqreturn_t (*handler)(int, void *, struct pt_regs *),
765 unsigned long irq_flags, const char * devname, void *dev_id)
767 unsigned long retval;
768 struct irqaction *action;
770 if (irq >= NR_IRQS || !irq_desc[irq].valid || !handler ||
771 (irq_flags & SA_SHIRQ && !dev_id))
774 action = (struct irqaction *)kmalloc(sizeof(struct irqaction), GFP_KERNEL);
778 action->handler = handler;
779 action->flags = irq_flags;
780 cpus_clear(action->mask);
781 action->name = devname;
783 action->dev_id = dev_id;
785 retval = setup_irq(irq, action);
792 EXPORT_SYMBOL(request_irq);
795 * free_irq - free an interrupt
796 * @irq: Interrupt line to free
797 * @dev_id: Device identity to free
799 * Remove an interrupt handler. The handler is removed and if the
800 * interrupt line is no longer in use by any driver it is disabled.
801 * On a shared IRQ the caller must ensure the interrupt is disabled
802 * on the card it drives before calling this function.
804 * This function must not be called from interrupt context.
806 void free_irq(unsigned int irq, void *dev_id)
808 struct irqaction * action, **p;
811 if (irq >= NR_IRQS || !irq_desc[irq].valid) {
812 printk(KERN_ERR "Trying to free IRQ%d\n",irq);
817 spin_lock_irqsave(&irq_controller_lock, flags);
818 for (p = &irq_desc[irq].action; (action = *p) != NULL; p = &action->next) {
819 if (action->dev_id != dev_id)
822 /* Found it - now free it */
826 spin_unlock_irqrestore(&irq_controller_lock, flags);
829 printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
832 synchronize_irq(irq);
837 EXPORT_SYMBOL(free_irq);
839 static DECLARE_MUTEX(probe_sem);
841 /* Start the interrupt probing. Unlike other architectures,
842 * we don't return a mask of interrupts from probe_irq_on,
843 * but return the number of interrupts enabled for the probe.
844 * The interrupts which have been enabled for probing is
845 * instead recorded in the irq_desc structure.
847 unsigned long probe_irq_on(void)
849 unsigned int i, irqs = 0;
855 * first snaffle up any unassigned but
856 * probe-able interrupts
858 spin_lock_irq(&irq_controller_lock);
859 for (i = 0; i < NR_IRQS; i++) {
860 if (!irq_desc[i].probe_ok || irq_desc[i].action)
863 irq_desc[i].probing = 1;
864 irq_desc[i].triggered = 0;
865 if (irq_desc[i].chip->set_type)
866 irq_desc[i].chip->set_type(i, IRQT_PROBE);
867 irq_desc[i].chip->unmask(i);
870 spin_unlock_irq(&irq_controller_lock);
873 * wait for spurious interrupts to mask themselves out again
875 for (delay = jiffies + HZ/10; time_before(jiffies, delay); )
876 /* min 100ms delay */;
879 * now filter out any obviously spurious interrupts
881 spin_lock_irq(&irq_controller_lock);
882 for (i = 0; i < NR_IRQS; i++) {
883 if (irq_desc[i].probing && irq_desc[i].triggered) {
884 irq_desc[i].probing = 0;
888 spin_unlock_irq(&irq_controller_lock);
893 EXPORT_SYMBOL(probe_irq_on);
895 unsigned int probe_irq_mask(unsigned long irqs)
897 unsigned int mask = 0, i;
899 spin_lock_irq(&irq_controller_lock);
900 for (i = 0; i < 16 && i < NR_IRQS; i++)
901 if (irq_desc[i].probing && irq_desc[i].triggered)
903 spin_unlock_irq(&irq_controller_lock);
909 EXPORT_SYMBOL(probe_irq_mask);
912 * Possible return values:
913 * >= 0 - interrupt number
914 * -1 - no interrupt/many interrupts
916 int probe_irq_off(unsigned long irqs)
919 int irq_found = NO_IRQ;
922 * look at the interrupts, and find exactly one
923 * that we were probing has been triggered
925 spin_lock_irq(&irq_controller_lock);
926 for (i = 0; i < NR_IRQS; i++) {
927 if (irq_desc[i].probing &&
928 irq_desc[i].triggered) {
929 if (irq_found != NO_IRQ) {
940 spin_unlock_irq(&irq_controller_lock);
947 EXPORT_SYMBOL(probe_irq_off);
950 static void route_irq(struct irqdesc *desc, unsigned int irq, unsigned int cpu)
952 pr_debug("IRQ%u: moving from cpu%u to cpu%u\n", irq, desc->cpu, cpu);
954 spin_lock_irq(&irq_controller_lock);
956 desc->chip->set_cpu(desc, irq, cpu);
957 spin_unlock_irq(&irq_controller_lock);
960 #ifdef CONFIG_PROC_FS
962 irq_affinity_read_proc(char *page, char **start, off_t off, int count,
963 int *eof, void *data)
965 struct irqdesc *desc = irq_desc + ((int)data);
966 int len = cpumask_scnprintf(page, count, desc->affinity);
977 irq_affinity_write_proc(struct file *file, const char __user *buffer,
978 unsigned long count, void *data)
980 unsigned int irq = (unsigned int)data;
981 struct irqdesc *desc = irq_desc + irq;
982 cpumask_t affinity, tmp;
985 if (!desc->chip->set_cpu)
988 ret = cpumask_parse(buffer, count, affinity);
992 cpus_and(tmp, affinity, cpu_online_map);
993 if (cpus_empty(tmp)) {
998 desc->affinity = affinity;
999 route_irq(desc, irq, first_cpu(tmp));
1008 void __init init_irq_proc(void)
1010 #if defined(CONFIG_SMP) && defined(CONFIG_PROC_FS)
1011 struct proc_dir_entry *dir;
1014 dir = proc_mkdir("irq", NULL);
1018 for (irq = 0; irq < NR_IRQS; irq++) {
1019 struct proc_dir_entry *entry;
1020 struct irqdesc *desc;
1023 desc = irq_desc + irq;
1024 memset(name, 0, sizeof(name));
1025 snprintf(name, sizeof(name) - 1, "%u", irq);
1027 desc->procdir = proc_mkdir(name, dir);
1031 entry = create_proc_entry("smp_affinity", 0600, desc->procdir);
1034 entry->data = (void *)irq;
1035 entry->read_proc = irq_affinity_read_proc;
1036 entry->write_proc = irq_affinity_write_proc;
1042 void __init init_IRQ(void)
1044 struct irqdesc *desc;
1048 bad_irq_desc.affinity = CPU_MASK_ALL;
1049 bad_irq_desc.cpu = smp_processor_id();
1052 for (irq = 0, desc = irq_desc; irq < NR_IRQS; irq++, desc++) {
1053 *desc = bad_irq_desc;
1054 INIT_LIST_HEAD(&desc->pend);
1060 static int __init noirqdebug_setup(char *str)
1066 __setup("noirqdebug", noirqdebug_setup);
1068 #ifdef CONFIG_HOTPLUG_CPU
1070 * The CPU has been marked offline. Migrate IRQs off this CPU. If
1071 * the affinity settings do not allow other CPUs, force them onto any
1074 void migrate_irqs(void)
1076 unsigned int i, cpu = smp_processor_id();
1078 for (i = 0; i < NR_IRQS; i++) {
1079 struct irqdesc *desc = irq_desc + i;
1081 if (desc->cpu == cpu) {
1082 unsigned int newcpu = any_online_cpu(desc->affinity);
1084 if (newcpu == NR_CPUS) {
1085 if (printk_ratelimit())
1086 printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n",
1089 cpus_setall(desc->affinity);
1090 newcpu = any_online_cpu(desc->affinity);
1093 route_irq(desc, i, newcpu);
1097 #endif /* CONFIG_HOTPLUG_CPU */