[POWERPC] Export msi symbols
[usb.git] / arch / powerpc / kernel / irq.c
blobb2ded6460a8606543ff52378f6cdbb6e979292db
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>
55 #include <linux/pci.h>
57 #include <asm/uaccess.h>
58 #include <asm/system.h>
59 #include <asm/io.h>
60 #include <asm/pgtable.h>
61 #include <asm/irq.h>
62 #include <asm/cache.h>
63 #include <asm/prom.h>
64 #include <asm/ptrace.h>
65 #include <asm/machdep.h>
66 #include <asm/udbg.h>
67 #ifdef CONFIG_PPC_ISERIES
68 #include <asm/paca.h>
69 #endif
71 int __irq_offset_value;
72 static int ppc_spurious_interrupts;
74 #ifdef CONFIG_PPC32
75 EXPORT_SYMBOL(__irq_offset_value);
76 atomic_t ppc_n_lost_interrupts;
78 #ifndef CONFIG_PPC_MERGE
79 #define NR_MASK_WORDS ((NR_IRQS + 31) / 32)
80 unsigned long ppc_cached_irq_mask[NR_MASK_WORDS];
81 #endif
83 #ifdef CONFIG_TAU_INT
84 extern int tau_initialized;
85 extern int tau_interrupts(int);
86 #endif
87 #endif /* CONFIG_PPC32 */
89 #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_MERGE)
90 extern atomic_t ipi_recv;
91 extern atomic_t ipi_sent;
92 #endif
94 #ifdef CONFIG_PPC64
95 EXPORT_SYMBOL(irq_desc);
97 int distribute_irqs = 1;
98 #endif /* CONFIG_PPC64 */
100 int show_interrupts(struct seq_file *p, void *v)
102 int i = *(loff_t *)v, j;
103 struct irqaction *action;
104 irq_desc_t *desc;
105 unsigned long flags;
107 if (i == 0) {
108 seq_puts(p, " ");
109 for_each_online_cpu(j)
110 seq_printf(p, "CPU%d ", j);
111 seq_putc(p, '\n');
114 if (i < NR_IRQS) {
115 desc = get_irq_desc(i);
116 spin_lock_irqsave(&desc->lock, flags);
117 action = desc->action;
118 if (!action || !action->handler)
119 goto skip;
120 seq_printf(p, "%3d: ", i);
121 #ifdef CONFIG_SMP
122 for_each_online_cpu(j)
123 seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
124 #else
125 seq_printf(p, "%10u ", kstat_irqs(i));
126 #endif /* CONFIG_SMP */
127 if (desc->chip)
128 seq_printf(p, " %s ", desc->chip->typename);
129 else
130 seq_puts(p, " None ");
131 seq_printf(p, "%s", (desc->status & IRQ_LEVEL) ? "Level " : "Edge ");
132 seq_printf(p, " %s", action->name);
133 for (action = action->next; action; action = action->next)
134 seq_printf(p, ", %s", action->name);
135 seq_putc(p, '\n');
136 skip:
137 spin_unlock_irqrestore(&desc->lock, flags);
138 } else if (i == NR_IRQS) {
139 #ifdef CONFIG_PPC32
140 #ifdef CONFIG_TAU_INT
141 if (tau_initialized){
142 seq_puts(p, "TAU: ");
143 for_each_online_cpu(j)
144 seq_printf(p, "%10u ", tau_interrupts(j));
145 seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n");
147 #endif
148 #if defined(CONFIG_SMP) && !defined(CONFIG_PPC_MERGE)
149 /* should this be per processor send/receive? */
150 seq_printf(p, "IPI (recv/sent): %10u/%u\n",
151 atomic_read(&ipi_recv), atomic_read(&ipi_sent));
152 #endif
153 #endif /* CONFIG_PPC32 */
154 seq_printf(p, "BAD: %10u\n", ppc_spurious_interrupts);
156 return 0;
159 #ifdef CONFIG_HOTPLUG_CPU
160 void fixup_irqs(cpumask_t map)
162 unsigned int irq;
163 static int warned;
165 for_each_irq(irq) {
166 cpumask_t mask;
168 if (irq_desc[irq].status & IRQ_PER_CPU)
169 continue;
171 cpus_and(mask, irq_desc[irq].affinity, map);
172 if (any_online_cpu(mask) == NR_CPUS) {
173 printk("Breaking affinity for irq %i\n", irq);
174 mask = map;
176 if (irq_desc[irq].chip->set_affinity)
177 irq_desc[irq].chip->set_affinity(irq, mask);
178 else if (irq_desc[irq].action && !(warned++))
179 printk("Cannot set affinity for irq %i\n", irq);
182 local_irq_enable();
183 mdelay(1);
184 local_irq_disable();
186 #endif
188 void do_IRQ(struct pt_regs *regs)
190 unsigned int irq;
191 #ifdef CONFIG_IRQSTACKS
192 struct thread_info *curtp, *irqtp;
193 #endif
195 irq_enter();
197 #ifdef CONFIG_DEBUG_STACKOVERFLOW
198 /* Debugging check for stack overflow: is there less than 2KB free? */
200 long sp;
202 sp = __get_SP() & (THREAD_SIZE-1);
204 if (unlikely(sp < (sizeof(struct thread_info) + 2048))) {
205 printk("do_IRQ: stack overflow: %ld\n",
206 sp - sizeof(struct thread_info));
207 dump_stack();
210 #endif
213 * Every platform is required to implement ppc_md.get_irq.
214 * This function will either return an irq number or -1 to
215 * indicate there are no more pending.
216 * The value -2 is for buggy hardware and means that this IRQ
217 * has already been handled. -- Tom
219 irq = ppc_md.get_irq(regs);
221 if (irq != NO_IRQ && irq != NO_IRQ_IGNORE) {
222 #ifdef CONFIG_IRQSTACKS
223 /* Switch to the irq stack to handle this */
224 curtp = current_thread_info();
225 irqtp = hardirq_ctx[smp_processor_id()];
226 if (curtp != irqtp) {
227 struct irq_desc *desc = irq_desc + irq;
228 void *handler = desc->handle_irq;
229 if (handler == NULL)
230 handler = &__do_IRQ;
231 irqtp->task = curtp->task;
232 irqtp->flags = 0;
233 call_handle_irq(irq, desc, regs, irqtp, handler);
234 irqtp->task = NULL;
235 if (irqtp->flags)
236 set_bits(irqtp->flags, &curtp->flags);
237 } else
238 #endif
239 generic_handle_irq(irq, regs);
240 } else if (irq != NO_IRQ_IGNORE)
241 /* That's not SMP safe ... but who cares ? */
242 ppc_spurious_interrupts++;
244 irq_exit();
246 #ifdef CONFIG_PPC_ISERIES
247 if (get_lppaca()->int_dword.fields.decr_int) {
248 get_lppaca()->int_dword.fields.decr_int = 0;
249 /* Signal a fake decrementer interrupt */
250 timer_interrupt(regs);
252 #endif
255 void __init init_IRQ(void)
257 ppc_md.init_IRQ();
258 #ifdef CONFIG_PPC64
259 irq_ctx_init();
260 #endif
264 #ifdef CONFIG_IRQSTACKS
265 struct thread_info *softirq_ctx[NR_CPUS] __read_mostly;
266 struct thread_info *hardirq_ctx[NR_CPUS] __read_mostly;
268 void irq_ctx_init(void)
270 struct thread_info *tp;
271 int i;
273 for_each_possible_cpu(i) {
274 memset((void *)softirq_ctx[i], 0, THREAD_SIZE);
275 tp = softirq_ctx[i];
276 tp->cpu = i;
277 tp->preempt_count = SOFTIRQ_OFFSET;
279 memset((void *)hardirq_ctx[i], 0, THREAD_SIZE);
280 tp = hardirq_ctx[i];
281 tp->cpu = i;
282 tp->preempt_count = HARDIRQ_OFFSET;
286 static inline void do_softirq_onstack(void)
288 struct thread_info *curtp, *irqtp;
290 curtp = current_thread_info();
291 irqtp = softirq_ctx[smp_processor_id()];
292 irqtp->task = curtp->task;
293 call_do_softirq(irqtp);
294 irqtp->task = NULL;
297 #else
298 #define do_softirq_onstack() __do_softirq()
299 #endif /* CONFIG_IRQSTACKS */
301 void do_softirq(void)
303 unsigned long flags;
305 if (in_interrupt())
306 return;
308 local_irq_save(flags);
310 if (local_softirq_pending())
311 do_softirq_onstack();
313 local_irq_restore(flags);
315 EXPORT_SYMBOL(do_softirq);
319 * IRQ controller and virtual interrupts
322 #ifdef CONFIG_PPC_MERGE
324 static LIST_HEAD(irq_hosts);
325 static spinlock_t irq_big_lock = SPIN_LOCK_UNLOCKED;
327 struct irq_map_entry irq_map[NR_IRQS];
328 static unsigned int irq_virq_count = NR_IRQS;
329 static struct irq_host *irq_default_host;
331 struct irq_host *irq_alloc_host(unsigned int revmap_type,
332 unsigned int revmap_arg,
333 struct irq_host_ops *ops,
334 irq_hw_number_t inval_irq)
336 struct irq_host *host;
337 unsigned int size = sizeof(struct irq_host);
338 unsigned int i;
339 unsigned int *rmap;
340 unsigned long flags;
342 /* Allocate structure and revmap table if using linear mapping */
343 if (revmap_type == IRQ_HOST_MAP_LINEAR)
344 size += revmap_arg * sizeof(unsigned int);
345 if (mem_init_done)
346 host = kzalloc(size, GFP_KERNEL);
347 else {
348 host = alloc_bootmem(size);
349 if (host)
350 memset(host, 0, size);
352 if (host == NULL)
353 return NULL;
355 /* Fill structure */
356 host->revmap_type = revmap_type;
357 host->inval_irq = inval_irq;
358 host->ops = ops;
360 spin_lock_irqsave(&irq_big_lock, flags);
362 /* If it's a legacy controller, check for duplicates and
363 * mark it as allocated (we use irq 0 host pointer for that
365 if (revmap_type == IRQ_HOST_MAP_LEGACY) {
366 if (irq_map[0].host != NULL) {
367 spin_unlock_irqrestore(&irq_big_lock, flags);
368 /* If we are early boot, we can't free the structure,
369 * too bad...
370 * this will be fixed once slab is made available early
371 * instead of the current cruft
373 if (mem_init_done)
374 kfree(host);
375 return NULL;
377 irq_map[0].host = host;
380 list_add(&host->link, &irq_hosts);
381 spin_unlock_irqrestore(&irq_big_lock, flags);
383 /* Additional setups per revmap type */
384 switch(revmap_type) {
385 case IRQ_HOST_MAP_LEGACY:
386 /* 0 is always the invalid number for legacy */
387 host->inval_irq = 0;
388 /* setup us as the host for all legacy interrupts */
389 for (i = 1; i < NUM_ISA_INTERRUPTS; i++) {
390 irq_map[i].hwirq = 0;
391 smp_wmb();
392 irq_map[i].host = host;
393 smp_wmb();
395 /* Clear norequest flags */
396 get_irq_desc(i)->status &= ~IRQ_NOREQUEST;
398 /* Legacy flags are left to default at this point,
399 * one can then use irq_create_mapping() to
400 * explicitely change them
402 ops->map(host, i, i);
404 break;
405 case IRQ_HOST_MAP_LINEAR:
406 rmap = (unsigned int *)(host + 1);
407 for (i = 0; i < revmap_arg; i++)
408 rmap[i] = IRQ_NONE;
409 host->revmap_data.linear.size = revmap_arg;
410 smp_wmb();
411 host->revmap_data.linear.revmap = rmap;
412 break;
413 default:
414 break;
417 pr_debug("irq: Allocated host of type %d @0x%p\n", revmap_type, host);
419 return host;
422 struct irq_host *irq_find_host(struct device_node *node)
424 struct irq_host *h, *found = NULL;
425 unsigned long flags;
427 /* We might want to match the legacy controller last since
428 * it might potentially be set to match all interrupts in
429 * the absence of a device node. This isn't a problem so far
430 * yet though...
432 spin_lock_irqsave(&irq_big_lock, flags);
433 list_for_each_entry(h, &irq_hosts, link)
434 if (h->ops->match == NULL || h->ops->match(h, node)) {
435 found = h;
436 break;
438 spin_unlock_irqrestore(&irq_big_lock, flags);
439 return found;
441 EXPORT_SYMBOL_GPL(irq_find_host);
443 void irq_set_default_host(struct irq_host *host)
445 pr_debug("irq: Default host set to @0x%p\n", host);
447 irq_default_host = host;
450 void irq_set_virq_count(unsigned int count)
452 pr_debug("irq: Trying to set virq count to %d\n", count);
454 BUG_ON(count < NUM_ISA_INTERRUPTS);
455 if (count < NR_IRQS)
456 irq_virq_count = count;
459 unsigned int irq_create_mapping(struct irq_host *host,
460 irq_hw_number_t hwirq)
462 unsigned int virq, hint;
464 pr_debug("irq: irq_create_mapping(0x%p, 0x%lx)\n", host, hwirq);
466 /* Look for default host if nececssary */
467 if (host == NULL)
468 host = irq_default_host;
469 if (host == NULL) {
470 printk(KERN_WARNING "irq_create_mapping called for"
471 " NULL host, hwirq=%lx\n", hwirq);
472 WARN_ON(1);
473 return NO_IRQ;
475 pr_debug("irq: -> using host @%p\n", host);
477 /* Check if mapping already exist, if it does, call
478 * host->ops->map() to update the flags
480 virq = irq_find_mapping(host, hwirq);
481 if (virq != IRQ_NONE) {
482 pr_debug("irq: -> existing mapping on virq %d\n", virq);
483 return virq;
486 /* Get a virtual interrupt number */
487 if (host->revmap_type == IRQ_HOST_MAP_LEGACY) {
488 /* Handle legacy */
489 virq = (unsigned int)hwirq;
490 if (virq == 0 || virq >= NUM_ISA_INTERRUPTS)
491 return NO_IRQ;
492 return virq;
493 } else {
494 /* Allocate a virtual interrupt number */
495 hint = hwirq % irq_virq_count;
496 virq = irq_alloc_virt(host, 1, hint);
497 if (virq == NO_IRQ) {
498 pr_debug("irq: -> virq allocation failed\n");
499 return NO_IRQ;
502 pr_debug("irq: -> obtained virq %d\n", virq);
504 /* Clear IRQ_NOREQUEST flag */
505 get_irq_desc(virq)->status &= ~IRQ_NOREQUEST;
507 /* map it */
508 smp_wmb();
509 irq_map[virq].hwirq = hwirq;
510 smp_mb();
511 if (host->ops->map(host, virq, hwirq)) {
512 pr_debug("irq: -> mapping failed, freeing\n");
513 irq_free_virt(virq, 1);
514 return NO_IRQ;
516 return virq;
518 EXPORT_SYMBOL_GPL(irq_create_mapping);
520 extern unsigned int irq_create_of_mapping(struct device_node *controller,
521 u32 *intspec, unsigned int intsize)
523 struct irq_host *host;
524 irq_hw_number_t hwirq;
525 unsigned int type = IRQ_TYPE_NONE;
526 unsigned int virq;
528 if (controller == NULL)
529 host = irq_default_host;
530 else
531 host = irq_find_host(controller);
532 if (host == NULL) {
533 printk(KERN_WARNING "irq: no irq host found for %s !\n",
534 controller->full_name);
535 return NO_IRQ;
538 /* If host has no translation, then we assume interrupt line */
539 if (host->ops->xlate == NULL)
540 hwirq = intspec[0];
541 else {
542 if (host->ops->xlate(host, controller, intspec, intsize,
543 &hwirq, &type))
544 return NO_IRQ;
547 /* Create mapping */
548 virq = irq_create_mapping(host, hwirq);
549 if (virq == NO_IRQ)
550 return virq;
552 /* Set type if specified and different than the current one */
553 if (type != IRQ_TYPE_NONE &&
554 type != (get_irq_desc(virq)->status & IRQF_TRIGGER_MASK))
555 set_irq_type(virq, type);
556 return virq;
558 EXPORT_SYMBOL_GPL(irq_create_of_mapping);
560 unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
562 struct of_irq oirq;
564 if (of_irq_map_one(dev, index, &oirq))
565 return NO_IRQ;
567 return irq_create_of_mapping(oirq.controller, oirq.specifier,
568 oirq.size);
570 EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
572 void irq_dispose_mapping(unsigned int virq)
574 struct irq_host *host = irq_map[virq].host;
575 irq_hw_number_t hwirq;
576 unsigned long flags;
578 WARN_ON (host == NULL);
579 if (host == NULL)
580 return;
582 /* Never unmap legacy interrupts */
583 if (host->revmap_type == IRQ_HOST_MAP_LEGACY)
584 return;
586 /* remove chip and handler */
587 set_irq_chip_and_handler(virq, NULL, NULL);
589 /* Make sure it's completed */
590 synchronize_irq(virq);
592 /* Tell the PIC about it */
593 if (host->ops->unmap)
594 host->ops->unmap(host, virq);
595 smp_mb();
597 /* Clear reverse map */
598 hwirq = irq_map[virq].hwirq;
599 switch(host->revmap_type) {
600 case IRQ_HOST_MAP_LINEAR:
601 if (hwirq < host->revmap_data.linear.size)
602 host->revmap_data.linear.revmap[hwirq] = IRQ_NONE;
603 break;
604 case IRQ_HOST_MAP_TREE:
605 /* Check if radix tree allocated yet */
606 if (host->revmap_data.tree.gfp_mask == 0)
607 break;
608 /* XXX radix tree not safe ! remove lock whem it becomes safe
609 * and use some RCU sync to make sure everything is ok before we
610 * can re-use that map entry
612 spin_lock_irqsave(&irq_big_lock, flags);
613 radix_tree_delete(&host->revmap_data.tree, hwirq);
614 spin_unlock_irqrestore(&irq_big_lock, flags);
615 break;
618 /* Destroy map */
619 smp_mb();
620 irq_map[virq].hwirq = host->inval_irq;
622 /* Set some flags */
623 get_irq_desc(virq)->status |= IRQ_NOREQUEST;
625 /* Free it */
626 irq_free_virt(virq, 1);
628 EXPORT_SYMBOL_GPL(irq_dispose_mapping);
630 unsigned int irq_find_mapping(struct irq_host *host,
631 irq_hw_number_t hwirq)
633 unsigned int i;
634 unsigned int hint = hwirq % irq_virq_count;
636 /* Look for default host if nececssary */
637 if (host == NULL)
638 host = irq_default_host;
639 if (host == NULL)
640 return NO_IRQ;
642 /* legacy -> bail early */
643 if (host->revmap_type == IRQ_HOST_MAP_LEGACY)
644 return hwirq;
646 /* Slow path does a linear search of the map */
647 if (hint < NUM_ISA_INTERRUPTS)
648 hint = NUM_ISA_INTERRUPTS;
649 i = hint;
650 do {
651 if (irq_map[i].host == host &&
652 irq_map[i].hwirq == hwirq)
653 return i;
654 i++;
655 if (i >= irq_virq_count)
656 i = NUM_ISA_INTERRUPTS;
657 } while(i != hint);
658 return NO_IRQ;
660 EXPORT_SYMBOL_GPL(irq_find_mapping);
663 unsigned int irq_radix_revmap(struct irq_host *host,
664 irq_hw_number_t hwirq)
666 struct radix_tree_root *tree;
667 struct irq_map_entry *ptr;
668 unsigned int virq;
669 unsigned long flags;
671 WARN_ON(host->revmap_type != IRQ_HOST_MAP_TREE);
673 /* Check if the radix tree exist yet. We test the value of
674 * the gfp_mask for that. Sneaky but saves another int in the
675 * structure. If not, we fallback to slow mode
677 tree = &host->revmap_data.tree;
678 if (tree->gfp_mask == 0)
679 return irq_find_mapping(host, hwirq);
681 /* XXX Current radix trees are NOT SMP safe !!! Remove that lock
682 * when that is fixed (when Nick's patch gets in
684 spin_lock_irqsave(&irq_big_lock, flags);
686 /* Now try to resolve */
687 ptr = radix_tree_lookup(tree, hwirq);
688 /* Found it, return */
689 if (ptr) {
690 virq = ptr - irq_map;
691 goto bail;
694 /* If not there, try to insert it */
695 virq = irq_find_mapping(host, hwirq);
696 if (virq != NO_IRQ)
697 radix_tree_insert(tree, virq, &irq_map[virq]);
698 bail:
699 spin_unlock_irqrestore(&irq_big_lock, flags);
700 return virq;
703 unsigned int irq_linear_revmap(struct irq_host *host,
704 irq_hw_number_t hwirq)
706 unsigned int *revmap;
708 WARN_ON(host->revmap_type != IRQ_HOST_MAP_LINEAR);
710 /* Check revmap bounds */
711 if (unlikely(hwirq >= host->revmap_data.linear.size))
712 return irq_find_mapping(host, hwirq);
714 /* Check if revmap was allocated */
715 revmap = host->revmap_data.linear.revmap;
716 if (unlikely(revmap == NULL))
717 return irq_find_mapping(host, hwirq);
719 /* Fill up revmap with slow path if no mapping found */
720 if (unlikely(revmap[hwirq] == NO_IRQ))
721 revmap[hwirq] = irq_find_mapping(host, hwirq);
723 return revmap[hwirq];
726 unsigned int irq_alloc_virt(struct irq_host *host,
727 unsigned int count,
728 unsigned int hint)
730 unsigned long flags;
731 unsigned int i, j, found = NO_IRQ;
732 unsigned int limit = irq_virq_count - count;
734 if (count == 0 || count > (irq_virq_count - NUM_ISA_INTERRUPTS))
735 return NO_IRQ;
737 spin_lock_irqsave(&irq_big_lock, flags);
739 /* Use hint for 1 interrupt if any */
740 if (count == 1 && hint >= NUM_ISA_INTERRUPTS &&
741 hint < irq_virq_count && irq_map[hint].host == NULL) {
742 found = hint;
743 goto hint_found;
746 /* Look for count consecutive numbers in the allocatable
747 * (non-legacy) space
749 for (i = NUM_ISA_INTERRUPTS; i <= limit; ) {
750 for (j = i; j < (i + count); j++)
751 if (irq_map[j].host != NULL) {
752 i = j + 1;
753 continue;
755 found = i;
756 break;
758 if (found == NO_IRQ) {
759 spin_unlock_irqrestore(&irq_big_lock, flags);
760 return NO_IRQ;
762 hint_found:
763 for (i = found; i < (found + count); i++) {
764 irq_map[i].hwirq = host->inval_irq;
765 smp_wmb();
766 irq_map[i].host = host;
768 spin_unlock_irqrestore(&irq_big_lock, flags);
769 return found;
772 void irq_free_virt(unsigned int virq, unsigned int count)
774 unsigned long flags;
775 unsigned int i;
777 WARN_ON (virq < NUM_ISA_INTERRUPTS);
778 WARN_ON (count == 0 || (virq + count) > irq_virq_count);
780 spin_lock_irqsave(&irq_big_lock, flags);
781 for (i = virq; i < (virq + count); i++) {
782 struct irq_host *host;
784 if (i < NUM_ISA_INTERRUPTS ||
785 (virq + count) > irq_virq_count)
786 continue;
788 host = irq_map[i].host;
789 irq_map[i].hwirq = host->inval_irq;
790 smp_wmb();
791 irq_map[i].host = NULL;
793 spin_unlock_irqrestore(&irq_big_lock, flags);
796 void irq_early_init(void)
798 unsigned int i;
800 for (i = 0; i < NR_IRQS; i++)
801 get_irq_desc(i)->status |= IRQ_NOREQUEST;
804 /* We need to create the radix trees late */
805 static int irq_late_init(void)
807 struct irq_host *h;
808 unsigned long flags;
810 spin_lock_irqsave(&irq_big_lock, flags);
811 list_for_each_entry(h, &irq_hosts, link) {
812 if (h->revmap_type == IRQ_HOST_MAP_TREE)
813 INIT_RADIX_TREE(&h->revmap_data.tree, GFP_ATOMIC);
815 spin_unlock_irqrestore(&irq_big_lock, flags);
817 return 0;
819 arch_initcall(irq_late_init);
821 #endif /* CONFIG_PPC_MERGE */
823 #ifdef CONFIG_PCI_MSI
824 int pci_enable_msi(struct pci_dev * pdev)
826 if (ppc_md.enable_msi)
827 return ppc_md.enable_msi(pdev);
828 else
829 return -1;
831 EXPORT_SYMBOL(pci_enable_msi);
833 void pci_disable_msi(struct pci_dev * pdev)
835 if (ppc_md.disable_msi)
836 ppc_md.disable_msi(pdev);
838 EXPORT_SYMBOL(pci_disable_msi);
840 void pci_scan_msi_device(struct pci_dev *dev) {}
841 int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) {return -1;}
842 void pci_disable_msix(struct pci_dev *dev) {}
843 void msi_remove_pci_irq_vectors(struct pci_dev *dev) {}
844 void disable_msi_mode(struct pci_dev *dev, int pos, int type) {}
845 void pci_no_msi(void) {}
846 EXPORT_SYMBOL(pci_enable_msix);
847 EXPORT_SYMBOL(pci_disable_msix);
849 #endif
851 #ifdef CONFIG_PPC64
852 static int __init setup_noirqdistrib(char *str)
854 distribute_irqs = 0;
855 return 1;
858 __setup("noirqdistrib", setup_noirqdistrib);
859 #endif /* CONFIG_PPC64 */