aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc64
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2005-11-09 02:07:45 -0500
committerStephen Rothwell <sfr@canb.auug.org.au>2005-11-09 02:07:45 -0500
commit756e7104fefc82e3ebaa5f1da5ba6659c9c1cae5 (patch)
tree6b99d450f4fd8da4afb526d6ac0d169ffa9ccef6 /arch/ppc64
parentd4be4f37d9d2a5afc8e79a95beafbac4b83f20c5 (diff)
powerpc: merge irq.c
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'arch/ppc64')
-rw-r--r--arch/ppc64/kernel/Makefile2
-rw-r--r--arch/ppc64/kernel/irq.c415
2 files changed, 1 insertions, 416 deletions
diff --git a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile
index c441aebe7648..13e479846249 100644
--- a/arch/ppc64/kernel/Makefile
+++ b/arch/ppc64/kernel/Makefile
@@ -11,7 +11,7 @@ obj-y := misc.o prom.o
11 11
12endif 12endif
13 13
14obj-y += irq.o idle.o dma.o \ 14obj-y += idle.o dma.o \
15 align.o pacaData.o \ 15 align.o pacaData.o \
16 udbg.o ioctl32.o \ 16 udbg.o ioctl32.o \
17 rtc.o \ 17 rtc.o \
diff --git a/arch/ppc64/kernel/irq.c b/arch/ppc64/kernel/irq.c
deleted file mode 100644
index bd6a95a5914d..000000000000
--- a/arch/ppc64/kernel/irq.c
+++ /dev/null
@@ -1,415 +0,0 @@
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)
8 * Updated and modified by Cort Dougan (cort@cs.nmt.edu)
9 * Copyright (C) 1996 Cort Dougan
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).
13 *
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.
24 */
25
26#include <linux/errno.h>
27#include <linux/module.h>
28#include <linux/threads.h>
29#include <linux/kernel_stat.h>
30#include <linux/signal.h>
31#include <linux/sched.h>
32#include <linux/ioport.h>
33#include <linux/interrupt.h>
34#include <linux/timex.h>
35#include <linux/config.h>
36#include <linux/init.h>
37#include <linux/slab.h>
38#include <linux/pci.h>
39#include <linux/delay.h>
40#include <linux/irq.h>
41#include <linux/proc_fs.h>
42#include <linux/random.h>
43#include <linux/kallsyms.h>
44#include <linux/profile.h>
45#include <linux/bitops.h>
46
47#include <asm/uaccess.h>
48#include <asm/system.h>
49#include <asm/io.h>
50#include <asm/pgtable.h>
51#include <asm/irq.h>
52#include <asm/cache.h>
53#include <asm/prom.h>
54#include <asm/ptrace.h>
55#include <asm/iseries/it_lp_queue.h>
56#include <asm/machdep.h>
57#include <asm/paca.h>
58
59#ifdef CONFIG_SMP
60extern void iSeries_smp_message_recv( struct pt_regs * );
61#endif
62
63extern irq_desc_t irq_desc[NR_IRQS];
64EXPORT_SYMBOL(irq_desc);
65
66int distribute_irqs = 1;
67int __irq_offset_value;
68int ppc_spurious_interrupts;
69u64 ppc64_interrupt_controller;
70
71int show_interrupts(struct seq_file *p, void *v)
72{
73 int i = *(loff_t *) v, j;
74 struct irqaction * action;
75 irq_desc_t *desc;
76 unsigned long flags;
77
78 if (i == 0) {
79 seq_printf(p, " ");
80 for (j=0; j<NR_CPUS; j++) {
81 if (cpu_online(j))
82 seq_printf(p, "CPU%d ",j);
83 }
84 seq_putc(p, '\n');
85 }
86
87 if (i < NR_IRQS) {
88 desc = get_irq_desc(i);
89 spin_lock_irqsave(&desc->lock, flags);
90 action = desc->action;
91 if (!action || !action->handler)
92 goto skip;
93 seq_printf(p, "%3d: ", i);
94#ifdef CONFIG_SMP
95 for (j = 0; j < NR_CPUS; j++) {
96 if (cpu_online(j))
97 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
98 }
99#else
100 seq_printf(p, "%10u ", kstat_irqs(i));
101#endif /* CONFIG_SMP */
102 if (desc->handler)
103 seq_printf(p, " %s ", desc->handler->typename );
104 else
105 seq_printf(p, " None ");
106 seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge ");
107 seq_printf(p, " %s",action->name);
108 for (action=action->next; action; action = action->next)
109 seq_printf(p, ", %s", action->name);
110 seq_putc(p, '\n');
111skip:
112 spin_unlock_irqrestore(&desc->lock, flags);
113 } else if (i == NR_IRQS)
114 seq_printf(p, "BAD: %10u\n", ppc_spurious_interrupts);
115 return 0;
116}
117
118#ifdef CONFIG_HOTPLUG_CPU
119void fixup_irqs(cpumask_t map)
120{
121 unsigned int irq;
122 static int warned;
123
124 for_each_irq(irq) {
125 cpumask_t mask;
126
127 if (irq_desc[irq].status & IRQ_PER_CPU)
128 continue;
129
130 cpus_and(mask, irq_affinity[irq], map);
131 if (any_online_cpu(mask) == NR_CPUS) {
132 printk("Breaking affinity for irq %i\n", irq);
133 mask = map;
134 }
135 if (irq_desc[irq].handler->set_affinity)
136 irq_desc[irq].handler->set_affinity(irq, mask);
137 else if (irq_desc[irq].action && !(warned++))
138 printk("Cannot set affinity for irq %i\n", irq);
139 }
140
141 local_irq_enable();
142 mdelay(1);
143 local_irq_disable();
144}
145#endif
146
147#ifdef CONFIG_PPC_ISERIES
148void do_IRQ(struct pt_regs *regs)
149{
150 struct paca_struct *lpaca;
151
152 irq_enter();
153
154#ifdef CONFIG_DEBUG_STACKOVERFLOW
155 /* Debugging check for stack overflow: is there less than 2KB free? */
156 {
157 long sp;
158
159 sp = __get_SP() & (THREAD_SIZE-1);
160
161 if (unlikely(sp < (sizeof(struct thread_info) + 2048))) {
162 printk("do_IRQ: stack overflow: %ld\n",
163 sp - sizeof(struct thread_info));
164 dump_stack();
165 }
166 }
167#endif
168
169 lpaca = get_paca();
170#ifdef CONFIG_SMP
171 if (lpaca->lppaca.int_dword.fields.ipi_cnt) {
172 lpaca->lppaca.int_dword.fields.ipi_cnt = 0;
173 iSeries_smp_message_recv(regs);
174 }
175#endif /* CONFIG_SMP */
176 if (hvlpevent_is_pending())
177 process_hvlpevents(regs);
178
179 irq_exit();
180
181 if (lpaca->lppaca.int_dword.fields.decr_int) {
182 lpaca->lppaca.int_dword.fields.decr_int = 0;
183 /* Signal a fake decrementer interrupt */
184 timer_interrupt(regs);
185 }
186}
187
188#else /* CONFIG_PPC_ISERIES */
189
190void do_IRQ(struct pt_regs *regs)
191{
192 int irq;
193#ifdef CONFIG_IRQSTACKS
194 struct thread_info *curtp, *irqtp;
195#endif
196
197 irq_enter();
198
199#ifdef CONFIG_DEBUG_STACKOVERFLOW
200 /* Debugging check for stack overflow: is there less than 2KB free? */
201 {
202 long sp;
203
204 sp = __get_SP() & (THREAD_SIZE-1);
205
206 if (unlikely(sp < (sizeof(struct thread_info) + 2048))) {
207 printk("do_IRQ: stack overflow: %ld\n",
208 sp - sizeof(struct thread_info));
209 dump_stack();
210 }
211 }
212#endif
213
214 irq = ppc_md.get_irq(regs);
215
216 if (irq >= 0) {
217#ifdef CONFIG_IRQSTACKS
218 /* Switch to the irq stack to handle this */
219 curtp = current_thread_info();
220 irqtp = hardirq_ctx[smp_processor_id()];
221 if (curtp != irqtp) {
222 irqtp->task = curtp->task;
223 irqtp->flags = 0;
224 call___do_IRQ(irq, regs, irqtp);
225 irqtp->task = NULL;
226 if (irqtp->flags)
227 set_bits(irqtp->flags, &curtp->flags);
228 } else
229#endif
230 __do_IRQ(irq, regs);
231 } else
232 /* That's not SMP safe ... but who cares ? */
233 ppc_spurious_interrupts++;
234
235 irq_exit();
236}
237#endif /* CONFIG_PPC_ISERIES */
238
239void __init init_IRQ(void)
240{
241 static int once = 0;
242
243 if (once)
244 return;
245
246 once++;
247
248 ppc_md.init_IRQ();
249 irq_ctx_init();
250}
251
252#ifndef CONFIG_PPC_ISERIES
253/*
254 * Virtual IRQ mapping code, used on systems with XICS interrupt controllers.
255 */
256
257#define UNDEFINED_IRQ 0xffffffff
258unsigned int virt_irq_to_real_map[NR_IRQS];
259
260/*
261 * Don't use virtual irqs 0, 1, 2 for devices.
262 * The pcnet32 driver considers interrupt numbers < 2 to be invalid,
263 * and 2 is the XICS IPI interrupt.
264 * We limit virtual irqs to 17 less than NR_IRQS so that when we
265 * offset them by 16 (to reserve the first 16 for ISA interrupts)
266 * we don't end up with an interrupt number >= NR_IRQS.
267 */
268#define MIN_VIRT_IRQ 3
269#define MAX_VIRT_IRQ (NR_IRQS - NUM_ISA_INTERRUPTS - 1)
270#define NR_VIRT_IRQS (MAX_VIRT_IRQ - MIN_VIRT_IRQ + 1)
271
272void
273virt_irq_init(void)
274{
275 int i;
276 for (i = 0; i < NR_IRQS; i++)
277 virt_irq_to_real_map[i] = UNDEFINED_IRQ;
278}
279
280/* Create a mapping for a real_irq if it doesn't already exist.
281 * Return the virtual irq as a convenience.
282 */
283int virt_irq_create_mapping(unsigned int real_irq)
284{
285 unsigned int virq, first_virq;
286 static int warned;
287
288 if (ppc64_interrupt_controller == IC_OPEN_PIC)
289 return real_irq; /* no mapping for openpic (for now) */
290
291 if (ppc64_interrupt_controller == IC_CELL_PIC)
292 return real_irq; /* no mapping for iic either */
293
294 /* don't map interrupts < MIN_VIRT_IRQ */
295 if (real_irq < MIN_VIRT_IRQ) {
296 virt_irq_to_real_map[real_irq] = real_irq;
297 return real_irq;
298 }
299
300 /* map to a number between MIN_VIRT_IRQ and MAX_VIRT_IRQ */
301 virq = real_irq;
302 if (virq > MAX_VIRT_IRQ)
303 virq = (virq % NR_VIRT_IRQS) + MIN_VIRT_IRQ;
304
305 /* search for this number or a free slot */
306 first_virq = virq;
307 while (virt_irq_to_real_map[virq] != UNDEFINED_IRQ) {
308 if (virt_irq_to_real_map[virq] == real_irq)
309 return virq;
310 if (++virq > MAX_VIRT_IRQ)
311 virq = MIN_VIRT_IRQ;
312 if (virq == first_virq)
313 goto nospace; /* oops, no free slots */
314 }
315
316 virt_irq_to_real_map[virq] = real_irq;
317 return virq;
318
319 nospace:
320 if (!warned) {
321 printk(KERN_CRIT "Interrupt table is full\n");
322 printk(KERN_CRIT "Increase NR_IRQS (currently %d) "
323 "in your kernel sources and rebuild.\n", NR_IRQS);
324 warned = 1;
325 }
326 return NO_IRQ;
327}
328
329/*
330 * In most cases will get a hit on the very first slot checked in the
331 * virt_irq_to_real_map. Only when there are a large number of
332 * IRQs will this be expensive.
333 */
334unsigned int real_irq_to_virt_slowpath(unsigned int real_irq)
335{
336 unsigned int virq;
337 unsigned int first_virq;
338
339 virq = real_irq;
340
341 if (virq > MAX_VIRT_IRQ)
342 virq = (virq % NR_VIRT_IRQS) + MIN_VIRT_IRQ;
343
344 first_virq = virq;
345
346 do {
347 if (virt_irq_to_real_map[virq] == real_irq)
348 return virq;
349
350 virq++;
351
352 if (virq >= MAX_VIRT_IRQ)
353 virq = 0;
354
355 } while (first_virq != virq);
356
357 return NO_IRQ;
358
359}
360
361#endif /* CONFIG_PPC_ISERIES */
362
363#ifdef CONFIG_IRQSTACKS
364struct thread_info *softirq_ctx[NR_CPUS];
365struct thread_info *hardirq_ctx[NR_CPUS];
366
367void irq_ctx_init(void)
368{
369 struct thread_info *tp;
370 int i;
371
372 for_each_cpu(i) {
373 memset((void *)softirq_ctx[i], 0, THREAD_SIZE);
374 tp = softirq_ctx[i];
375 tp->cpu = i;
376 tp->preempt_count = SOFTIRQ_OFFSET;
377
378 memset((void *)hardirq_ctx[i], 0, THREAD_SIZE);
379 tp = hardirq_ctx[i];
380 tp->cpu = i;
381 tp->preempt_count = HARDIRQ_OFFSET;
382 }
383}
384
385void do_softirq(void)
386{
387 unsigned long flags;
388 struct thread_info *curtp, *irqtp;
389
390 if (in_interrupt())
391 return;
392
393 local_irq_save(flags);
394
395 if (local_softirq_pending()) {
396 curtp = current_thread_info();
397 irqtp = softirq_ctx[smp_processor_id()];
398 irqtp->task = curtp->task;
399 call_do_softirq(irqtp);
400 irqtp->task = NULL;
401 }
402
403 local_irq_restore(flags);
404}
405EXPORT_SYMBOL(do_softirq);
406
407#endif /* CONFIG_IRQSTACKS */
408
409static int __init setup_noirqdistrib(char *str)
410{
411 distribute_irqs = 0;
412 return 1;
413}
414
415__setup("noirqdistrib", setup_noirqdistrib);