Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/pci-2.6
[safe/jmp/linux-2.6] / arch / powerpc / kernel / irq.c
index 24bea97..425616f 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/mutex.h>
 #include <linux/bootmem.h>
 #include <linux/pci.h>
+#include <linux/debugfs.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -113,7 +114,7 @@ static inline void set_soft_enabled(unsigned long enable)
        : : "r" (enable), "i" (offsetof(struct paca_struct, soft_enabled)));
 }
 
-void local_irq_restore(unsigned long en)
+void raw_local_irq_restore(unsigned long en)
 {
        /*
         * get_paca()->soft_enabled = en;
@@ -142,7 +143,6 @@ void local_irq_restore(unsigned long en)
                 */
                if (local_paca->lppaca_ptr->int_dword.any_int)
                        iseries_handle_interrupts();
-               return;
        }
 
        /*
@@ -174,6 +174,7 @@ void local_irq_restore(unsigned long en)
 
        __hard_irq_enable();
 }
+EXPORT_SYMBOL(raw_local_irq_restore);
 #endif /* CONFIG_PPC64 */
 
 int show_interrupts(struct seq_file *p, void *v)
@@ -272,7 +273,7 @@ void do_IRQ(struct pt_regs *regs)
        struct thread_info *curtp, *irqtp;
 #endif
 
-        irq_enter();
+       irq_enter();
 
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
        /* Debugging check for stack overflow: is there less than 2KB free? */
@@ -310,8 +311,21 @@ void do_IRQ(struct pt_regs *regs)
                                handler = &__do_IRQ;
                        irqtp->task = curtp->task;
                        irqtp->flags = 0;
+
+                       /* Copy the softirq bits in preempt_count so that the
+                        * softirq checks work in the hardirq context.
+                        */
+                       irqtp->preempt_count =
+                               (irqtp->preempt_count & ~SOFTIRQ_MASK) |
+                               (curtp->preempt_count & SOFTIRQ_MASK);
+
                        call_handle_irq(irq, desc, irqtp, handler);
                        irqtp->task = NULL;
+
+
+                       /* Set any flag that may have been set on the
+                        * alternate stack
+                        */
                        if (irqtp->flags)
                                set_bits(irqtp->flags, &curtp->flags);
                } else
@@ -321,7 +335,7 @@ void do_IRQ(struct pt_regs *regs)
                /* That's not SMP safe ... but who cares ? */
                ppc_spurious_interrupts++;
 
-        irq_exit();
+       irq_exit();
        set_irq_regs(old_regs);
 
 #ifdef CONFIG_PPC_ISERIES
@@ -357,7 +371,7 @@ void irq_ctx_init(void)
                memset((void *)softirq_ctx[i], 0, THREAD_SIZE);
                tp = softirq_ctx[i];
                tp->cpu = i;
-               tp->preempt_count = SOFTIRQ_OFFSET;
+               tp->preempt_count = 0;
 
                memset((void *)hardirq_ctx[i], 0, THREAD_SIZE);
                tp = hardirq_ctx[i];
@@ -395,7 +409,6 @@ void do_softirq(void)
 
        local_irq_restore(flags);
 }
-EXPORT_SYMBOL(do_softirq);
 
 
 /*
@@ -418,10 +431,16 @@ irq_hw_number_t virq_to_hw(unsigned int virq)
 }
 EXPORT_SYMBOL_GPL(virq_to_hw);
 
-__init_refok struct irq_host *irq_alloc_host(unsigned int revmap_type,
-                                               unsigned int revmap_arg,
-                                               struct irq_host_ops *ops,
-                                               irq_hw_number_t inval_irq)
+static int default_irq_host_match(struct irq_host *h, struct device_node *np)
+{
+       return h->of_node != NULL && h->of_node == np;
+}
+
+struct irq_host *irq_alloc_host(struct device_node *of_node,
+                               unsigned int revmap_type,
+                               unsigned int revmap_arg,
+                               struct irq_host_ops *ops,
+                               irq_hw_number_t inval_irq)
 {
        struct irq_host *host;
        unsigned int size = sizeof(struct irq_host);
@@ -432,13 +451,7 @@ __init_refok struct irq_host *irq_alloc_host(unsigned int revmap_type,
        /* Allocate structure and revmap table if using linear mapping */
        if (revmap_type == IRQ_HOST_MAP_LINEAR)
                size += revmap_arg * sizeof(unsigned int);
-       if (mem_init_done)
-               host = kzalloc(size, GFP_KERNEL);
-       else {
-               host = alloc_bootmem(size);
-               if (host)
-                       memset(host, 0, size);
-       }
+       host = zalloc_maybe_bootmem(size, GFP_KERNEL);
        if (host == NULL)
                return NULL;
 
@@ -446,6 +459,10 @@ __init_refok struct irq_host *irq_alloc_host(unsigned int revmap_type,
        host->revmap_type = revmap_type;
        host->inval_irq = inval_irq;
        host->ops = ops;
+       host->of_node = of_node;
+
+       if (host->ops->match == NULL)
+               host->ops->match = default_irq_host_match;
 
        spin_lock_irqsave(&irq_big_lock, flags);
 
@@ -477,7 +494,7 @@ __init_refok struct irq_host *irq_alloc_host(unsigned int revmap_type,
                host->inval_irq = 0;
                /* setup us as the host for all legacy interrupts */
                for (i = 1; i < NUM_ISA_INTERRUPTS; i++) {
-                       irq_map[i].hwirq = 0;
+                       irq_map[i].hwirq = i;
                        smp_wmb();
                        irq_map[i].host = host;
                        smp_wmb();
@@ -487,7 +504,7 @@ __init_refok struct irq_host *irq_alloc_host(unsigned int revmap_type,
 
                        /* Legacy flags are left to default at this point,
                         * one can then use irq_create_mapping() to
-                        * explicitely change them
+                        * explicitly change them
                         */
                        ops->map(host, i, i);
                }
@@ -521,7 +538,7 @@ struct irq_host *irq_find_host(struct device_node *node)
         */
        spin_lock_irqsave(&irq_big_lock, flags);
        list_for_each_entry(h, &irq_hosts, link)
-               if (h->ops->match == NULL || h->ops->match(h, node)) {
+               if (h->ops->match(h, node)) {
                        found = h;
                        break;
                }
@@ -996,6 +1013,68 @@ static int irq_late_init(void)
 }
 arch_initcall(irq_late_init);
 
+#ifdef CONFIG_VIRQ_DEBUG
+static int virq_debug_show(struct seq_file *m, void *private)
+{
+       unsigned long flags;
+       irq_desc_t *desc;
+       const char *p;
+       char none[] = "none";
+       int i;
+
+       seq_printf(m, "%-5s  %-7s  %-15s  %s\n", "virq", "hwirq",
+                     "chip name", "host name");
+
+       for (i = 1; i < NR_IRQS; i++) {
+               desc = get_irq_desc(i);
+               spin_lock_irqsave(&desc->lock, flags);
+
+               if (desc->action && desc->action->handler) {
+                       seq_printf(m, "%5d  ", i);
+                       seq_printf(m, "0x%05lx  ", virq_to_hw(i));
+
+                       if (desc->chip && desc->chip->typename)
+                               p = desc->chip->typename;
+                       else
+                               p = none;
+                       seq_printf(m, "%-15s  ", p);
+
+                       if (irq_map[i].host && irq_map[i].host->of_node)
+                               p = irq_map[i].host->of_node->full_name;
+                       else
+                               p = none;
+                       seq_printf(m, "%s\n", p);
+               }
+
+               spin_unlock_irqrestore(&desc->lock, flags);
+       }
+
+       return 0;
+}
+
+static int virq_debug_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, virq_debug_show, inode->i_private);
+}
+
+static const struct file_operations virq_debug_fops = {
+       .open = virq_debug_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
+
+static int __init irq_debugfs_init(void)
+{
+       if (debugfs_create_file("virq_mapping", S_IRUGO, powerpc_debugfs_root,
+                                NULL, &virq_debug_fops))
+               return -ENOMEM;
+
+       return 0;
+}
+__initcall(irq_debugfs_init);
+#endif /* CONFIG_VIRQ_DEBUG */
+
 #endif /* CONFIG_PPC_MERGE */
 
 #ifdef CONFIG_PPC64