lkml.org 
[lkml]   [2023]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 04/21] microblaze: dma-mapping: skip extra DMA flushes
Date
From: Arnd Bergmann <arnd@arndb.de>

The microblaze dma_sync_* implementation uses the same function
for both _for_cpu() and _for_device(), which is inconsistent
with other architectures and slightly more expensive.

Split it up into separate functions and skip the parts that
are not needed:

- on dma_sync_*_for_cpu(..., DMA_TO_DEVICE), skip the second
writeback, which does nothing.

- on dma_sync_*_for_cpu(..., DMA_BIDIRECTIONAL), only invalidate
the cache to clear out cache lines that got loaded speculatively,
but skip the extraneous writeback.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/microblaze/kernel/dma.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/microblaze/kernel/dma.c b/arch/microblaze/kernel/dma.c
index 04d091ade417..b4c4e45fd45e 100644
--- a/arch/microblaze/kernel/dma.c
+++ b/arch/microblaze/kernel/dma.c
@@ -14,8 +14,8 @@
#include <linux/bug.h>
#include <asm/cacheflush.h>

-static void __dma_sync(phys_addr_t paddr, size_t size,
- enum dma_data_direction direction)
+void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
+ enum dma_data_direction dir)
{
switch (direction) {
case DMA_TO_DEVICE:
@@ -30,14 +30,16 @@ static void __dma_sync(phys_addr_t paddr, size_t size,
}
}

-void arch_sync_dma_for_device(phys_addr_t paddr, size_t size,
- enum dma_data_direction dir)
-{
- __dma_sync(paddr, size, dir);
-}
-
void arch_sync_dma_for_cpu(phys_addr_t paddr, size_t size,
enum dma_data_direction dir)
{
- __dma_sync(paddr, size, dir);
-}
+ switch (direction) {
+ case DMA_TO_DEVICE:
+ break;
+ case DMA_BIDIRECTIONAL:
+ case DMA_FROM_DEVICE:
+ invalidate_dcache_range(paddr, paddr + size);
+ break;
+ default:
+ BUG();
+ }}
--
2.39.2
\
 
 \ /
  Last update: 2023-03-27 14:15    [W:0.532 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site