Commit 34318b80 authored by Sergey Senozhatsky's avatar Sergey Senozhatsky Committed by Mauro Carvalho Chehab
Browse files

media: venus: provide ctx queue lock for ioctl synchronization



Video device has to provide a lock so that __video_do_ioctl()
can serialize IOCTL calls. Introduce a dedicated venus_inst
mutex for the purpose of vb2 operations synchronization.

Signed-off-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: default avatarVikash Garodia <quic_vgarodia@quicinc.com>
Reviewed-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: default avatarStanimir Varbanov <stanimir.k.varbanov@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 08998cf3
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -411,6 +411,7 @@ enum venus_inst_modes {
 * @sequence_out:	a sequence counter for output queue
 * @sequence_out:	a sequence counter for output queue
 * @m2m_dev:	a reference to m2m device structure
 * @m2m_dev:	a reference to m2m device structure
 * @m2m_ctx:	a reference to m2m context structure
 * @m2m_ctx:	a reference to m2m context structure
 * @ctx_q_lock:	a lock to serialize video device ioctl calls
 * @state:	current state of the instance
 * @state:	current state of the instance
 * @done:	a completion for sync HFI operation
 * @done:	a completion for sync HFI operation
 * @error:	an error returned during last HFI sync operation
 * @error:	an error returned during last HFI sync operation
@@ -482,6 +483,7 @@ struct venus_inst {
	u32 sequence_out;
	u32 sequence_out;
	struct v4l2_m2m_dev *m2m_dev;
	struct v4l2_m2m_dev *m2m_dev;
	struct v4l2_m2m_ctx *m2m_ctx;
	struct v4l2_m2m_ctx *m2m_ctx;
	struct mutex ctx_q_lock;
	unsigned int state;
	unsigned int state;
	struct completion done;
	struct completion done;
	unsigned int error;
	unsigned int error;
+4 −0
Original line number Original line Diff line number Diff line
@@ -1643,6 +1643,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
	src_vq->allow_zero_bytesused = 1;
	src_vq->allow_zero_bytesused = 1;
	src_vq->min_buffers_needed = 0;
	src_vq->min_buffers_needed = 0;
	src_vq->dev = inst->core->dev;
	src_vq->dev = inst->core->dev;
	src_vq->lock = &inst->ctx_q_lock;
	ret = vb2_queue_init(src_vq);
	ret = vb2_queue_init(src_vq);
	if (ret)
	if (ret)
		return ret;
		return ret;
@@ -1657,6 +1658,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
	dst_vq->allow_zero_bytesused = 1;
	dst_vq->allow_zero_bytesused = 1;
	dst_vq->min_buffers_needed = 0;
	dst_vq->min_buffers_needed = 0;
	dst_vq->dev = inst->core->dev;
	dst_vq->dev = inst->core->dev;
	dst_vq->lock = &inst->ctx_q_lock;
	return vb2_queue_init(dst_vq);
	return vb2_queue_init(dst_vq);
}
}


@@ -1675,6 +1677,7 @@ static int vdec_open(struct file *file)
	INIT_LIST_HEAD(&inst->internalbufs);
	INIT_LIST_HEAD(&inst->internalbufs);
	INIT_LIST_HEAD(&inst->list);
	INIT_LIST_HEAD(&inst->list);
	mutex_init(&inst->lock);
	mutex_init(&inst->lock);
	mutex_init(&inst->ctx_q_lock);


	inst->core = core;
	inst->core = core;
	inst->session_type = VIDC_SESSION_TYPE_DEC;
	inst->session_type = VIDC_SESSION_TYPE_DEC;
@@ -1750,6 +1753,7 @@ static int vdec_close(struct file *file)
	ida_destroy(&inst->dpb_ids);
	ida_destroy(&inst->dpb_ids);
	hfi_session_destroy(inst);
	hfi_session_destroy(inst);
	mutex_destroy(&inst->lock);
	mutex_destroy(&inst->lock);
	mutex_destroy(&inst->ctx_q_lock);
	v4l2_fh_del(&inst->fh);
	v4l2_fh_del(&inst->fh);
	v4l2_fh_exit(&inst->fh);
	v4l2_fh_exit(&inst->fh);


+4 −0
Original line number Original line Diff line number Diff line
@@ -1400,6 +1400,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
	src_vq->allow_zero_bytesused = 1;
	src_vq->allow_zero_bytesused = 1;
	src_vq->min_buffers_needed = 1;
	src_vq->min_buffers_needed = 1;
	src_vq->dev = inst->core->dev;
	src_vq->dev = inst->core->dev;
	src_vq->lock = &inst->ctx_q_lock;
	if (inst->core->res->hfi_version == HFI_VERSION_1XX)
	if (inst->core->res->hfi_version == HFI_VERSION_1XX)
		src_vq->bidirectional = 1;
		src_vq->bidirectional = 1;
	ret = vb2_queue_init(src_vq);
	ret = vb2_queue_init(src_vq);
@@ -1416,6 +1417,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
	dst_vq->allow_zero_bytesused = 1;
	dst_vq->allow_zero_bytesused = 1;
	dst_vq->min_buffers_needed = 1;
	dst_vq->min_buffers_needed = 1;
	dst_vq->dev = inst->core->dev;
	dst_vq->dev = inst->core->dev;
	dst_vq->lock = &inst->ctx_q_lock;
	return vb2_queue_init(dst_vq);
	return vb2_queue_init(dst_vq);
}
}


@@ -1448,6 +1450,7 @@ static int venc_open(struct file *file)
	INIT_LIST_HEAD(&inst->internalbufs);
	INIT_LIST_HEAD(&inst->internalbufs);
	INIT_LIST_HEAD(&inst->list);
	INIT_LIST_HEAD(&inst->list);
	mutex_init(&inst->lock);
	mutex_init(&inst->lock);
	mutex_init(&inst->ctx_q_lock);


	inst->core = core;
	inst->core = core;
	inst->session_type = VIDC_SESSION_TYPE_ENC;
	inst->session_type = VIDC_SESSION_TYPE_ENC;
@@ -1517,6 +1520,7 @@ static int venc_close(struct file *file)
	venc_ctrl_deinit(inst);
	venc_ctrl_deinit(inst);
	hfi_session_destroy(inst);
	hfi_session_destroy(inst);
	mutex_destroy(&inst->lock);
	mutex_destroy(&inst->lock);
	mutex_destroy(&inst->ctx_q_lock);
	v4l2_fh_del(&inst->fh);
	v4l2_fh_del(&inst->fh);
	v4l2_fh_exit(&inst->fh);
	v4l2_fh_exit(&inst->fh);