2 * linux/arch/ia64/kernel/irq.c
4 * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
6 * This file contains the code used by various IRQ handling routines:
7 * asking for different IRQ's should be done through these routines
8 * instead of just grabbing them. Thus setups with different IRQ numbers
9 * shouldn't result in any weird surprises, and installing new handlers
14 * (mostly architecture independent, will move to kernel/irq.c in 2.5.)
16 * IRQs are in fact implemented a bit like signal handlers for the kernel.
17 * Naturally it's not a 1:1 relation, but there are similarities.
20 #include <linux/config.h>
21 #include <linux/errno.h>
22 #include <linux/module.h>
23 #include <linux/signal.h>
24 #include <linux/sched.h>
25 #include <linux/ioport.h>
26 #include <linux/interrupt.h>
27 #include <linux/timex.h>
28 #include <linux/slab.h>
29 #include <linux/random.h>
30 #include <linux/ctype.h>
31 #include <linux/smp_lock.h>
32 #include <linux/init.h>
33 #include <linux/kernel_stat.h>
34 #include <linux/irq.h>
35 #include <linux/proc_fs.h>
36 #include <linux/seq_file.h>
37 #include <linux/kallsyms.h>
39 #include <asm/atomic.h>
42 #include <asm/system.h>
43 #include <asm/bitops.h>
44 #include <asm/uaccess.h>
45 #include <asm/pgalloc.h>
46 #include <asm/delay.h>
52 * Linux has a controller-independent x86 interrupt architecture.
53 * every controller has a 'controller-template', that is used
54 * by the main code to do the right thing. Each driver-visible
55 * interrupt source is transparently wired to the appropriate
56 * controller. Thus drivers need not be aware of the
57 * interrupt-controller.
59 * Various interrupt controllers we handle: 8259 PIC, SMP IO-APIC,
60 * PIIX4's internal 8259 PIC and SGI's Visual Workstation Cobalt (IO-)APIC.
61 * (IO-APICs assumed to be messaging to Pentium local-APICs)
63 * the code is designed to be easily extended with new/different
64 * interrupt controllers, without having to do assembly magic.
68 * Controller mappings for all interrupt sources:
70 irq_desc_t _irq_desc[NR_IRQS] __cacheline_aligned = {
72 .status = IRQ_DISABLED,
73 .handler = &no_irq_type,
74 .lock = SPIN_LOCK_UNLOCKED
78 #ifdef CONFIG_IA64_GENERIC
79 irq_desc_t * __ia64_irq_desc (unsigned int irq)
81 return _irq_desc + irq;
84 ia64_vector __ia64_irq_to_vector (unsigned int irq)
86 return (ia64_vector) irq;
89 unsigned int __ia64_local_vector_to_irq (ia64_vector vec)
91 return (unsigned int) vec;
95 static void register_irq_proc (unsigned int irq);
98 * Special irq handlers.
101 irqreturn_t no_action(int cpl, void *dev_id, struct pt_regs *regs)
105 * Generic no controller code
108 static void enable_none(unsigned int irq) { }
109 static unsigned int startup_none(unsigned int irq) { return 0; }
110 static void disable_none(unsigned int irq) { }
111 static void ack_none(unsigned int irq)
114 * 'what should we do if we get a hw irq event on an illegal vector'.
115 * each architecture has to answer this themselves, it doesn't deserve
116 * a generic callback i think.
119 printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq);
120 #ifdef CONFIG_X86_LOCAL_APIC
122 * Currently unexpected vectors happen only on SMP and APIC.
123 * We _must_ ack these because every local APIC has only N
124 * irq slots per priority level, and a 'hanging, unacked' IRQ
125 * holds up an irq slot - in excessive cases (when multiple
126 * unexpected vectors occur) that might lock up the APIC
133 printk(KERN_ERR "Unexpected irq vector 0x%x on CPU %u!\n", irq, smp_processor_id());
137 /* startup is the same as "enable", shutdown is same as "disable" */
138 #define shutdown_none disable_none
139 #define end_none enable_none
141 struct hw_interrupt_type no_irq_type = {
151 atomic_t irq_err_count;
152 #ifdef CONFIG_X86_IO_APIC
153 #ifdef APIC_MISMATCH_DEBUG
154 atomic_t irq_mis_count;
159 * Generic, controller-independent functions:
162 int show_interrupts(struct seq_file *p, void *v)
164 int j, i = *(loff_t *) v;
165 struct irqaction * action;
171 for (j=0; j<NR_CPUS; j++)
173 seq_printf(p, "CPU%d ",j);
178 idesc = irq_descp(i);
179 spin_lock_irqsave(&idesc->lock, flags);
180 action = idesc->action;
183 seq_printf(p, "%3d: ",i);
185 seq_printf(p, "%10u ", kstat_irqs(i));
187 for (j = 0; j < NR_CPUS; j++)
189 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
191 seq_printf(p, " %14s", idesc->handler->typename);
192 seq_printf(p, " %s", action->name);
194 for (action=action->next; action; action = action->next)
195 seq_printf(p, ", %s", action->name);
199 spin_unlock_irqrestore(&idesc->lock, flags);
200 } else if (i == NR_IRQS) {
201 seq_puts(p, "NMI: ");
202 for (j = 0; j < NR_CPUS; j++)
204 seq_printf(p, "%10u ", nmi_count(j));
206 #ifdef CONFIG_X86_LOCAL_APIC
207 seq_puts(p, "LOC: ");
208 for (j = 0; j < NR_CPUS; j++)
210 seq_printf(p, "%10u ", irq_stat[j].apic_timer_irqs);
213 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
214 #ifdef CONFIG_X86_IO_APIC
215 #ifdef APIC_MISMATCH_DEBUG
216 seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count));
224 inline void synchronize_irq(unsigned int irq)
226 while (irq_descp(irq)->status & IRQ_INPROGRESS)
229 EXPORT_SYMBOL(synchronize_irq);
233 * This should really return information about whether
234 * we should do bottom half handling etc. Right now we
235 * end up _always_ checking the bottom half, which is a
236 * waste of time and is not what some drivers would
239 int handle_IRQ_event(unsigned int irq,
240 struct pt_regs *regs, struct irqaction *action)
242 int status = 1; /* Force the "do bottom halves" bit */
245 if (!(action->flags & SA_INTERRUPT))
249 status |= action->flags;
250 retval |= action->handler(irq, action->dev_id, regs);
251 action = action->next;
253 if (status & SA_SAMPLE_RANDOM)
254 add_interrupt_randomness(irq);
259 static void __report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
261 struct irqaction *action;
263 if (action_ret != IRQ_HANDLED && action_ret != IRQ_NONE) {
264 printk(KERN_ERR "irq event %d: bogus return value %x\n",
267 printk(KERN_ERR "irq %d: nobody cared!\n", irq);
270 printk(KERN_ERR "handlers:\n");
271 action = desc->action;
273 printk(KERN_ERR "[<%p>]", action->handler);
274 print_symbol(" (%s)",
275 (unsigned long)action->handler);
277 action = action->next;
281 static void report_bad_irq(int irq, irq_desc_t *desc, irqreturn_t action_ret)
283 static int count = 100;
287 __report_bad_irq(irq, desc, action_ret);
291 static int noirqdebug;
293 static int __init noirqdebug_setup(char *str)
296 printk("IRQ lockup detection disabled\n");
300 __setup("noirqdebug", noirqdebug_setup);
303 * If 99,900 of the previous 100,000 interrupts have not been handled then
304 * assume that the IRQ is stuck in some manner. Drop a diagnostic and try to
307 * (The other 100-of-100,000 interrupts may have been a correctly-functioning
308 * device sharing an IRQ with the failing one)
310 * Called under desc->lock
312 static void note_interrupt(int irq, irq_desc_t *desc, irqreturn_t action_ret)
314 if (action_ret != IRQ_HANDLED) {
315 desc->irqs_unhandled++;
316 if (action_ret != IRQ_NONE)
317 report_bad_irq(irq, desc, action_ret);
321 if (desc->irq_count < 100000)
325 if (desc->irqs_unhandled > 99900) {
327 * The interrupt is stuck
329 __report_bad_irq(irq, desc, action_ret);
333 printk(KERN_EMERG "Disabling IRQ #%d\n", irq);
334 desc->status |= IRQ_DISABLED;
335 desc->handler->disable(irq);
337 desc->irqs_unhandled = 0;
341 * Generic enable/disable code: this just calls
342 * down into the PIC-specific version for the actual
343 * hardware disable after having gotten the irq
348 * disable_irq_nosync - disable an irq without waiting
349 * @irq: Interrupt to disable
351 * Disable the selected interrupt line. Disables and Enables are
353 * Unlike disable_irq(), this function does not ensure existing
354 * instances of the IRQ handler have completed before returning.
356 * This function may be called from IRQ context.
359 inline void disable_irq_nosync(unsigned int irq)
361 irq_desc_t *desc = irq_descp(irq);
364 spin_lock_irqsave(&desc->lock, flags);
365 if (!desc->depth++) {
366 desc->status |= IRQ_DISABLED;
367 desc->handler->disable(irq);
369 spin_unlock_irqrestore(&desc->lock, flags);
371 EXPORT_SYMBOL(disable_irq_nosync);
374 * disable_irq - disable an irq and wait for completion
375 * @irq: Interrupt to disable
377 * Disable the selected interrupt line. Enables and Disables are
379 * This function waits for any pending IRQ handlers for this interrupt
380 * to complete before returning. If you use this function while
381 * holding a resource the IRQ handler may need you will deadlock.
383 * This function may be called - with care - from IRQ context.
386 void disable_irq(unsigned int irq)
388 irq_desc_t *desc = irq_descp(irq);
390 disable_irq_nosync(irq);
392 synchronize_irq(irq);
394 EXPORT_SYMBOL(disable_irq);
397 * enable_irq - enable handling of an irq
398 * @irq: Interrupt to enable
400 * Undoes the effect of one call to disable_irq(). If this
401 * matches the last disable, processing of interrupts on this
402 * IRQ line is re-enabled.
404 * This function may be called from IRQ context.
407 void enable_irq(unsigned int irq)
409 irq_desc_t *desc = irq_descp(irq);
412 spin_lock_irqsave(&desc->lock, flags);
413 switch (desc->depth) {
415 unsigned int status = desc->status & ~IRQ_DISABLED;
416 desc->status = status;
417 if ((status & (IRQ_PENDING | IRQ_REPLAY)) == IRQ_PENDING) {
418 desc->status = status | IRQ_REPLAY;
419 hw_resend_irq(desc->handler,irq);
421 desc->handler->enable(irq);
428 printk(KERN_ERR "enable_irq(%u) unbalanced from %p\n",
429 irq, (void *) __builtin_return_address(0));
431 spin_unlock_irqrestore(&desc->lock, flags);
433 EXPORT_SYMBOL(enable_irq);
436 * do_IRQ handles all normal device IRQ's (the special
437 * SMP cross-CPU interrupts have their own specific
440 unsigned int do_IRQ(unsigned long irq, struct pt_regs *regs)
443 * We ack quickly, we don't want the irq controller
444 * thinking we're snobs just because some other CPU has
445 * disabled global interrupts (we have already done the
446 * INT_ACK cycles, it's too late to try to pretend to the
447 * controller that we aren't taking the interrupt).
449 * 0 return value means that this irq is already being
450 * handled by some other CPU. (or is disabled)
452 irq_desc_t *desc = irq_descp(irq);
453 struct irqaction * action;
454 irqreturn_t action_ret;
459 cpu = smp_processor_id(); /* for CONFIG_PREEMPT, this must come after irq_enter()! */
461 kstat_cpu(cpu).irqs[irq]++;
463 if (desc->status & IRQ_PER_CPU) {
464 /* no locking required for CPU-local interrupts: */
465 desc->handler->ack(irq);
466 action_ret = handle_IRQ_event(irq, regs, desc->action);
467 desc->handler->end(irq);
469 spin_lock(&desc->lock);
470 desc->handler->ack(irq);
472 * REPLAY is when Linux resends an IRQ that was dropped earlier
473 * WAITING is used by probe to mark irqs that are being tested
475 status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
476 status |= IRQ_PENDING; /* we _want_ to handle it */
479 * If the IRQ is disabled for whatever reason, we cannot
480 * use the action we have.
483 if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
484 action = desc->action;
485 status &= ~IRQ_PENDING; /* we commit to handling */
486 status |= IRQ_INPROGRESS; /* we are handling it */
488 desc->status = status;
491 * If there is no IRQ handler or it was disabled, exit early.
492 * Since we set PENDING, if another processor is handling
493 * a different instance of this same irq, the other processor
494 * will take care of it.
496 if (unlikely(!action))
500 * Edge triggered interrupts need to remember
502 * This applies to any hw interrupts that allow a second
503 * instance of the same irq to arrive while we are in do_IRQ
504 * or in the handler. But the code here only handles the _second_
505 * instance of the irq, not the third or fourth. So it is mostly
506 * useful for irq hardware that does not mask cleanly in an
510 spin_unlock(&desc->lock);
511 action_ret = handle_IRQ_event(irq, regs, action);
512 spin_lock(&desc->lock);
514 note_interrupt(irq, desc, action_ret);
515 if (!(desc->status & IRQ_PENDING))
517 desc->status &= ~IRQ_PENDING;
519 desc->status &= ~IRQ_INPROGRESS;
522 * The ->end() handler has to deal with interrupts which got
523 * disabled while the handler was running.
525 desc->handler->end(irq);
526 spin_unlock(&desc->lock);
533 * request_irq - allocate an interrupt line
534 * @irq: Interrupt line to allocate
535 * @handler: Function to be called when the IRQ occurs
536 * @irqflags: Interrupt type flags
537 * @devname: An ascii name for the claiming device
538 * @dev_id: A cookie passed back to the handler function
540 * This call allocates interrupt resources and enables the
541 * interrupt line and IRQ handling. From the point this
542 * call is made your handler function may be invoked. Since
543 * your handler function must clear any interrupt the board
544 * raises, you must take care both to initialise your hardware
545 * and to set up the interrupt handler in the right order.
547 * Dev_id must be globally unique. Normally the address of the
548 * device data structure is used as the cookie. Since the handler
549 * receives this value it makes sense to use it.
551 * If your interrupt is shared you must pass a non NULL dev_id
552 * as this is required when freeing the interrupt.
556 * SA_SHIRQ Interrupt is shared
558 * SA_INTERRUPT Disable local interrupts while processing
560 * SA_SAMPLE_RANDOM The interrupt can be used for entropy
564 int request_irq(unsigned int irq,
565 irqreturn_t (*handler)(int, void *, struct pt_regs *),
566 unsigned long irqflags,
567 const char * devname,
571 struct irqaction * action;
575 * Sanity-check: shared interrupts should REALLY pass in
576 * a real dev-ID, otherwise we'll have trouble later trying
577 * to figure out which interrupt is which (messes up the
578 * interrupt freeing logic etc).
580 if (irqflags & SA_SHIRQ) {
582 printk(KERN_ERR "Bad boy: %s called us without a dev_id!\n", devname);
591 action = (struct irqaction *)
592 kmalloc(sizeof(struct irqaction), GFP_ATOMIC);
596 action->handler = handler;
597 action->flags = irqflags;
599 action->name = devname;
601 action->dev_id = dev_id;
603 retval = setup_irq(irq, action);
609 EXPORT_SYMBOL(request_irq);
612 * free_irq - free an interrupt
613 * @irq: Interrupt line to free
614 * @dev_id: Device identity to free
616 * Remove an interrupt handler. The handler is removed and if the
617 * interrupt line is no longer in use by any driver it is disabled.
618 * On a shared IRQ the caller must ensure the interrupt is disabled
619 * on the card it drives before calling this function. The function
620 * does not return until any executing interrupts for this IRQ
623 * This function must not be called from interrupt context.
626 void free_irq(unsigned int irq, void *dev_id)
629 struct irqaction **p;
635 desc = irq_descp(irq);
636 spin_lock_irqsave(&desc->lock,flags);
639 struct irqaction * action = *p;
641 struct irqaction **pp = p;
643 if (action->dev_id != dev_id)
646 /* Found it - now remove it from the list of entries */
649 desc->status |= IRQ_DISABLED;
650 desc->handler->shutdown(irq);
652 spin_unlock_irqrestore(&desc->lock,flags);
654 /* Wait to make sure it's not being used on another CPU */
655 synchronize_irq(irq);
659 printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
660 spin_unlock_irqrestore(&desc->lock,flags);
665 EXPORT_SYMBOL(free_irq);
668 * IRQ autodetection code..
670 * This depends on the fact that any interrupt that
671 * comes in on to an unassigned handler will get stuck
672 * with "IRQ_WAITING" cleared and the interrupt
676 static DECLARE_MUTEX(probe_sem);
679 * probe_irq_on - begin an interrupt autodetect
681 * Commence probing for an interrupt. The interrupts are scanned
682 * and a mask of potential interrupt lines is returned.
686 unsigned long probe_irq_on(void)
695 * something may have generated an irq long ago and we want to
696 * flush such a longstanding irq before considering it as spurious.
698 for (i = NR_IRQS-1; i > 0; i--) {
701 spin_lock_irq(&desc->lock);
703 desc->handler->startup(i);
704 spin_unlock_irq(&desc->lock);
707 /* Wait for longstanding interrupts to trigger. */
708 for (delay = jiffies + HZ/50; time_after(delay, jiffies); )
709 /* about 20ms delay */ barrier();
712 * enable any unassigned irqs
713 * (we must startup again here because if a longstanding irq
714 * happened in the previous stage, it may have masked itself)
716 for (i = NR_IRQS-1; i > 0; i--) {
719 spin_lock_irq(&desc->lock);
721 desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
722 if (desc->handler->startup(i))
723 desc->status |= IRQ_PENDING;
725 spin_unlock_irq(&desc->lock);
729 * Wait for spurious interrupts to trigger
731 for (delay = jiffies + HZ/10; time_after(delay, jiffies); )
732 /* about 100ms delay */ barrier();
735 * Now filter out any obviously spurious interrupts
738 for (i = 0; i < NR_IRQS; i++) {
739 irq_desc_t *desc = irq_descp(i);
742 spin_lock_irq(&desc->lock);
743 status = desc->status;
745 if (status & IRQ_AUTODETECT) {
746 /* It triggered already - consider it spurious. */
747 if (!(status & IRQ_WAITING)) {
748 desc->status = status & ~IRQ_AUTODETECT;
749 desc->handler->shutdown(i);
754 spin_unlock_irq(&desc->lock);
760 EXPORT_SYMBOL(probe_irq_on);
763 * probe_irq_mask - scan a bitmap of interrupt lines
764 * @val: mask of interrupts to consider
766 * Scan the ISA bus interrupt lines and return a bitmap of
767 * active interrupts. The interrupt probe logic state is then
768 * returned to its previous value.
770 * Note: we need to scan all the irq's even though we will
771 * only return ISA irq numbers - just so that we reset them
772 * all to a known state.
774 unsigned int probe_irq_mask(unsigned long val)
780 for (i = 0; i < 16; i++) {
781 irq_desc_t *desc = irq_descp(i);
784 spin_lock_irq(&desc->lock);
785 status = desc->status;
787 if (status & IRQ_AUTODETECT) {
788 if (!(status & IRQ_WAITING))
791 desc->status = status & ~IRQ_AUTODETECT;
792 desc->handler->shutdown(i);
794 spin_unlock_irq(&desc->lock);
800 EXPORT_SYMBOL(probe_irq_mask);
803 * probe_irq_off - end an interrupt autodetect
804 * @val: mask of potential interrupts (unused)
806 * Scans the unused interrupt lines and returns the line which
807 * appears to have triggered the interrupt. If no interrupt was
808 * found then zero is returned. If more than one interrupt is
809 * found then minus the first candidate is returned to indicate
812 * The interrupt probe logic state is returned to its previous
815 * BUGS: When used in a module (which arguably shouldn't happen)
816 * nothing prevents two IRQ probe callers from overlapping. The
817 * results of this are non-optimal.
820 int probe_irq_off(unsigned long val)
822 int i, irq_found, nr_irqs;
826 for (i = 0; i < NR_IRQS; i++) {
827 irq_desc_t *desc = irq_descp(i);
830 spin_lock_irq(&desc->lock);
831 status = desc->status;
833 if (status & IRQ_AUTODETECT) {
834 if (!(status & IRQ_WAITING)) {
839 desc->status = status & ~IRQ_AUTODETECT;
840 desc->handler->shutdown(i);
842 spin_unlock_irq(&desc->lock);
847 irq_found = -irq_found;
851 EXPORT_SYMBOL(probe_irq_off);
853 int setup_irq(unsigned int irq, struct irqaction * new)
857 struct irqaction *old, **p;
858 irq_desc_t *desc = irq_descp(irq);
860 if (desc->handler == &no_irq_type)
863 * Some drivers like serial.c use request_irq() heavily,
864 * so we have to be careful not to interfere with a
867 if (new->flags & SA_SAMPLE_RANDOM) {
869 * This function might sleep, we want to call it first,
870 * outside of the atomic block.
871 * Yes, this might clear the entropy pool if the wrong
872 * driver is attempted to be loaded, without actually
873 * installing a new handler, but is this really a problem,
874 * only the sysadmin is able to do this.
876 rand_initialize_irq(irq);
879 if (new->flags & SA_PERCPU_IRQ) {
880 desc->status |= IRQ_PER_CPU;
881 desc->handler = &irq_type_ia64_lsapic;
885 * The following block of code has to be executed atomically
887 spin_lock_irqsave(&desc->lock,flags);
889 if ((old = *p) != NULL) {
890 /* Can't share interrupts unless both agree to */
891 if (!(old->flags & new->flags & SA_SHIRQ)) {
892 spin_unlock_irqrestore(&desc->lock,flags);
896 /* add new interrupt at end of irq queue */
908 desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS);
909 desc->handler->startup(irq);
911 spin_unlock_irqrestore(&desc->lock,flags);
913 register_irq_proc(irq);
917 static struct proc_dir_entry * root_irq_dir;
918 static struct proc_dir_entry * irq_dir [NR_IRQS];
922 static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
924 static cpumask_t irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
926 static char irq_redir [NR_IRQS]; // = { [0 ... NR_IRQS-1] = 1 };
928 void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
930 cpumask_t mask = CPU_MASK_NONE;
932 cpu_set(cpu_logical_id(hwid), mask);
935 irq_affinity[irq] = mask;
936 irq_redir[irq] = (char) (redir & 0xff);
940 static int irq_affinity_read_proc (char *page, char **start, off_t off,
941 int count, int *eof, void *data)
943 int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
946 len += sprintf(page + len, "\n");
950 static int irq_affinity_write_proc (struct file *file, const char *buffer,
951 unsigned long count, void *data)
953 unsigned int irq = (unsigned long) data;
954 int full_count = count, err;
955 cpumask_t new_value, tmp;
956 # define R_PREFIX_LEN 16
957 char rbuf[R_PREFIX_LEN];
960 irq_desc_t *desc = irq_descp(irq);
962 if (!desc->handler->set_affinity)
966 * If string being written starts with a prefix of 'r' or 'R'
967 * and some limited number of spaces, set IA64_IRQ_REDIRECTED.
968 * If more than (R_PREFIX_LEN - 2) spaces are passed, they won't
969 * all be trimmed as part of prelen, the untrimmed spaces will
970 * cause the hex parsing to fail, and this write() syscall will
976 rlen = min(sizeof(rbuf)-1, count);
977 if (copy_from_user(rbuf, buffer, rlen))
981 if (tolower(*rbuf) == 'r') {
982 prelen = strspn(rbuf, "Rr ");
983 irq |= IA64_IRQ_REDIRECTED;
986 err = cpumask_parse(buffer+prelen, count-prelen, new_value);
991 * Do not allow disabling IRQs completely - it's a too easy
992 * way to make the system unusable accidentally :-) At least
993 * one online CPU still has to be targeted.
995 cpus_and(tmp, new_value, cpu_online_map);
999 desc->handler->set_affinity(irq, new_value);
1003 #endif /* CONFIG_SMP */
1005 static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
1006 int count, int *eof, void *data)
1008 int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
1009 if (count - len < 2)
1011 len += sprintf(page + len, "\n");
1015 static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
1016 unsigned long count, void *data)
1018 cpumask_t *mask = (cpumask_t *)data;
1019 unsigned long full_count = count, err;
1020 cpumask_t new_value;
1022 err = cpumask_parse(buffer, count, new_value);
1030 #define MAX_NAMELEN 10
1032 static void register_irq_proc (unsigned int irq)
1034 char name [MAX_NAMELEN];
1036 if (!root_irq_dir || (irq_descp(irq)->handler == &no_irq_type) || irq_dir[irq])
1039 memset(name, 0, MAX_NAMELEN);
1040 sprintf(name, "%d", irq);
1042 /* create /proc/irq/1234 */
1043 irq_dir[irq] = proc_mkdir(name, root_irq_dir);
1047 struct proc_dir_entry *entry;
1049 /* create /proc/irq/1234/smp_affinity */
1050 entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
1054 entry->data = (void *)(long)irq;
1055 entry->read_proc = irq_affinity_read_proc;
1056 entry->write_proc = irq_affinity_write_proc;
1059 smp_affinity_entry[irq] = entry;
1064 cpumask_t prof_cpu_mask = CPU_MASK_ALL;
1066 void init_irq_proc (void)
1068 struct proc_dir_entry *entry;
1071 /* create /proc/irq */
1072 root_irq_dir = proc_mkdir("irq", 0);
1074 /* create /proc/irq/prof_cpu_mask */
1075 entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
1081 entry->data = (void *)&prof_cpu_mask;
1082 entry->read_proc = prof_cpu_mask_read_proc;
1083 entry->write_proc = prof_cpu_mask_write_proc;
1086 * Create entries for all existing IRQs.
1088 for (i = 0; i < NR_IRQS; i++) {
1089 if (irq_descp(i)->handler == &no_irq_type)
1091 register_irq_proc(i);