diff options
author | Richard Liu <xuegang.liu@nxp.com> | 2020-03-20 15:42:01 +0000 |
---|---|---|
committer | Richard Liu <xuegang.liu@nxp.com> | 2020-03-23 11:49:37 +0000 |
commit | 3d549870d99b2522d863a4940cd320d2a87eaad7 (patch) | |
tree | 2c3bf492e89756b401743cf7a2f615853be7492d /drivers/staging/android | |
parent | 2c4cf9ce2fcf9581d6625025b76ae73f77dde922 (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>
Reviewed-by: Bing Song <bing.song@nxp.com>
Diffstat (limited to 'drivers/staging/android')
-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 bf65e67ef9d8..52af33b48e3c 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -13,6 +13,7 @@ #include <linux/cma.h> #include <linux/scatterlist.h> #include <linux/highmem.h> +#include <asm/cacheflush.h> #include "ion.h" @@ -51,12 +52,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); |