intel-iommu: Clean up address handling in domain_page_mapping()

!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/1c5a46ed49e37f56f8aa9000bb1c2ac59670c372
Commit:     1c5a46ed49e37f56f8aa9000bb1c2ac59670c372
Parent:     b026fd28ea23af24a3eea6e5be3f3d0193a8e87d
Author:     David Woodhouse <David.Woodhouse@intel.com>
AuthorDate: Sun Jun 28 10:53:37 2009 +0100
Committer:  David Woodhouse <David.Woodhouse@intel.com>
CommitDate: Mon Jun 29 13:33:11 2009 +0100

    intel-iommu: Clean up address handling in domain_page_mapping()
    
    No more masking and alignment; just use pfns.
    
    Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
 drivers/pci/intel-iommu.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index dfbabd1..f08d786 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1647,20 +1647,18 @@ static int
 domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova,
 			u64 hpa, size_t size, int prot)
 {
-	u64 start_pfn, end_pfn;
+	unsigned long start_pfn = hpa >> VTD_PAGE_SHIFT;
+	unsigned long last_pfn = (hpa + size - 1) >> VTD_PAGE_SHIFT;
 	struct dma_pte *pte;
-	int index;
-	int addr_width = agaw_to_width(domain->agaw);
+	int index = 0;
+	int addr_width = agaw_to_width(domain->agaw) - VTD_PAGE_SHIFT;
 
-	BUG_ON(hpa >> addr_width);
+	BUG_ON(addr_width < BITS_PER_LONG && last_pfn >> addr_width);
 
 	if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0)
 		return -EINVAL;
-	iova &= PAGE_MASK;
-	start_pfn = ((u64)hpa) >> VTD_PAGE_SHIFT;
-	end_pfn = (VTD_PAGE_ALIGN(((u64)hpa) + size)) >> VTD_PAGE_SHIFT;
-	index = 0;
-	while (start_pfn < end_pfn) {
+
+	while (start_pfn <= last_pfn) {
 		pte = pfn_to_dma_pte(domain, (iova >> VTD_PAGE_SHIFT) + index);
 		if (!pte)
 			return -ENOMEM;
--
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 address handling in domain_page_mappin..., Linux Kernel Mailing List..., (Fri Jul 3, 5:59 pm)