From 84ee1e6446dd34a06d209af65595951e5b323936 Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Thu, 22 Feb 2018 15:52:48 +0900 Subject: [PATCH] android: ion: do not cache flush for uncached buffers Uncached buffers are touched by CPU with uncached addresses. Cache maintenance on the uncached buffers is just redundant, no effect. Change-Id: I04283f55760845834c1d12102669caa6ccc4f45a Signed-off-by: Cho KyongHo --- drivers/staging/android/ion/ion.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index e02ef7aef6f0..89cf91901641 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -233,9 +233,13 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment, enum dma_data_direction direction) { struct sg_table *table = attachment->priv; + unsigned long attrs = 0; - if (!dma_map_sg(attachment->dev, table->sgl, table->nents, - direction)) + if (!ion_buffer_cached(attachment->dmabuf->priv)) + attrs = DMA_ATTR_SKIP_CPU_SYNC; + + if (!dma_map_sg_attrs(attachment->dev, table->sgl, table->nents, + direction, attrs)) return ERR_PTR(-ENOMEM); return table; @@ -245,7 +249,13 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment, struct sg_table *table, enum dma_data_direction direction) { - dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction); + unsigned long attrs = 0; + + if (!ion_buffer_cached(attachment->dmabuf->priv)) + attrs = DMA_ATTR_SKIP_CPU_SYNC; + + dma_unmap_sg_attrs(attachment->dev, table->sgl, table->nents, + direction, attrs); } static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) -- 2.20.1