]> err.no Git - linux-2.6/blobdiff - arch/ia64/kernel/iosapic.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6
[linux-2.6] / arch / ia64 / kernel / iosapic.c
index e647254c27073d888eabc234087206a434a7fc55..cfe4654838f445423455979bca494d0e8fd1394a 100644 (file)
@@ -142,7 +142,7 @@ struct iosapic_rte_info {
 static struct iosapic_intr_info {
        struct list_head rtes;          /* RTEs using this vector (empty =>
                                         * not an IOSAPIC interrupt) */
-       int             count;          /* # of RTEs that shares this vector */
+       int             count;          /* # of registered RTEs */
        u32             low32;          /* current value of low word of
                                         * Redirection table entry */
        unsigned int    dest;           /* destination CPU physical ID */
@@ -313,7 +313,7 @@ mask_irq (unsigned int irq)
        int rte_index;
        struct iosapic_rte_info *rte;
 
-       if (list_empty(&iosapic_intr_info[irq].rtes))
+       if (!iosapic_intr_info[irq].count)
                return;                 /* not an IOSAPIC interrupt! */
 
        /* set only the mask bit */
@@ -331,7 +331,7 @@ unmask_irq (unsigned int irq)
        int rte_index;
        struct iosapic_rte_info *rte;
 
-       if (list_empty(&iosapic_intr_info[irq].rtes))
+       if (!iosapic_intr_info[irq].count)
                return;                 /* not an IOSAPIC interrupt! */
 
        low32 = iosapic_intr_info[irq].low32 &= ~IOSAPIC_MASK;
@@ -354,14 +354,16 @@ iosapic_set_affinity (unsigned int irq, cpumask_t mask)
 
        irq &= (~IA64_IRQ_REDIRECTED);
 
-       /* IRQ migration across domain is not supported yet */
-       cpus_and(mask, mask, irq_to_domain(irq));
+       cpus_and(mask, mask, cpu_online_map);
        if (cpus_empty(mask))
                return;
 
+       if (reassign_irq_vector(irq, first_cpu(mask)))
+               return;
+
        dest = cpu_physical_id(first_cpu(mask));
 
-       if (list_empty(&iosapic_intr_info[irq].rtes))
+       if (!iosapic_intr_info[irq].count)
                return;                 /* not an IOSAPIC interrupt */
 
        set_irq_affinity_info(irq, dest, redir);
@@ -376,6 +378,8 @@ iosapic_set_affinity (unsigned int irq, cpumask_t mask)
        else
                /* change delivery mode to fixed */
                low32 |= (IOSAPIC_FIXED << IOSAPIC_DELIVERY_SHIFT);
+       low32 &= IOSAPIC_VECTOR_MASK;
+       low32 |= irq_to_vector(irq);
 
        iosapic_intr_info[irq].low32 = low32;
        iosapic_intr_info[irq].dest = dest;
@@ -404,10 +408,20 @@ iosapic_end_level_irq (unsigned int irq)
 {
        ia64_vector vec = irq_to_vector(irq);
        struct iosapic_rte_info *rte;
+       int do_unmask_irq = 0;
+
+       if (unlikely(irq_desc[irq].status & IRQ_MOVE_PENDING)) {
+               do_unmask_irq = 1;
+               mask_irq(irq);
+       }
 
-       move_native_irq(irq);
        list_for_each_entry(rte, &iosapic_intr_info[irq].rtes, rte_list)
                iosapic_eoi(rte->iosapic->addr, vec);
+
+       if (unlikely(do_unmask_irq)) {
+               move_masked_irq(irq);
+               unmask_irq(irq);
+       }
 }
 
 #define iosapic_shutdown_level_irq     mask_irq
@@ -528,7 +542,7 @@ iosapic_reassign_vector (int irq)
 {
        int new_irq;
 
-       if (!list_empty(&iosapic_intr_info[irq].rtes)) {
+       if (iosapic_intr_info[irq].count) {
                new_irq = create_irq();
                if (new_irq < 0)
                        panic("%s: out of interrupt vectors!\n", __FUNCTION__);
@@ -546,7 +560,7 @@ iosapic_reassign_vector (int irq)
        }
 }
 
-static struct iosapic_rte_info *iosapic_alloc_rte (void)
+static struct iosapic_rte_info * __init_refok iosapic_alloc_rte (void)
 {
        int i;
        struct iosapic_rte_info *rte;
@@ -579,14 +593,6 @@ static struct iosapic_rte_info *iosapic_alloc_rte (void)
        return rte;
 }
 
-static void iosapic_free_rte (struct iosapic_rte_info *rte)
-{
-       if (rte->flags & RTE_PREALLOCATED)
-               list_add_tail(&rte->rte_list, &free_rte_list);
-       else
-               kfree(rte);
-}
-
 static inline int irq_is_shared (int irq)
 {
        return (iosapic_intr_info[irq].count > 1);
@@ -671,7 +677,7 @@ get_target_cpu (unsigned int gsi, int irq)
         * In case of vector shared by multiple RTEs, all RTEs that
         * share the vector need to use the same destination CPU.
         */
-       if (!list_empty(&iosapic_intr_info[irq].rtes))
+       if (iosapic_intr_info[irq].count)
                return iosapic_intr_info[irq].dest;
 
        /*
@@ -788,8 +794,9 @@ iosapic_register_intr (unsigned int gsi,
        err = register_intr(gsi, irq, IOSAPIC_LOWEST_PRIORITY,
                            polarity, trigger);
        if (err < 0) {
+               spin_unlock(&irq_desc[irq].lock);
                irq = err;
-               goto unlock_all;
+               goto unlock_iosapic_lock;
        }
 
        /*
@@ -805,7 +812,7 @@ iosapic_register_intr (unsigned int gsi,
               gsi, (trigger == IOSAPIC_EDGE ? "edge" : "level"),
               (polarity == IOSAPIC_POL_HIGH ? "high" : "low"),
               cpu_logical_id(dest), dest, irq_to_vector(irq));
- unlock_all:
+
        spin_unlock(&irq_desc[irq].lock);
  unlock_iosapic_lock:
        spin_unlock_irqrestore(&iosapic_lock, flags);