aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/dma/direct.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index e269b6f9b444..59bdceea3737 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -234,12 +234,14 @@ void dma_direct_sync_sg_for_device(struct device *dev,
234 int i; 234 int i;
235 235
236 for_each_sg(sgl, sg, nents, i) { 236 for_each_sg(sgl, sg, nents, i) {
237 if (unlikely(is_swiotlb_buffer(sg_phys(sg)))) 237 phys_addr_t paddr = dma_to_phys(dev, sg_dma_address(sg));
238 swiotlb_tbl_sync_single(dev, sg_phys(sg), sg->length, 238
239 if (unlikely(is_swiotlb_buffer(paddr)))
240 swiotlb_tbl_sync_single(dev, paddr, sg->length,
239 dir, SYNC_FOR_DEVICE); 241 dir, SYNC_FOR_DEVICE);
240 242
241 if (!dev_is_dma_coherent(dev)) 243 if (!dev_is_dma_coherent(dev))
242 arch_sync_dma_for_device(dev, sg_phys(sg), sg->length, 244 arch_sync_dma_for_device(dev, paddr, sg->length,
243 dir); 245 dir);
244 } 246 }
245} 247}
@@ -271,11 +273,13 @@ void dma_direct_sync_sg_for_cpu(struct device *dev,
271 int i; 273 int i;
272 274
273 for_each_sg(sgl, sg, nents, i) { 275 for_each_sg(sgl, sg, nents, i) {
276 phys_addr_t paddr = dma_to_phys(dev, sg_dma_address(sg));
277
274 if (!dev_is_dma_coherent(dev)) 278 if (!dev_is_dma_coherent(dev))
275 arch_sync_dma_for_cpu(dev, sg_phys(sg), sg->length, dir); 279 arch_sync_dma_for_cpu(dev, paddr, sg->length, dir);
276 280
277 if (unlikely(is_swiotlb_buffer(sg_phys(sg)))) 281 if (unlikely(is_swiotlb_buffer(paddr)))
278 swiotlb_tbl_sync_single(dev, sg_phys(sg), sg->length, dir, 282 swiotlb_tbl_sync_single(dev, paddr, sg->length, dir,
279 SYNC_FOR_CPU); 283 SYNC_FOR_CPU);
280 } 284 }
281 285