[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] Better separate IOAPIC management from interrupt vector management



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1233916946 0
# Node ID 4fcf4c9c9751ccb8ed427470655e4c100db4f908
# Parent  501bc4129e41b654cb3236b810ee60b272df11cc
Better separate IOAPIC management from interrupt vector management

Don't automatically update ioapic_irq array when allocating vectors.
Only do so when actually allocating IOAPIC irqs.  Also move some
IOAPIC specific defines to io_apic.c.

Signed-off-by: Espen Skoglund <espen.skoglund@xxxxxxxxxxxxx>
---
 xen/arch/x86/io_apic.c    |   15 +++++++++++----
 xen/arch/x86/irq.c        |    6 ++----
 xen/arch/x86/smpboot.c    |    2 --
 xen/include/asm-x86/irq.h |   31 ++++++++++++++++---------------
 4 files changed, 29 insertions(+), 25 deletions(-)

diff -r 501bc4129e41 -r 4fcf4c9c9751 xen/arch/x86/io_apic.c
--- a/xen/arch/x86/io_apic.c    Fri Feb 06 10:40:00 2009 +0000
+++ b/xen/arch/x86/io_apic.c    Fri Feb 06 10:42:26 2009 +0000
@@ -39,6 +39,10 @@
 #include <io_ports.h>
 #include <public/physdev.h>
 
+
+#define IO_APIC_IRQ(irq)    (!IS_LEGACY_IRQ(irq))
+#define IO_APIC_VECTOR(irq) (ioapic_irq_vector[irq])
+
 /* Different to Linux: our implementation can be simpler. */
 #define make_8259A_irq(irq) (io_apic_irqs &= ~(1<<(irq)))
 
@@ -662,8 +666,8 @@ static inline int IO_APIC_irq_trigger(in
     return 0;
 }
 
-/* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */
-u8 irq_vector[NR_IRQS] __read_mostly;
+/* irq vectors are indexed by the sum of all RTEs in all I/O APICs. */
+u8 ioapic_irq_vector[NR_IRQS] __read_mostly;
 
 static struct hw_interrupt_type ioapic_level_type;
 static struct hw_interrupt_type ioapic_edge_type;
@@ -740,6 +744,7 @@ static void __init setup_IO_APIC_irqs(vo
 
             if (IO_APIC_IRQ(irq)) {
                 vector = assign_irq_vector(irq);
+                ioapic_irq_vector[irq] = vector;
                 entry.vector = vector;
                 ioapic_register_intr(irq, vector, IOAPIC_AUTO);
                
@@ -933,9 +938,9 @@ void /*__init*/ __print_IO_APIC(void)
         struct irq_pin_list *entry = irq_2_pin + i;
         if (entry->pin < 0)
             continue;
-        printk(KERN_DEBUG "IRQ%d ", IO_APIC_VECTOR(i));
+        printk(KERN_DEBUG "IRQ%-3d (vec %3d)", i, IO_APIC_VECTOR(i));
         for (;;) {
-            printk("-> %d:%d", entry->apic, entry->pin);
+            printk(" -> %d:%d", entry->apic, entry->pin);
             if (!entry->next)
                 break;
             entry = irq_2_pin + entry->next;
@@ -1662,6 +1667,7 @@ static inline void check_timer(void)
      */
     disable_8259A_irq(0);
     vector = assign_irq_vector(0);
+    ioapic_irq_vector[0] = vector;
 
     irq_desc[IO_APIC_VECTOR(0)].action = irq_desc[LEGACY_VECTOR(0)].action;
     irq_desc[IO_APIC_VECTOR(0)].depth  = 0;
@@ -2019,6 +2025,7 @@ int io_apic_set_pci_routing (int ioapic,
         add_pin_to_irq(irq, ioapic, pin);
 
     entry.vector = assign_irq_vector(irq);
+    ioapic_irq_vector[irq] = entry.vector;
 
     apic_printk(APIC_DEBUG, KERN_DEBUG "IOAPIC[%d]: Set PCI routing entry "
                "(%d-%d -> 0x%x -> IRQ %d Mode:%i Active:%i)\n", ioapic,
diff -r 501bc4129e41 -r 4fcf4c9c9751 xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c        Fri Feb 06 10:40:00 2009 +0000
+++ b/xen/arch/x86/irq.c        Fri Feb 06 10:42:26 2009 +0000
@@ -82,9 +82,9 @@ int assign_irq_vector(int irq)
 
     spin_lock(&vector_lock);
 
-    if ((irq != AUTO_ASSIGN) && (IO_APIC_VECTOR(irq) > 0)) {
+    if ((irq != AUTO_ASSIGN) && (ioapic_irq_vector[irq] > 0)) {
         spin_unlock(&vector_lock);
-        return IO_APIC_VECTOR(irq);
+        return ioapic_irq_vector[irq];
     }
 
     vector = current_vector;
@@ -101,8 +101,6 @@ int assign_irq_vector(int irq)
 
     current_vector = vector;
     vector_irq[vector] = irq;
-    if (irq != AUTO_ASSIGN)
-        IO_APIC_VECTOR(irq) = vector;
 
     spin_unlock(&vector_lock);
 
diff -r 501bc4129e41 -r 4fcf4c9c9751 xen/arch/x86/smpboot.c
--- a/xen/arch/x86/smpboot.c    Fri Feb 06 10:40:00 2009 +0000
+++ b/xen/arch/x86/smpboot.c    Fri Feb 06 10:42:26 2009 +0000
@@ -1477,7 +1477,6 @@ void __init smp_intr_init(void)
         * IRQ0 must be given a fixed assignment and initialized,
         * because it's used before the IO-APIC is set up.
         */
-       irq_vector[0] = FIRST_HIPRIORITY_VECTOR;
        vector_irq[FIRST_HIPRIORITY_VECTOR] = 0;
 
        /*
@@ -1487,7 +1486,6 @@ void __init smp_intr_init(void)
        for (seridx = 0; seridx < 2; seridx++) {
                if ((irq = serial_irq(seridx)) < 0)
                        continue;
-               irq_vector[irq] = FIRST_HIPRIORITY_VECTOR + seridx + 1;
                vector_irq[FIRST_HIPRIORITY_VECTOR + seridx + 1] = irq;
        }
 
diff -r 501bc4129e41 -r 4fcf4c9c9751 xen/include/asm-x86/irq.h
--- a/xen/include/asm-x86/irq.h Fri Feb 06 10:40:00 2009 +0000
+++ b/xen/include/asm-x86/irq.h Fri Feb 06 10:42:26 2009 +0000
@@ -7,21 +7,20 @@
 #include <asm/atomic.h>
 #include <irq_vectors.h>
 
-#define IO_APIC_IRQ(irq)    (((irq) >= 16) || ((1<<(irq)) & io_apic_irqs))
-#define IO_APIC_VECTOR(irq) (irq_vector[irq])
-
+#define IS_LEGACY_IRQ(irq) (((irq) < 16) && !((1 << (irq)) & io_apic_irqs))
 #define LEGACY_VECTOR(irq)          ((irq) + FIRST_LEGACY_VECTOR)
 #define LEGACY_IRQ_FROM_VECTOR(vec) ((vec) - FIRST_LEGACY_VECTOR)
 
-#define irq_to_vector(irq)  \
-    (IO_APIC_IRQ(irq) ? IO_APIC_VECTOR(irq) : LEGACY_VECTOR(irq))
-#define vector_to_irq(vec)  (vector_irq[vec])
-
-extern int vector_irq[NR_VECTORS];
-extern u8 irq_vector[NR_IRQS];
+/* Special IRQ numbers */
 #define AUTO_ASSIGN    -1
 #define NEVER_ASSIGN   -2
 #define FREE_TO_ASSIGN -3
+extern int vector_irq[NR_VECTORS];
+extern u8 ioapic_irq_vector[NR_IRQS];
+
+#define vector_to_irq(vec)              (vector_irq[vec])
+#define irq_to_vector(irq) \
+    (IS_LEGACY_IRQ(irq) ? LEGACY_VECTOR(irq) : ioapic_irq_vector[irq])
 
 #define platform_legacy_irq(irq)       ((irq) < 16)
 
@@ -60,12 +59,14 @@ int get_free_pirq(struct domain *d, int 
 int get_free_pirq(struct domain *d, int type, int index);
 void free_domain_pirqs(struct domain *d);
 
-#define domain_irq_to_vector(d, irq) ((d)->arch.pirq_vector[irq] ?: \
-                                      IO_APIC_IRQ(irq) ? 0 : 
LEGACY_VECTOR(irq))
-#define domain_vector_to_irq(d, vec) ((d)->arch.vector_pirq[vec] ?: \
-                                      ((vec) < FIRST_LEGACY_VECTOR || \
-                                       (vec) > LAST_LEGACY_VECTOR) ? \
-                                      0 : LEGACY_IRQ_FROM_VECTOR(vec))
+#define domain_irq_to_vector(d, irq)                            \
+    ((d)->arch.pirq_vector[irq] ? (d)->arch.pirq_vector[irq] :  \
+     IS_LEGACY_IRQ(irq) ? LEGACY_VECTOR(irq) : 0)
+
+#define domain_vector_to_irq(d, vec)                                    \
+    ((d)->arch.vector_pirq[vec] ? (d)->arch.vector_pirq[vec] :          \
+     ((vec) < FIRST_LEGACY_VECTOR || (vec) > LAST_LEGACY_VECTOR) ?      \
+     0 : LEGACY_IRQ_FROM_VECTOR(vec))
 
 int pirq_guest_force_unbind(struct domain *d, int irq);
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.