xcp-1.6-updates/xen-4.1.hg

changeset 23242:96db1984e878

Move IOMMU faults handling into softirq for VT-d.

Dealing with interrupts from VT-d IOMMU(s) is deferred to a
softirq-tasklet, raised by the actual IRQ handler. Since a new
interrupt is not generated, even if further faults occur, until we
cleared all the pending ones, there's no need of disabling IRQs, as
the hardware does it by its own. 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@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 24517:a7ae457c327c
xen-unstable date: Tue Jan 17 11:11:26 2012 +0000
author Dario Faggioli <dario.faggioli@citrix.com>
date Wed Mar 07 08:22:38 2012 +0000 (2012-03-07)
parents d21100f1d00e
children 871ed74bbefd
files xen/drivers/passthrough/vtd/iommu.c
line diff
     1.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Wed Mar 07 08:19:48 2012 +0000
     1.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Wed Mar 07 08:22:38 2012 +0000
     1.3 @@ -53,6 +53,8 @@ bool_t __read_mostly untrusted_msi;
     1.4  
     1.5  int nr_iommus;
     1.6  
     1.7 +static struct tasklet vtd_fault_tasklet;
     1.8 +
     1.9  static void setup_dom0_devices(struct domain *d);
    1.10  static void setup_dom0_rmrr(struct domain *d);
    1.11  
    1.12 @@ -872,10 +874,8 @@ static void iommu_fault_status(u32 fault
    1.13  }
    1.14  
    1.15  #define PRIMARY_FAULT_REG_LEN (16)
    1.16 -static void iommu_page_fault(int irq, void *dev_id,
    1.17 -                             struct cpu_user_regs *regs)
    1.18 +static void __do_iommu_page_fault(struct iommu *iommu)
    1.19  {
    1.20 -    struct iommu *iommu = dev_id;
    1.21      int reg, fault_index;
    1.22      u32 fault_status;
    1.23      unsigned long flags;
    1.24 @@ -949,6 +949,38 @@ clear_overflow:
    1.25      }
    1.26  }
    1.27  
    1.28 +static void do_iommu_page_fault(unsigned long data)
    1.29 +{
    1.30 +    struct acpi_drhd_unit *drhd;
    1.31 +
    1.32 +    if ( list_empty(&acpi_drhd_units) )
    1.33 +    {
    1.34 +        dprintk(XENLOG_WARNING VTDPREFIX,
    1.35 +                "no device found, something must be very wrong!\n");
    1.36 +       return;
    1.37 +    }
    1.38 +
    1.39 +    /*
    1.40 +     * No matter from whom the interrupt came from, check all the
    1.41 +     * IOMMUs present in the system. This allows for having just one
    1.42 +     * tasklet (instead of one per each IOMMUs) and should be more than
    1.43 +     * fine, considering how rare the event of a fault should be.
    1.44 +     */
    1.45 +    for_each_drhd_unit ( drhd )
    1.46 +        __do_iommu_page_fault(drhd->iommu);
    1.47 +}
    1.48 +
    1.49 +static void iommu_page_fault(int irq, void *dev_id,
    1.50 +                             struct cpu_user_regs *regs)
    1.51 +{
    1.52 +    /*
    1.53 +     * Just flag the tasklet as runnable. This is fine, according to VT-d
    1.54 +     * specs since a new interrupt won't be generated until we clear all
    1.55 +     * the faults that caused this one to happen.
    1.56 +     */
    1.57 +    tasklet_schedule(&vtd_fault_tasklet);
    1.58 +}
    1.59 +
    1.60  static void dma_msi_unmask(unsigned int irq)
    1.61  {
    1.62      struct iommu *iommu = irq_to_iommu[irq];
    1.63 @@ -2089,6 +2121,8 @@ int __init intel_vtd_setup(void)
    1.64              iommu_hap_pt_share = FALSE;
    1.65      }
    1.66  
    1.67 +    softirq_tasklet_init(&vtd_fault_tasklet, do_iommu_page_fault, 0);
    1.68 +
    1.69      if ( !iommu_qinval && iommu_intremap )
    1.70      {
    1.71          iommu_intremap = 0;