]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
intel-iommu: Clean up address handling in domain_page_mapping()
authorDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 28 Jun 2009 09:53:37 +0000 (10:53 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 29 Jun 2009 12:33:11 +0000 (13:33 +0100)
No more masking and alignment; just use pfns.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/pci/intel-iommu.c

index dfbabd151a9c863615c60a2dbb76613d28f53d00..f08d7865fe00632a6700ee0f12feb515bae4ca90 100644 (file)
@@ -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;