From e1229de58bc29460b172dc5936d0a5fe1eb9301c Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Wed, 4 Aug 2021 16:00:14 +0800 Subject: [PATCH] staging: ion: do flush_cache_all for large size Change-Id: Iac8e5bd0d4405cb9faf84ca2f0579b085861997c Signed-off-by: Jianqun Xu --- drivers/staging/android/ion/ion.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index b2c6d7b11203..77d6f43c69fa 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -29,6 +29,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include "ion_trace.h" @@ -530,6 +531,18 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf, mutex_unlock(&buffer->lock); } + if (buffer->size >= SZ_1M) { + if (direction == DMA_FROM_DEVICE) { + flush_cache_all(); + goto exit; + } else { +#ifdef CONFIG_ARM64 + __flush_dcache_all(); + goto exit; +#endif + } + } + mutex_lock(&buffer->lock); if (IS_ENABLED(CONFIG_ION_FORCE_DMA_SYNC)) { struct device *dev = ion_dev; @@ -557,7 +570,7 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf, } unlock: mutex_unlock(&buffer->lock); - +exit: return 0; } @@ -614,6 +627,18 @@ static int ion_dma_buf_end_cpu_access_partial(struct dma_buf *dmabuf, struct ion_dma_buf_attachment *a; int ret = 0; + if (len >= SZ_1M) { + if (direction == DMA_FROM_DEVICE) { + flush_cache_all(); + goto exit; + } else { +#ifdef CONFIG_ARM64 + __flush_dcache_all(); + goto exit; +#endif + } + } + mutex_lock(&buffer->lock); if (IS_ENABLED(CONFIG_ION_FORCE_DMA_SYNC)) { if (dev) { @@ -638,7 +663,7 @@ static int ion_dma_buf_end_cpu_access_partial(struct dma_buf *dmabuf, } unlock: mutex_unlock(&buffer->lock); - +exit: return ret; }