Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0bccf66 authored by George Shen's avatar George Shen
Browse files

msm: cvp: Fix a problem when closing CVP device



De-reference cvp instance when it's no longer used.

Change-Id: I04203712f70019016dc1317ab5f57519e79e58f4
Signed-off-by: default avatarGeorge Shen <sqiao@codeaurora.org>
parent 364475ab
Loading
Loading
Loading
Loading
+14 −3
Original line number Original line Diff line number Diff line
@@ -666,9 +666,20 @@ int cvp_create_pkt_cmd_session_release_buffers(


	pkt->packet_type = HFI_CMD_SESSION_CVP_RELEASE_BUFFERS;
	pkt->packet_type = HFI_CMD_SESSION_CVP_RELEASE_BUFFERS;
	pkt->session_id = hash32_ptr(session);
	pkt->session_id = hash32_ptr(session);
	pkt->buffer_type = 0xdeadbeef;
	pkt->num_buffers = buffer_info->num_buffers;
	pkt->num_buffers = 0;

	pkt->size = sizeof(struct hfi_cmd_session_cvp_release_buffers_packet);
	if (buffer_info->buffer_type == HAL_BUFFER_OUTPUT ||
		buffer_info->buffer_type == HAL_BUFFER_OUTPUT2) {
		dprintk(CVP_ERR, "%s: deprecated buffer_type\n", __func__);
		return -EINVAL;
	}

	pkt->size = sizeof(struct hfi_cmd_session_set_buffers_packet) +
		((buffer_info->num_buffers - 1) * sizeof(u32));

	pkt->buffer_type = get_hfi_buffer(buffer_info->buffer_type);
	if (!pkt->buffer_type)
		return -EINVAL;


	return 0;
	return 0;
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -597,7 +597,7 @@ int msm_cvp_handle_syscall(struct msm_cvp_inst *inst, struct msm_cvp_arg *arg)
		dprintk(CVP_ERR, "%s: invalid args\n", __func__);
		dprintk(CVP_ERR, "%s: invalid args\n", __func__);
		return -EINVAL;
		return -EINVAL;
	}
	}
	dprintk(CVP_DBG, "%s:: arg->type = %d", __func__, arg->type);
	dprintk(CVP_DBG, "%s:: arg->type = %x", __func__, arg->type);


	switch (arg->type) {
	switch (arg->type) {
	case MSM_CVP_GET_SESSION_INFO:
	case MSM_CVP_GET_SESSION_INFO:
+7 −2
Original line number Original line Diff line number Diff line
@@ -614,6 +614,7 @@ static void cvp_handle_session_cmd_done(enum hal_command_response cmd,
	} else
	} else
		dprintk(CVP_ERR,
		dprintk(CVP_ERR,
			"%s: Invalid inst cmd response: %d\n", __func__, cmd);
			"%s: Invalid inst cmd response: %d\n", __func__, cmd);
	cvp_put_inst(inst);
}
}


static void handle_session_set_buf_done(enum hal_command_response cmd,
static void handle_session_set_buf_done(enum hal_command_response cmd,
@@ -644,6 +645,7 @@ static void handle_session_set_buf_done(enum hal_command_response cmd,
		complete(&inst->completions[SESSION_MSG_INDEX(cmd)]);
		complete(&inst->completions[SESSION_MSG_INDEX(cmd)]);
	else
	else
		dprintk(CVP_ERR, "set_buf_done: invalid cmd: %d\n", cmd);
		dprintk(CVP_ERR, "set_buf_done: invalid cmd: %d\n", cmd);
	cvp_put_inst(inst);


}
}


@@ -1137,6 +1139,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
				HAL_BUFFER_OUTPUT);
				HAL_BUFFER_OUTPUT);
		if (!bufreq) {
		if (!bufreq) {
			mutex_unlock(&inst->lock);
			mutex_unlock(&inst->lock);
			cvp_put_inst(inst);
			return;
			return;
		}
		}


@@ -1148,6 +1151,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
				HAL_BUFFER_OUTPUT2);
				HAL_BUFFER_OUTPUT2);
		if (!bufreq) {
		if (!bufreq) {
			mutex_unlock(&inst->lock);
			mutex_unlock(&inst->lock);
			cvp_put_inst(inst);
			return;
			return;
		}
		}


@@ -1162,6 +1166,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
				HAL_BUFFER_OUTPUT);
				HAL_BUFFER_OUTPUT);
		if (!bufreq) {
		if (!bufreq) {
			mutex_unlock(&inst->lock);
			mutex_unlock(&inst->lock);
			cvp_put_inst(inst);
			return;
			return;
		}
		}


@@ -1485,7 +1490,7 @@ static void handle_sys_error(enum hal_command_response cmd, void *data)
	}
	}


	dprintk(CVP_WARN, "SYS_ERROR received for core %pK\n", core);
	dprintk(CVP_WARN, "SYS_ERROR received for core %pK\n", core);
	msm_cvp_noc_error_info(core);
	/* msm_cvp_noc_error_info(core) is disabled as of now */
	call_hfi_op(hdev, flush_debug_queue, hdev->hfi_device_data);
	call_hfi_op(hdev, flush_debug_queue, hdev->hfi_device_data);
	list_for_each_entry(inst, &core->instances, list) {
	list_for_each_entry(inst, &core->instances, list) {
		dprintk(CVP_WARN,
		dprintk(CVP_WARN,
@@ -1975,7 +1980,7 @@ static int msm_comm_init_core(struct msm_cvp_inst *inst)
	hdev = core->device;
	hdev = core->device;
	mutex_lock(&core->lock);
	mutex_lock(&core->lock);
	if (core->state >= CVP_CORE_INIT) {
	if (core->state >= CVP_CORE_INIT) {
		dprintk(CVP_INFO, "Video core: %d is already in state: %d\n",
		dprintk(CVP_DBG, "CVP core: %d is already in state: %d\n",
				core->id, core->state);
				core->id, core->state);
		goto core_already_inited;
		goto core_already_inited;
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -1262,7 +1262,7 @@ int msm_cvp_destroy(struct msm_cvp_inst *inst)


	msm_cvp_debugfs_deinit_inst(inst);
	msm_cvp_debugfs_deinit_inst(inst);


	pr_info(CVP_DBG_TAG "Closed video instance: %pK\n",
	pr_info(CVP_DBG_TAG "Closed cvp instance: %pK\n",
			"info", inst);
			"info", inst);
	kfree(inst);
	kfree(inst);
	return 0;
	return 0;
+2 −1
Original line number Original line Diff line number Diff line
@@ -63,12 +63,13 @@ static int msm_cvp_v4l2_open(struct file *filp)


static int msm_cvp_v4l2_close(struct file *filp)
static int msm_cvp_v4l2_close(struct file *filp)
{
{
	int rc = 0;
	struct msm_cvp_inst *cvp_inst;
	struct msm_cvp_inst *cvp_inst;


	trace_msm_v4l2_cvp_close_start("msm v4l2_close start");
	trace_msm_v4l2_cvp_close_start("msm v4l2_close start");
	cvp_inst = get_cvp_inst(filp, NULL);
	cvp_inst = get_cvp_inst(filp, NULL);


	//rc = msm_cvp_close(cvp_inst);
	rc = msm_cvp_close(cvp_inst);
	filp->private_data = NULL;
	filp->private_data = NULL;
	trace_msm_v4l2_cvp_close_end("msm v4l2_close end");
	trace_msm_v4l2_cvp_close_end("msm v4l2_close end");
	return 0;
	return 0;