diff options
author | Denis Orlov <denorl2009@gmail.com> | 2023-06-05 00:45:01 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2023-06-06 09:12:28 +0200 |
commit | 00ac36614d66c25702ee712e91c793d2ac7dd9a2 (patch) | |
tree | bb8d5612534c523151c9067561c4a6fd2b2a8eba /arch/sandbox | |
parent | 9d1bfb8417329b998407a7141d5a8558f735bf40 (diff) | |
download | barebox-00ac36614d66c25702ee712e91c793d2ac7dd9a2.tar.gz barebox-00ac36614d66c25702ee712e91c793d2ac7dd9a2.tar.xz |
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 <denorl2009@gmail.com>
Link: https://lore.barebox.org/20230604215002.20240-2-denorl2009@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/sandbox')
-rw-r--r-- | arch/sandbox/include/asm/dma.h | 12 |
1 files changed, 6 insertions, 6 deletions
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) { } |