[RFC 2/5] WIP: MIPS: implement dma mapping functions

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

 



TODO: fix warnings

arch/mips/include/asm/dma-mapping.h: In function ‘dma_free_coherent’:
arch/mips/include/asm/dma-mapping.h:31:21: warning: passing argument 1 of ‘phys_to_virt’
makes integer from pointer without a cast [-Wint-conversion]
   free(phys_to_virt(vaddr));
                     ^~~~~
In file included from include/common.h:33:0,
                 from drivers/net/e1000/main.c:32:
arch/mips/include/asm/io.h:40:21: note: expected ‘long unsigned int’ but argument is of type ‘void *’
 static inline void *phys_to_virt(unsigned long address)
                     ^~~~~~~~~~~~

Signed-off-by: Antony Pavlov <antonynpavlov@xxxxxxxxx>
Signed-off-by: Peter Mamonov <pmamonov@xxxxxxxxx>
---
 arch/mips/include/asm/dma-mapping.h |  2 +-
 arch/mips/lib/dma-default.c         | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index c71a087038..5013e7b369 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -28,7 +28,7 @@ static inline void dma_free_coherent(void *vaddr, dma_addr_t dma_handle,
 				     size_t size)
 {
 	if (IS_ENABLED(CONFIG_MMU))
-		free((void *)CKSEG0ADDR(vaddr));
+		free(phys_to_virt(vaddr));
 	else
 		free(vaddr);
 }
diff --git a/arch/mips/lib/dma-default.c b/arch/mips/lib/dma-default.c
index fbe627c24c..40caf6f91b 100644
--- a/arch/mips/lib/dma-default.c
+++ b/arch/mips/lib/dma-default.c
@@ -8,9 +8,11 @@
 
 #if defined(CONFIG_CPU_MIPS32) || \
 	defined(CONFIG_CPU_MIPS64)
-static inline void __dma_sync_mips(unsigned long addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t _addr, size_t size,
 				   enum dma_data_direction direction)
 {
+	void *addr = phys_to_virt(_addr);
+
 	switch (direction) {
 	case DMA_TO_DEVICE:
 		dma_flush_range(addr, addr + size);
@@ -29,7 +31,7 @@ static inline void __dma_sync_mips(unsigned long addr, size_t size,
 	}
 }
 #else
-static inline void __dma_sync_mips(void *addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t addr, size_t size,
 	enum dma_data_direction direction)
 {
 }
@@ -46,3 +48,19 @@ void dma_sync_single_for_device(dma_addr_t address, size_t size,
 {
 	__dma_sync_mips(address, size, dir);
 }
+
+dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
+			  enum dma_data_direction dir)
+{
+	unsigned long addr = virt_to_phys(ptr);
+
+	dma_sync_single_for_device(addr, size, dir);
+
+	return addr;
+}
+
+void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+		      enum dma_data_direction dir)
+{
+	dma_sync_single_for_cpu(addr, size, dir);
+}
-- 
2.24.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




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

  Powered by Linux