mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-13 08:07:32 -04:00
ANDROID: staging: ion: optimize cache operation for non-cached buffer
The non-cached ion buffer is flushed when allocated. And then, that is is always mapped as non-cached after allocation. In the absence of caching, cache maintenance operations become unnecessary. However dma_buf_ops tries to maintain cache coherency for non-cached buffer on begin[end]_cpu_access and map[unmap]_dma_buf functions. It creates unnecessary overhead, so let's remove it. Bug: 151775080 Signed-off-by: Hyesoo Yu <hyesoo.yu@samsung.com> Change-Id: I168117c7002aec7930c84168d15816a09750b7d8 Signed-off-by: Hridya Valsaraju <hridya@google.com> (cherry picked from commit 2c3b4cba8ab38d7eb9f474c78f9b4c70867bf71d) Signed-off-by: Hridya Valsaraju <hridya@google.com>
This commit is contained in:
parent
8d814964bc
commit
48675044f9
1 changed files with 18 additions and 2 deletions
|
|
@ -105,6 +105,7 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
|
|||
struct ion_heap *heap = buffer->heap;
|
||||
struct ion_dma_buf_attachment *a;
|
||||
struct sg_table *table;
|
||||
unsigned long attrs = attachment->dma_map_attrs;
|
||||
|
||||
if (heap->buf_ops.map_dma_buf)
|
||||
return heap->buf_ops.map_dma_buf(attachment, direction);
|
||||
|
|
@ -112,8 +113,11 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment,
|
|||
a = attachment->priv;
|
||||
table = a->table;
|
||||
|
||||
if (!(buffer->flags & ION_FLAG_CACHED))
|
||||
attrs |= DMA_ATTR_SKIP_CPU_SYNC;
|
||||
|
||||
if (!dma_map_sg_attrs(attachment->dev, table->sgl, table->nents,
|
||||
direction, attachment->dma_map_attrs))
|
||||
direction, attrs))
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
a->mapped = true;
|
||||
|
|
@ -128,6 +132,7 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
|
|||
struct ion_buffer *buffer = attachment->dmabuf->priv;
|
||||
struct ion_heap *heap = buffer->heap;
|
||||
struct ion_dma_buf_attachment *a = attachment->priv;
|
||||
unsigned long attrs = attachment->dma_map_attrs;
|
||||
|
||||
a->mapped = false;
|
||||
|
||||
|
|
@ -135,8 +140,11 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,
|
|||
return heap->buf_ops.unmap_dma_buf(attachment, table,
|
||||
direction);
|
||||
|
||||
if (!(buffer->flags & ION_FLAG_CACHED))
|
||||
attrs |= DMA_ATTR_SKIP_CPU_SYNC;
|
||||
|
||||
dma_unmap_sg_attrs(attachment->dev, table->sgl, table->nents,
|
||||
direction, attachment->dma_map_attrs);
|
||||
direction, attrs);
|
||||
}
|
||||
|
||||
static void ion_dma_buf_release(struct dma_buf *dmabuf)
|
||||
|
|
@ -174,6 +182,9 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
|
|||
goto unlock;
|
||||
}
|
||||
|
||||
if (!(buffer->flags & ION_FLAG_CACHED))
|
||||
goto unlock;
|
||||
|
||||
list_for_each_entry(a, &buffer->attachments, list) {
|
||||
if (!a->mapped)
|
||||
continue;
|
||||
|
|
@ -218,12 +229,17 @@ static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf,
|
|||
mutex_lock(&buffer->lock);
|
||||
|
||||
ion_buffer_kmap_put(buffer);
|
||||
|
||||
if (!(buffer->flags & ION_FLAG_CACHED))
|
||||
goto unlock;
|
||||
|
||||
list_for_each_entry(a, &buffer->attachments, list) {
|
||||
if (!a->mapped)
|
||||
continue;
|
||||
dma_sync_sg_for_device(a->dev, a->table->sgl, a->table->nents,
|
||||
direction);
|
||||
}
|
||||
unlock:
|
||||
mutex_unlock(&buffer->lock);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue