瀏覽代碼

ubwcp: don’t apply CMO at end of UBWC-P read

Driver was applying CMO at end of UBWC-P read, this CMO isn’t required
so remove it to improve performance.

Also update trace to print direction used with dma sync calls.

Change-Id: If140a9a772768efb9171305e28688b142c8651f8
Signed-off-by: Liam Mark <[email protected]>
Liam Mark 1 年之前
父節點
當前提交
8679cc4830
共有 2 個文件被更改,包括 43 次插入20 次删除
  1. 11 8
      ubwcp/ubwcp_main.c
  2. 32 12
      ubwcp/ubwcp_trace.h

+ 11 - 8
ubwcp/ubwcp_main.c

@@ -449,9 +449,9 @@ static void ula_unmap(struct ubwcp_driver *ubwcp)
 
 static void ula_sync_for_cpu(struct device *dev, u64 addr, unsigned long size)
 {
-	trace_ubwcp_dma_sync_single_for_cpu_start(size);
+	trace_ubwcp_dma_sync_single_for_cpu_start(size, DMA_BIDIRECTIONAL);
 	dma_sync_single_for_cpu(dev, addr, size, DMA_BIDIRECTIONAL);
-	trace_ubwcp_dma_sync_single_for_cpu_end(size);
+	trace_ubwcp_dma_sync_single_for_cpu_end(size, DMA_BIDIRECTIONAL);
 }
 
 /** Remove ula memory in chunks
@@ -1940,9 +1940,9 @@ static int ubwcp_lock(struct dma_buf *dmabuf, enum dma_data_direction dir)
 		 */
 		if (dir == DMA_TO_DEVICE)
 			dir = DMA_BIDIRECTIONAL;
-		trace_ubwcp_dma_sync_single_for_cpu_start(buf->ula_size);
+		trace_ubwcp_dma_sync_single_for_cpu_start(buf->ula_size, dir);
 		dma_sync_single_for_cpu(ubwcp->dev, buf->ula_pa, buf->ula_size, dir);
-		trace_ubwcp_dma_sync_single_for_cpu_end(buf->ula_size);
+		trace_ubwcp_dma_sync_single_for_cpu_end(buf->ula_size, dir);
 		buf->dma_dir = dir;
 	} else {
 		DBG("buf already locked");
@@ -1997,10 +1997,13 @@ static int unlock_internal(struct ubwcp_buf *buf, enum dma_data_direction dir, b
 
 	ubwcp = buf->ubwcp;
 
-	/* Flush/invalidate ULA PA from CPU caches */
-	trace_ubwcp_dma_sync_single_for_device_start(buf->ula_size);
-	dma_sync_single_for_device(ubwcp->dev, buf->ula_pa, buf->ula_size, buf->dma_dir);
-	trace_ubwcp_dma_sync_single_for_device_end(buf->ula_size);
+	/* Only apply CMOs if there were potential CPU writes */
+	if (buf->dma_dir == DMA_TO_DEVICE || buf->dma_dir == DMA_BIDIRECTIONAL) {
+		/* Flush/invalidate ULA PA from CPU caches */
+		trace_ubwcp_dma_sync_single_for_device_start(buf->ula_size, buf->dma_dir);
+		dma_sync_single_for_device(ubwcp->dev, buf->ula_pa, buf->ula_size, buf->dma_dir);
+		trace_ubwcp_dma_sync_single_for_device_end(buf->ula_size, buf->dma_dir);
+	}
 
 	/* disable range check */
 	DBG("disabling range check");

+ 32 - 12
ubwcp/ubwcp_trace.h

@@ -89,6 +89,26 @@ DECLARE_EVENT_CLASS(ubwcp_size_event,
 	TP_printk("size:%zu", __entry->size)
 );
 
+DECLARE_EVENT_CLASS(ubwcp_sync_event,
+
+	TP_PROTO(size_t size,
+		 int dir),
+
+	TP_ARGS(size, dir),
+
+	TP_STRUCT__entry(
+		__field(size_t, size)
+		__field(int, dir)
+	),
+
+	TP_fast_assign(
+		__entry->size = size;
+		__entry->dir = dir;
+	),
+
+	TP_printk("size:%zu, dir:%d", __entry->size, __entry->dir)
+);
+
 DEFINE_EVENT(ubwcp_dmabuf_event, ubwcp_init_buffer_start,
 
 	TP_PROTO(struct dma_buf *dbuf_addr),
@@ -173,32 +193,32 @@ DEFINE_EVENT(ubwcp_size_event, ubwcp_offline_sync_end,
 	TP_ARGS(size)
 );
 
-DEFINE_EVENT(ubwcp_size_event, ubwcp_dma_sync_single_for_device_start,
+DEFINE_EVENT(ubwcp_sync_event, ubwcp_dma_sync_single_for_device_start,
 
-	TP_PROTO(size_t size),
+	TP_PROTO(size_t size, int dir),
 
-	TP_ARGS(size)
+	TP_ARGS(size, dir)
 );
 
-DEFINE_EVENT(ubwcp_size_event, ubwcp_dma_sync_single_for_device_end,
+DEFINE_EVENT(ubwcp_sync_event, ubwcp_dma_sync_single_for_device_end,
 
-	TP_PROTO(size_t size),
+	TP_PROTO(size_t size, int dir),
 
-	TP_ARGS(size)
+	TP_ARGS(size, dir)
 );
 
-DEFINE_EVENT(ubwcp_size_event, ubwcp_dma_sync_single_for_cpu_start,
+DEFINE_EVENT(ubwcp_sync_event, ubwcp_dma_sync_single_for_cpu_start,
 
-	TP_PROTO(size_t size),
+	TP_PROTO(size_t size, int dir),
 
-	TP_ARGS(size)
+	TP_ARGS(size, dir)
 );
 
-DEFINE_EVENT(ubwcp_size_event, ubwcp_dma_sync_single_for_cpu_end,
+DEFINE_EVENT(ubwcp_sync_event, ubwcp_dma_sync_single_for_cpu_end,
 
-	TP_PROTO(size_t size),
+	TP_PROTO(size_t size, int dir),
 
-	TP_ARGS(size)
+	TP_ARGS(size, dir)
 );
 
 DEFINE_EVENT(ubwcp_size_event, ubwcp_hw_flush_start,