ia64/xen-unstable

changeset 19458:80ecfc3d6a8e

vtd: fix iommu vector leak

When we do Dom0 S3 for many times, iommu_set_interrupt() would fail
during S3 resume because it can't obtain vector. We should not request
new vector for every Dom0 S3 resume. We should re-use the same vector.

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:41:13 2009 +0100 (2009-03-31)
parents 9202d800b06f
children cd6b3af19191
files xen/drivers/passthrough/vtd/iommu.c xen/include/xen/iommu.h
line diff
     1.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Tue Mar 31 11:40:28 2009 +0100
     1.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Tue Mar 31 11:41:13 2009 +0100
     1.3 @@ -911,6 +911,8 @@ static int iommu_alloc(struct acpi_drhd_
     1.4          return -ENOMEM;
     1.5      memset(iommu, 0, sizeof(struct iommu));
     1.6  
     1.7 +    iommu->vector = -1; /* No vector assigned yet. */
     1.8 +
     1.9      iommu->intel = alloc_intel_iommu();
    1.10      if ( iommu->intel == NULL )
    1.11      {
    1.12 @@ -1666,15 +1668,18 @@ static int init_vtd_hw(void)
    1.13              return -EIO;
    1.14          }
    1.15  
    1.16 -        vector = iommu_set_interrupt(iommu);
    1.17 -        if ( vector < 0 )
    1.18 +        if ( iommu->vector < 0 )
    1.19          {
    1.20 -            gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: interrupt setup failed\n");
    1.21 -            return vector;
    1.22 +            vector = iommu_set_interrupt(iommu);
    1.23 +            if ( vector < 0 )
    1.24 +            {
    1.25 +                gdprintk(XENLOG_ERR VTDPREFIX, "IOMMU: interrupt setup failed\n");
    1.26 +                return vector;
    1.27 +            }
    1.28 +            iommu->vector = vector;
    1.29          }
    1.30 -        dma_msi_data_init(iommu, vector);
    1.31 +        dma_msi_data_init(iommu, iommu->vector);
    1.32          dma_msi_addr_init(iommu, cpu_physical_id(first_cpu(cpu_online_map)));
    1.33 -        iommu->vector = vector;
    1.34          clear_fault_bits(iommu);
    1.35          dmar_writel(iommu->reg, DMAR_FECTL_REG, 0);
    1.36  
     2.1 --- a/xen/include/xen/iommu.h	Tue Mar 31 11:40:28 2009 +0100
     2.2 +++ b/xen/include/xen/iommu.h	Tue Mar 31 11:41:13 2009 +0100
     2.3 @@ -55,7 +55,7 @@ struct iommu {
     2.4      spinlock_t lock; /* protect context, domain ids */
     2.5      spinlock_t register_lock; /* protect iommu register handling */
     2.6      u64 root_maddr; /* root entry machine address */
     2.7 -    unsigned int vector;
     2.8 +    int vector;
     2.9      struct intel_iommu *intel;
    2.10  };
    2.11