Revert "dma-buf: system_heap: do force sync only if attachment list empty"

This reverts commit 33b98bf612.
Use rk_system_heap.c instead of system_heap.c now, reverts all changes.

Signed-off-by: Tao Huang <huangtao@rock-chips.com>
Change-Id: Id265fd16b1531708478f07187f50fe23e74e427e
This commit is contained in:
Tao Huang
2022-09-24 09:16:42 +08:00
parent ea59f61ab4
commit 940557cb33

View File

@@ -26,6 +26,8 @@
#include "page_pool.h"
#include "deferred-free-helper.h"
#define CONFIG_SYSTEM_HEAP_FORCE_DMA_SYNC
static struct dma_heap *sys_heap;
static struct dma_heap *sys_dma32_heap;
static struct dma_heap *sys_uncached_heap;
@@ -239,7 +241,7 @@ static int system_heap_sgl_sync_range(struct device *dev,
for_each_sg(sgl, sg, nents, i) {
unsigned int sg_offset, sg_left, size = 0;
sg_dma_addr = sg_phys(sg);
sg_dma_addr = sg_dma_address(sg);
len += sg->length;
if (len <= offset)
@@ -280,6 +282,18 @@ system_heap_dma_buf_begin_cpu_access_partial(struct dma_buf *dmabuf,
return 0;
mutex_lock(&buffer->lock);
if (IS_ENABLED(CONFIG_SYSTEM_HEAP_FORCE_DMA_SYNC)) {
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->sgl,
table->nents,
offset, len,
direction, true);
goto unlock;
}
if (buffer->vmap_cnt)
invalidate_kernel_vmap_range(buffer->vaddr, buffer->len);
@@ -295,16 +309,7 @@ system_heap_dma_buf_begin_cpu_access_partial(struct dma_buf *dmabuf,
offset, len,
direction, true);
}
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->sgl,
table->nents,
offset, len,
direction, true);
}
unlock:
mutex_unlock(&buffer->lock);
@@ -322,6 +327,18 @@ system_heap_dma_buf_end_cpu_access_partial(struct dma_buf *dmabuf,
int ret = 0;
mutex_lock(&buffer->lock);
if (IS_ENABLED(CONFIG_SYSTEM_HEAP_FORCE_DMA_SYNC)) {
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->sgl,
table->nents,
offset, len,
direction, false);
goto unlock;
}
if (buffer->vmap_cnt)
flush_kernel_vmap_range(buffer->vaddr, buffer->len);
@@ -337,16 +354,6 @@ system_heap_dma_buf_end_cpu_access_partial(struct dma_buf *dmabuf,
offset, len,
direction, false);
}
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->sgl,
table->nents,
offset, len,
direction, false);
}
unlock:
mutex_unlock(&buffer->lock);