]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/x86/kernel/irq_64.c
x86: unify show_interrupts() and proc helpers
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / irq_64.c
1 /*
2  *      Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
3  *
4  * This file contains the lowest level x86_64-specific interrupt
5  * entry and irq statistics code. All the remaining irq logic is
6  * done by the generic kernel/irq/ code and in the
7  * x86_64-specific irq controller code. (e.g. i8259.c and
8  * io_apic.c.)
9  */
10
11 #include <linux/kernel_stat.h>
12 #include <linux/interrupt.h>
13 #include <linux/seq_file.h>
14 #include <linux/module.h>
15 #include <linux/delay.h>
16 #include <asm/uaccess.h>
17 #include <asm/io_apic.h>
18 #include <asm/idle.h>
19 #include <asm/smp.h>
20
21 /*
22  * 'what should we do if we get a hw irq event on an illegal vector'.
23  * each architecture has to answer this themselves.
24  */
25 void ack_bad_irq(unsigned int irq)
26 {
27         printk(KERN_WARNING "unexpected IRQ trap at vector %02x\n", irq);
28         /*
29          * Currently unexpected vectors happen only on SMP and APIC.
30          * We _must_ ack these because every local APIC has only N
31          * irq slots per priority level, and a 'hanging, unacked' IRQ
32          * holds up an irq slot - in excessive cases (when multiple
33          * unexpected vectors occur) that might lock up the APIC
34          * completely.
35          * But don't ack when the APIC is disabled. -AK
36          */
37         if (!disable_apic)
38                 ack_APIC_irq();
39 }
40
41 #ifdef CONFIG_DEBUG_STACKOVERFLOW
42 /*
43  * Probabilistic stack overflow check:
44  *
45  * Only check the stack in process context, because everything else
46  * runs on the big interrupt stacks. Checking reliably is too expensive,
47  * so we just check from interrupts.
48  */
49 static inline void stack_overflow_check(struct pt_regs *regs)
50 {
51         u64 curbase = (u64)task_stack_page(current);
52         static unsigned long warned = -60*HZ;
53
54         if (regs->sp >= curbase && regs->sp <= curbase + THREAD_SIZE &&
55             regs->sp <  curbase + sizeof(struct thread_info) + 128 &&
56             time_after(jiffies, warned + 60*HZ)) {
57                 printk("do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n",
58                        current->comm, curbase, regs->sp);
59                 show_stack(NULL,NULL);
60                 warned = jiffies;
61         }
62 }
63 #endif
64
65 /*
66  * do_IRQ handles all normal device IRQ's (the special
67  * SMP cross-CPU interrupts have their own specific
68  * handlers).
69  */
70 asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
71 {
72         struct pt_regs *old_regs = set_irq_regs(regs);
73         struct irq_desc *desc;
74
75         /* high bit used in ret_from_ code  */
76         unsigned vector = ~regs->orig_ax;
77         unsigned irq;
78
79         exit_idle();
80         irq_enter();
81         irq = __get_cpu_var(vector_irq)[vector];
82
83 #ifdef CONFIG_DEBUG_STACKOVERFLOW
84         stack_overflow_check(regs);
85 #endif
86
87         desc = irq_to_desc(irq);
88         if (likely(desc))
89                 generic_handle_irq_desc(irq, desc);
90         else {
91                 if (!disable_apic)
92                         ack_APIC_irq();
93
94                 if (printk_ratelimit())
95                         printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
96                                 __func__, smp_processor_id(), vector);
97         }
98
99         irq_exit();
100
101         set_irq_regs(old_regs);
102         return 1;
103 }
104
105 #ifdef CONFIG_HOTPLUG_CPU
106 void fixup_irqs(cpumask_t map)
107 {
108         unsigned int irq;
109         static int warned;
110         struct irq_desc *desc;
111
112         for_each_irq_desc(irq, desc) {
113                 cpumask_t mask;
114                 int break_affinity = 0;
115                 int set_affinity = 1;
116
117                 if (irq == 2)
118                         continue;
119
120                 /* interrupt's are disabled at this point */
121                 spin_lock(&desc->lock);
122
123                 if (!irq_has_action(irq) ||
124                     cpus_equal(desc->affinity, map)) {
125                         spin_unlock(&desc->lock);
126                         continue;
127                 }
128
129                 cpus_and(mask, desc->affinity, map);
130                 if (cpus_empty(mask)) {
131                         break_affinity = 1;
132                         mask = map;
133                 }
134
135                 if (desc->chip->mask)
136                         desc->chip->mask(irq);
137
138                 if (desc->chip->set_affinity)
139                         desc->chip->set_affinity(irq, mask);
140                 else if (!(warned++))
141                         set_affinity = 0;
142
143                 if (desc->chip->unmask)
144                         desc->chip->unmask(irq);
145
146                 spin_unlock(&desc->lock);
147
148                 if (break_affinity && set_affinity)
149                         printk("Broke affinity for irq %i\n", irq);
150                 else if (!set_affinity)
151                         printk("Cannot set affinity for irq %i\n", irq);
152         }
153
154         /* That doesn't seem sufficient.  Give it 1ms. */
155         local_irq_enable();
156         mdelay(1);
157         local_irq_disable();
158 }
159 #endif
160
161 extern void call_softirq(void);
162
163 asmlinkage void do_softirq(void)
164 {
165         __u32 pending;
166         unsigned long flags;
167
168         if (in_interrupt())
169                 return;
170
171         local_irq_save(flags);
172         pending = local_softirq_pending();
173         /* Switch to interrupt stack */
174         if (pending) {
175                 call_softirq();
176                 WARN_ON_ONCE(softirq_count());
177         }
178         local_irq_restore(flags);
179 }