ARM: dma-mapping: Skip cache maint for invalid page
Hiroshi Doyu [Tue, 28 Aug 2012 08:51:56 +0000 (11:51 +0300)]
Skip cache maint for invalid page but warn it.

Change-Id: I780587d132fd9440767046877c0724939897889f
Signed-off-by: Hiroshi Doyu <hdoyu@nvidia.com>

Rebase-Id: Rb3610fd43422fbce269431146defbc6eb7272de8

arch/arm/mm/dma-mapping.c

index 2d0a5a6..062e384 100644 (file)
@@ -1726,6 +1726,9 @@ static void arm_iommu_unmap_page(struct device *dev, dma_addr_t handle,
        if (!iova)
                return;
 
+       if (WARN_ON(!pfn_valid(page_to_pfn(page))))
+               return;
+
        if (!dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs))
                __dma_page_dev_to_cpu(page, offset, size, dir);
 
@@ -1744,6 +1747,9 @@ static void arm_iommu_sync_single_for_cpu(struct device *dev,
        if (!iova)
                return;
 
+       if (WARN_ON(!pfn_valid(page_to_pfn(page))))
+               return;
+
        __dma_page_dev_to_cpu(page, offset, size, dir);
 }
 
@@ -1758,6 +1764,9 @@ static void arm_iommu_sync_single_for_device(struct device *dev,
        if (!iova)
                return;
 
+       if (WARN_ON(!pfn_valid(page_to_pfn(page))))
+               return;
+
        __dma_page_cpu_to_dev(page, offset, size, dir);
 }