diff options
author | Guo Ren <ren_guo@c-sky.com> | 2019-07-30 11:16:28 +0200 |
---|---|---|
committer | Guo Ren <ren_guo@c-sky.com> | 2019-08-06 09:15:34 +0200 |
commit | ae76f635d4e1cffa6870cc5472567ca9d6940a22 (patch) | |
tree | b2eb9bedbf954e9301722f1cad5ddd7c426021a8 /arch/csky/mm/cachev2.c | |
parent | csky/dma: Fixup cache_op failed when cross memory ZONEs (diff) | |
download | linux-ae76f635d4e1cffa6870cc5472567ca9d6940a22.tar.xz linux-ae76f635d4e1cffa6870cc5472567ca9d6940a22.zip |
csky: Optimize arch_sync_dma_for_cpu/device with dma_inv_range
DMA_FROM_DEVICE only need to read dma data of memory into CPU cache,
so there is no need to clear cache before. Also clear + inv for
DMA_FROM_DEVICE won't cause problem, because the memory range for dma
won't be touched by software during dma working.
Changes for V2:
- Remove clr cache and ignore the DMA_TO_DEVICE in _for_cpu.
- Change inv to wbinv cache with DMA_FROM_DEVICE in _for_device.
Signed-off-by: Guo Ren <ren_guo@c-sky.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/csky/mm/cachev2.c')
-rw-r--r-- | arch/csky/mm/cachev2.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/arch/csky/mm/cachev2.c b/arch/csky/mm/cachev2.c index baaf05d69f44..b61be6518e21 100644 --- a/arch/csky/mm/cachev2.c +++ b/arch/csky/mm/cachev2.c @@ -69,11 +69,20 @@ void dma_wbinv_range(unsigned long start, unsigned long end) sync_is(); } +void dma_inv_range(unsigned long start, unsigned long end) +{ + unsigned long i = start & ~(L1_CACHE_BYTES - 1); + + for (; i < end; i += L1_CACHE_BYTES) + asm volatile("dcache.iva %0\n"::"r"(i):"memory"); + sync_is(); +} + void dma_wb_range(unsigned long start, unsigned long end) { unsigned long i = start & ~(L1_CACHE_BYTES - 1); for (; i < end; i += L1_CACHE_BYTES) - asm volatile("dcache.civa %0\n"::"r"(i):"memory"); + asm volatile("dcache.cva %0\n"::"r"(i):"memory"); sync_is(); } |