diff options
author | Richard Liu <xuegang.liu@nxp.com> | 2020-03-20 15:42:01 +0000 |
---|---|---|
committer | Yong Gan <yong.gan@nxp.com> | 2020-04-23 17:47:32 +0800 |
commit | 03cfd33c5f341370509952e7d8f06bd60fdc92b5 (patch) | |
tree | 69c8b4c6425e4b5be0fe50eca0a0d7dc171655e9 | |
parent | 252217e0dc992ffed64f76fabf79cedae95e09f5 (diff) |
MGS-5565 staging: android: ion: Flush cache after zero CMA allocated memory
ION CMA memory default is cacheable, need flush cache after memset(),
else cache and physical memory not sync may cause problem.
Issue case:
VPU Video playback or GPU render have dirty line issue.
Root cause:
ION CMA allocate cacheable buffer and do memset(), some data still in cache
not in physical memory, VPU or GPU write the buffer with physical address,
or user call ion_mmap() to map the buffer through pgprot_writecombine() as
no-cache and write the buffer, later some CPU cache access trigger cache
flush, previous memset() data go to physical memory as dirty data.
Change-Id: I82b4cb61bbe6cffc687d452f9f81c1e35914d2f1
Signed-off-by: Richard Liu <xuegang.liu@nxp.com>
(cherry picked from commit 5d360f25f3523311b5f478b7b1c7bc9020cfda58)
-rw-r--r-- | drivers/staging/android/ion/ion_cma_heap.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index fa3e4b7e0c9f..80df813372e4 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -22,6 +22,7 @@ #include <linux/cma.h> #include <linux/scatterlist.h> #include <linux/highmem.h> +#include <asm/cacheflush.h> #include "ion.h" @@ -60,12 +61,22 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, void *vaddr = kmap_atomic(page); memset(vaddr, 0, PAGE_SIZE); +#ifdef CONFIG_ARM64 + __flush_dcache_area(vaddr,PAGE_SIZE); +#else + __cpuc_flush_dcache_area(vaddr,PAGE_SIZE); +#endif kunmap_atomic(vaddr); page++; nr_clear_pages--; } } else { memset(page_address(pages), 0, size); +#ifdef CONFIG_ARM64 + __flush_dcache_area(page_address(pages),size); +#else + __cpuc_flush_dcache_area(page_address(pages),size); +#endif } table = kmalloc(sizeof(*table), GFP_KERNEL); |