mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
dma-buf: system_heap: do force sync only if attachment list empty
When the dmabuf attachment list is empty, do force sync with the heap
device, it is useful for partial access for cpu.
Fixes: 21f2fd663e ("dma-buf: system_heap: support cpu access partial dma-buf")
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Change-Id: Ie266767aeb03a361e1541ba9e84f3dd027350a75
This commit is contained in:
@@ -26,8 +26,6 @@
|
|||||||
#include "page_pool.h"
|
#include "page_pool.h"
|
||||||
#include "deferred-free-helper.h"
|
#include "deferred-free-helper.h"
|
||||||
|
|
||||||
#define CONFIG_SYSTEM_HEAP_FORCE_DMA_SYNC
|
|
||||||
|
|
||||||
static struct dma_heap *sys_heap;
|
static struct dma_heap *sys_heap;
|
||||||
static struct dma_heap *sys_dma32_heap;
|
static struct dma_heap *sys_dma32_heap;
|
||||||
static struct dma_heap *sys_uncached_heap;
|
static struct dma_heap *sys_uncached_heap;
|
||||||
@@ -241,7 +239,7 @@ static int system_heap_sgl_sync_range(struct device *dev,
|
|||||||
for_each_sg(sgl, sg, nents, i) {
|
for_each_sg(sgl, sg, nents, i) {
|
||||||
unsigned int sg_offset, sg_left, size = 0;
|
unsigned int sg_offset, sg_left, size = 0;
|
||||||
|
|
||||||
sg_dma_addr = sg_dma_address(sg);
|
sg_dma_addr = sg_phys(sg);
|
||||||
|
|
||||||
len += sg->length;
|
len += sg->length;
|
||||||
if (len <= offset)
|
if (len <= offset)
|
||||||
@@ -282,18 +280,6 @@ system_heap_dma_buf_begin_cpu_access_partial(struct dma_buf *dmabuf,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mutex_lock(&buffer->lock);
|
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)
|
if (buffer->vmap_cnt)
|
||||||
invalidate_kernel_vmap_range(buffer->vaddr, buffer->len);
|
invalidate_kernel_vmap_range(buffer->vaddr, buffer->len);
|
||||||
|
|
||||||
@@ -309,7 +295,16 @@ system_heap_dma_buf_begin_cpu_access_partial(struct dma_buf *dmabuf,
|
|||||||
offset, len,
|
offset, len,
|
||||||
direction, true);
|
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:
|
unlock:
|
||||||
mutex_unlock(&buffer->lock);
|
mutex_unlock(&buffer->lock);
|
||||||
|
|
||||||
@@ -327,18 +322,6 @@ system_heap_dma_buf_end_cpu_access_partial(struct dma_buf *dmabuf,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
mutex_lock(&buffer->lock);
|
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)
|
if (buffer->vmap_cnt)
|
||||||
flush_kernel_vmap_range(buffer->vaddr, buffer->len);
|
flush_kernel_vmap_range(buffer->vaddr, buffer->len);
|
||||||
|
|
||||||
@@ -354,6 +337,16 @@ system_heap_dma_buf_end_cpu_access_partial(struct dma_buf *dmabuf,
|
|||||||
offset, len,
|
offset, len,
|
||||||
direction, false);
|
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:
|
unlock:
|
||||||
mutex_unlock(&buffer->lock);
|
mutex_unlock(&buffer->lock);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user