summaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorDenis Orlov <denorl2009@gmail.com>2023-06-05 00:45:01 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2023-06-06 09:12:28 +0200
commit00ac36614d66c25702ee712e91c793d2ac7dd9a2 (patch)
treebb8d5612534c523151c9067561c4a6fd2b2a8eba /arch/mips
parent9d1bfb8417329b998407a7141d5a8558f735bf40 (diff)
downloadbarebox-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/mips')
-rw-r--r--arch/mips/lib/dma-default.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/arch/mips/lib/dma-default.c b/arch/mips/lib/dma-default.c
index 0347d7a7db..54e6665468 100644
--- a/arch/mips/lib/dma-default.c
+++ b/arch/mips/lib/dma-default.c
@@ -6,35 +6,35 @@
#include <dma.h>
#include <asm/io.h>
-void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
- enum dma_data_direction dir)
+void arch_sync_dma_for_cpu(void *vaddr, size_t size,
+ enum dma_data_direction dir)
{
- unsigned long virt = (unsigned long)phys_to_virt(address);
+ unsigned long start = (unsigned long)vaddr;
switch (dir) {
case DMA_TO_DEVICE:
break;
case DMA_FROM_DEVICE:
case DMA_BIDIRECTIONAL:
- dma_inv_range(virt, virt + size);
+ dma_inv_range(start, start + size);
break;
default:
BUG();
}
}
-void dma_sync_single_for_device(dma_addr_t address, size_t size,
- enum dma_data_direction dir)
+void arch_sync_dma_for_device(void *vaddr, size_t size,
+ enum dma_data_direction dir)
{
- unsigned long virt = (unsigned long)phys_to_virt(address);
+ unsigned long start = (unsigned long)vaddr;
switch (dir) {
case DMA_FROM_DEVICE:
- dma_inv_range(virt, virt + size);
+ dma_inv_range(start, start + size);
break;
case DMA_TO_DEVICE:
case DMA_BIDIRECTIONAL:
- dma_flush_range(virt, virt + size);
+ dma_flush_range(start, start + size);
break;
default:
BUG();