Browse Source

msm: eva: Initial migration to new dma-buf API

Per Waipio requirement.

Change-Id: Ic501909c93e9c12cb873458f47f7f86e598f16b0
Signed-off-by: George Shen <[email protected]>
George Shen 4 years ago
parent
commit
928365194b
4 changed files with 10 additions and 18 deletions
  1. 0 12
      msm/eva/cvp_hfi.c
  2. 2 2
      msm/eva/msm_cvp_buf.c
  3. 1 0
      msm/eva/msm_cvp_buf.h
  4. 7 4
      msm/eva/msm_smem.c

+ 0 - 12
msm/eva/cvp_hfi.c

@@ -1357,7 +1357,6 @@ static int __iface_cmdq_write_relaxed(struct iris_hfi_device *device,
 	struct cvp_iface_q_info *q_info;
 	struct cvp_hal_cmd_pkt_hdr *cmd_packet;
 	int result = -E2BIG;
-	struct dma_buf *dbuf;
 
 	if (!device || !pkt) {
 		dprintk(CVP_ERR, "Invalid Params\n");
@@ -1366,9 +1365,6 @@ static int __iface_cmdq_write_relaxed(struct iris_hfi_device *device,
 
 	__strict_check(device);
 
-	dbuf = device->iface_q_table.mem_data.dma_buf;
-	dma_buf_begin_cpu_access(dbuf, DMA_BIDIRECTIONAL);
-
 	if (!__core_in_valid_state(device)) {
 		dprintk(CVP_ERR, "%s - fw not in init state\n", __func__);
 		result = -EINVAL;
@@ -1414,7 +1410,6 @@ static int __iface_cmdq_write_relaxed(struct iris_hfi_device *device,
 
 err_q_write:
 err_q_null:
-	dma_buf_end_cpu_access(dbuf, DMA_BIDIRECTIONAL);
 	return result;
 }
 
@@ -2961,7 +2956,6 @@ static int __response_handler(struct iris_hfi_device *device)
 	int packet_count = 0;
 	u8 *raw_packet = NULL;
 	bool requeue_pm_work = true;
-	struct dma_buf *dbuf_sfr, *dbuf_hfi;
 
 	if (!device || device->state != IRIS_STATE_INIT)
 		return 0;
@@ -2977,10 +2971,6 @@ static int __response_handler(struct iris_hfi_device *device)
 		return 0;
 	}
 
-	dbuf_sfr = device->sfr.mem_data.dma_buf;
-	dbuf_hfi = device->iface_q_table.mem_data.dma_buf;
-	dma_buf_begin_cpu_access(dbuf_sfr, DMA_BIDIRECTIONAL);
-	dma_buf_begin_cpu_access(dbuf_hfi, DMA_BIDIRECTIONAL);
 	if (device->intr_status & CVP_FATAL_INTR_BMSK) {
 		struct cvp_hfi_sfr_struct *vsfr = (struct cvp_hfi_sfr_struct *)
 			device->sfr.align_virtual_addr;
@@ -3083,8 +3073,6 @@ static int __response_handler(struct iris_hfi_device *device)
 
 exit:
 	__flush_debug_queue(device, raw_packet);
-	dma_buf_end_cpu_access(dbuf_hfi, DMA_BIDIRECTIONAL);
-	dma_buf_end_cpu_access(dbuf_sfr, DMA_BIDIRECTIONAL);
 	return packet_count;
 }
 

+ 2 - 2
msm/eva/msm_cvp_buf.c

@@ -511,7 +511,7 @@ static void msm_cvp_unmap_frame_buf(struct msm_cvp_inst *inst,
 		if (smem->bitmap_index >= MAX_DMABUF_NUMS) {
 			/* smem not in dmamap cache */
 			msm_cvp_unmap_smem(inst, smem, "unmap cpu");
-			dma_buf_put(smem->dma_buf);
+			dma_heap_buffer_free(smem->dma_buf);
 			kmem_cache_free(cvp_driver->smem_cache, smem);
 			buf->smem = NULL;
 		} else {
@@ -589,7 +589,7 @@ int msm_cvp_unmap_user_persist(struct msm_cvp_inst *inst,
 				/* smem not in dmamap cache */
 				msm_cvp_unmap_smem(inst, smem,
 						"unmap cpu");
-				dma_buf_put(smem->dma_buf);
+				dma_heap_buffer_free(smem->dma_buf);
 				kmem_cache_free(
 					cvp_driver->smem_cache,
 					smem);

+ 1 - 0
msm/eva/msm_cvp_buf.h

@@ -9,6 +9,7 @@
 #include <linux/poll.h>
 #include <linux/types.h>
 #include <linux/dma-buf.h>
+#include <linux/dma-heap.h>
 #include <linux/ion.h>
 #include <linux/msm_ion.h>
 #include <linux/refcount.h>

+ 7 - 4
msm/eva/msm_smem.c

@@ -4,6 +4,7 @@
  */
 
 #include <linux/dma-buf.h>
+#include <linux/dma-heap.h>
 #include <linux/dma-direction.h>
 #include <linux/iommu.h>
 #include <linux/msm_dma_iommu_mapping.h>
@@ -156,7 +157,7 @@ void msm_cvp_smem_put_dma_buf(void *dma_buf)
 		return;
 	}
 
-	dma_buf_put((struct dma_buf *)dma_buf);
+	dma_heap_buffer_free((struct dma_buf *)dma_buf);
 }
 
 int msm_cvp_map_smem(struct msm_cvp_inst *inst,
@@ -246,6 +247,7 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, int map_kernel,
 	int rc = 0;
 	int ion_flags = 0;
 	struct dma_buf *dbuf = NULL;
+	struct dma_heap *heap;
 
 	if (!res) {
 		dprintk(CVP_ERR, "%s: NULL res\n", __func__);
@@ -280,7 +282,8 @@ static int alloc_dma_mem(size_t size, u32 align, u32 flags, int map_kernel,
 		heap_mask = ION_HEAP(ION_SECURE_HEAP_ID);
 	}
 
-	dbuf = ion_alloc(size, heap_mask, ion_flags);
+	heap = dma_heap_find("qcom,system");
+	dbuf = dma_heap_buffer_alloc(heap, size, 0, 0);
 	if (IS_ERR_OR_NULL(dbuf)) {
 		dprintk(CVP_ERR,
 		"Failed to allocate shared memory = %x bytes, %llx, %x %x\n",
@@ -330,7 +333,7 @@ fail_map:
 	if (map_kernel)
 		dma_buf_end_cpu_access(dbuf, DMA_BIDIRECTIONAL);
 fail_device_address:
-	dma_buf_put(dbuf);
+	dma_heap_buffer_free(dbuf);
 fail_shared_mem_alloc:
 	return rc;
 }
@@ -354,7 +357,7 @@ static int free_dma_mem(struct msm_cvp_smem *mem)
 	}
 
 	if (mem->dma_buf) {
-		dma_buf_put(mem->dma_buf);
+		dma_heap_buffer_free(mem->dma_buf);
 		mem->dma_buf = NULL;
 	}