[POWERPC] Add new interrupt mapping core and change platforms to use it
[linux-2.6.22.y-op.git] / arch / powerpc / kernel / irq.c
blob05a700940f672b705f0506872797d461daf67819
1 /*
2 * Derived from arch/i386/kernel/irq.c
3 * Copyright (C) 1992 Linus Torvalds
4 * Adapted from arch/i386 by Gary Thomas
5 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
6 * Updated and modified by Cort Dougan <cort@fsmlabs.com>
7 * Copyright (C) 1996-2001 Cort Dougan
8 * Adapted for Power Macintosh by Paul Mackerras
9 * Copyright (C) 1996 Paul Mackerras (paulus@cs.anu.edu.au)
10 * Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
17 * This file contains the code used by various IRQ handling routines:
18 * asking for different IRQ's should be done through these routines
19 * instead of just grabbing them. Thus setups with different IRQ numbers
20 * shouldn't result in any weird surprises, and installing new handlers
21 * should be easier.
23 * The MPC8xx has an interrupt mask in the SIU. If a bit is set, the
24 * interrupt is _enabled_. As expected, IRQ0 is bit 0 in the 32-bit
25 * mask register (of which only 16 are defined), hence the weird shifting
26 * and complement of the cached_irq_mask. I want to be able to stuff
27 * this right into the SIU SMASK register.
28 * Many of the prep/chrp functions are conditional compiled on CONFIG_8xx
29 * to reduce code space and undefined function references.
32 #undef DEBUG
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>
39 #include <linux/ptrace.h>
40 #include <linux/ioport.h>
41 #include <linux/interrupt.h>
42 #include <linux/timex.h>
43 #include <linux/init.h>
44 #include <linux/slab.h>
45 #include <linux/delay.h>
46 #include <linux/irq.h>
47 #include <linux/seq_file.h>
48 #include <linux/cpumask.h>
49 #include <linux/profile.h>
50 #include <linux/bitops.h>
51 #include <linux/list.h>
52 #include <linux/radix-tree.h>
53 #include <linux/mutex.h>
54 #include <linux/bootmem.h>
56 #include <asm/uaccess.h>
57 #include <asm/system.h>
58 #include <asm/io.h>
59 #include <asm/pgtable.h>
60 #include <asm/irq.h>
61 #include <asm/cache.h>
62 #include <asm/prom.h>
63 #include <asm/ptrace.h>
64 #include <asm/machdep.h>
65 #include <asm/udbg.h>
66 #ifdef CONFIG_PPC_ISERIES
67 #include <asm/paca.h>
68 #endif
70 int __irq_offset_value;
71 static int ppc_spurious_interrupts;
73 #ifdef CONFIG_PPC32
74 EXPORT_SYMBOL(__irq_offset_value);
75 atomic_t ppc_n_lost_interrupts;
77 #ifndef CONFIG_PPC_MERGE
78 #define NR_MASK_WORDS ((NR_IRQS + 31) / 32)
79 unsigned long ppc_cached_irq_mask[NR_MASK_WORDS];
80 #endif
82 #ifdef CONFIG_TAU_INT
83 extern int tau_initialized;
84 extern int tau_interrupts(int);
85 #endif
86 #endif /* CONFIG_PPC32 */
88 #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_MERGE)
89 extern atomic_t ipi_recv;
90 extern atomic_t ipi_sent;
91 #endif
93 #ifdef CONFIG_PPC64
94 EXPORT_SYMBOL(irq_desc);
96 int distribute_irqs = 1;
97 #endif /* CONFIG_PPC64 */
99 int show_interrupts(struct seq_file *p, void *v)
101 int i = *(loff_t *)v, j;
102 struct irqaction *action;
103 irq_desc_t *desc;
104 unsigned long flags;
106 if (i == 0) {
107 seq_puts(p, " ");
108 for_each_online_cpu(j)
109 seq_printf(p, "CPU%d ", j);
110 seq_putc(p, '\n');
113 if (i < NR_IRQS) {
114 desc = get_irq_desc(i);
115 spin_lock_irqsave(&desc->lock, flags);
116 action = desc->action;
117 if (!action || !action->handler)
118 goto skip;
119 seq_printf(p, "%3d: ", i);
120 #ifdef CONFIG_SMP
121 for_each_online_cpu(j)
122 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
123 #else
124 seq_printf(p, "%10u ", kstat_irqs(i));
125 #endif /* CONFIG_SMP */
126 if (desc->chip)
127 seq_printf(p, " %s ", desc->chip->typename);
128 else
129 seq_puts(p, " None ");
130 seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge ");
131 seq_printf(p, " %s", action->name);
132 for (action = action->next; action; action = action->next)
133 seq_printf(p, ", %s", action->name);
134 seq_putc(p, '\n');
135 skip:
136 spin_unlock_irqrestore(&desc->lock, flags);
137 } else if (i == NR_IRQS) {
138 #ifdef CONFIG_PPC32
139 #ifdef CONFIG_TAU_INT
140 if (tau_initialized){
141 seq_puts(p, "TAU: ");
142 for_each_online_cpu(j)
143 seq_printf(p, "%10u ", tau_interrupts(j));
144 seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n");
146 #endif
147 #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_MERGE)
148 /* should this be per processor send/receive? */
149 seq_printf(p, "IPI (recv/sent): %10u/%u\n",
150 atomic_read(&ipi_recv), atomic_read(&ipi_sent));
151 #endif
152 #endif /* CONFIG_PPC32 */
153 seq_printf(p, "BAD: %10u\n", ppc_spurious_interrupts);
155 return 0;
158 #ifdef CONFIG_HOTPLUG_CPU
159 void fixup_irqs(cpumask_t map)
161 unsigned int irq;
162 static int warned;
164 for_each_irq(irq) {
165 cpumask_t mask;
167 if (irq_desc[irq].status & IRQ_PER_CPU)
168 continue;
170 cpus_and(mask, irq_desc[irq].affinity, map);
171 if (any_online_cpu(mask) == NR_CPUS) {
172 printk("Breaking affinity for irq %i\n", irq);
173 mask = map;
175 if (irq_desc[irq].chip->set_affinity)
176 irq_desc[irq].chip->set_affinity(irq, mask);
177 else if (irq_desc[irq].action && !(warned++))
178 printk("Cannot set affinity for irq %i\n", irq);
181 local_irq_enable();
182 mdelay(1);
183 local_irq_disable();
185 #endif
187 void do_IRQ(struct pt_regs *regs)
189 unsigned int irq;
190 #ifdef CONFIG_IRQSTACKS
191 struct thread_info *curtp, *irqtp;
192 #endif
194 irq_enter();
196 #ifdef CONFIG_DEBUG_STACKOVERFLOW
197 /* Debugging check for stack overflow: is there less than 2KB free? */
199 long sp;
201 sp = __get_SP() & (THREAD_SIZE-1);
203 if (unlikely(sp < (sizeof(struct thread_info) + 2048))) {
204 printk("do_IRQ: stack overflow: %ld\n",
205 sp - sizeof(struct thread_info));
206 dump_stack();
209 #endif
212 * Every platform is required to implement ppc_md.get_irq.
213 * This function will either return an irq number or -1 to
214 * indicate there are no more pending.
215 * The value -2 is for buggy hardware and means that this IRQ
216 * has already been handled. -- Tom
218 irq = ppc_md.get_irq(regs);
220 if (irq != NO_IRQ && irq != NO_IRQ_IGNORE) {
221 #ifdef CONFIG_IRQSTACKS
222 /* Switch to the irq stack to handle this */
223 curtp = current_thread_info();
224 irqtp = hardirq_ctx[smp_processor_id()];
225 if (curtp != irqtp) {
226 struct irq_desc *desc = irq_desc + irq;
227 void *handler = desc->handle_irq;
228 if (handler == NULL)
229 handler = &__do_IRQ;
230 irqtp->task = curtp->task;
231 irqtp->flags = 0;
232 call_handle_irq(irq, desc, regs, irqtp, handler);
233 irqtp->task = NULL;
234 if (irqtp->flags)
235 set_bits(irqtp->flags, &curtp->flags);
236 } else
237 #endif
238 generic_handle_irq(irq, regs);
239 } else if (irq != NO_IRQ_IGNORE)
240 /* That's not SMP safe ... but who cares ? */
241 ppc_spurious_interrupts++;
243 irq_exit();
245 #ifdef CONFIG_PPC_ISERIES
246 if (get_lppaca()->int_dword.fields.decr_int) {
247 get_lppaca()->int_dword.fields.decr_int = 0;
248 /* Signal a fake decrementer interrupt */
249 timer_interrupt(regs);
251 #endif
254 void __init init_IRQ(void)
256 ppc_md.init_IRQ();
257 #ifdef CONFIG_PPC64
258 irq_ctx_init();
259 #endif
263 #ifdef CONFIG_IRQSTACKS
264 struct thread_info *softirq_ctx[NR_CPUS] __read_mostly;
265 struct thread_info *hardirq_ctx[NR_CPUS] __read_mostly;
267 void irq_ctx_init(void)
269 struct thread_info *tp;
270 int i;
272 for_each_possible_cpu(i) {
273 memset((void *)softirq_ctx[i], 0, THREAD_SIZE);
274 tp = softirq_ctx[i];
275 tp->cpu = i;
276 tp->preempt_count = SOFTIRQ_OFFSET;
278 memset((void *)hardirq_ctx[i], 0, THREAD_SIZE);
279 tp = hardirq_ctx[i];
280 tp->cpu = i;
281 tp->preempt_count = HARDIRQ_OFFSET;
285 static inline void do_softirq_onstack(void)
287 struct thread_info *curtp, *irqtp;
289 curtp = current_thread_info();
290 irqtp = softirq_ctx[smp_processor_id()];
291 irqtp->task = curtp->task;
292 call_do_softirq(irqtp);
293 irqtp->task = NULL;
296 #else
297 #define do_softirq_onstack() __do_softirq()
298 #endif /* CONFIG_IRQSTACKS */
300 void do_softirq(void)
302 unsigned long flags;
304 if (in_interrupt())
305 return;
307 local_irq_save(flags);
309 if (local_softirq_pending()) {
310 account_system_vtime(current);
311 local_bh_disable();
312 do_softirq_onstack();
313 account_system_vtime(current);
314 __local_bh_enable();
317 local_irq_restore(flags);
319 EXPORT_SYMBOL(do_softirq);
323 * IRQ controller and virtual interrupts
326 #ifdef CONFIG_PPC_MERGE
328 static LIST_HEAD(irq_hosts);
329 static spinlock_t irq_big_lock = SPIN_LOCK_UNLOCKED;
331 struct irq_map_entry irq_map[NR_IRQS];
332 static unsigned int irq_virq_count = NR_IRQS;
333 static struct irq_host *irq_default_host;
335 struct irq_host *irq_alloc_host(unsigned int revmap_type,
336 unsigned int revmap_arg,
337 struct irq_host_ops *ops,
338 irq_hw_number_t inval_irq)
340 struct irq_host *host;
341 unsigned int size = sizeof(struct irq_host);
342 unsigned int i;
343 unsigned int *rmap;
344 unsigned long flags;
346 /* Allocate structure and revmap table if using linear mapping */
347 if (revmap_type == IRQ_HOST_MAP_LINEAR)
348 size += revmap_arg * sizeof(unsigned int);
349 if (mem_init_done)
350 host = kzalloc(size, GFP_KERNEL);
351 else {
352 host = alloc_bootmem(size);
353 if (host)
354 memset(host, 0, size);
356 if (host == NULL)
357 return NULL;
359 /* Fill structure */
360 host->revmap_type = revmap_type;
361 host->inval_irq = inval_irq;
362 host->ops = ops;
364 spin_lock_irqsave(&irq_big_lock, flags);
366 /* If it's a legacy controller, check for duplicates and
367 * mark it as allocated (we use irq 0 host pointer for that
369 if (revmap_type == IRQ_HOST_MAP_LEGACY) {
370 if (irq_map[0].host != NULL) {
371 spin_unlock_irqrestore(&irq_big_lock, flags);
372 /* If we are early boot, we can't free the structure,
373 * too bad...
374 * this will be fixed once slab is made available early
375 * instead of the current cruft
377 if (mem_init_done)
378 kfree(host);
379 return NULL;
381 irq_map[0].host = host;
384 list_add(&host->link, &irq_hosts);
385 spin_unlock_irqrestore(&irq_big_lock, flags);
387 /* Additional setups per revmap type */
388 switch(revmap_type) {
389 case IRQ_HOST_MAP_LEGACY:
390 /* 0 is always the invalid number for legacy */
391 host->inval_irq = 0;
392 /* setup us as the host for all legacy interrupts */
393 for (i = 1; i < NUM_ISA_INTERRUPTS; i++) {
394 irq_map[i].hwirq = 0;
395 smp_wmb();
396 irq_map[i].host = host;
397 smp_wmb();
399 /* Clear some flags */
400 get_irq_desc(i)->status
401 &= ~(IRQ_NOREQUEST | IRQ_LEVEL);
403 /* Legacy flags are left to default at this point,
404 * one can then use irq_create_mapping() to
405 * explicitely change them
407 ops->map(host, i, i, 0);
409 break;
410 case IRQ_HOST_MAP_LINEAR:
411 rmap = (unsigned int *)(host + 1);
412 for (i = 0; i < revmap_arg; i++)
413 rmap[i] = IRQ_NONE;
414 host->revmap_data.linear.size = revmap_arg;
415 smp_wmb();
416 host->revmap_data.linear.revmap = rmap;
417 break;
418 default:
419 break;
422 pr_debug("irq: Allocated host of type %d @0x%p\n", revmap_type, host);
424 return host;
427 struct irq_host *irq_find_host(struct device_node *node)
429 struct irq_host *h, *found = NULL;
430 unsigned long flags;
432 /* We might want to match the legacy controller last since
433 * it might potentially be set to match all interrupts in
434 * the absence of a device node. This isn't a problem so far
435 * yet though...
437 spin_lock_irqsave(&irq_big_lock, flags);
438 list_for_each_entry(h, &irq_hosts, link)
439 if (h->ops->match == NULL || h->ops->match(h, node)) {
440 found = h;
441 break;
443 spin_unlock_irqrestore(&irq_big_lock, flags);
444 return found;
446 EXPORT_SYMBOL_GPL(irq_find_host);
448 void irq_set_default_host(struct irq_host *host)
450 pr_debug("irq: Default host set to @0x%p\n", host);
452 irq_default_host = host;
455 void irq_set_virq_count(unsigned int count)
457 pr_debug("irq: Trying to set virq count to %d\n", count);
459 BUG_ON(count < NUM_ISA_INTERRUPTS);
460 if (count < NR_IRQS)
461 irq_virq_count = count;
464 unsigned int irq_create_mapping(struct irq_host *host,
465 irq_hw_number_t hwirq,
466 unsigned int flags)
468 unsigned int virq, hint;
470 pr_debug("irq: irq_create_mapping(0x%p, 0x%lx, 0x%x)\n",
471 host, hwirq, flags);
473 /* Look for default host if nececssary */
474 if (host == NULL)
475 host = irq_default_host;
476 if (host == NULL) {
477 printk(KERN_WARNING "irq_create_mapping called for"
478 " NULL host, hwirq=%lx\n", hwirq);
479 WARN_ON(1);
480 return NO_IRQ;
482 pr_debug("irq: -> using host @%p\n", host);
484 /* Check if mapping already exist, if it does, call
485 * host->ops->map() to update the flags
487 virq = irq_find_mapping(host, hwirq);
488 if (virq != IRQ_NONE) {
489 pr_debug("irq: -> existing mapping on virq %d\n", virq);
490 host->ops->map(host, virq, hwirq, flags);
491 return virq;
494 /* Get a virtual interrupt number */
495 if (host->revmap_type == IRQ_HOST_MAP_LEGACY) {
496 /* Handle legacy */
497 virq = (unsigned int)hwirq;
498 if (virq == 0 || virq >= NUM_ISA_INTERRUPTS)
499 return NO_IRQ;
500 return virq;
501 } else {
502 /* Allocate a virtual interrupt number */
503 hint = hwirq % irq_virq_count;
504 virq = irq_alloc_virt(host, 1, hint);
505 if (virq == NO_IRQ) {
506 pr_debug("irq: -> virq allocation failed\n");
507 return NO_IRQ;
510 pr_debug("irq: -> obtained virq %d\n", virq);
512 /* Clear some flags */
513 get_irq_desc(virq)->status &= ~(IRQ_NOREQUEST | IRQ_LEVEL);
515 /* map it */
516 if (host->ops->map(host, virq, hwirq, flags)) {
517 pr_debug("irq: -> mapping failed, freeing\n");
518 irq_free_virt(virq, 1);
519 return NO_IRQ;
521 smp_wmb();
522 irq_map[virq].hwirq = hwirq;
523 smp_mb();
524 return virq;
526 EXPORT_SYMBOL_GPL(irq_create_mapping);
528 extern unsigned int irq_create_of_mapping(struct device_node *controller,
529 u32 *intspec, unsigned int intsize)
531 struct irq_host *host;
532 irq_hw_number_t hwirq;
533 unsigned int flags = IRQ_TYPE_NONE;
535 if (controller == NULL)
536 host = irq_default_host;
537 else
538 host = irq_find_host(controller);
539 if (host == NULL)
540 return NO_IRQ;
542 /* If host has no translation, then we assume interrupt line */
543 if (host->ops->xlate == NULL)
544 hwirq = intspec[0];
545 else {
546 if (host->ops->xlate(host, controller, intspec, intsize,
547 &hwirq, &flags))
548 return NO_IRQ;
551 return irq_create_mapping(host, hwirq, flags);
553 EXPORT_SYMBOL_GPL(irq_create_of_mapping);
555 unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
557 struct of_irq oirq;
559 if (of_irq_map_one(dev, index, &oirq))
560 return NO_IRQ;
562 return irq_create_of_mapping(oirq.controller, oirq.specifier,
563 oirq.size);
565 EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
567 void irq_dispose_mapping(unsigned int virq)
569 struct irq_host *host = irq_map[virq].host;
570 irq_hw_number_t hwirq;
571 unsigned long flags;
573 WARN_ON (host == NULL);
574 if (host == NULL)
575 return;
577 /* Never unmap legacy interrupts */
578 if (host->revmap_type == IRQ_HOST_MAP_LEGACY)
579 return;
581 /* remove chip and handler */
582 set_irq_chip_and_handler(virq, NULL, NULL);
584 /* Make sure it's completed */
585 synchronize_irq(virq);
587 /* Tell the PIC about it */
588 if (host->ops->unmap)
589 host->ops->unmap(host, virq);
590 smp_mb();
592 /* Clear reverse map */
593 hwirq = irq_map[virq].hwirq;
594 switch(host->revmap_type) {
595 case IRQ_HOST_MAP_LINEAR:
596 if (hwirq < host->revmap_data.linear.size)
597 host->revmap_data.linear.revmap[hwirq] = IRQ_NONE;
598 break;
599 case IRQ_HOST_MAP_TREE:
600 /* Check if radix tree allocated yet */
601 if (host->revmap_data.tree.gfp_mask == 0)
602 break;
603 /* XXX radix tree not safe ! remove lock whem it becomes safe
604 * and use some RCU sync to make sure everything is ok before we
605 * can re-use that map entry
607 spin_lock_irqsave(&irq_big_lock, flags);
608 radix_tree_delete(&host->revmap_data.tree, hwirq);
609 spin_unlock_irqrestore(&irq_big_lock, flags);
610 break;
613 /* Destroy map */
614 smp_mb();
615 irq_map[virq].hwirq = host->inval_irq;
617 /* Set some flags */
618 get_irq_desc(virq)->status |= IRQ_NOREQUEST;
620 /* Free it */
621 irq_free_virt(virq, 1);
623 EXPORT_SYMBOL_GPL(irq_dispose_mapping);
625 unsigned int irq_find_mapping(struct irq_host *host,
626 irq_hw_number_t hwirq)
628 unsigned int i;
629 unsigned int hint = hwirq % irq_virq_count;
631 /* Look for default host if nececssary */
632 if (host == NULL)
633 host = irq_default_host;
634 if (host == NULL)
635 return NO_IRQ;
637 /* legacy -> bail early */
638 if (host->revmap_type == IRQ_HOST_MAP_LEGACY)
639 return hwirq;
641 /* Slow path does a linear search of the map */
642 if (hint < NUM_ISA_INTERRUPTS)
643 hint = NUM_ISA_INTERRUPTS;
644 i = hint;
645 do {
646 if (irq_map[i].host == host &&
647 irq_map[i].hwirq == hwirq)
648 return i;
649 i++;
650 if (i >= irq_virq_count)
651 i = NUM_ISA_INTERRUPTS;
652 } while(i != hint);
653 return NO_IRQ;
655 EXPORT_SYMBOL_GPL(irq_find_mapping);
658 unsigned int irq_radix_revmap(struct irq_host *host,
659 irq_hw_number_t hwirq)
661 struct radix_tree_root *tree;
662 struct irq_map_entry *ptr;
663 unsigned int virq;
664 unsigned long flags;
666 WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE);
668 /* Check if the radix tree exist yet. We test the value of
669 * the gfp_mask for that. Sneaky but saves another int in the
670 * structure. If not, we fallback to slow mode
672 tree = &host->revmap_data.tree;
673 if (tree->gfp_mask == 0)
674 return irq_find_mapping(host, hwirq);
676 /* XXX Current radix trees are NOT SMP safe !!! Remove that lock
677 * when that is fixed (when Nick's patch gets in
679 spin_lock_irqsave(&irq_big_lock, flags);
681 /* Now try to resolve */
682 ptr = radix_tree_lookup(tree, hwirq);
683 /* Found it, return */
684 if (ptr) {
685 virq = ptr - irq_map;
686 goto bail;
689 /* If not there, try to insert it */
690 virq = irq_find_mapping(host, hwirq);
691 if (virq != NO_IRQ)
692 radix_tree_insert(tree, virq, &irq_map[virq]);
693 bail:
694 spin_unlock_irqrestore(&irq_big_lock, flags);
695 return virq;
698 unsigned int irq_linear_revmap(struct irq_host *host,
699 irq_hw_number_t hwirq)
701 unsigned int *revmap;
703 WARN_ON(host->revmap_type != IRQ_HOST_MAP_LINEAR);
705 /* Check revmap bounds */
706 if (unlikely(hwirq >= host->revmap_data.linear.size))
707 return irq_find_mapping(host, hwirq);
709 /* Check if revmap was allocated */
710 revmap = host->revmap_data.linear.revmap;
711 if (unlikely(revmap == NULL))
712 return irq_find_mapping(host, hwirq);
714 /* Fill up revmap with slow path if no mapping found */
715 if (unlikely(revmap[hwirq] == NO_IRQ))
716 revmap[hwirq] = irq_find_mapping(host, hwirq);
718 return revmap[hwirq];
721 unsigned int irq_alloc_virt(struct irq_host *host,
722 unsigned int count,
723 unsigned int hint)
725 unsigned long flags;
726 unsigned int i, j, found = NO_IRQ;
727 unsigned int limit = irq_virq_count - count;
729 if (count == 0 || count > (irq_virq_count - NUM_ISA_INTERRUPTS))
730 return NO_IRQ;
732 spin_lock_irqsave(&irq_big_lock, flags);
734 /* Use hint for 1 interrupt if any */
735 if (count == 1 && hint >= NUM_ISA_INTERRUPTS &&
736 hint < irq_virq_count && irq_map[hint].host == NULL) {
737 found = hint;
738 goto hint_found;
741 /* Look for count consecutive numbers in the allocatable
742 * (non-legacy) space
744 for (i = NUM_ISA_INTERRUPTS; i <= limit; ) {
745 for (j = i; j < (i + count); j++)
746 if (irq_map[j].host != NULL) {
747 i = j + 1;
748 continue;
750 found = i;
751 break;
753 if (found == NO_IRQ) {
754 spin_unlock_irqrestore(&irq_big_lock, flags);
755 return NO_IRQ;
757 hint_found:
758 for (i = found; i < (found + count); i++) {
759 irq_map[i].hwirq = host->inval_irq;
760 smp_wmb();
761 irq_map[i].host = host;
763 spin_unlock_irqrestore(&irq_big_lock, flags);
764 return found;
767 void irq_free_virt(unsigned int virq, unsigned int count)
769 unsigned long flags;
770 unsigned int i;
772 WARN_ON (virq < NUM_ISA_INTERRUPTS);
773 WARN_ON (count == 0 || (virq + count) > irq_virq_count);
775 spin_lock_irqsave(&irq_big_lock, flags);
776 for (i = virq; i < (virq + count); i++) {
777 struct irq_host *host;
779 if (i < NUM_ISA_INTERRUPTS ||
780 (virq + count) > irq_virq_count)
781 continue;
783 host = irq_map[i].host;
784 irq_map[i].hwirq = host->inval_irq;
785 smp_wmb();
786 irq_map[i].host = NULL;
788 spin_unlock_irqrestore(&irq_big_lock, flags);
791 void irq_early_init(void)
793 unsigned int i;
795 for (i = 0; i < NR_IRQS; i++)
796 get_irq_desc(i)->status |= IRQ_NOREQUEST;
799 /* We need to create the radix trees late */
800 static int irq_late_init(void)
802 struct irq_host *h;
803 unsigned long flags;
805 spin_lock_irqsave(&irq_big_lock, flags);
806 list_for_each_entry(h, &irq_hosts, link) {
807 if (h->revmap_type == IRQ_HOST_MAP_TREE)
808 INIT_RADIX_TREE(&h->revmap_data.tree, GFP_ATOMIC);
810 spin_unlock_irqrestore(&irq_big_lock, flags);
812 return 0;
814 arch_initcall(irq_late_init);
816 #endif /* CONFIG_PPC_MERGE */
818 #ifdef CONFIG_PCI_MSI
819 int pci_enable_msi(struct pci_dev * pdev)
821 if (ppc_md.enable_msi)
822 return ppc_md.enable_msi(pdev);
823 else
824 return -1;
827 void pci_disable_msi(struct pci_dev * pdev)
829 if (ppc_md.disable_msi)
830 ppc_md.disable_msi(pdev);
833 void pci_scan_msi_device(struct pci_dev *dev) {}
834 int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) {return -1;}
835 void pci_disable_msix(struct pci_dev *dev) {}
836 void msi_remove_pci_irq_vectors(struct pci_dev *dev) {}
837 void disable_msi_mode(struct pci_dev *dev, int pos, int type) {}
838 void pci_no_msi(void) {}
840 #endif
842 #ifdef CONFIG_PPC64
843 static int __init setup_noirqdistrib(char *str)
845 distribute_irqs = 0;
846 return 1;
849 __setup("noirqdistrib", setup_noirqdistrib);
850 #endif /* CONFIG_PPC64 */