From 00ac36614d66c25702ee712e91c793d2ac7dd9a2 Mon Sep 17 00:00:00 2001 From: Denis Orlov Date: Mon, 5 Jun 2023 00:45:01 +0300 Subject: dma: rework dma_sync_single_for_*() interface Currently, a lot of code handles dma_addr_t values as if they actually hold CPU addresses. However, this is not always true. For example, MIPS architecture requires an explicit conversion from the physical address space to some virtual address space segment to get a valid CPU-side pointer. Another issue is that DMA ranges that may be specified in a device tree will not work this way. To get from a virtual address to a dma handle and vice versa we need to add/subtract some offset, which is calculated from "dma-ranges" property. Only dma_map_single() was doing this, but dma_sync_single_for_*() also should. Improve the interface by adding 'struct device' as the first argument to the dma_sync_single_for_*(). This allows to do cpu_to_dma/dma_to_cpu() conversions in common code and call into arch-specific code with proper cpu-side addresses. To make things more clear, make the virtual address argument of those arch-side functions be properly represented with a void* type. Apply the required changes in device drivers that use the affected functions, making them pass the appropriate device pointer. Signed-off-by: Denis Orlov Link: https://lore.barebox.org/20230604215002.20240-2-denorl2009@gmail.com Signed-off-by: Sascha Hauer --- arch/sandbox/include/asm/dma.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'arch/sandbox') diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h index 958d10e2a1..ac8b408aae 100644 --- a/arch/sandbox/include/asm/dma.h +++ b/arch/sandbox/include/asm/dma.h @@ -43,15 +43,15 @@ static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle, free(mem); } -#define dma_sync_single_for_cpu dma_sync_single_for_cpu -static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size, - enum dma_data_direction dir) +#define arch_sync_dma_for_cpu arch_sync_dma_for_cpu +static inline void arch_sync_dma_for_cpu(void *vaddr, size_t size, + enum dma_data_direction dir) { } -#define dma_sync_single_for_device dma_sync_single_for_device -static inline void dma_sync_single_for_device(dma_addr_t address, size_t size, - enum dma_data_direction dir) +#define arch_sync_dma_for_device arch_sync_dma_for_device +static inline void arch_sync_dma_for_device(void *vaddr, size_t size, + enum dma_data_direction dir) { } -- cgit v1.2.3