From bec15067c2a4c625014737d24b9b7766745bcaf3 Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Wed, 24 Feb 2021 15:24:22 +0800 Subject: [PATCH] staging: android: ion: do cache flush for system heap pages Change-Id: I57505aaee2c2f9af796313bfc729cef0ce9cfece Signed-off-by: Jianqun Xu --- drivers/staging/android/ion/ion_system_heap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 6f73363c2282..9fdf4f742186 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -5,6 +5,7 @@ * Copyright (C) 2011 Google, Inc. */ +#include #include #include #include @@ -189,6 +190,17 @@ static int ion_system_heap_allocate(struct ion_heap *heap, } buffer->sg_table = table; + + if (!(buffer->flags & ION_FLAG_CACHED)) { + for_each_sg(table->sgl, sg, table->orig_nents, i) { + void *start; + + page = sg_page(sg); + start = page_address(page); + dmac_flush_range(start, start + sg->length); + } + } + return 0; free_table: