Thread (4 messages) 4 messages, 2 authors, 2021-08-31

Re: [PATCH] dma-buf: heaps: remove duplicated cache sync

From: Christian König <christian.koenig@amd.com>
Date: 2021-08-30 10:16:43
Also in: dri-devel, linux-arm-kernel, linux-media, lkml

Am 30.08.21 um 12:01 schrieb guangming.cao@mediatek.com:
From: Guangming Cao <redacted>

Current flow, one dmabuf maybe call cache sync many times if
it has beed mapped more than one time.
Well I'm not an expert on DMA heaps, but this will most likely not work 
correctly.
Is there any case that attachments of one dmabuf will points to
different memory? If not, seems do sync only one time is more better.
I think that this can happen, yes.

Christian.

quoted hunk ↗ jump to hunk
Signed-off-by: Guangming Cao <redacted>
---
  drivers/dma-buf/heaps/system_heap.c | 14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
index 23a7e74ef966..909ef652a8c8 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -162,9 +162,10 @@ static int system_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
  		invalidate_kernel_vmap_range(buffer->vaddr, buffer->len);
  
  	list_for_each_entry(a, &buffer->attachments, list) {
-		if (!a->mapped)
-			continue;
-		dma_sync_sgtable_for_cpu(a->dev, a->table, direction);
+		if (a->mapped) {
+			dma_sync_sgtable_for_cpu(a->dev, a->table, direction);
+			break;
+		}
  	}
  	mutex_unlock(&buffer->lock);
  
@@ -183,9 +184,10 @@ static int system_heap_dma_buf_end_cpu_access(struct dma_buf *dmabuf,
  		flush_kernel_vmap_range(buffer->vaddr, buffer->len);
  
  	list_for_each_entry(a, &buffer->attachments, list) {
-		if (!a->mapped)
-			continue;
-		dma_sync_sgtable_for_device(a->dev, a->table, direction);
+		if (!a->mapped) {
+			dma_sync_sgtable_for_device(a->dev, a->table, direction);
+			break;
+		}
  	}
  	mutex_unlock(&buffer->lock);
  

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help