dma-direct: correct the physical addr in dma_direct_sync_sg_for_cpu/device
[linux-2.6-block.git] / kernel / dma / direct.c
index e269b6f9b4441e36e0810507648139007538ebad..59bdceea3737a4a095555723f4a7b79fda15c048 100644 (file)
@@ -234,12 +234,14 @@ void dma_direct_sync_sg_for_device(struct device *dev,
        int i;
 
        for_each_sg(sgl, sg, nents, i) {
-               if (unlikely(is_swiotlb_buffer(sg_phys(sg))))
-                       swiotlb_tbl_sync_single(dev, sg_phys(sg), sg->length,
+               phys_addr_t paddr = dma_to_phys(dev, sg_dma_address(sg));
+
+               if (unlikely(is_swiotlb_buffer(paddr)))
+                       swiotlb_tbl_sync_single(dev, paddr, sg->length,
                                        dir, SYNC_FOR_DEVICE);
 
                if (!dev_is_dma_coherent(dev))
-                       arch_sync_dma_for_device(dev, sg_phys(sg), sg->length,
+                       arch_sync_dma_for_device(dev, paddr, sg->length,
                                        dir);
        }
 }
@@ -271,11 +273,13 @@ void dma_direct_sync_sg_for_cpu(struct device *dev,
        int i;
 
        for_each_sg(sgl, sg, nents, i) {
+               phys_addr_t paddr = dma_to_phys(dev, sg_dma_address(sg));
+
                if (!dev_is_dma_coherent(dev))
-                       arch_sync_dma_for_cpu(dev, sg_phys(sg), sg->length, dir);
-       
-               if (unlikely(is_swiotlb_buffer(sg_phys(sg))))
-                       swiotlb_tbl_sync_single(dev, sg_phys(sg), sg->length, dir,
+                       arch_sync_dma_for_cpu(dev, paddr, sg->length, dir);
+
+               if (unlikely(is_swiotlb_buffer(paddr)))
+                       swiotlb_tbl_sync_single(dev, paddr, sg->length, dir,
                                        SYNC_FOR_CPU);
        }