ia64/xen-unstable

changeset 16341:b544448502a4

vt-d: Disable PMR on every vt-d engine.

Signed-off-by Gang Wei (Jimmy) <gang.wei@intel.com>
Signed-off-by Kevin Tian <kevin.tian@intel.com>
author Keir Fraser <keir@xensource.com>
date Wed Nov 07 09:13:48 2007 +0000 (2007-11-07)
parents 14faf0a94123
children 11dcbf74edf2
files xen/arch/x86/hvm/vmx/vtd/intel-iommu.c xen/arch/x86/hvm/vmx/vtd/utils.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c	Tue Nov 06 16:04:13 2007 +0000
     1.2 +++ b/xen/arch/x86/hvm/vmx/vtd/intel-iommu.c	Wed Nov 07 09:13:48 2007 +0000
     1.3 @@ -688,6 +688,9 @@ static int iommu_enable_translation(stru
     1.4              break;
     1.5          cpu_relax();
     1.6      }
     1.7 +
     1.8 +    /* Disable PMRs when VT-d engine takes effect per spec definition */
     1.9 +    disable_pmr(iommu);
    1.10      spin_unlock_irqrestore(&iommu->register_lock, flags);
    1.11      return 0;
    1.12  }
    1.13 @@ -1767,7 +1770,7 @@ int iommu_setup(void)
    1.14      struct hvm_iommu *hd  = domain_hvm_iommu(dom0);
    1.15      struct acpi_drhd_unit *drhd;
    1.16      struct iommu *iommu;
    1.17 -    unsigned long i, status;
    1.18 +    unsigned long i;
    1.19  
    1.20      if ( !vtd_enabled )
    1.21          return 0;
    1.22 @@ -1797,10 +1800,6 @@ int iommu_setup(void)
    1.23      if ( enable_vtd_translation() )
    1.24          goto error;
    1.25  
    1.26 -    status = dmar_readl(iommu->reg, DMAR_PMEN_REG);
    1.27 -    if (status & DMA_PMEN_PRS)
    1.28 -        disable_pmr(iommu);
    1.29 -
    1.30      return 0;
    1.31  
    1.32   error:
     2.1 --- a/xen/arch/x86/hvm/vmx/vtd/utils.c	Tue Nov 06 16:04:13 2007 +0000
     2.2 +++ b/xen/arch/x86/hvm/vmx/vtd/utils.c	Wed Nov 07 09:13:48 2007 +0000
     2.3 @@ -67,25 +67,30 @@ int vtd_hw_check(void)
     2.4  /* Disable vt-d protected memory registers. */
     2.5  void disable_pmr(struct iommu *iommu)
     2.6  {
     2.7 -    unsigned long start_time, status;
     2.8 +    unsigned long start_time;
     2.9      unsigned int val;
    2.10  
    2.11      val = dmar_readl(iommu->reg, DMAR_PMEN_REG);
    2.12 +    if ( !(val & DMA_PMEN_PRS) )
    2.13 +        return;
    2.14 +
    2.15      dmar_writel(iommu->reg, DMAR_PMEN_REG, val & ~DMA_PMEN_EPM);
    2.16      start_time = jiffies;
    2.17  
    2.18      for ( ; ; )
    2.19      {
    2.20 -        status = dmar_readl(iommu->reg, DMAR_PMEN_REG);
    2.21 -        if ( (status & DMA_PMEN_PRS) == 0 )
    2.22 +        val = dmar_readl(iommu->reg, DMAR_PMEN_REG);
    2.23 +        if ( (val & DMA_PMEN_PRS) == 0 )
    2.24              break;
    2.25 +
    2.26          if ( time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT) )
    2.27 -            panic("Cannot set QIE field for queue invalidation\n");
    2.28 +            panic("Disable PMRs timeout\n");
    2.29 +
    2.30          cpu_relax();
    2.31      }
    2.32  
    2.33      dprintk(XENLOG_INFO VTDPREFIX,
    2.34 -            "disabled protected memory registers\n");
    2.35 +            "Disabled protected memory registers\n");
    2.36  }
    2.37  
    2.38  #if defined(__x86_64__)