diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2009-06-28 11:35:56 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2009-06-29 08:39:12 -0400 |
commit | c5395d5c4a82159889cb650de93b591ea51d8c56 (patch) | |
tree | e53e62d8b5edf352e17c061f876589a49f73e875 /drivers/pci/intel-iommu.c | |
parent | 1a4a45516d7a57de0691352d899d7008f2e090d1 (diff) |
intel-iommu: Clean up iommu_domain_identity_map()
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/pci/intel-iommu.c')
-rw-r--r-- | drivers/pci/intel-iommu.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index a55f5fb06b14..c5caf7d63a0f 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -1861,31 +1861,25 @@ static int iommu_domain_identity_map(struct dmar_domain *domain, | |||
1861 | unsigned long long start, | 1861 | unsigned long long start, |
1862 | unsigned long long end) | 1862 | unsigned long long end) |
1863 | { | 1863 | { |
1864 | unsigned long size; | 1864 | unsigned long first_vpfn = start >> VTD_PAGE_SHIFT; |
1865 | unsigned long long base; | 1865 | unsigned long last_vpfn = end >> VTD_PAGE_SHIFT; |
1866 | 1866 | ||
1867 | /* The address might not be aligned */ | 1867 | if (!reserve_iova(&domain->iovad, dma_to_mm_pfn(first_vpfn), |
1868 | base = start & PAGE_MASK; | 1868 | dma_to_mm_pfn(last_vpfn))) { |
1869 | size = end - base; | ||
1870 | size = PAGE_ALIGN(size); | ||
1871 | if (!reserve_iova(&domain->iovad, IOVA_PFN(base), | ||
1872 | IOVA_PFN(base + size) - 1)) { | ||
1873 | printk(KERN_ERR "IOMMU: reserve iova failed\n"); | 1869 | printk(KERN_ERR "IOMMU: reserve iova failed\n"); |
1874 | return -ENOMEM; | 1870 | return -ENOMEM; |
1875 | } | 1871 | } |
1876 | 1872 | ||
1877 | pr_debug("Mapping reserved region %lx@%llx for domain %d\n", | 1873 | pr_debug("Mapping reserved region %llx-%llx for domain %d\n", |
1878 | size, base, domain->id); | 1874 | start, end, domain->id); |
1879 | /* | 1875 | /* |
1880 | * RMRR range might have overlap with physical memory range, | 1876 | * RMRR range might have overlap with physical memory range, |
1881 | * clear it first | 1877 | * clear it first |
1882 | */ | 1878 | */ |
1883 | dma_pte_clear_range(domain, base >> VTD_PAGE_SHIFT, | 1879 | dma_pte_clear_range(domain, first_vpfn, last_vpfn); |
1884 | (base + size - 1) >> VTD_PAGE_SHIFT); | ||
1885 | 1880 | ||
1886 | return domain_pfn_mapping(domain, base >> VTD_PAGE_SHIFT, | 1881 | return domain_pfn_mapping(domain, first_vpfn, first_vpfn, |
1887 | base >> VTD_PAGE_SHIFT, | 1882 | last_vpfn - first_vpfn + 1, |
1888 | size >> VTD_PAGE_SHIFT, | ||
1889 | DMA_PTE_READ|DMA_PTE_WRITE); | 1883 | DMA_PTE_READ|DMA_PTE_WRITE); |
1890 | } | 1884 | } |
1891 | 1885 | ||