Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/ppc/kernel/irq.c |
| 3 | * |
| 4 | * Derived from arch/i386/kernel/irq.c |
| 5 | * Copyright (C) 1992 Linus Torvalds |
| 6 | * Adapted from arch/i386 by Gary Thomas |
| 7 | * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 8 | * Updated and modified by Cort Dougan <cort@fsmlabs.com> |
| 9 | * Copyright (C) 1996-2001 Cort Dougan |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * Adapted for Power Macintosh by Paul Mackerras |
| 11 | * Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au) |
| 12 | * Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk). |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 13 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License |
| 16 | * as published by the Free Software Foundation; either version |
| 17 | * 2 of the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This file contains the code used by various IRQ handling routines: |
| 20 | * asking for different IRQ's should be done through these routines |
| 21 | * instead of just grabbing them. Thus setups with different IRQ numbers |
| 22 | * shouldn't result in any weird surprises, and installing new handlers |
| 23 | * should be easier. |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 24 | * |
| 25 | * The MPC8xx has an interrupt mask in the SIU. If a bit is set, the |
| 26 | * interrupt is _enabled_. As expected, IRQ0 is bit 0 in the 32-bit |
| 27 | * mask register (of which only 16 are defined), hence the weird shifting |
| 28 | * and complement of the cached_irq_mask. I want to be able to stuff |
| 29 | * this right into the SIU SMASK register. |
| 30 | * Many of the prep/chrp functions are conditional compiled on CONFIG_8xx |
| 31 | * to reduce code space and undefined function references. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | */ |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #include <linux/module.h> |
| 35 | #include <linux/threads.h> |
| 36 | #include <linux/kernel_stat.h> |
| 37 | #include <linux/signal.h> |
| 38 | #include <linux/sched.h> |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 39 | #include <linux/ptrace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | #include <linux/ioport.h> |
| 41 | #include <linux/interrupt.h> |
| 42 | #include <linux/timex.h> |
| 43 | #include <linux/config.h> |
| 44 | #include <linux/init.h> |
| 45 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <linux/delay.h> |
| 47 | #include <linux/irq.h> |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 48 | #include <linux/seq_file.h> |
| 49 | #include <linux/cpumask.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #include <linux/profile.h> |
| 51 | #include <linux/bitops.h> |
| 52 | |
| 53 | #include <asm/uaccess.h> |
| 54 | #include <asm/system.h> |
| 55 | #include <asm/io.h> |
| 56 | #include <asm/pgtable.h> |
| 57 | #include <asm/irq.h> |
| 58 | #include <asm/cache.h> |
| 59 | #include <asm/prom.h> |
| 60 | #include <asm/ptrace.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #include <asm/machdep.h> |
Stephen Rothwell | a50b56d | 2005-11-17 16:14:17 +1100 | [diff] [blame] | 62 | #ifdef CONFIG_PPC_ISERIES |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | #include <asm/paca.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | #endif |
| 65 | |
Stephen Rothwell | 868accb | 2005-11-10 18:38:46 +1100 | [diff] [blame] | 66 | int __irq_offset_value; |
| 67 | #ifdef CONFIG_PPC32 |
| 68 | EXPORT_SYMBOL(__irq_offset_value); |
| 69 | #endif |
| 70 | |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 71 | static int ppc_spurious_interrupts; |
| 72 | |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 73 | #ifdef CONFIG_PPC32 |
| 74 | #define NR_MASK_WORDS ((NR_IRQS + 31) / 32) |
| 75 | |
| 76 | unsigned long ppc_cached_irq_mask[NR_MASK_WORDS]; |
| 77 | atomic_t ppc_n_lost_interrupts; |
| 78 | |
| 79 | #ifdef CONFIG_TAU_INT |
| 80 | extern int tau_initialized; |
| 81 | extern int tau_interrupts(int); |
| 82 | #endif |
| 83 | |
| 84 | #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_MERGE) |
| 85 | extern atomic_t ipi_recv; |
| 86 | extern atomic_t ipi_sent; |
| 87 | #endif |
| 88 | #endif /* CONFIG_PPC32 */ |
| 89 | |
| 90 | #ifdef CONFIG_PPC64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | EXPORT_SYMBOL(irq_desc); |
| 92 | |
| 93 | int distribute_irqs = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | u64 ppc64_interrupt_controller; |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 95 | #endif /* CONFIG_PPC64 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | int show_interrupts(struct seq_file *p, void *v) |
| 98 | { |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 99 | int i = *(loff_t *)v, j; |
| 100 | struct irqaction *action; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | irq_desc_t *desc; |
| 102 | unsigned long flags; |
| 103 | |
| 104 | if (i == 0) { |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 105 | seq_puts(p, " "); |
| 106 | for_each_online_cpu(j) |
| 107 | seq_printf(p, "CPU%d ", j); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | seq_putc(p, '\n'); |
| 109 | } |
| 110 | |
| 111 | if (i < NR_IRQS) { |
| 112 | desc = get_irq_desc(i); |
| 113 | spin_lock_irqsave(&desc->lock, flags); |
| 114 | action = desc->action; |
| 115 | if (!action || !action->handler) |
| 116 | goto skip; |
| 117 | seq_printf(p, "%3d: ", i); |
| 118 | #ifdef CONFIG_SMP |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 119 | for_each_online_cpu(j) |
| 120 | seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | #else |
| 122 | seq_printf(p, "%10u ", kstat_irqs(i)); |
| 123 | #endif /* CONFIG_SMP */ |
| 124 | if (desc->handler) |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 125 | seq_printf(p, " %s ", desc->handler->typename); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | else |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 127 | seq_puts(p, " None "); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge "); |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 129 | seq_printf(p, " %s", action->name); |
| 130 | for (action = action->next; action; action = action->next) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | seq_printf(p, ", %s", action->name); |
| 132 | seq_putc(p, '\n'); |
| 133 | skip: |
| 134 | spin_unlock_irqrestore(&desc->lock, flags); |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 135 | } else if (i == NR_IRQS) { |
| 136 | #ifdef CONFIG_PPC32 |
| 137 | #ifdef CONFIG_TAU_INT |
| 138 | if (tau_initialized){ |
| 139 | seq_puts(p, "TAU: "); |
| 140 | for (j = 0; j < NR_CPUS; j++) |
| 141 | if (cpu_online(j)) |
| 142 | seq_printf(p, "%10u ", tau_interrupts(j)); |
| 143 | seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n"); |
| 144 | } |
| 145 | #endif |
| 146 | #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_MERGE) |
| 147 | /* should this be per processor send/receive? */ |
| 148 | seq_printf(p, "IPI (recv/sent): %10u/%u\n", |
| 149 | atomic_read(&ipi_recv), atomic_read(&ipi_sent)); |
| 150 | #endif |
| 151 | #endif /* CONFIG_PPC32 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | seq_printf(p, "BAD: %10u\n", ppc_spurious_interrupts); |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 153 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | #ifdef CONFIG_HOTPLUG_CPU |
| 158 | void fixup_irqs(cpumask_t map) |
| 159 | { |
| 160 | unsigned int irq; |
| 161 | static int warned; |
| 162 | |
| 163 | for_each_irq(irq) { |
| 164 | cpumask_t mask; |
| 165 | |
| 166 | if (irq_desc[irq].status & IRQ_PER_CPU) |
| 167 | continue; |
| 168 | |
| 169 | cpus_and(mask, irq_affinity[irq], map); |
| 170 | if (any_online_cpu(mask) == NR_CPUS) { |
| 171 | printk("Breaking affinity for irq %i\n", irq); |
| 172 | mask = map; |
| 173 | } |
| 174 | if (irq_desc[irq].handler->set_affinity) |
| 175 | irq_desc[irq].handler->set_affinity(irq, mask); |
| 176 | else if (irq_desc[irq].action && !(warned++)) |
| 177 | printk("Cannot set affinity for irq %i\n", irq); |
| 178 | } |
| 179 | |
| 180 | local_irq_enable(); |
| 181 | mdelay(1); |
| 182 | local_irq_disable(); |
| 183 | } |
| 184 | #endif |
| 185 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | void do_IRQ(struct pt_regs *regs) |
| 187 | { |
| 188 | int irq; |
Stephen Rothwell | b709c08 | 2005-11-09 13:28:33 +1100 | [diff] [blame] | 189 | #ifdef CONFIG_IRQSTACKS |
| 190 | struct thread_info *curtp, *irqtp; |
| 191 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 193 | irq_enter(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
| 195 | #ifdef CONFIG_DEBUG_STACKOVERFLOW |
| 196 | /* Debugging check for stack overflow: is there less than 2KB free? */ |
| 197 | { |
| 198 | long sp; |
| 199 | |
| 200 | sp = __get_SP() & (THREAD_SIZE-1); |
| 201 | |
| 202 | if (unlikely(sp < (sizeof(struct thread_info) + 2048))) { |
| 203 | printk("do_IRQ: stack overflow: %ld\n", |
| 204 | sp - sizeof(struct thread_info)); |
| 205 | dump_stack(); |
| 206 | } |
| 207 | } |
| 208 | #endif |
| 209 | |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 210 | /* |
| 211 | * Every platform is required to implement ppc_md.get_irq. |
| 212 | * This function will either return an irq number or -1 to |
| 213 | * indicate there are no more pending. |
| 214 | * The value -2 is for buggy hardware and means that this IRQ |
| 215 | * has already been handled. -- Tom |
| 216 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | irq = ppc_md.get_irq(regs); |
| 218 | |
Stephen Rothwell | b709c08 | 2005-11-09 13:28:33 +1100 | [diff] [blame] | 219 | if (irq >= 0) { |
| 220 | #ifdef CONFIG_IRQSTACKS |
| 221 | /* Switch to the irq stack to handle this */ |
| 222 | curtp = current_thread_info(); |
| 223 | irqtp = hardirq_ctx[smp_processor_id()]; |
| 224 | if (curtp != irqtp) { |
| 225 | irqtp->task = curtp->task; |
| 226 | irqtp->flags = 0; |
Stephen Rothwell | d4be4f3 | 2005-11-09 16:19:53 +1100 | [diff] [blame] | 227 | call___do_IRQ(irq, regs, irqtp); |
Stephen Rothwell | b709c08 | 2005-11-09 13:28:33 +1100 | [diff] [blame] | 228 | irqtp->task = NULL; |
| 229 | if (irqtp->flags) |
| 230 | set_bits(irqtp->flags, &curtp->flags); |
| 231 | } else |
| 232 | #endif |
Stephen Rothwell | d4be4f3 | 2005-11-09 16:19:53 +1100 | [diff] [blame] | 233 | __do_IRQ(irq, regs); |
Stephen Rothwell | e199500 | 2005-11-16 18:53:29 +1100 | [diff] [blame] | 234 | } else if (irq != -2) |
| 235 | /* That's not SMP safe ... but who cares ? */ |
| 236 | ppc_spurious_interrupts++; |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 237 | |
Stephen Rothwell | e199500 | 2005-11-16 18:53:29 +1100 | [diff] [blame] | 238 | irq_exit(); |
| 239 | |
| 240 | #ifdef CONFIG_PPC_ISERIES |
David Gibson | 3356bb9 | 2006-01-13 10:26:42 +1100 | [diff] [blame^] | 241 | if (get_lppaca()->int_dword.fields.decr_int) { |
| 242 | get_lppaca()->int_dword.fields.decr_int = 0; |
| 243 | /* Signal a fake decrementer interrupt */ |
| 244 | timer_interrupt(regs); |
Stephen Rothwell | e199500 | 2005-11-16 18:53:29 +1100 | [diff] [blame] | 245 | } |
| 246 | #endif |
| 247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
| 249 | void __init init_IRQ(void) |
| 250 | { |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 251 | #ifdef CONFIG_PPC64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | static int once = 0; |
| 253 | |
| 254 | if (once) |
| 255 | return; |
| 256 | |
| 257 | once++; |
| 258 | |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 259 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | ppc_md.init_IRQ(); |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 261 | #ifdef CONFIG_PPC64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | irq_ctx_init(); |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 263 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 266 | #ifdef CONFIG_PPC64 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | /* |
| 268 | * Virtual IRQ mapping code, used on systems with XICS interrupt controllers. |
| 269 | */ |
| 270 | |
| 271 | #define UNDEFINED_IRQ 0xffffffff |
| 272 | unsigned int virt_irq_to_real_map[NR_IRQS]; |
| 273 | |
| 274 | /* |
| 275 | * Don't use virtual irqs 0, 1, 2 for devices. |
| 276 | * The pcnet32 driver considers interrupt numbers < 2 to be invalid, |
| 277 | * and 2 is the XICS IPI interrupt. |
| 278 | * We limit virtual irqs to 17 less than NR_IRQS so that when we |
| 279 | * offset them by 16 (to reserve the first 16 for ISA interrupts) |
| 280 | * we don't end up with an interrupt number >= NR_IRQS. |
| 281 | */ |
| 282 | #define MIN_VIRT_IRQ 3 |
| 283 | #define MAX_VIRT_IRQ (NR_IRQS - NUM_ISA_INTERRUPTS - 1) |
| 284 | #define NR_VIRT_IRQS (MAX_VIRT_IRQ - MIN_VIRT_IRQ + 1) |
| 285 | |
| 286 | void |
| 287 | virt_irq_init(void) |
| 288 | { |
| 289 | int i; |
| 290 | for (i = 0; i < NR_IRQS; i++) |
| 291 | virt_irq_to_real_map[i] = UNDEFINED_IRQ; |
| 292 | } |
| 293 | |
| 294 | /* Create a mapping for a real_irq if it doesn't already exist. |
| 295 | * Return the virtual irq as a convenience. |
| 296 | */ |
| 297 | int virt_irq_create_mapping(unsigned int real_irq) |
| 298 | { |
| 299 | unsigned int virq, first_virq; |
| 300 | static int warned; |
| 301 | |
| 302 | if (ppc64_interrupt_controller == IC_OPEN_PIC) |
| 303 | return real_irq; /* no mapping for openpic (for now) */ |
| 304 | |
Arnd Bergmann | f3f66f5 | 2005-10-31 20:08:37 -0500 | [diff] [blame] | 305 | if (ppc64_interrupt_controller == IC_CELL_PIC) |
Arnd Bergmann | fef1c77 | 2005-06-23 09:43:37 +1000 | [diff] [blame] | 306 | return real_irq; /* no mapping for iic either */ |
| 307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | /* don't map interrupts < MIN_VIRT_IRQ */ |
| 309 | if (real_irq < MIN_VIRT_IRQ) { |
| 310 | virt_irq_to_real_map[real_irq] = real_irq; |
| 311 | return real_irq; |
| 312 | } |
| 313 | |
| 314 | /* map to a number between MIN_VIRT_IRQ and MAX_VIRT_IRQ */ |
| 315 | virq = real_irq; |
| 316 | if (virq > MAX_VIRT_IRQ) |
| 317 | virq = (virq % NR_VIRT_IRQS) + MIN_VIRT_IRQ; |
| 318 | |
| 319 | /* search for this number or a free slot */ |
| 320 | first_virq = virq; |
| 321 | while (virt_irq_to_real_map[virq] != UNDEFINED_IRQ) { |
| 322 | if (virt_irq_to_real_map[virq] == real_irq) |
| 323 | return virq; |
| 324 | if (++virq > MAX_VIRT_IRQ) |
| 325 | virq = MIN_VIRT_IRQ; |
| 326 | if (virq == first_virq) |
| 327 | goto nospace; /* oops, no free slots */ |
| 328 | } |
| 329 | |
| 330 | virt_irq_to_real_map[virq] = real_irq; |
| 331 | return virq; |
| 332 | |
| 333 | nospace: |
| 334 | if (!warned) { |
| 335 | printk(KERN_CRIT "Interrupt table is full\n"); |
| 336 | printk(KERN_CRIT "Increase NR_IRQS (currently %d) " |
| 337 | "in your kernel sources and rebuild.\n", NR_IRQS); |
| 338 | warned = 1; |
| 339 | } |
| 340 | return NO_IRQ; |
| 341 | } |
| 342 | |
| 343 | /* |
| 344 | * In most cases will get a hit on the very first slot checked in the |
| 345 | * virt_irq_to_real_map. Only when there are a large number of |
| 346 | * IRQs will this be expensive. |
| 347 | */ |
| 348 | unsigned int real_irq_to_virt_slowpath(unsigned int real_irq) |
| 349 | { |
| 350 | unsigned int virq; |
| 351 | unsigned int first_virq; |
| 352 | |
| 353 | virq = real_irq; |
| 354 | |
| 355 | if (virq > MAX_VIRT_IRQ) |
| 356 | virq = (virq % NR_VIRT_IRQS) + MIN_VIRT_IRQ; |
| 357 | |
| 358 | first_virq = virq; |
| 359 | |
| 360 | do { |
| 361 | if (virt_irq_to_real_map[virq] == real_irq) |
| 362 | return virq; |
| 363 | |
| 364 | virq++; |
| 365 | |
| 366 | if (virq >= MAX_VIRT_IRQ) |
| 367 | virq = 0; |
| 368 | |
| 369 | } while (first_virq != virq); |
| 370 | |
| 371 | return NO_IRQ; |
| 372 | |
| 373 | } |
| 374 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | #ifdef CONFIG_IRQSTACKS |
| 376 | struct thread_info *softirq_ctx[NR_CPUS]; |
| 377 | struct thread_info *hardirq_ctx[NR_CPUS]; |
| 378 | |
| 379 | void irq_ctx_init(void) |
| 380 | { |
| 381 | struct thread_info *tp; |
| 382 | int i; |
| 383 | |
| 384 | for_each_cpu(i) { |
| 385 | memset((void *)softirq_ctx[i], 0, THREAD_SIZE); |
| 386 | tp = softirq_ctx[i]; |
| 387 | tp->cpu = i; |
| 388 | tp->preempt_count = SOFTIRQ_OFFSET; |
| 389 | |
| 390 | memset((void *)hardirq_ctx[i], 0, THREAD_SIZE); |
| 391 | tp = hardirq_ctx[i]; |
| 392 | tp->cpu = i; |
| 393 | tp->preempt_count = HARDIRQ_OFFSET; |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | void do_softirq(void) |
| 398 | { |
| 399 | unsigned long flags; |
| 400 | struct thread_info *curtp, *irqtp; |
| 401 | |
| 402 | if (in_interrupt()) |
| 403 | return; |
| 404 | |
| 405 | local_irq_save(flags); |
| 406 | |
| 407 | if (local_softirq_pending()) { |
| 408 | curtp = current_thread_info(); |
| 409 | irqtp = softirq_ctx[smp_processor_id()]; |
| 410 | irqtp->task = curtp->task; |
| 411 | call_do_softirq(irqtp); |
| 412 | irqtp->task = NULL; |
| 413 | } |
| 414 | |
| 415 | local_irq_restore(flags); |
| 416 | } |
| 417 | EXPORT_SYMBOL(do_softirq); |
| 418 | |
| 419 | #endif /* CONFIG_IRQSTACKS */ |
| 420 | |
| 421 | static int __init setup_noirqdistrib(char *str) |
| 422 | { |
| 423 | distribute_irqs = 0; |
| 424 | return 1; |
| 425 | } |
| 426 | |
| 427 | __setup("noirqdistrib", setup_noirqdistrib); |
Stephen Rothwell | 756e710 | 2005-11-09 18:07:45 +1100 | [diff] [blame] | 428 | #endif /* CONFIG_PPC64 */ |