ia64/xen-unstable

changeset 19200:32b154137492

vtd: move the snoop control detection out of acpi_dmar_init()
where the capability value is not initialized thus we may
get random value.

Signed-off-by: Xin, Xiaohui<xiaohui.xin@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 12 10:54:17 2009 +0000 (2009-02-12)
parents 94e12fa57816
children c7cba853583d
files xen/drivers/passthrough/vtd/dmar.c xen/drivers/passthrough/vtd/iommu.c
line diff
     1.1 --- a/xen/drivers/passthrough/vtd/dmar.c	Thu Feb 12 10:53:10 2009 +0000
     1.2 +++ b/xen/drivers/passthrough/vtd/dmar.c	Thu Feb 12 10:54:17 2009 +0000
     1.3 @@ -519,8 +519,6 @@ static int __init acpi_parse_dmar(struct
     1.4  int acpi_dmar_init(void)
     1.5  {
     1.6      int rc;
     1.7 -    struct acpi_drhd_unit *drhd;
     1.8 -    struct iommu *iommu;
     1.9  
    1.10      rc = -ENODEV;
    1.11      if ( force_iommu )
    1.12 @@ -537,22 +535,7 @@ int acpi_dmar_init(void)
    1.13      if ( list_empty(&acpi_drhd_units) )
    1.14          goto fail;
    1.15  
    1.16 -    /* Giving that all devices within guest use same io page table,
    1.17 -     * enable snoop control only if all VT-d engines support it.
    1.18 -     */
    1.19 -    if ( iommu_snoop )
    1.20 -    {
    1.21 -        for_each_drhd_unit ( drhd )
    1.22 -        {
    1.23 -            iommu = drhd->iommu;
    1.24 -            if ( !ecap_snp_ctl(iommu->ecap) ) {
    1.25 -                iommu_snoop = 0;
    1.26 -                break;
    1.27 -            }
    1.28 -        }
    1.29 -    }
    1.30 -
    1.31 -    printk("Intel VT-d has been enabled, snoop_control=%d.\n", iommu_snoop);
    1.32 +    printk("Intel VT-d has been enabled\n");
    1.33  
    1.34      return 0;
    1.35  
     2.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Thu Feb 12 10:53:10 2009 +0000
     2.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Thu Feb 12 10:54:17 2009 +0000
     2.3 @@ -1765,6 +1765,23 @@ int intel_vtd_setup(void)
     2.4      if ( init_vtd_hw() )
     2.5          goto error;
     2.6  
     2.7 +    /* Giving that all devices within guest use same io page table,
     2.8 +     * enable snoop control only if all VT-d engines support it.
     2.9 +     */
    2.10 +
    2.11 +    if ( iommu_snoop )
    2.12 +    {
    2.13 +        for_each_drhd_unit ( drhd )
    2.14 +        {
    2.15 +            iommu = drhd->iommu;
    2.16 +            if ( !ecap_snp_ctl(iommu->ecap) ) {
    2.17 +                iommu_snoop = 0;
    2.18 +                break;
    2.19 +            }
    2.20 +        }
    2.21 +    }
    2.22 +    
    2.23 +    printk("Intel VT-d snoop control %sabled\n", iommu_snoop ? "en" : "dis");
    2.24      register_keyhandler('V', dump_iommu_info, "dump iommu info");
    2.25  
    2.26      return 0;
    2.27 @@ -1773,6 +1790,7 @@ int intel_vtd_setup(void)
    2.28      for_each_drhd_unit ( drhd )
    2.29          iommu_free(drhd);
    2.30      vtd_enabled = 0;
    2.31 +    iommu_snoop = 0;
    2.32      return -ENOMEM;
    2.33  }
    2.34