intel-iommu: Clean up iommu_domain_identity_map()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git-commits-head@...>
Date: Friday, July 3, 2009 - 5:59 pm

Gitweb:     http://git.kernel.org/linus/c5395d5c4a82159889cb650de93b591ea51d8c56
Commit:     c5395d5c4a82159889cb650de93b591ea51d8c56
Parent:     1a4a45516d7a57de0691352d899d7008f2e090d1
Author:     David Woodhouse <David.Woodhouse@intel.com>
AuthorDate: Sun Jun 28 16:35:56 2009 +0100
Committer:  David Woodhouse <David.Woodhouse@intel.com>
CommitDate: Mon Jun 29 13:39:12 2009 +0100

    intel-iommu: Clean up iommu_domain_identity_map()
    
    Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
 drivers/pci/intel-iommu.c |   26 ++++++++++----------------
 1 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index a55f5fb..c5caf7d 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,
 				     unsigned long long start,
 				     unsigned long long end)
 {
-	unsigned long size;
-	unsigned long long base;
+	unsigned long first_vpfn = start >> VTD_PAGE_SHIFT;
+	unsigned long last_vpfn = end >> VTD_PAGE_SHIFT;
 
-	/* The address might not be aligned */
-	base = start & PAGE_MASK;
-	size = end - base;
-	size = PAGE_ALIGN(size);
-	if (!reserve_iova(&domain->iovad, IOVA_PFN(base),
-			IOVA_PFN(base + size) - 1)) {
+	if (!reserve_iova(&domain->iovad, dma_to_mm_pfn(first_vpfn),
+			  dma_to_mm_pfn(last_vpfn))) {
 		printk(KERN_ERR "IOMMU: reserve iova failed\n");
 		return -ENOMEM;
 	}
 
-	pr_debug("Mapping reserved region %lx@%llx for domain %d\n",
-		 size, base, domain->id);
+	pr_debug("Mapping reserved region %llx-%llx for domain %d\n",
+		 start, end, domain->id);
 	/*
 	 * RMRR range might have overlap with physical memory range,
 	 * clear it first
 	 */
-	dma_pte_clear_range(domain, base >> VTD_PAGE_SHIFT,
-			    (base + size - 1) >> VTD_PAGE_SHIFT);
+	dma_pte_clear_range(domain, first_vpfn, last_vpfn);
 
-	return domain_pfn_mapping(domain, base >> VTD_PAGE_SHIFT,
-				  base >> VTD_PAGE_SHIFT,
-				  size >> VTD_PAGE_SHIFT,
+	return domain_pfn_mapping(domain, first_vpfn, first_vpfn,
+				  last_vpfn - first_vpfn + 1,
 				  DMA_PTE_READ|DMA_PTE_WRITE);
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
intel-iommu: Clean up iommu_domain_identity_map(), Linux Kernel Mailing List..., (Fri Jul 3, 5:59 pm)