Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar |
| 3 | * |
| 4 | * This file contains the lowest level x86-specific interrupt |
| 5 | * entry, irq-stacks and irq statistics code. All the remaining |
| 6 | * irq logic is done by the generic kernel/irq/ code and |
| 7 | * by the x86-specific irq controller code. (e.g. i8259.c and |
| 8 | * io_apic.c.) |
| 9 | */ |
| 10 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/module.h> |
| 12 | #include <linux/seq_file.h> |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/kernel_stat.h> |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 15 | #include <linux/notifier.h> |
| 16 | #include <linux/cpu.h> |
| 17 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Thomas Gleixner | e05d723 | 2007-02-16 01:27:58 -0800 | [diff] [blame] | 19 | #include <asm/apic.h> |
| 20 | #include <asm/uaccess.h> |
| 21 | |
Fenghua Yu | f34e3b6 | 2007-07-19 01:48:13 -0700 | [diff] [blame] | 22 | DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | EXPORT_PER_CPU_SYMBOL(irq_stat); |
| 24 | |
Jeremy Fitzhardinge | 7c3576d | 2007-05-02 19:27:16 +0200 | [diff] [blame] | 25 | DEFINE_PER_CPU(struct pt_regs *, irq_regs); |
| 26 | EXPORT_PER_CPU_SYMBOL(irq_regs); |
| 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | /* |
| 29 | * 'what should we do if we get a hw irq event on an illegal vector'. |
| 30 | * each architecture has to answer this themselves. |
| 31 | */ |
| 32 | void ack_bad_irq(unsigned int irq) |
| 33 | { |
Thomas Gleixner | e05d723 | 2007-02-16 01:27:58 -0800 | [diff] [blame] | 34 | printk(KERN_ERR "unexpected IRQ trap at vector %02x\n", irq); |
| 35 | |
| 36 | #ifdef CONFIG_X86_LOCAL_APIC |
| 37 | /* |
| 38 | * Currently unexpected vectors happen only on SMP and APIC. |
| 39 | * We _must_ ack these because every local APIC has only N |
| 40 | * irq slots per priority level, and a 'hanging, unacked' IRQ |
| 41 | * holds up an irq slot - in excessive cases (when multiple |
| 42 | * unexpected vectors occur) that might lock up the APIC |
| 43 | * completely. |
| 44 | * But only ack when the APIC is enabled -AK |
| 45 | */ |
| 46 | if (cpu_has_apic) |
| 47 | ack_APIC_irq(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #endif |
Thomas Gleixner | e05d723 | 2007-02-16 01:27:58 -0800 | [diff] [blame] | 49 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
| 51 | #ifdef CONFIG_4KSTACKS |
| 52 | /* |
| 53 | * per-CPU IRQ handling contexts (thread information and stack) |
| 54 | */ |
| 55 | union irq_ctx { |
| 56 | struct thread_info tinfo; |
| 57 | u32 stack[THREAD_SIZE/sizeof(u32)]; |
| 58 | }; |
| 59 | |
Andreas Mohr | 2272205 | 2006-06-23 02:05:30 -0700 | [diff] [blame] | 60 | static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly; |
| 61 | static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | #endif |
| 63 | |
Andi Kleen | 04b361a | 2008-05-05 12:36:38 +0200 | [diff] [blame^] | 64 | static void stack_overflow(void) |
| 65 | { |
| 66 | printk("low stack detected by irq handler\n"); |
| 67 | dump_stack(); |
| 68 | } |
| 69 | |
| 70 | static inline void call_on_stack2(void *func, void *stack, |
| 71 | unsigned long arg1, unsigned long arg2) |
| 72 | { |
| 73 | unsigned long bx; |
| 74 | asm volatile( |
| 75 | " xchgl %%ebx,%%esp \n" |
| 76 | " call *%%edi \n" |
| 77 | " movl %%ebx,%%esp \n" |
| 78 | : "=a" (arg1), "=d" (arg2), "=b" (bx) |
| 79 | : "0" (arg1), "1" (arg2), "2" (stack), |
| 80 | "D" (func) |
| 81 | : "memory", "cc", "ecx"); |
| 82 | } |
| 83 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | /* |
| 85 | * do_IRQ handles all normal device IRQ's (the special |
| 86 | * SMP cross-CPU interrupts have their own specific |
| 87 | * handlers). |
| 88 | */ |
Harvey Harrison | 75604d7 | 2008-01-30 13:31:17 +0100 | [diff] [blame] | 89 | unsigned int do_IRQ(struct pt_regs *regs) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | { |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 91 | struct pt_regs *old_regs; |
Rusty Russell | 19eadf9 | 2006-06-27 02:53:44 -0700 | [diff] [blame] | 92 | /* high bit used in ret_from_ code */ |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 93 | int irq = ~regs->orig_ax; |
Ingo Molnar | f5b9ed7 | 2006-10-04 02:16:26 -0700 | [diff] [blame] | 94 | struct irq_desc *desc = irq_desc + irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | #ifdef CONFIG_4KSTACKS |
| 96 | union irq_ctx *curctx, *irqctx; |
| 97 | u32 *isp; |
| 98 | #endif |
Andi Kleen | 04b361a | 2008-05-05 12:36:38 +0200 | [diff] [blame^] | 99 | int overflow = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Andrew Morton | a052b68 | 2006-06-28 04:26:43 -0700 | [diff] [blame] | 101 | if (unlikely((unsigned)irq >= NR_IRQS)) { |
| 102 | printk(KERN_EMERG "%s: cannot handle IRQ %d\n", |
Harvey Harrison | 77bf90e | 2008-03-03 11:37:23 -0800 | [diff] [blame] | 103 | __func__, irq); |
Andrew Morton | a052b68 | 2006-06-28 04:26:43 -0700 | [diff] [blame] | 104 | BUG(); |
| 105 | } |
| 106 | |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 107 | old_regs = set_irq_regs(regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | irq_enter(); |
| 109 | #ifdef CONFIG_DEBUG_STACKOVERFLOW |
| 110 | /* Debugging check for stack overflow: is there less than 1KB free? */ |
| 111 | { |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 112 | long sp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | __asm__ __volatile__("andl %%esp,%0" : |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 115 | "=r" (sp) : "0" (THREAD_SIZE - 1)); |
Andi Kleen | 04b361a | 2008-05-05 12:36:38 +0200 | [diff] [blame^] | 116 | if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) |
| 117 | overflow = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | } |
| 119 | #endif |
| 120 | |
| 121 | #ifdef CONFIG_4KSTACKS |
| 122 | |
| 123 | curctx = (union irq_ctx *) current_thread_info(); |
| 124 | irqctx = hardirq_ctx[smp_processor_id()]; |
| 125 | |
| 126 | /* |
| 127 | * this is where we switch to the IRQ stack. However, if we are |
| 128 | * already using the IRQ stack (because we interrupted a hardirq |
| 129 | * handler) we can't do that and just have to keep using the |
| 130 | * current stack (which is the irq stack already after all) |
| 131 | */ |
| 132 | if (curctx != irqctx) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | /* build the stack frame on the IRQ stack */ |
| 134 | isp = (u32*) ((char*)irqctx + sizeof(*irqctx)); |
| 135 | irqctx->tinfo.task = curctx->tinfo.task; |
| 136 | irqctx->tinfo.previous_esp = current_stack_pointer; |
| 137 | |
Björn Steinbrink | a5d157e | 2006-06-25 16:24:40 +0200 | [diff] [blame] | 138 | /* |
| 139 | * Copy the softirq bits in preempt_count so that the |
| 140 | * softirq checks work in the hardirq context. |
| 141 | */ |
| 142 | irqctx->tinfo.preempt_count = |
Andrew Morton | 91bf460 | 2006-06-27 02:55:09 -0700 | [diff] [blame] | 143 | (irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) | |
| 144 | (curctx->tinfo.preempt_count & SOFTIRQ_MASK); |
Björn Steinbrink | a5d157e | 2006-06-25 16:24:40 +0200 | [diff] [blame] | 145 | |
Andi Kleen | 04b361a | 2008-05-05 12:36:38 +0200 | [diff] [blame^] | 146 | /* Execute warning on interrupt stack */ |
| 147 | if (unlikely(overflow)) |
| 148 | call_on_stack2(stack_overflow, isp, 0, 0); |
| 149 | |
| 150 | call_on_stack2(desc->handle_irq, isp, irq, (unsigned long)desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | } else |
| 152 | #endif |
Andi Kleen | 04b361a | 2008-05-05 12:36:38 +0200 | [diff] [blame^] | 153 | { |
| 154 | /* AK: Slightly bogus here */ |
| 155 | if (overflow) |
| 156 | stack_overflow(); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 157 | desc->handle_irq(irq, desc); |
Andi Kleen | 04b361a | 2008-05-05 12:36:38 +0200 | [diff] [blame^] | 158 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | |
| 160 | irq_exit(); |
David Howells | 7d12e78 | 2006-10-05 14:55:46 +0100 | [diff] [blame] | 161 | set_irq_regs(old_regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | return 1; |
| 163 | } |
| 164 | |
| 165 | #ifdef CONFIG_4KSTACKS |
| 166 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | static char softirq_stack[NR_CPUS * THREAD_SIZE] |
Robert P. J. Day | 09fce8a | 2007-07-21 17:11:41 +0200 | [diff] [blame] | 168 | __attribute__((__section__(".bss.page_aligned"))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
| 170 | static char hardirq_stack[NR_CPUS * THREAD_SIZE] |
Robert P. J. Day | 09fce8a | 2007-07-21 17:11:41 +0200 | [diff] [blame] | 171 | __attribute__((__section__(".bss.page_aligned"))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | |
| 173 | /* |
| 174 | * allocate per-cpu stacks for hardirq and for softirq processing |
| 175 | */ |
| 176 | void irq_ctx_init(int cpu) |
| 177 | { |
| 178 | union irq_ctx *irqctx; |
| 179 | |
| 180 | if (hardirq_ctx[cpu]) |
| 181 | return; |
| 182 | |
| 183 | irqctx = (union irq_ctx*) &hardirq_stack[cpu*THREAD_SIZE]; |
| 184 | irqctx->tinfo.task = NULL; |
| 185 | irqctx->tinfo.exec_domain = NULL; |
| 186 | irqctx->tinfo.cpu = cpu; |
| 187 | irqctx->tinfo.preempt_count = HARDIRQ_OFFSET; |
| 188 | irqctx->tinfo.addr_limit = MAKE_MM_SEG(0); |
| 189 | |
| 190 | hardirq_ctx[cpu] = irqctx; |
| 191 | |
| 192 | irqctx = (union irq_ctx*) &softirq_stack[cpu*THREAD_SIZE]; |
| 193 | irqctx->tinfo.task = NULL; |
| 194 | irqctx->tinfo.exec_domain = NULL; |
| 195 | irqctx->tinfo.cpu = cpu; |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 196 | irqctx->tinfo.preempt_count = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | irqctx->tinfo.addr_limit = MAKE_MM_SEG(0); |
| 198 | |
| 199 | softirq_ctx[cpu] = irqctx; |
| 200 | |
| 201 | printk("CPU %u irqstacks, hard=%p soft=%p\n", |
| 202 | cpu,hardirq_ctx[cpu],softirq_ctx[cpu]); |
| 203 | } |
| 204 | |
Li Shaohua | e1367da | 2005-06-25 14:54:56 -0700 | [diff] [blame] | 205 | void irq_ctx_exit(int cpu) |
| 206 | { |
| 207 | hardirq_ctx[cpu] = NULL; |
| 208 | } |
| 209 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | asmlinkage void do_softirq(void) |
| 211 | { |
| 212 | unsigned long flags; |
| 213 | struct thread_info *curctx; |
| 214 | union irq_ctx *irqctx; |
| 215 | u32 *isp; |
| 216 | |
| 217 | if (in_interrupt()) |
| 218 | return; |
| 219 | |
| 220 | local_irq_save(flags); |
| 221 | |
| 222 | if (local_softirq_pending()) { |
| 223 | curctx = current_thread_info(); |
| 224 | irqctx = softirq_ctx[smp_processor_id()]; |
| 225 | irqctx->tinfo.task = curctx->task; |
| 226 | irqctx->tinfo.previous_esp = current_stack_pointer; |
| 227 | |
| 228 | /* build the stack frame on the softirq stack */ |
| 229 | isp = (u32*) ((char*)irqctx + sizeof(*irqctx)); |
| 230 | |
| 231 | asm volatile( |
| 232 | " xchgl %%ebx,%%esp \n" |
| 233 | " call __do_softirq \n" |
| 234 | " movl %%ebx,%%esp \n" |
| 235 | : "=b"(isp) |
| 236 | : "0"(isp) |
| 237 | : "memory", "cc", "edx", "ecx", "eax" |
| 238 | ); |
Ingo Molnar | 55f327f | 2006-07-03 00:24:43 -0700 | [diff] [blame] | 239 | /* |
| 240 | * Shouldnt happen, we returned above if in_interrupt(): |
| 241 | */ |
| 242 | WARN_ON_ONCE(softirq_count()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | local_irq_restore(flags); |
| 246 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | #endif |
| 248 | |
| 249 | /* |
| 250 | * Interrupt statistics: |
| 251 | */ |
| 252 | |
| 253 | atomic_t irq_err_count; |
| 254 | |
| 255 | /* |
| 256 | * /proc/interrupts printing: |
| 257 | */ |
| 258 | |
| 259 | int show_interrupts(struct seq_file *p, void *v) |
| 260 | { |
| 261 | int i = *(loff_t *) v, j; |
| 262 | struct irqaction * action; |
| 263 | unsigned long flags; |
| 264 | |
| 265 | if (i == 0) { |
| 266 | seq_printf(p, " "); |
Natalie Protasevich | 9f40a72 | 2005-10-30 14:59:32 -0800 | [diff] [blame] | 267 | for_each_online_cpu(j) |
Jan Beulich | bdbdaa7 | 2006-06-26 13:59:23 +0200 | [diff] [blame] | 268 | seq_printf(p, "CPU%-8d",j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | seq_putc(p, '\n'); |
| 270 | } |
| 271 | |
| 272 | if (i < NR_IRQS) { |
Jan Beulich | 072f5d8 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 273 | unsigned any_count = 0; |
| 274 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | spin_lock_irqsave(&irq_desc[i].lock, flags); |
Jan Beulich | 072f5d8 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 276 | #ifndef CONFIG_SMP |
| 277 | any_count = kstat_irqs(i); |
| 278 | #else |
| 279 | for_each_online_cpu(j) |
| 280 | any_count |= kstat_cpu(j).irqs[i]; |
| 281 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | action = irq_desc[i].action; |
Jan Beulich | 072f5d8 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 283 | if (!action && !any_count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | goto skip; |
| 285 | seq_printf(p, "%3d: ",i); |
| 286 | #ifndef CONFIG_SMP |
| 287 | seq_printf(p, "%10u ", kstat_irqs(i)); |
| 288 | #else |
Natalie Protasevich | 9f40a72 | 2005-10-30 14:59:32 -0800 | [diff] [blame] | 289 | for_each_online_cpu(j) |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 290 | seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | #endif |
Ingo Molnar | f5b9ed7 | 2006-10-04 02:16:26 -0700 | [diff] [blame] | 292 | seq_printf(p, " %8s", irq_desc[i].chip->name); |
Ingo Molnar | a460e74 | 2006-10-17 00:10:03 -0700 | [diff] [blame] | 293 | seq_printf(p, "-%-8s", irq_desc[i].name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Jan Beulich | 072f5d8 | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 295 | if (action) { |
| 296 | seq_printf(p, " %s", action->name); |
| 297 | while ((action = action->next) != NULL) |
| 298 | seq_printf(p, ", %s", action->name); |
| 299 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | |
| 301 | seq_putc(p, '\n'); |
| 302 | skip: |
| 303 | spin_unlock_irqrestore(&irq_desc[i].lock, flags); |
| 304 | } else if (i == NR_IRQS) { |
| 305 | seq_printf(p, "NMI: "); |
Natalie Protasevich | 9f40a72 | 2005-10-30 14:59:32 -0800 | [diff] [blame] | 306 | for_each_online_cpu(j) |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 307 | seq_printf(p, "%10u ", nmi_count(j)); |
Joe Korty | 38e760a | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 308 | seq_printf(p, " Non-maskable interrupts\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | #ifdef CONFIG_X86_LOCAL_APIC |
| 310 | seq_printf(p, "LOC: "); |
Natalie Protasevich | 9f40a72 | 2005-10-30 14:59:32 -0800 | [diff] [blame] | 311 | for_each_online_cpu(j) |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 312 | seq_printf(p, "%10u ", |
| 313 | per_cpu(irq_stat,j).apic_timer_irqs); |
Joe Korty | 38e760a | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 314 | seq_printf(p, " Local timer interrupts\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | #endif |
Joe Korty | 38e760a | 2007-10-17 18:04:40 +0200 | [diff] [blame] | 316 | #ifdef CONFIG_SMP |
| 317 | seq_printf(p, "RES: "); |
| 318 | for_each_online_cpu(j) |
| 319 | seq_printf(p, "%10u ", |
| 320 | per_cpu(irq_stat,j).irq_resched_count); |
| 321 | seq_printf(p, " Rescheduling interrupts\n"); |
| 322 | seq_printf(p, "CAL: "); |
| 323 | for_each_online_cpu(j) |
| 324 | seq_printf(p, "%10u ", |
| 325 | per_cpu(irq_stat,j).irq_call_count); |
| 326 | seq_printf(p, " function call interrupts\n"); |
| 327 | seq_printf(p, "TLB: "); |
| 328 | for_each_online_cpu(j) |
| 329 | seq_printf(p, "%10u ", |
| 330 | per_cpu(irq_stat,j).irq_tlb_count); |
| 331 | seq_printf(p, " TLB shootdowns\n"); |
| 332 | #endif |
| 333 | seq_printf(p, "TRM: "); |
| 334 | for_each_online_cpu(j) |
| 335 | seq_printf(p, "%10u ", |
| 336 | per_cpu(irq_stat,j).irq_thermal_count); |
| 337 | seq_printf(p, " Thermal event interrupts\n"); |
| 338 | seq_printf(p, "SPU: "); |
| 339 | for_each_online_cpu(j) |
| 340 | seq_printf(p, "%10u ", |
| 341 | per_cpu(irq_stat,j).irq_spurious_count); |
| 342 | seq_printf(p, " Spurious interrupts\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); |
| 344 | #if defined(CONFIG_X86_IO_APIC) |
| 345 | seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count)); |
| 346 | #endif |
| 347 | } |
| 348 | return 0; |
| 349 | } |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 350 | |
| 351 | #ifdef CONFIG_HOTPLUG_CPU |
| 352 | #include <mach_apic.h> |
| 353 | |
| 354 | void fixup_irqs(cpumask_t map) |
| 355 | { |
| 356 | unsigned int irq; |
| 357 | static int warned; |
| 358 | |
| 359 | for (irq = 0; irq < NR_IRQS; irq++) { |
| 360 | cpumask_t mask; |
| 361 | if (irq == 2) |
| 362 | continue; |
| 363 | |
Ingo Molnar | a53da52 | 2006-06-29 02:24:38 -0700 | [diff] [blame] | 364 | cpus_and(mask, irq_desc[irq].affinity, map); |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 365 | if (any_online_cpu(mask) == NR_CPUS) { |
| 366 | printk("Breaking affinity for irq %i\n", irq); |
| 367 | mask = map; |
| 368 | } |
Ingo Molnar | d1bef4e | 2006-06-29 02:24:36 -0700 | [diff] [blame] | 369 | if (irq_desc[irq].chip->set_affinity) |
| 370 | irq_desc[irq].chip->set_affinity(irq, mask); |
Zwane Mwaikambo | f370513 | 2005-06-25 14:54:50 -0700 | [diff] [blame] | 371 | else if (irq_desc[irq].action && !(warned++)) |
| 372 | printk("Cannot set affinity for irq %i\n", irq); |
| 373 | } |
| 374 | |
| 375 | #if 0 |
| 376 | barrier(); |
| 377 | /* Ingo Molnar says: "after the IO-APIC masks have been redirected |
| 378 | [note the nop - the interrupt-enable boundary on x86 is two |
| 379 | instructions from sti] - to flush out pending hardirqs and |
| 380 | IPIs. After this point nothing is supposed to reach this CPU." */ |
| 381 | __asm__ __volatile__("sti; nop; cli"); |
| 382 | barrier(); |
| 383 | #else |
| 384 | /* That doesn't seem sufficient. Give it 1ms. */ |
| 385 | local_irq_enable(); |
| 386 | mdelay(1); |
| 387 | local_irq_disable(); |
| 388 | #endif |
| 389 | } |
| 390 | #endif |
| 391 | |