[PATCH 1/3] dma: use dma/cpu conversions correctly in dma_map/unmap_single

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We should not treat dma handles as if they correspond one-to-one to the
virtual addresses in common code. So make sure that dma handles are
properly passed to the dma_sync_single_for_* functions. Otherwise, it
just doesn't make much sense, as dma_sync funcs will receive proper dma
handles when called directly, and a virtual address treated as one when
called from dma_map funcs.

Signed-off-by: Denis Orlov <denorl2009@xxxxxxxxx>
---
 drivers/dma/map.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/map.c b/drivers/dma/map.c
index 114c0f7db3..fea04c38a3 100644
--- a/drivers/dma/map.c
+++ b/drivers/dma/map.c
@@ -23,17 +23,15 @@ static inline void *dma_to_cpu(struct device *dev, dma_addr_t addr)
 dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
 			  enum dma_data_direction dir)
 {
-	unsigned long addr = (unsigned long)ptr;
+	dma_addr_t ret = cpu_to_dma(dev, ptr);
 
-	dma_sync_single_for_device(addr, size, dir);
+	dma_sync_single_for_device(ret, size, dir);
 
-	return cpu_to_dma(dev, ptr);
+	return ret;
 }
 
 void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
 		      enum dma_data_direction dir)
 {
-	unsigned long addr = (unsigned long)dma_to_cpu(dev, dma_addr);
-
-	dma_sync_single_for_cpu(addr, size, dir);
+	dma_sync_single_for_cpu(dma_addr, size, dir);
 }
-- 
2.30.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux