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

[Xen-devel] [PATCH] fix iommu interrupt setup



iommu is disabled since cset 19175:ab514cfbcdc5 with the following message:

(XEN) [VT-D]iommu.c:890:d32767 IOMMU: can't request irq
(XEN) [VT-D]iommu.c:1686:d32767 IOMMU: interrupt setup failed
(XEN) I/O virtualisation disabled

This patch fixes it.
- rename request_irq to request_vector, no conversion by irq_to_vector(irq)
- set vector_to_iommu[vector] before calling request_vector
  since null pointer exceptions occurs
- some cleanups

Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>

diff -r bf9cdbec516a xen/arch/ia64/linux-xen/irq_ia64.c
--- a/xen/arch/ia64/linux-xen/irq_ia64.c        Wed Feb 11 16:36:59 2009 +0000
+++ b/xen/arch/ia64/linux-xen/irq_ia64.c        Thu Feb 12 11:01:54 2009 +0900
@@ -267,7 +267,7 @@ register_percpu_irq (ia64_vector vec, st
 }
 
 #ifdef XEN
-int request_irq(unsigned int irq,
+int request_vector(unsigned int vector,
                void (*handler)(int, void *, struct cpu_user_regs *),
                unsigned long irqflags, const char * devname, void *dev_id)
 {
@@ -279,7 +279,7 @@ int request_irq(unsigned int irq,
         * otherwise we'll have trouble later trying to figure out
         * which interrupt is which (messes up the interrupt freeing logic etc).
         *                          */
-       if (irq >= NR_IRQS)
+       if (vector >= NR_VECTORS)
                return -EINVAL;
        if (!handler)
                return -EINVAL;
@@ -291,7 +291,7 @@ int request_irq(unsigned int irq,
        action->handler = handler;
        action->name = devname;
        action->dev_id = dev_id;
-       setup_vector(irq, action);
+       setup_vector(vector, action);
        if (retval)
                xfree(action);
 
diff -r bf9cdbec516a xen/arch/x86/irq.c
--- a/xen/arch/x86/irq.c        Wed Feb 11 16:36:59 2009 +0000
+++ b/xen/arch/x86/irq.c        Thu Feb 12 11:01:54 2009 +0900
@@ -33,6 +33,7 @@ int vector_irq[NR_VECTORS] __read_mostly
 };
 
 static void __do_IRQ_guest(int vector);
+static int setup_vector(unsigned int vector, struct irqaction *new);
 
 void no_action(int cpl, void *dev_id, struct cpu_user_regs *regs) { }
 
@@ -159,7 +160,7 @@ asmlinkage void do_IRQ(struct cpu_user_r
     spin_unlock(&desc->lock);
 }
 
-int request_irq(unsigned int irq,
+int request_vector(unsigned int vector,
         void (*handler)(int, void *, struct cpu_user_regs *),
         unsigned long irqflags, const char * devname, void *dev_id)
 {
@@ -172,7 +173,7 @@ int request_irq(unsigned int irq,
      * which interrupt is which (messes up the interrupt freeing
      * logic etc).
      */
-    if (irq >= NR_IRQS)
+    if (vector >= NR_VECTORS)
         return -EINVAL;
     if (!handler)
         return -EINVAL;
@@ -185,7 +186,7 @@ int request_irq(unsigned int irq,
     action->name = devname;
     action->dev_id = dev_id;
 
-    retval = setup_irq(irq, action);
+    retval = setup_vector(vector, action);
     if (retval)
         xfree(action);
 
@@ -209,9 +210,8 @@ void free_irq(unsigned int irq)
     do { smp_mb(); } while ( desc->status & IRQ_INPROGRESS );
 }
 
-int setup_irq(unsigned int irq, struct irqaction *new)
+static int setup_vector(unsigned int vector, struct irqaction *new)
 {
-    unsigned int  vector = irq_to_vector(irq);
     irq_desc_t   *desc = &irq_desc[vector];
     unsigned long flags;
  
@@ -231,6 +231,11 @@ int setup_irq(unsigned int irq, struct i
     spin_unlock_irqrestore(&desc->lock,flags);
 
     return 0;
+}
+
+int setup_irq(unsigned int irq, struct irqaction *new)
+{
+    return setup_vector(irq_to_vector(irq), new);
 }
 
 
diff -r bf9cdbec516a xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c  Wed Feb 11 16:36:59 2009 +0000
+++ b/xen/drivers/passthrough/amd/iommu_init.c  Thu Feb 12 11:01:54 2009 +0900
@@ -487,10 +487,12 @@ static int set_iommu_interrupt_handler(s
     }
 
     irq_desc[vector].handler = &iommu_msi_type;
-    ret = request_irq(vector, amd_iommu_page_fault, 0, "amd_iommu", iommu);
+    vector_to_iommu[vector] = iommu;
+    ret = request_vector(vector, amd_iommu_page_fault, 0, "amd_iommu", iommu);
     if ( ret )
     {
         irq_desc[vector].handler = &no_irq_type;
+        vector_to_iommu[vector] = NULL;
         free_irq_vector(vector);
         amd_iov_error("can't request irq\n");
         return 0;
@@ -498,7 +500,6 @@ static int set_iommu_interrupt_handler(s
 
     /* Make sure that vector is never re-used. */
     vector_irq[vector] = NEVER_ASSIGN;
-    vector_to_iommu[vector] = iommu;
     iommu->vector = vector;
     return vector;
 }
diff -r bf9cdbec516a xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c       Wed Feb 11 16:36:59 2009 +0000
+++ b/xen/drivers/passthrough/vtd/iommu.c       Thu Feb 12 11:01:54 2009 +0900
@@ -870,7 +870,7 @@ static struct hw_interrupt_type dma_msi_
     .set_affinity = dma_msi_set_affinity,
 };
 
-int iommu_set_interrupt(struct iommu *iommu)
+static int iommu_set_interrupt(struct iommu *iommu)
 {
     int vector, ret;
 
@@ -882,10 +882,12 @@ int iommu_set_interrupt(struct iommu *io
     }
 
     irq_desc[vector].handler = &dma_msi_type;
-    ret = request_irq(vector, iommu_page_fault, 0, "dmar", iommu);
+    vector_to_iommu[vector] = iommu;
+    ret = request_vector(vector, iommu_page_fault, 0, "dmar", iommu);
     if ( ret )
     {
         irq_desc[vector].handler = &no_irq_type;
+        vector_to_iommu[vector] = NULL;
         free_irq_vector(vector);
         gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: can't request irq\n");
         return ret;
@@ -893,7 +895,6 @@ int iommu_set_interrupt(struct iommu *io
 
     /* Make sure that vector is never re-used. */
     vector_irq[vector] = NEVER_ASSIGN;
-    vector_to_iommu[vector] = iommu;
 
     return vector;
 }
diff -r bf9cdbec516a xen/include/xen/irq.h
--- a/xen/include/xen/irq.h     Wed Feb 11 16:36:59 2009 +0000
+++ b/xen/include/xen/irq.h     Thu Feb 12 11:01:54 2009 +0900
@@ -66,7 +66,7 @@ extern irq_desc_t irq_desc[NR_VECTORS];
 
 extern int setup_irq(unsigned int, struct irqaction *);
 extern void free_irq(unsigned int);
-extern int request_irq(unsigned int irq,
+extern int request_vector(unsigned int irq,
                void (*handler)(int, void *, struct cpu_user_regs *),
                unsigned long irqflags, const char * devname, void *dev_id);
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

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