diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index 6b7f1ad0178b..7bb7723f0cb8 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -272,8 +272,9 @@ system_heap_dma_buf_begin_cpu_access_partial(struct dma_buf *dmabuf, unsigned int len) { struct system_heap_buffer *buffer = dmabuf->priv; - struct dma_heap_attachment *a; - int ret = 0; + struct dma_heap *heap = buffer->heap; + struct sg_table *table = &buffer->sg_table; + int ret; if (direction == DMA_TO_DEVICE) return 0; @@ -282,25 +283,13 @@ system_heap_dma_buf_begin_cpu_access_partial(struct dma_buf *dmabuf, if (buffer->vmap_cnt) invalidate_kernel_vmap_range(buffer->vaddr, buffer->len); - if (buffer->uncached) - goto unlock; - - list_for_each_entry(a, &buffer->attachments, list) { - if (!a->mapped) - continue; - - ret = system_heap_sgl_sync_range(a->dev, a->table, offset, len, - direction, true); + if (buffer->uncached) { + mutex_unlock(&buffer->lock); + return 0; } - if (list_empty(&buffer->attachments)) { - struct dma_heap *heap = buffer->heap; - struct sg_table *table = &buffer->sg_table; - ret = system_heap_sgl_sync_range(dma_heap_get_dev(heap), table, - offset, len, - direction, true); - } -unlock: + ret = system_heap_sgl_sync_range(dma_heap_get_dev(heap), table, + offset, len, direction, true); mutex_unlock(&buffer->lock); return ret; @@ -313,32 +302,21 @@ system_heap_dma_buf_end_cpu_access_partial(struct dma_buf *dmabuf, unsigned int len) { struct system_heap_buffer *buffer = dmabuf->priv; - struct dma_heap_attachment *a; - int ret = 0; + struct dma_heap *heap = buffer->heap; + struct sg_table *table = &buffer->sg_table; + int ret; mutex_lock(&buffer->lock); if (buffer->vmap_cnt) flush_kernel_vmap_range(buffer->vaddr, buffer->len); - if (buffer->uncached) - goto unlock; - - list_for_each_entry(a, &buffer->attachments, list) { - if (!a->mapped) - continue; - - ret = system_heap_sgl_sync_range(a->dev, a->table, offset, len, - direction, false); + if (buffer->uncached) { + mutex_unlock(&buffer->lock); + return 0; } - if (list_empty(&buffer->attachments)) { - struct dma_heap *heap = buffer->heap; - struct sg_table *table = &buffer->sg_table; - ret = system_heap_sgl_sync_range(dma_heap_get_dev(heap), table, - offset, len, - direction, false); - } -unlock: + ret = system_heap_sgl_sync_range(dma_heap_get_dev(heap), table, + offset, len, direction, false); mutex_unlock(&buffer->lock); return ret;