ia64/xen-unstable

changeset 18619:e4bddd01cb3e

vtd: move some x86-dependent functions into x86-specific directory.

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Oct 13 10:09:09 2008 +0100 (2008-10-13)
parents 98d5370fec1a
children a26194601c8f
files xen/drivers/passthrough/vtd/iommu.c xen/drivers/passthrough/vtd/vtd.h xen/drivers/passthrough/vtd/x86/vtd.c
line diff
     1.1 --- a/xen/drivers/passthrough/vtd/iommu.c	Mon Oct 13 10:08:36 2008 +0100
     1.2 +++ b/xen/drivers/passthrough/vtd/iommu.c	Mon Oct 13 10:09:09 2008 +0100
     1.3 @@ -123,7 +123,7 @@ static void __iommu_flush_cache(void *ad
     1.4          return;
     1.5  
     1.6      for ( i = 0; i < size; i += clflush_size )
     1.7 -        clflush((char *)addr + i);
     1.8 +        cacheline_flush((char *)addr + i);
     1.9  }
    1.10  
    1.11  void iommu_flush_cache_entry(void *addr)
    1.12 @@ -525,7 +525,7 @@ void iommu_flush_all(void)
    1.13      struct acpi_drhd_unit *drhd;
    1.14      struct iommu *iommu;
    1.15  
    1.16 -    wbinvd();
    1.17 +    flush_all_cache();
    1.18      for_each_drhd_unit ( drhd )
    1.19      {
    1.20          iommu = drhd->iommu;
    1.21 @@ -962,8 +962,7 @@ static int iommu_alloc(struct acpi_drhd_
    1.22          return -ENOMEM;
    1.23      }
    1.24  
    1.25 -    set_fixmap_nocache(FIX_IOMMU_REGS_BASE_0 + nr_iommus, drhd->address);
    1.26 -    iommu->reg = (void *)fix_to_virt(FIX_IOMMU_REGS_BASE_0 + nr_iommus);
    1.27 +    iommu->reg = map_to_nocache_virt(nr_iommus, drhd->address);
    1.28      iommu->index = nr_iommus++;
    1.29  
    1.30      iommu->cap = dmar_readq(iommu->reg, DMAR_CAP_REG);
    1.31 @@ -1768,7 +1767,7 @@ int intel_vtd_setup(void)
    1.32          return -ENODEV;
    1.33  
    1.34      spin_lock_init(&domid_bitmap_lock);
    1.35 -    clflush_size = get_clflush_size();
    1.36 +    clflush_size = get_cache_line_size();
    1.37  
    1.38      for_each_drhd_unit ( drhd )
    1.39          if ( iommu_alloc(drhd) != 0 )
     2.1 --- a/xen/drivers/passthrough/vtd/vtd.h	Mon Oct 13 10:08:36 2008 +0100
     2.2 +++ b/xen/drivers/passthrough/vtd/vtd.h	Mon Oct 13 10:09:09 2008 +0100
     2.3 @@ -97,7 +97,10 @@ struct msi_msg_remap_entry {
     2.4      u32	data;		/* msi message data */
     2.5  };
     2.6  
     2.7 -unsigned int get_clflush_size(void);
     2.8 +unsigned int get_cache_line_size(void);
     2.9 +void cacheline_flush(char *);
    2.10 +void flush_all_cache(void);
    2.11 +void *map_to_nocache_virt(int nr_iommus, u64 maddr);
    2.12  u64 alloc_pgtable_maddr(void);
    2.13  void free_pgtable_maddr(u64 maddr);
    2.14  void *map_vtd_domain_page(u64 maddr);
     3.1 --- a/xen/drivers/passthrough/vtd/x86/vtd.c	Mon Oct 13 10:08:36 2008 +0100
     3.2 +++ b/xen/drivers/passthrough/vtd/x86/vtd.c	Mon Oct 13 10:09:09 2008 +0100
     3.3 @@ -60,11 +60,27 @@ void free_pgtable_maddr(u64 maddr)
     3.4          free_domheap_page(maddr_to_page(maddr));
     3.5  }
     3.6  
     3.7 -unsigned int get_clflush_size(void)
     3.8 +unsigned int get_cache_line_size(void)
     3.9  {
    3.10      return ((cpuid_ebx(1) >> 8) & 0xff) * 8;
    3.11  }
    3.12  
    3.13 +void cacheline_flush(char * addr)
    3.14 +{
    3.15 +    clflush(addr);
    3.16 +}
    3.17 +
    3.18 +void flush_all_cache()
    3.19 +{
    3.20 +    wbinvd();
    3.21 +}
    3.22 +
    3.23 +void *map_to_nocache_virt(int nr_iommus, u64 maddr)
    3.24 +{
    3.25 +    set_fixmap_nocache(FIX_IOMMU_REGS_BASE_0 + nr_iommus, maddr);
    3.26 +    return (void *)fix_to_virt(FIX_IOMMU_REGS_BASE_0 + nr_iommus);
    3.27 +}
    3.28 +
    3.29  struct hvm_irq_dpci *domain_get_irq_dpci(struct domain *domain)
    3.30  {
    3.31      if ( !domain )