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;
458 cpu = smp_processor_id(); /* for CONFIG_PREEMPT, this must come after irq_enter()! */
460 kstat_cpu(cpu).irqs[irq]++;
462 if (desc->status & IRQ_PER_CPU) {
463 /* no locking required for CPU-local interrupts: */
464 desc->handler->ack(irq);
465 action_ret = handle_IRQ_event(irq, regs, desc->action);
466 desc->handler->end(irq);
468 spin_lock(&desc->lock);
469 desc->handler->ack(irq);
471 * REPLAY is when Linux resends an IRQ that was dropped earlier
472 * WAITING is used by probe to mark irqs that are being tested
474 status = desc->status & ~(IRQ_REPLAY | IRQ_WAITING);
475 status |= IRQ_PENDING; /* we _want_ to handle it */
478 * If the IRQ is disabled for whatever reason, we cannot
479 * use the action we have.
482 if (likely(!(status & (IRQ_DISABLED | IRQ_INPROGRESS)))) {
483 action = desc->action;
484 status &= ~IRQ_PENDING; /* we commit to handling */
485 status |= IRQ_INPROGRESS; /* we are handling it */
487 desc->status = status;
490 * If there is no IRQ handler or it was disabled, exit early.
491 * Since we set PENDING, if another processor is handling
492 * a different instance of this same irq, the other processor
493 * will take care of it.
495 if (unlikely(!action))
499 * Edge triggered interrupts need to remember
501 * This applies to any hw interrupts that allow a second
502 * instance of the same irq to arrive while we are in do_IRQ
503 * or in the handler. But the code here only handles the _second_
504 * instance of the irq, not the third or fourth. So it is mostly
505 * useful for irq hardware that does not mask cleanly in an
509 spin_unlock(&desc->lock);
510 action_ret = handle_IRQ_event(irq, regs, action);
511 spin_lock(&desc->lock);
513 note_interrupt(irq, desc, action_ret);
514 if (!(desc->status & IRQ_PENDING))
516 desc->status &= ~IRQ_PENDING;
518 desc->status &= ~IRQ_INPROGRESS;
521 * The ->end() handler has to deal with interrupts which got
522 * disabled while the handler was running.
524 desc->handler->end(irq);
525 spin_unlock(&desc->lock);
531 * request_irq - allocate an interrupt line
532 * @irq: Interrupt line to allocate
533 * @handler: Function to be called when the IRQ occurs
534 * @irqflags: Interrupt type flags
535 * @devname: An ascii name for the claiming device
536 * @dev_id: A cookie passed back to the handler function
538 * This call allocates interrupt resources and enables the
539 * interrupt line and IRQ handling. From the point this
540 * call is made your handler function may be invoked. Since
541 * your handler function must clear any interrupt the board
542 * raises, you must take care both to initialise your hardware
543 * and to set up the interrupt handler in the right order.
545 * Dev_id must be globally unique. Normally the address of the
546 * device data structure is used as the cookie. Since the handler
547 * receives this value it makes sense to use it.
549 * If your interrupt is shared you must pass a non NULL dev_id
550 * as this is required when freeing the interrupt.
554 * SA_SHIRQ Interrupt is shared
556 * SA_INTERRUPT Disable local interrupts while processing
558 * SA_SAMPLE_RANDOM The interrupt can be used for entropy
562 int request_irq(unsigned int irq,
563 irqreturn_t (*handler)(int, void *, struct pt_regs *),
564 unsigned long irqflags,
565 const char * devname,
569 struct irqaction * action;
573 * Sanity-check: shared interrupts should REALLY pass in
574 * a real dev-ID, otherwise we'll have trouble later trying
575 * to figure out which interrupt is which (messes up the
576 * interrupt freeing logic etc).
578 if (irqflags & SA_SHIRQ) {
580 printk(KERN_ERR "Bad boy: %s called us without a dev_id!\n", devname);
589 action = (struct irqaction *)
590 kmalloc(sizeof(struct irqaction), GFP_ATOMIC);
594 action->handler = handler;
595 action->flags = irqflags;
597 action->name = devname;
599 action->dev_id = dev_id;
601 retval = setup_irq(irq, action);
607 EXPORT_SYMBOL(request_irq);
610 * free_irq - free an interrupt
611 * @irq: Interrupt line to free
612 * @dev_id: Device identity to free
614 * Remove an interrupt handler. The handler is removed and if the
615 * interrupt line is no longer in use by any driver it is disabled.
616 * On a shared IRQ the caller must ensure the interrupt is disabled
617 * on the card it drives before calling this function. The function
618 * does not return until any executing interrupts for this IRQ
621 * This function must not be called from interrupt context.
624 void free_irq(unsigned int irq, void *dev_id)
627 struct irqaction **p;
633 desc = irq_descp(irq);
634 spin_lock_irqsave(&desc->lock,flags);
637 struct irqaction * action = *p;
639 struct irqaction **pp = p;
641 if (action->dev_id != dev_id)
644 /* Found it - now remove it from the list of entries */
647 desc->status |= IRQ_DISABLED;
648 desc->handler->shutdown(irq);
650 spin_unlock_irqrestore(&desc->lock,flags);
652 /* Wait to make sure it's not being used on another CPU */
653 synchronize_irq(irq);
657 printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
658 spin_unlock_irqrestore(&desc->lock,flags);
663 EXPORT_SYMBOL(free_irq);
666 * IRQ autodetection code..
668 * This depends on the fact that any interrupt that
669 * comes in on to an unassigned handler will get stuck
670 * with "IRQ_WAITING" cleared and the interrupt
674 static DECLARE_MUTEX(probe_sem);
677 * probe_irq_on - begin an interrupt autodetect
679 * Commence probing for an interrupt. The interrupts are scanned
680 * and a mask of potential interrupt lines is returned.
684 unsigned long probe_irq_on(void)
693 * something may have generated an irq long ago and we want to
694 * flush such a longstanding irq before considering it as spurious.
696 for (i = NR_IRQS-1; i > 0; i--) {
699 spin_lock_irq(&desc->lock);
701 desc->handler->startup(i);
702 spin_unlock_irq(&desc->lock);
705 /* Wait for longstanding interrupts to trigger. */
706 for (delay = jiffies + HZ/50; time_after(delay, jiffies); )
707 /* about 20ms delay */ barrier();
710 * enable any unassigned irqs
711 * (we must startup again here because if a longstanding irq
712 * happened in the previous stage, it may have masked itself)
714 for (i = NR_IRQS-1; i > 0; i--) {
717 spin_lock_irq(&desc->lock);
719 desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
720 if (desc->handler->startup(i))
721 desc->status |= IRQ_PENDING;
723 spin_unlock_irq(&desc->lock);
727 * Wait for spurious interrupts to trigger
729 for (delay = jiffies + HZ/10; time_after(delay, jiffies); )
730 /* about 100ms delay */ barrier();
733 * Now filter out any obviously spurious interrupts
736 for (i = 0; i < NR_IRQS; i++) {
737 irq_desc_t *desc = irq_descp(i);
740 spin_lock_irq(&desc->lock);
741 status = desc->status;
743 if (status & IRQ_AUTODETECT) {
744 /* It triggered already - consider it spurious. */
745 if (!(status & IRQ_WAITING)) {
746 desc->status = status & ~IRQ_AUTODETECT;
747 desc->handler->shutdown(i);
752 spin_unlock_irq(&desc->lock);
758 EXPORT_SYMBOL(probe_irq_on);
761 * probe_irq_mask - scan a bitmap of interrupt lines
762 * @val: mask of interrupts to consider
764 * Scan the ISA bus interrupt lines and return a bitmap of
765 * active interrupts. The interrupt probe logic state is then
766 * returned to its previous value.
768 * Note: we need to scan all the irq's even though we will
769 * only return ISA irq numbers - just so that we reset them
770 * all to a known state.
772 unsigned int probe_irq_mask(unsigned long val)
778 for (i = 0; i < 16; i++) {
779 irq_desc_t *desc = irq_descp(i);
782 spin_lock_irq(&desc->lock);
783 status = desc->status;
785 if (status & IRQ_AUTODETECT) {
786 if (!(status & IRQ_WAITING))
789 desc->status = status & ~IRQ_AUTODETECT;
790 desc->handler->shutdown(i);
792 spin_unlock_irq(&desc->lock);
798 EXPORT_SYMBOL(probe_irq_mask);
801 * probe_irq_off - end an interrupt autodetect
802 * @val: mask of potential interrupts (unused)
804 * Scans the unused interrupt lines and returns the line which
805 * appears to have triggered the interrupt. If no interrupt was
806 * found then zero is returned. If more than one interrupt is
807 * found then minus the first candidate is returned to indicate
810 * The interrupt probe logic state is returned to its previous
813 * BUGS: When used in a module (which arguably shouldn't happen)
814 * nothing prevents two IRQ probe callers from overlapping. The
815 * results of this are non-optimal.
818 int probe_irq_off(unsigned long val)
820 int i, irq_found, nr_irqs;
824 for (i = 0; i < NR_IRQS; i++) {
825 irq_desc_t *desc = irq_descp(i);
828 spin_lock_irq(&desc->lock);
829 status = desc->status;
831 if (status & IRQ_AUTODETECT) {
832 if (!(status & IRQ_WAITING)) {
837 desc->status = status & ~IRQ_AUTODETECT;
838 desc->handler->shutdown(i);
840 spin_unlock_irq(&desc->lock);
845 irq_found = -irq_found;
849 EXPORT_SYMBOL(probe_irq_off);
851 int setup_irq(unsigned int irq, struct irqaction * new)
855 struct irqaction *old, **p;
856 irq_desc_t *desc = irq_descp(irq);
858 if (desc->handler == &no_irq_type)
861 * Some drivers like serial.c use request_irq() heavily,
862 * so we have to be careful not to interfere with a
865 if (new->flags & SA_SAMPLE_RANDOM) {
867 * This function might sleep, we want to call it first,
868 * outside of the atomic block.
869 * Yes, this might clear the entropy pool if the wrong
870 * driver is attempted to be loaded, without actually
871 * installing a new handler, but is this really a problem,
872 * only the sysadmin is able to do this.
874 rand_initialize_irq(irq);
877 if (new->flags & SA_PERCPU_IRQ) {
878 desc->status |= IRQ_PER_CPU;
879 desc->handler = &irq_type_ia64_lsapic;
883 * The following block of code has to be executed atomically
885 spin_lock_irqsave(&desc->lock,flags);
887 if ((old = *p) != NULL) {
888 /* Can't share interrupts unless both agree to */
889 if (!(old->flags & new->flags & SA_SHIRQ)) {
890 spin_unlock_irqrestore(&desc->lock,flags);
894 /* add new interrupt at end of irq queue */
906 desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS);
907 desc->handler->startup(irq);
909 spin_unlock_irqrestore(&desc->lock,flags);
911 register_irq_proc(irq);
915 static struct proc_dir_entry * root_irq_dir;
916 static struct proc_dir_entry * irq_dir [NR_IRQS];
920 static struct proc_dir_entry * smp_affinity_entry [NR_IRQS];
922 static cpumask_t irq_affinity [NR_IRQS] = { [0 ... NR_IRQS-1] = CPU_MASK_ALL };
924 static char irq_redir [NR_IRQS]; // = { [0 ... NR_IRQS-1] = 1 };
926 void set_irq_affinity_info (unsigned int irq, int hwid, int redir)
928 cpumask_t mask = CPU_MASK_NONE;
930 cpu_set(cpu_logical_id(hwid), mask);
933 irq_affinity[irq] = mask;
934 irq_redir[irq] = (char) (redir & 0xff);
938 static int irq_affinity_read_proc (char *page, char **start, off_t off,
939 int count, int *eof, void *data)
941 int len = cpumask_scnprintf(page, count, irq_affinity[(long)data]);
944 len += sprintf(page + len, "\n");
948 static int irq_affinity_write_proc (struct file *file, const char *buffer,
949 unsigned long count, void *data)
951 unsigned int irq = (unsigned long) data;
952 int full_count = count, err;
953 cpumask_t new_value, tmp;
954 # define R_PREFIX_LEN 16
955 char rbuf[R_PREFIX_LEN];
958 irq_desc_t *desc = irq_descp(irq);
960 if (!desc->handler->set_affinity)
964 * If string being written starts with a prefix of 'r' or 'R'
965 * and some limited number of spaces, set IA64_IRQ_REDIRECTED.
966 * If more than (R_PREFIX_LEN - 2) spaces are passed, they won't
967 * all be trimmed as part of prelen, the untrimmed spaces will
968 * cause the hex parsing to fail, and this write() syscall will
974 rlen = min(sizeof(rbuf)-1, count);
975 if (copy_from_user(rbuf, buffer, rlen))
979 if (tolower(*rbuf) == 'r') {
980 prelen = strspn(rbuf, "Rr ");
981 irq |= IA64_IRQ_REDIRECTED;
984 err = cpumask_parse(buffer+prelen, count-prelen, new_value);
989 * Do not allow disabling IRQs completely - it's a too easy
990 * way to make the system unusable accidentally :-) At least
991 * one online CPU still has to be targeted.
993 cpus_and(tmp, new_value, cpu_online_map);
997 desc->handler->set_affinity(irq, new_value);
1001 #endif /* CONFIG_SMP */
1003 static int prof_cpu_mask_read_proc (char *page, char **start, off_t off,
1004 int count, int *eof, void *data)
1006 int len = cpumask_scnprintf(page, count, *(cpumask_t *)data);
1007 if (count - len < 2)
1009 len += sprintf(page + len, "\n");
1013 static int prof_cpu_mask_write_proc (struct file *file, const char *buffer,
1014 unsigned long count, void *data)
1016 cpumask_t *mask = (cpumask_t *)data;
1017 unsigned long full_count = count, err;
1018 cpumask_t new_value;
1020 err = cpumask_parse(buffer, count, new_value);
1028 #define MAX_NAMELEN 10
1030 static void register_irq_proc (unsigned int irq)
1032 char name [MAX_NAMELEN];
1034 if (!root_irq_dir || (irq_descp(irq)->handler == &no_irq_type) || irq_dir[irq])
1037 memset(name, 0, MAX_NAMELEN);
1038 sprintf(name, "%d", irq);
1040 /* create /proc/irq/1234 */
1041 irq_dir[irq] = proc_mkdir(name, root_irq_dir);
1045 struct proc_dir_entry *entry;
1047 /* create /proc/irq/1234/smp_affinity */
1048 entry = create_proc_entry("smp_affinity", 0600, irq_dir[irq]);
1052 entry->data = (void *)(long)irq;
1053 entry->read_proc = irq_affinity_read_proc;
1054 entry->write_proc = irq_affinity_write_proc;
1057 smp_affinity_entry[irq] = entry;
1062 cpumask_t prof_cpu_mask = CPU_MASK_ALL;
1064 void init_irq_proc (void)
1066 struct proc_dir_entry *entry;
1069 /* create /proc/irq */
1070 root_irq_dir = proc_mkdir("irq", 0);
1072 /* create /proc/irq/prof_cpu_mask */
1073 entry = create_proc_entry("prof_cpu_mask", 0600, root_irq_dir);
1079 entry->data = (void *)&prof_cpu_mask;
1080 entry->read_proc = prof_cpu_mask_read_proc;
1081 entry->write_proc = prof_cpu_mask_write_proc;
1084 * Create entries for all existing IRQs.
1086 for (i = 0; i < NR_IRQS; i++) {
1087 if (irq_descp(i)->handler == &no_irq_type)
1089 register_irq_proc(i);