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

[Xen-changelog] [xen-4.1-testing] iommu: Move IOMMU faults handling into softirq for AMD-Vi.



# HG changeset patch
# User Dario Faggioli <dario.faggioli@xxxxxxxxxx>
# Date 1331201104 0
# Node ID b01091775dd9bfe2ea3ebad478a1668703c19434
# Parent  7c0d02aa4742e45507bef41fbc2fc03129a33a7b
iommu: Move IOMMU faults handling into softirq for AMD-Vi.

Dealing with interrupts from AMD-Vi IOMMU(s) is deferred to a
softirq-tasklet, raised by the actual IRQ handler. To avoid more
interrupts being generated (because of further faults), they must be
masked in the IOMMU within the low level IRQ handler and enabled back
in the tasklet body. Notice that this may cause the log to overflow,
but none of the existing entry will be overwritten.

Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
Committed-by: Keir Fraser <keir@xxxxxxx>
xen-unstable changeset:   24527:028230eb2359
xen-unstable date:        Fri Jan 20 10:20:32 2012 +0000
---


diff -r 7c0d02aa4742 -r b01091775dd9 xen/drivers/passthrough/amd/iommu_init.c
--- a/xen/drivers/passthrough/amd/iommu_init.c  Thu Mar 08 10:04:22 2012 +0000
+++ b/xen/drivers/passthrough/amd/iommu_init.c  Thu Mar 08 10:05:04 2012 +0000
@@ -33,6 +33,8 @@
 static long amd_iommu_cmd_buffer_entries = IOMMU_CMD_BUFFER_DEFAULT_ENTRIES;
 static long amd_iommu_event_log_entries = IOMMU_EVENT_LOG_DEFAULT_ENTRIES;
 
+static struct tasklet amd_iommu_irq_tasklet;
+
 unsigned short ivrs_bdf_entries;
 struct ivrs_mappings *ivrs_mappings;
 struct list_head amd_iommu_head;
@@ -517,34 +519,70 @@
     }
 }
 
+static void do_amd_iommu_irq(unsigned long data)
+{
+    struct amd_iommu *iommu;
+
+    if ( !iommu_found() )
+    {
+        AMD_IOMMU_DEBUG("no device found, something must be very wrong!\n");
+        return;
+   }
+
+    /*
+     * No matter from where the interrupt came from, check all the
+     * IOMMUs present in the system. This allows for having just one
+     * tasklet (instead of one per each IOMMUs).
+     */
+    for_each_amd_iommu ( iommu )
+    {
+        u32 entry;
+        unsigned long flags;
+        int of;
+
+        spin_lock_irqsave(&iommu->lock, flags);
+        amd_iommu_read_event_log(iommu);
+
+        /* check event overflow */
+        entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
+        of = get_field_from_reg_u32(entry,
+                                   IOMMU_STATUS_EVENT_OVERFLOW_MASK,
+                                   IOMMU_STATUS_EVENT_OVERFLOW_SHIFT);
+
+        /* reset event log if event overflow */
+        if ( of )
+            amd_iommu_reset_event_log(iommu);
+
+        /* reset interrupt status bit */
+        entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
+        set_field_in_reg_u32(IOMMU_CONTROL_ENABLED, entry,
+                             IOMMU_STATUS_EVENT_LOG_INT_MASK,
+                             IOMMU_STATUS_EVENT_LOG_INT_SHIFT, &entry);
+        writel(entry, iommu->mmio_base+IOMMU_STATUS_MMIO_OFFSET);
+        spin_unlock_irqrestore(&iommu->lock, flags);
+    }
+}
+
 static void amd_iommu_page_fault(int irq, void *dev_id,
                              struct cpu_user_regs *regs)
 {
     u32 entry;
     unsigned long flags;
-    int of;
     struct amd_iommu *iommu = dev_id;
 
     spin_lock_irqsave(&iommu->lock, flags);
-    amd_iommu_read_event_log(iommu);
 
-    /*check event overflow */
+    /* Silence interrupts from both event logging */
     entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
-    of = get_field_from_reg_u32(entry,
-                               IOMMU_STATUS_EVENT_OVERFLOW_MASK,
-                               IOMMU_STATUS_EVENT_OVERFLOW_SHIFT);
-
-    /* reset event log if event overflow */
-    if ( of )
-        amd_iommu_reset_event_log(iommu);
-
-    /* reset interrupt status bit */
-    entry = readl(iommu->mmio_base + IOMMU_STATUS_MMIO_OFFSET);
-    set_field_in_reg_u32(IOMMU_CONTROL_ENABLED, entry,
+    set_field_in_reg_u32(IOMMU_CONTROL_DISABLED, entry,
                          IOMMU_STATUS_EVENT_LOG_INT_MASK,
                          IOMMU_STATUS_EVENT_LOG_INT_SHIFT, &entry);
     writel(entry, iommu->mmio_base+IOMMU_STATUS_MMIO_OFFSET);
+
     spin_unlock_irqrestore(&iommu->lock, flags);
+
+    /* It is the tasklet that will clear the logs and re-enable interrupts */
+    tasklet_schedule(&amd_iommu_irq_tasklet);
 }
 
 static int set_iommu_interrupt_handler(struct amd_iommu *iommu)
@@ -689,6 +727,8 @@
     printk("AMD-Vi: IOMMU %d Enabled.\n", nr_amd_iommus );
     nr_amd_iommus++;
 
+    softirq_tasklet_init(&amd_iommu_irq_tasklet, do_amd_iommu_irq, 0);
+
     return 0;
 
 error_out:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
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®.