]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/x86/kernel/irq_64.c
Merge branch 'x86/iommu' into x86/core
[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  * Probabilistic stack overflow check:
23  *
24  * Only check the stack in process context, because everything else
25  * runs on the big interrupt stacks. Checking reliably is too expensive,
26  * so we just check from interrupts.
27  */
28 static inline void stack_overflow_check(struct pt_regs *regs)
29 {
30 #ifdef CONFIG_DEBUG_STACKOVERFLOW
31         u64 curbase = (u64)task_stack_page(current);
32
33         WARN_ONCE(regs->sp >= curbase &&
34                   regs->sp <= curbase + THREAD_SIZE &&
35                   regs->sp <  curbase + sizeof(struct thread_info) +
36                                         sizeof(struct pt_regs) + 128,
37
38                   "do_IRQ: %s near stack overflow (cur:%Lx,sp:%lx)\n",
39                         current->comm, curbase, regs->sp);
40 #endif
41 }
42
43 /*
44  * do_IRQ handles all normal device IRQ's (the special
45  * SMP cross-CPU interrupts have their own specific
46  * handlers).
47  */
48 asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
49 {
50         struct pt_regs *old_regs = set_irq_regs(regs);
51         struct irq_desc *desc;
52
53         /* high bit used in ret_from_ code  */
54         unsigned vector = ~regs->orig_ax;
55         unsigned irq;
56
57         exit_idle();
58         irq_enter();
59         irq = __get_cpu_var(vector_irq)[vector];
60
61         stack_overflow_check(regs);
62
63         desc = irq_to_desc(irq);
64         if (likely(desc))
65                 generic_handle_irq_desc(irq, desc);
66         else {
67                 if (!disable_apic)
68                         ack_APIC_irq();
69
70                 if (printk_ratelimit())
71                         printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
72                                 __func__, smp_processor_id(), vector);
73         }
74
75         irq_exit();
76
77         set_irq_regs(old_regs);
78         return 1;
79 }
80
81 #ifdef CONFIG_HOTPLUG_CPU
82 void fixup_irqs(cpumask_t map)
83 {
84         unsigned int irq;
85         static int warned;
86         struct irq_desc *desc;
87
88         for_each_irq_desc(irq, desc) {
89                 cpumask_t mask;
90                 int break_affinity = 0;
91                 int set_affinity = 1;
92
93                 if (irq == 2)
94                         continue;
95
96                 /* interrupt's are disabled at this point */
97                 spin_lock(&desc->lock);
98
99                 if (!irq_has_action(irq) ||
100                     cpus_equal(desc->affinity, map)) {
101                         spin_unlock(&desc->lock);
102                         continue;
103                 }
104
105                 cpus_and(mask, desc->affinity, map);
106                 if (cpus_empty(mask)) {
107                         break_affinity = 1;
108                         mask = map;
109                 }
110
111                 if (desc->chip->mask)
112                         desc->chip->mask(irq);
113
114                 if (desc->chip->set_affinity)
115                         desc->chip->set_affinity(irq, mask);
116                 else if (!(warned++))
117                         set_affinity = 0;
118
119                 if (desc->chip->unmask)
120                         desc->chip->unmask(irq);
121
122                 spin_unlock(&desc->lock);
123
124                 if (break_affinity && set_affinity)
125                         printk("Broke affinity for irq %i\n", irq);
126                 else if (!set_affinity)
127                         printk("Cannot set affinity for irq %i\n", irq);
128         }
129
130         /* That doesn't seem sufficient.  Give it 1ms. */
131         local_irq_enable();
132         mdelay(1);
133         local_irq_disable();
134 }
135 #endif
136
137 extern void call_softirq(void);
138
139 asmlinkage void do_softirq(void)
140 {
141         __u32 pending;
142         unsigned long flags;
143
144         if (in_interrupt())
145                 return;
146
147         local_irq_save(flags);
148         pending = local_softirq_pending();
149         /* Switch to interrupt stack */
150         if (pending) {
151                 call_softirq();
152                 WARN_ON_ONCE(softirq_count());
153         }
154         local_irq_restore(flags);
155 }