Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / arm / kernel / irq.c
index ff187f4..2d5896b 100644 (file)
@@ -4,6 +4,10 @@
  *  Copyright (C) 1992 Linus Torvalds
  *  Modifications for ARM processor Copyright (C) 1995-2000 Russell King.
  *
+ *  Support for Dynamic Tick Timer Copyright (C) 2004-2005 Nokia Corporation.
+ *  Dynamic Tick Timer written by Tony Lindgren <tony@atomide.com> and
+ *  Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>.
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
@@ -37,6 +41,7 @@
 #include <asm/irq.h>
 #include <asm/system.h>
 #include <asm/mach/irq.h>
+#include <asm/mach/time.h>
 
 /*
  * Maximum IRQ count.  Currently, this is arbitary.  However, it should
@@ -202,8 +207,8 @@ void enable_irq_wake(unsigned int irq)
        unsigned long flags;
 
        spin_lock_irqsave(&irq_controller_lock, flags);
-       if (desc->chip->wake)
-               desc->chip->wake(irq, 1);
+       if (desc->chip->set_wake)
+               desc->chip->set_wake(irq, 1);
        spin_unlock_irqrestore(&irq_controller_lock, flags);
 }
 EXPORT_SYMBOL(enable_irq_wake);
@@ -214,8 +219,8 @@ void disable_irq_wake(unsigned int irq)
        unsigned long flags;
 
        spin_lock_irqsave(&irq_controller_lock, flags);
-       if (desc->chip->wake)
-               desc->chip->wake(irq, 0);
+       if (desc->chip->set_wake)
+               desc->chip->set_wake(irq, 0);
        spin_unlock_irqrestore(&irq_controller_lock, flags);
 }
 EXPORT_SYMBOL(disable_irq_wake);
@@ -259,6 +264,7 @@ unlock:
 #endif
 #ifdef CONFIG_SMP
                show_ipi_list(p);
+               show_local_irqs(p);
 #endif
                seq_printf(p, "Err: %10lu\n", irq_err_count);
        }
@@ -299,14 +305,19 @@ report_bad_irq(unsigned int irq, struct pt_regs *regs, struct irqdesc *desc, int
        static int count = 100;
        struct irqaction *action;
 
-       if (!count || noirqdebug)
+       if (noirqdebug)
                return;
 
-       count--;
-
        if (ret != IRQ_HANDLED && ret != IRQ_NONE) {
+               if (!count)
+                       return;
+               count--;
                printk("irq%u: bogus retval mask %x\n", irq, ret);
        } else {
+               desc->irqs_unhandled++;
+               if (desc->irqs_unhandled <= 99900)
+                       return;
+               desc->irqs_unhandled = 0;
                printk("irq%u: nobody cared\n", irq);
        }
        show_regs(regs);
@@ -329,6 +340,15 @@ __do_irq(unsigned int irq, struct irqaction *action, struct pt_regs *regs)
 
        spin_unlock(&irq_controller_lock);
 
+#ifdef CONFIG_NO_IDLE_HZ
+       if (!(action->flags & SA_TIMER) && system_timer->dyn_tick != NULL) {
+               write_seqlock(&xtime_lock);
+               if (system_timer->dyn_tick->state & DYN_TICK_ENABLED)
+                       system_timer->dyn_tick->handler(irq, 0, regs);
+               write_sequnlock(&xtime_lock);
+       }
+#endif
+
        if (!(action->flags & SA_INTERRUPT))
                local_irq_enable();
 
@@ -503,7 +523,7 @@ static void do_pending_irqs(struct pt_regs *regs)
                list_for_each_safe(l, n, &head) {
                        desc = list_entry(l, struct irqdesc, pend);
                        list_del_init(&desc->pend);
-                       desc->handle(desc - irq_desc, desc, regs);
+                       desc_handle_irq(desc - irq_desc, desc, regs);
                }
 
                /*
@@ -531,7 +551,7 @@ asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs)
 
        irq_enter();
        spin_lock(&irq_controller_lock);
-       desc->handle(irq, desc, regs);
+       desc_handle_irq(irq, desc, regs);
 
        /*
         * Now re-run any pending interrupts.
@@ -610,9 +630,9 @@ int set_irq_type(unsigned int irq, unsigned int type)
        }
 
        desc = irq_desc + irq;
-       if (desc->chip->type) {
+       if (desc->chip->set_type) {
                spin_lock_irqsave(&irq_controller_lock, flags);
-               ret = desc->chip->type(irq, type);
+               ret = desc->chip->set_type(irq, type);
                spin_unlock_irqrestore(&irq_controller_lock, flags);
        }
 
@@ -669,8 +689,12 @@ int setup_irq(unsigned int irq, struct irqaction *new)
        spin_lock_irqsave(&irq_controller_lock, flags);
        p = &desc->action;
        if ((old = *p) != NULL) {
-               /* Can't share interrupts unless both agree to */
-               if (!(old->flags & new->flags & SA_SHIRQ)) {
+               /*
+                * Can't share interrupts unless both agree to and are
+                * the same type.
+                */
+               if (!(old->flags & new->flags & SA_SHIRQ) ||
+                   (~old->flags & new->flags) & SA_TRIGGER_MASK) {
                        spin_unlock_irqrestore(&irq_controller_lock, flags);
                        return -EBUSY;
                }
@@ -690,6 +714,13 @@ int setup_irq(unsigned int irq, struct irqaction *new)
                desc->running = 0;
                desc->pending = 0;
                desc->disable_depth = 1;
+
+               if (new->flags & SA_TRIGGER_MASK &&
+                   desc->chip->set_type) {
+                       unsigned int type = new->flags & SA_TRIGGER_MASK;
+                       desc->chip->set_type(irq, type);
+               }
+
                if (!desc->noautoenable) {
                        desc->disable_depth = 0;
                        desc->chip->unmask(irq);
@@ -832,8 +863,8 @@ unsigned long probe_irq_on(void)
 
                irq_desc[i].probing = 1;
                irq_desc[i].triggered = 0;
-               if (irq_desc[i].chip->type)
-                       irq_desc[i].chip->type(i, IRQT_PROBE);
+               if (irq_desc[i].chip->set_type)
+                       irq_desc[i].chip->set_type(i, IRQT_PROBE);
                irq_desc[i].chip->unmask(i);
                irqs += 1;
        }
@@ -981,7 +1012,7 @@ void __init init_irq_proc(void)
        struct proc_dir_entry *dir;
        int irq;
 
-       dir = proc_mkdir("irq", 0);
+       dir = proc_mkdir("irq", NULL);
        if (!dir)
                return;
 
@@ -1012,7 +1043,6 @@ void __init init_irq_proc(void)
 void __init init_IRQ(void)
 {
        struct irqdesc *desc;
-       extern void init_dma(void);
        int irq;
 
 #ifdef CONFIG_SMP
@@ -1026,7 +1056,6 @@ void __init init_IRQ(void)
        }
 
        init_arch_irq();
-       init_dma();
 }
 
 static int __init noirqdebug_setup(char *str)
@@ -1036,3 +1065,34 @@ static int __init noirqdebug_setup(char *str)
 }
 
 __setup("noirqdebug", noirqdebug_setup);
+
+#ifdef CONFIG_HOTPLUG_CPU
+/*
+ * The CPU has been marked offline.  Migrate IRQs off this CPU.  If
+ * the affinity settings do not allow other CPUs, force them onto any
+ * available CPU.
+ */
+void migrate_irqs(void)
+{
+       unsigned int i, cpu = smp_processor_id();
+
+       for (i = 0; i < NR_IRQS; i++) {
+               struct irqdesc *desc = irq_desc + i;
+
+               if (desc->cpu == cpu) {
+                       unsigned int newcpu = any_online_cpu(desc->affinity);
+
+                       if (newcpu == NR_CPUS) {
+                               if (printk_ratelimit())
+                                       printk(KERN_INFO "IRQ%u no longer affine to CPU%u\n",
+                                              i, cpu);
+
+                               cpus_setall(desc->affinity);
+                               newcpu = any_online_cpu(desc->affinity);
+                       }
+
+                       route_irq(desc, i, newcpu);
+               }
+       }
+}
+#endif /* CONFIG_HOTPLUG_CPU */