瀏覽代碼

Merge 1ca3dee5f5f146f2a1b2b0de72605db684882d64 on remote branch

Change-Id: I71d04b11e1e9f8ca796b5f01377dfb6f63b16533
Linux Build Service Account 1 年之前
父節點
當前提交
7c704e7611
共有 5 個文件被更改,包括 73 次插入25 次删除
  1. 19 1
      msm/eva/cvp_smem.c
  2. 27 3
      msm/eva/msm_cvp.c
  3. 16 1
      msm/eva/msm_cvp_core.c
  4. 9 18
      msm/eva/msm_cvp_dsp.c
  5. 2 2
      msm/eva/msm_cvp_ioctl.c

+ 19 - 1
msm/eva/cvp_smem.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/dma-buf.h>
@@ -88,6 +88,8 @@ static int msm_dma_get_device_address(struct dma_buf *dbuf, u32 align,
 			dprintk(CVP_ERR, "Failed to attach dmabuf\n");
 			goto mem_buf_attach_failed;
 		}
+		dprintk(CVP_MEM, "%s: CB dev: %s, attach dev: %s, attach: 0x%lx, dbuf: 0x%lx",
+			__func__, dev_name(cb->dev), dev_name(attach->dev), attach, dbuf);
 
 		/*
 		 * Get the scatterlist for the given attachment
@@ -130,6 +132,9 @@ static int msm_dma_get_device_address(struct dma_buf *dbuf, u32 align,
 		mapping_info->attach = attach;
 		mapping_info->buf = dbuf;
 		mapping_info->cb_info = (void *)cb;
+
+		dprintk(CVP_MEM, "%s: sg-table: 0x%lx, dbuf: 0x%lx, table->sgl->dma_address: 0x%lx",
+			__func__, table, dbuf, table->sgl->dma_address);
 	} else {
 		dprintk(CVP_MEM, "iommu not present, use phys mem addr\n");
 	}
@@ -148,6 +153,10 @@ static int msm_dma_put_device_address(u32 flags,
 	struct cvp_dma_mapping_info *mapping_info)
 {
 	int rc = 0;
+	struct dma_buf_attachment *attach = NULL;
+	struct sg_table *table = NULL;
+	struct context_bank_info *cb = NULL;
+	struct dma_buf *dbuf = NULL;
 
 	if (!mapping_info) {
 		dprintk(CVP_WARN, "Invalid mapping_info\n");
@@ -161,6 +170,15 @@ static int msm_dma_put_device_address(u32 flags,
 		return -EINVAL;
 	}
 
+	attach = mapping_info->attach;
+	table = mapping_info->table;
+	cb = (struct context_bank_info *) mapping_info->cb_info;
+	dbuf = mapping_info->buf;
+	dprintk(CVP_MEM, "%s: CB dev_name: %s, attach dev_name: %s, attach: 0x%lx, dbuf: 0x%lx",
+		__func__, dev_name(cb->dev), dev_name(attach->dev), attach, dbuf);
+	dprintk(CVP_MEM, "%s: sg-table: 0x%lx, table->sgl->dma_address: 0x%lx",
+		__func__, table, dbuf, table->sgl->dma_address);
+
 	dma_buf_unmap_attachment(mapping_info->attach,
 		mapping_info->table, DMA_BIDIRECTIONAL);
 	dma_buf_detach(mapping_info->buf, mapping_info->attach);

+ 27 - 3
msm/eva/msm_cvp.c

@@ -927,7 +927,8 @@ int msm_cvp_session_stop(struct msm_cvp_inst *inst,
 	struct eva_kmd_session_control *sc = NULL;
 	struct msm_cvp_inst *s;
 	struct cvp_hfi_ops *ops_tbl;
-	int rc;
+	int rc = 0;
+	int curr_sq_state = -1;
 
 	if (!inst || !inst->core) {
 		dprintk(CVP_ERR, "%s: invalid params\n", __func__);
@@ -942,8 +943,27 @@ int msm_cvp_session_stop(struct msm_cvp_inst *inst,
 		return -ECONNRESET;
 
 	sq = &inst->session_queue;
+	curr_sq_state = sq->state;
 
 	spin_lock(&sq->lock);
+	if (sq->state != QUEUE_START) {
+		spin_unlock(&sq->lock);
+		dprintk(CVP_ERR,
+			"%s: Stop not allowed - curr state %d,  inst %llx, sess %llx, %s type %d\n",
+			__func__, sq->state, inst, inst->session, inst->proc_name,
+			inst->session_type);
+		rc = -EINVAL;
+		return rc;
+	}
+
+	if (sq->state == QUEUE_STOP) {
+		spin_unlock(&sq->lock);
+		dprintk(CVP_WARN,
+				"%s: Double stop session - inst %llx, sess %llx, %s of type %d\n",
+				__func__, inst, inst->session, inst->proc_name, inst->session_type);
+		return rc;
+	}
+
 	if (sq->msg_count) {
 		dprintk(CVP_ERR, "session stop incorrect: queue not empty%d\n",
 			sq->msg_count);
@@ -965,6 +985,9 @@ int msm_cvp_session_stop(struct msm_cvp_inst *inst,
 	if (rc) {
 		dprintk(CVP_WARN, "%s: session stop failed rc %d\n",
 				__func__, rc);
+		spin_lock(&sq->lock);
+		sq->state = curr_sq_state;
+		spin_unlock(&sq->lock);
 		goto stop_thread;
 	}
 
@@ -973,6 +996,9 @@ int msm_cvp_session_stop(struct msm_cvp_inst *inst,
 	if (rc) {
 		dprintk(CVP_WARN, "%s: wait for signal failed, rc %d\n",
 				__func__, rc);
+		spin_lock(&sq->lock);
+		sq->state = curr_sq_state;
+		spin_unlock(&sq->lock);
 		goto stop_thread;
 	}
 
@@ -998,8 +1024,6 @@ int msm_cvp_session_queue_stop(struct msm_cvp_inst *inst)
 		return 0;
 	}
 
-	sq->state = QUEUE_STOP;
-
 	dprintk(CVP_SESS, "Stop session queue: %pK session_id = %#x\n",
 			inst, hash32_ptr(inst->session));
 	spin_unlock(&sq->lock);

+ 16 - 1
msm/eva/msm_cvp_core.c

@@ -359,6 +359,16 @@ stop_session:
 			__func__, inst);
 		goto exit;
 	}
+	spin_lock(&sq->lock);
+	if (sq->state == QUEUE_STOP) {
+		spin_unlock(&sq->lock);
+		dprintk(CVP_WARN,
+			"%s: Double stop session - inst %llx, sess %llx, %s of type %d\n",
+			__func__, inst, inst->session, inst->proc_name, inst->session_type);
+		goto release_arp;
+	}
+	spin_unlock(&sq->lock);
+
 	if (!empty) {
 		/* STOP SESSION to avoid SMMU fault after releasing ARP */
 		ops_tbl = inst->core->dev_ops;
@@ -371,9 +381,14 @@ stop_session:
 
 		/*Fail stop session, release arp later may cause smmu fault*/
 		rc = wait_for_sess_signal_receipt(inst, HAL_SESSION_STOP_DONE);
-		if (rc)
+		if (rc) {
 			dprintk(CVP_WARN, "%s: wait for sess_stop fail, rc %d\n",
 					__func__, rc);
+		} else {
+			spin_lock(&sq->lock);
+			sq->state = QUEUE_STOP;
+			spin_unlock(&sq->lock);
+		}
 		/* Continue to release ARP anyway */
 	}
 release_arp:

+ 9 - 18
msm/eva/msm_cvp_dsp.c

@@ -1846,11 +1846,12 @@ void __dsp_cvp_mem_free(struct cvp_dsp_cmd_msg *cmd)
 	cmd->ret = 0;
 
 	dprintk(CVP_DSP,
-		"%s sess id 0x%x, low 0x%x, high 0x%x, hnl 0x%x\n",
+		"%s sess 0x%x, low 0x%x, high 0x%x, hnl 0x%x, iova 0x%x, fd 0x%x\n",
 		__func__, dsp2cpu_cmd->session_id,
 		dsp2cpu_cmd->session_cpu_low,
 		dsp2cpu_cmd->session_cpu_high,
-		dsp2cpu_cmd->pid);
+		dsp2cpu_cmd->pid, dsp2cpu_cmd->sbuf.iova,
+		dsp2cpu_cmd->sbuf.fd);
 
 	inst = (struct msm_cvp_inst *)get_inst_from_dsp(
 			dsp2cpu_cmd->session_cpu_high,
@@ -1968,19 +1969,11 @@ void __dsp_cvp_sess_stop(struct cvp_dsp_cmd_msg *cmd)
 {
 	struct cvp_dsp_apps *me = &gfa_cv;
 	struct msm_cvp_inst *inst;
-	struct cvp_session_queue *sq;
 	int rc;
 	struct cvp_dsp2cpu_cmd *dsp2cpu_cmd = &me->pending_dsp2cpu_cmd;
 
 	cmd->ret = 0;
 
-	dprintk(CVP_DSP,
-		"%s sess id 0x%x, low 0x%x, high 0x%x, pid 0x%x\n",
-		__func__, dsp2cpu_cmd->session_id,
-		dsp2cpu_cmd->session_cpu_low,
-		dsp2cpu_cmd->session_cpu_high,
-		dsp2cpu_cmd->pid);
-
 	inst = (struct msm_cvp_inst *)get_inst_from_dsp(
 			dsp2cpu_cmd->session_cpu_high,
 			dsp2cpu_cmd->session_cpu_low);
@@ -1991,14 +1984,12 @@ void __dsp_cvp_sess_stop(struct cvp_dsp_cmd_msg *cmd)
 		return;
 	}
 
-	sq = &inst->session_queue;
-	spin_lock(&sq->lock);
-	if (sq->state == QUEUE_STOP) {
-		spin_unlock(&sq->lock);
-		dprintk(CVP_WARN, "DSP double stopped session %llx\n", inst);
-		return;
-	}
-	spin_unlock(&sq->lock);
+	dprintk(CVP_DSP,
+		"%s sess id 0x%x low 0x%x high 0x%x, pid 0x%x, inst_kref_refcount 0x%x\n",
+		__func__, dsp2cpu_cmd->session_id,
+		dsp2cpu_cmd->session_cpu_low,
+		dsp2cpu_cmd->session_cpu_high,
+		dsp2cpu_cmd->pid, kref_read(&inst->kref));
 
 	rc = msm_cvp_session_stop(inst, (struct eva_kmd_arg *)NULL);
 	if (rc) {

+ 2 - 2
msm/eva/msm_cvp_ioctl.c

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/compat.h>
@@ -71,7 +71,7 @@ static int _copy_pkt_from_user(struct eva_kmd_arg *kp,
 
 	k = &kp->data.hfi_pkt;
 	u = &up->data.hfi_pkt;
-	for (i = start; i < size; i++)
+	for (i = start; i < start + size; i++)
 		if (get_user(k->pkt_data[i], &u->pkt_data[i]))
 			return -EFAULT;