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

[Xen-changelog] [linux-2.6.18-xen] evtchn: Clean up pirq/dynirq handling.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1221557945 -3600
# Node ID 0ba49e9e74f9a6ecb5ae6597b5913b255bb6ed7a
# Parent  de4d39818577c14de7f687ae3eed5745cc903d10
evtchn: Clean up pirq/dynirq handling.

 * Remove dynirq/pirq_to/from_irq() macros. It's clearer to use *_BASE
   and NR_* macros directly.
 * Avoid and fix confusion between a Linux 'pirq' and a Xen
   'pirq'. This is basically done by avoiding the notion of a Linux
   'pirq' at all.
 * Fix IA64 build.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 drivers/xen/core/evtchn.c                 |   91 +++++++++++++++---------------
 include/asm-i386/mach-xen/irq_vectors.h   |    6 -
 include/asm-ia64/irq.h                    |    6 -
 include/asm-powerpc/xen/asm/hypervisor.h  |    7 --
 include/asm-x86_64/mach-xen/irq_vectors.h |    6 -
 5 files changed, 46 insertions(+), 70 deletions(-)

diff -r de4d39818577 -r 0ba49e9e74f9 drivers/xen/core/evtchn.c
--- a/drivers/xen/core/evtchn.c Fri Sep 12 10:37:32 2008 +0100
+++ b/drivers/xen/core/evtchn.c Tue Sep 16 10:39:05 2008 +0100
@@ -319,13 +319,11 @@ static int find_unbound_irq(void)
 static int find_unbound_irq(void)
 {
        static int warned;
-       int dynirq, irq;
-
-       for (dynirq = 0; dynirq < NR_DYNIRQS; dynirq++) {
-               irq = dynirq_to_irq(dynirq);
+       int irq;
+
+       for (irq = DYNIRQ_BASE; irq < (DYNIRQ_BASE + NR_DYNIRQS); irq++)
                if (irq_bindcount[irq] == 0)
                        return irq;
-       }
 
        if (!warned) {
                warned = 1;
@@ -761,9 +759,12 @@ void evtchn_register_pirq(int irq)
        irq_info[irq] = mk_irq_info(IRQT_PIRQ, irq, 0);
 }
 
-#ifndef CONFIG_X86_IO_APIC
-#undef IO_APIC_IRQ
-#define IO_APIC_IRQ(irq) ((irq) >= pirq_to_irq(16))
+#if defined(CONFIG_X86_IO_APIC)
+#define identity_mapped_irq(irq) (!IO_APIC_IRQ((irq) - PIRQ_BASE))
+#elif defined(CONFIG_X86)
+#define identity_mapped_irq(irq) (((irq) - PIRQ_BASE) < 16)
+#else
+#define identity_mapped_irq(irq) (0)
 #endif
 
 int evtchn_map_pirq(int irq, int xen_pirq)
@@ -771,10 +772,10 @@ int evtchn_map_pirq(int irq, int xen_pir
        if (irq < 0) {
                static DEFINE_SPINLOCK(irq_alloc_lock);
 
-               irq = pirq_to_irq(NR_PIRQS - 1);
+               irq = PIRQ_BASE + NR_PIRQS - 1;
                spin_lock(&irq_alloc_lock);
                do {
-                       if (!IO_APIC_IRQ(irq))
+                       if (identity_mapped_irq(irq))
                                continue;
                        if (!index_from_irq(irq)) {
                                BUG_ON(type_from_irq(irq) != IRQT_UNBOUND);
@@ -782,9 +783,9 @@ int evtchn_map_pirq(int irq, int xen_pir
                                                            xen_pirq, 0);
                                break;
                        }
-               } while (--irq);
+               } while (--irq >= PIRQ_BASE);
                spin_unlock(&irq_alloc_lock);
-               if (irq < pirq_to_irq(16))
+               if (irq < PIRQ_BASE)
                        return -ENOSPC;
        } else if (!xen_pirq) {
                if (unlikely(type_from_irq(irq) != IRQT_PIRQ))
@@ -803,29 +804,28 @@ int evtchn_map_pirq(int irq, int xen_pir
 
 int evtchn_get_xen_pirq(int irq)
 {
-       if (!IO_APIC_IRQ(irq))
+       if (identity_mapped_irq(irq))
                return irq;
-       if (unlikely(type_from_irq(irq) != IRQT_PIRQ))
-               return 0;
+       BUG_ON(type_from_irq(irq) != IRQT_PIRQ);
        return index_from_irq(irq);
 }
 
-static inline void pirq_unmask_notify(int pirq)
-{
-       struct physdev_eoi eoi = { .irq = pirq };
-       if (unlikely(test_bit(pirq, pirq_needs_eoi)))
+static inline void pirq_unmask_notify(int irq)
+{
+       struct physdev_eoi eoi = { .irq = evtchn_get_xen_pirq(irq) };
+       if (unlikely(test_bit(irq - PIRQ_BASE, pirq_needs_eoi)))
                VOID(HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi));
 }
 
-static inline void pirq_query_unmask(int pirq)
+static inline void pirq_query_unmask(int irq)
 {
        struct physdev_irq_status_query irq_status;
-       irq_status.irq = pirq;
+       irq_status.irq = evtchn_get_xen_pirq(irq);
        if (HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status))
                irq_status.flags = 0;
-       clear_bit(pirq, pirq_needs_eoi);
+       clear_bit(irq - PIRQ_BASE, pirq_needs_eoi);
        if (irq_status.flags & XENIRQSTAT_needs_eoi)
-               set_bit(pirq, pirq_needs_eoi);
+               set_bit(irq - PIRQ_BASE, pirq_needs_eoi);
 }
 
 /*
@@ -853,7 +853,7 @@ static unsigned int startup_pirq(unsigne
        }
        evtchn = bind_pirq.port;
 
-       pirq_query_unmask(irq_to_pirq(irq));
+       pirq_query_unmask(irq);
 
        evtchn_to_irq[evtchn] = irq;
        bind_evtchn_to_cpu(evtchn, 0);
@@ -861,7 +861,7 @@ static unsigned int startup_pirq(unsigne
 
  out:
        unmask_evtchn(evtchn);
-       pirq_unmask_notify(irq_to_pirq(irq));
+       pirq_unmask_notify(irq);
 
        return 0;
 }
@@ -915,7 +915,7 @@ static void end_pirq(unsigned int irq)
                shutdown_pirq(irq);
        } else if (VALID_EVTCHN(evtchn)) {
                unmask_evtchn(evtchn);
-               pirq_unmask_notify(irq_to_pirq(irq));
+               pirq_unmask_notify(irq);
        }
 }
 
@@ -1062,7 +1062,7 @@ static void restore_cpu_ipis(unsigned in
 
 void irq_resume(void)
 {
-       unsigned int cpu, pirq, irq, evtchn;
+       unsigned int cpu, irq, evtchn;
 
        init_evtchn_cpu_bindings();
 
@@ -1071,8 +1071,8 @@ void irq_resume(void)
                mask_evtchn(evtchn);
 
        /* Check that no PIRQs are still bound. */
-       for (pirq = 0; pirq < NR_PIRQS; pirq++)
-               BUG_ON(irq_info[pirq_to_irq(pirq)] != IRQ_UNBOUND);
+       for (irq = PIRQ_BASE; irq < (PIRQ_BASE + NR_PIRQS); irq++)
+               BUG_ON(irq_info[irq] != IRQ_UNBOUND);
 
        /* No IRQ <-> event-channel mappings. */
        for (irq = 0; irq < NR_IRQS; irq++)
@@ -1102,28 +1102,29 @@ void __init xen_init_IRQ(void)
                irq_info[i] = IRQ_UNBOUND;
 
        /* Dynamic IRQ space is currently unbound. Zero the refcnts. */
-       for (i = 0; i < NR_DYNIRQS; i++) {
-               irq_bindcount[dynirq_to_irq(i)] = 0;
-
-               irq_desc[dynirq_to_irq(i)].status = IRQ_DISABLED;
-               irq_desc[dynirq_to_irq(i)].action = NULL;
-               irq_desc[dynirq_to_irq(i)].depth = 1;
-               irq_desc[dynirq_to_irq(i)].chip = &dynirq_type;
+       for (i = DYNIRQ_BASE; i < (DYNIRQ_BASE + NR_DYNIRQS); i++) {
+               irq_bindcount[i] = 0;
+
+               irq_desc[i].status = IRQ_DISABLED;
+               irq_desc[i].action = NULL;
+               irq_desc[i].depth = 1;
+               irq_desc[i].chip = &dynirq_type;
        }
 
        /* Phys IRQ space is statically bound (1:1 mapping). Nail refcnts. */
-       for (i = 0; i < NR_PIRQS; i++) {
-               irq_bindcount[pirq_to_irq(i)] = 1;
+       for (i = PIRQ_BASE; i < (PIRQ_BASE + NR_PIRQS); i++) {
+               irq_bindcount[i] = 1;
 
 #ifdef RTC_IRQ
                /* If not domain 0, force our RTC driver to fail its probe. */
-               if ((i == RTC_IRQ) && !is_initial_xendomain())
+               if (identity_mapped_irq(i) && ((i - PIRQ_BASE) == RTC_IRQ)
+                   && !is_initial_xendomain())
                        continue;
 #endif
 
-               irq_desc[pirq_to_irq(i)].status = IRQ_DISABLED;
-               irq_desc[pirq_to_irq(i)].action = NULL;
-               irq_desc[pirq_to_irq(i)].depth = 1;
-               irq_desc[pirq_to_irq(i)].chip = &pirq_type;
-       }
-}
+               irq_desc[i].status = IRQ_DISABLED;
+               irq_desc[i].action = NULL;
+               irq_desc[i].depth = 1;
+               irq_desc[i].chip = &pirq_type;
+       }
+}
diff -r de4d39818577 -r 0ba49e9e74f9 include/asm-i386/mach-xen/irq_vectors.h
--- a/include/asm-i386/mach-xen/irq_vectors.h   Fri Sep 12 10:37:32 2008 +0100
+++ b/include/asm-i386/mach-xen/irq_vectors.h   Tue Sep 16 10:39:05 2008 +0100
@@ -122,10 +122,4 @@
 #define NR_IRQS                        (NR_PIRQS + NR_DYNIRQS)
 #define NR_IRQ_VECTORS         NR_IRQS
 
-#define pirq_to_irq(_x)                ((_x) + PIRQ_BASE)
-#define irq_to_pirq(_x)                ((_x) - PIRQ_BASE)
-
-#define dynirq_to_irq(_x)      ((_x) + DYNIRQ_BASE)
-#define irq_to_dynirq(_x)      ((_x) - DYNIRQ_BASE)
-
 #endif /* _ASM_IRQ_VECTORS_H */
diff -r de4d39818577 -r 0ba49e9e74f9 include/asm-ia64/irq.h
--- a/include/asm-ia64/irq.h    Fri Sep 12 10:37:32 2008 +0100
+++ b/include/asm-ia64/irq.h    Tue Sep 16 10:39:05 2008 +0100
@@ -34,12 +34,6 @@
 #define NR_IRQS                        (NR_PIRQS + NR_DYNIRQS)
 #define NR_IRQ_VECTORS         NR_IRQS
 
-#define pirq_to_irq(_x)                ((_x) + PIRQ_BASE)
-#define irq_to_pirq(_x)                ((_x) - PIRQ_BASE)
-
-#define dynirq_to_irq(_x)      ((_x) + DYNIRQ_BASE)
-#define irq_to_dynirq(_x)      ((_x) - DYNIRQ_BASE)
-
 #define RESCHEDULE_VECTOR      0
 #define IPI_VECTOR             1
 #define CMCP_VECTOR            2
diff -r de4d39818577 -r 0ba49e9e74f9 include/asm-powerpc/xen/asm/hypervisor.h
--- a/include/asm-powerpc/xen/asm/hypervisor.h  Fri Sep 12 10:37:32 2008 +0100
+++ b/include/asm-powerpc/xen/asm/hypervisor.h  Tue Sep 16 10:39:05 2008 +0100
@@ -154,13 +154,6 @@ int direct_remap_pfn_range(struct vm_are
 
 #define NR_IRQ_VECTORS         NR_IRQS
 
-#define pirq_to_irq(_x)                ((_x) + PIRQ_BASE)
-#define irq_to_pirq(_x)                ((_x) - PIRQ_BASE)
-
-#define dynirq_to_irq(_x)      ((_x) + DYNIRQ_BASE)
-#define irq_to_dynirq(_x)      ((_x) - DYNIRQ_BASE)
-
-
 /* END:  all of these need a new home */
 
 #if defined(CONFIG_X86_64)
diff -r de4d39818577 -r 0ba49e9e74f9 include/asm-x86_64/mach-xen/irq_vectors.h
--- a/include/asm-x86_64/mach-xen/irq_vectors.h Fri Sep 12 10:37:32 2008 +0100
+++ b/include/asm-x86_64/mach-xen/irq_vectors.h Tue Sep 16 10:39:05 2008 +0100
@@ -114,10 +114,4 @@
 #define NR_IRQS                        (NR_PIRQS + NR_DYNIRQS)
 #define NR_IRQ_VECTORS         NR_IRQS
 
-#define pirq_to_irq(_x)                ((_x) + PIRQ_BASE)
-#define irq_to_pirq(_x)                ((_x) - PIRQ_BASE)
-
-#define dynirq_to_irq(_x)      ((_x) + DYNIRQ_BASE)
-#define irq_to_dynirq(_x)      ((_x) - DYNIRQ_BASE)
-
 #endif /* _ASM_IRQ_VECTORS_H */

_______________________________________________
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®.