* [PATCHv4] media: venus: provide ctx queue lock for ioctl synchronization
@ 2023-05-26 6:29 Sergey Senozhatsky
2023-05-26 7:28 ` Vikash Garodia
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2023-05-26 6:29 UTC (permalink / raw)
To: Stanimir Varbanov, Vikash Garodia, Andy Gross, Bjorn Andersson,
Konrad Dybcio
Cc: Hans Verkuil, linux-media, linux-arm-msm, Sergey Senozhatsky
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: Sergey Senozhatsky <senozhatsky@chromium.org>
---
drivers/media/platform/qcom/venus/core.h | 2 ++
drivers/media/platform/qcom/venus/vdec.c | 4 ++++
drivers/media/platform/qcom/venus/venc.c | 4 ++++
3 files changed, 10 insertions(+)
diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
index 4f81669986ba..06ed7b0d3262 100644
--- a/drivers/media/platform/qcom/venus/core.h
+++ b/drivers/media/platform/qcom/venus/core.h
@@ -389,6 +389,7 @@ enum venus_inst_modes {
* @sequence_out: a sequence counter for output queue
* @m2m_dev: a reference to m2m device 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
* @done: a completion for sync HFI operation
* @error: an error returned during last HFI sync operation
@@ -460,6 +461,7 @@ struct venus_inst {
u32 sequence_out;
struct v4l2_m2m_dev *m2m_dev;
struct v4l2_m2m_ctx *m2m_ctx;
+ struct mutex ctx_q_lock;
unsigned int state;
struct completion done;
unsigned int error;
diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
index 51a53bf82bd3..be3f8c4cda08 100644
--- a/drivers/media/platform/qcom/venus/vdec.c
+++ b/drivers/media/platform/qcom/venus/vdec.c
@@ -1609,6 +1609,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->allow_zero_bytesused = 1;
src_vq->min_buffers_needed = 0;
src_vq->dev = inst->core->dev;
+ src_vq->lock = &inst->ctx_q_lock;
ret = vb2_queue_init(src_vq);
if (ret)
return ret;
@@ -1623,6 +1624,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->allow_zero_bytesused = 1;
dst_vq->min_buffers_needed = 0;
dst_vq->dev = inst->core->dev;
+ dst_vq->lock = &inst->ctx_q_lock;
return vb2_queue_init(dst_vq);
}
@@ -1641,6 +1643,7 @@ static int vdec_open(struct file *file)
INIT_LIST_HEAD(&inst->internalbufs);
INIT_LIST_HEAD(&inst->list);
mutex_init(&inst->lock);
+ mutex_init(&inst->ctx_q_lock);
inst->core = core;
inst->session_type = VIDC_SESSION_TYPE_DEC;
@@ -1716,6 +1719,7 @@ static int vdec_close(struct file *file)
ida_destroy(&inst->dpb_ids);
hfi_session_destroy(inst);
mutex_destroy(&inst->lock);
+ mutex_destroy(&inst->ctx_q_lock);
v4l2_fh_del(&inst->fh);
v4l2_fh_exit(&inst->fh);
diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
index 4666f42feea3..8b86873f2458 100644
--- a/drivers/media/platform/qcom/venus/venc.c
+++ b/drivers/media/platform/qcom/venus/venc.c
@@ -1395,6 +1395,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
src_vq->allow_zero_bytesused = 1;
src_vq->min_buffers_needed = 1;
src_vq->dev = inst->core->dev;
+ src_vq->lock = &inst->ctx_q_lock;
if (inst->core->res->hfi_version == HFI_VERSION_1XX)
src_vq->bidirectional = 1;
ret = vb2_queue_init(src_vq);
@@ -1411,6 +1412,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
dst_vq->allow_zero_bytesused = 1;
dst_vq->min_buffers_needed = 1;
dst_vq->dev = inst->core->dev;
+ dst_vq->lock = &inst->ctx_q_lock;
return vb2_queue_init(dst_vq);
}
@@ -1443,6 +1445,7 @@ static int venc_open(struct file *file)
INIT_LIST_HEAD(&inst->internalbufs);
INIT_LIST_HEAD(&inst->list);
mutex_init(&inst->lock);
+ mutex_init(&inst->ctx_q_lock);
inst->core = core;
inst->session_type = VIDC_SESSION_TYPE_ENC;
@@ -1512,6 +1515,7 @@ static int venc_close(struct file *file)
venc_ctrl_deinit(inst);
hfi_session_destroy(inst);
mutex_destroy(&inst->lock);
+ mutex_destroy(&inst->ctx_q_lock);
v4l2_fh_del(&inst->fh);
v4l2_fh_exit(&inst->fh);
--
2.41.0.rc0.172.g3f132b7071-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCHv4] media: venus: provide ctx queue lock for ioctl synchronization
2023-05-26 6:29 [PATCHv4] media: venus: provide ctx queue lock for ioctl synchronization Sergey Senozhatsky
@ 2023-05-26 7:28 ` Vikash Garodia
2023-05-26 15:39 ` Bryan O'Donoghue
2023-05-26 15:40 ` Bryan O'Donoghue
2 siblings, 0 replies; 4+ messages in thread
From: Vikash Garodia @ 2023-05-26 7:28 UTC (permalink / raw)
To: Sergey Senozhatsky, Stanimir Varbanov, Andy Gross,
Bjorn Andersson, Konrad Dybcio
Cc: Hans Verkuil, linux-media, linux-arm-msm
On 5/26/2023 11:59 AM, Sergey Senozhatsky wrote:
> 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: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>
> ---
> drivers/media/platform/qcom/venus/core.h | 2 ++
> drivers/media/platform/qcom/venus/vdec.c | 4 ++++
> drivers/media/platform/qcom/venus/venc.c | 4 ++++
> 3 files changed, 10 insertions(+)
>
> diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h
> index 4f81669986ba..06ed7b0d3262 100644
> --- a/drivers/media/platform/qcom/venus/core.h
> +++ b/drivers/media/platform/qcom/venus/core.h
> @@ -389,6 +389,7 @@ enum venus_inst_modes {
> * @sequence_out: a sequence counter for output queue
> * @m2m_dev: a reference to m2m device 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
> * @done: a completion for sync HFI operation
> * @error: an error returned during last HFI sync operation
> @@ -460,6 +461,7 @@ struct venus_inst {
> u32 sequence_out;
> struct v4l2_m2m_dev *m2m_dev;
> struct v4l2_m2m_ctx *m2m_ctx;
> + struct mutex ctx_q_lock;
> unsigned int state;
> struct completion done;
> unsigned int error;
> diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c
> index 51a53bf82bd3..be3f8c4cda08 100644
> --- a/drivers/media/platform/qcom/venus/vdec.c
> +++ b/drivers/media/platform/qcom/venus/vdec.c
> @@ -1609,6 +1609,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->allow_zero_bytesused = 1;
> src_vq->min_buffers_needed = 0;
> src_vq->dev = inst->core->dev;
> + src_vq->lock = &inst->ctx_q_lock;
> ret = vb2_queue_init(src_vq);
> if (ret)
> return ret;
> @@ -1623,6 +1624,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->allow_zero_bytesused = 1;
> dst_vq->min_buffers_needed = 0;
> dst_vq->dev = inst->core->dev;
> + dst_vq->lock = &inst->ctx_q_lock;
> return vb2_queue_init(dst_vq);
> }
>
> @@ -1641,6 +1643,7 @@ static int vdec_open(struct file *file)
> INIT_LIST_HEAD(&inst->internalbufs);
> INIT_LIST_HEAD(&inst->list);
> mutex_init(&inst->lock);
> + mutex_init(&inst->ctx_q_lock);
>
> inst->core = core;
> inst->session_type = VIDC_SESSION_TYPE_DEC;
> @@ -1716,6 +1719,7 @@ static int vdec_close(struct file *file)
> ida_destroy(&inst->dpb_ids);
> hfi_session_destroy(inst);
> mutex_destroy(&inst->lock);
> + mutex_destroy(&inst->ctx_q_lock);
> v4l2_fh_del(&inst->fh);
> v4l2_fh_exit(&inst->fh);
>
> diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c
> index 4666f42feea3..8b86873f2458 100644
> --- a/drivers/media/platform/qcom/venus/venc.c
> +++ b/drivers/media/platform/qcom/venus/venc.c
> @@ -1395,6 +1395,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
> src_vq->allow_zero_bytesused = 1;
> src_vq->min_buffers_needed = 1;
> src_vq->dev = inst->core->dev;
> + src_vq->lock = &inst->ctx_q_lock;
> if (inst->core->res->hfi_version == HFI_VERSION_1XX)
> src_vq->bidirectional = 1;
> ret = vb2_queue_init(src_vq);
> @@ -1411,6 +1412,7 @@ static int m2m_queue_init(void *priv, struct vb2_queue *src_vq,
> dst_vq->allow_zero_bytesused = 1;
> dst_vq->min_buffers_needed = 1;
> dst_vq->dev = inst->core->dev;
> + dst_vq->lock = &inst->ctx_q_lock;
> return vb2_queue_init(dst_vq);
> }
>
> @@ -1443,6 +1445,7 @@ static int venc_open(struct file *file)
> INIT_LIST_HEAD(&inst->internalbufs);
> INIT_LIST_HEAD(&inst->list);
> mutex_init(&inst->lock);
> + mutex_init(&inst->ctx_q_lock);
>
> inst->core = core;
> inst->session_type = VIDC_SESSION_TYPE_ENC;
> @@ -1512,6 +1515,7 @@ static int venc_close(struct file *file)
> venc_ctrl_deinit(inst);
> hfi_session_destroy(inst);
> mutex_destroy(&inst->lock);
> + mutex_destroy(&inst->ctx_q_lock);
> v4l2_fh_del(&inst->fh);
> v4l2_fh_exit(&inst->fh);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCHv4] media: venus: provide ctx queue lock for ioctl synchronization
2023-05-26 6:29 [PATCHv4] media: venus: provide ctx queue lock for ioctl synchronization Sergey Senozhatsky
2023-05-26 7:28 ` Vikash Garodia
@ 2023-05-26 15:39 ` Bryan O'Donoghue
2023-05-26 15:40 ` Bryan O'Donoghue
2 siblings, 0 replies; 4+ messages in thread
From: Bryan O'Donoghue @ 2023-05-26 15:39 UTC (permalink / raw)
To: Sergey Senozhatsky, Stanimir Varbanov, Vikash Garodia,
Andy Gross, Bjorn Andersson, Konrad Dybcio
Cc: Hans Verkuil, linux-media, linux-arm-msm
On 26/05/2023 07:29, Sergey Senozhatsky wrote:
> 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: Sergey Senozhatsky <senozhatsky@chromium.org>
LGTM
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCHv4] media: venus: provide ctx queue lock for ioctl synchronization
2023-05-26 6:29 [PATCHv4] media: venus: provide ctx queue lock for ioctl synchronization Sergey Senozhatsky
2023-05-26 7:28 ` Vikash Garodia
2023-05-26 15:39 ` Bryan O'Donoghue
@ 2023-05-26 15:40 ` Bryan O'Donoghue
2 siblings, 0 replies; 4+ messages in thread
From: Bryan O'Donoghue @ 2023-05-26 15:40 UTC (permalink / raw)
To: Sergey Senozhatsky, Stanimir Varbanov, Vikash Garodia,
Andy Gross, Bjorn Andersson, Konrad Dybcio
Cc: Hans Verkuil, linux-media, linux-arm-msm
On 26/05/2023 07:29, Sergey Senozhatsky wrote:
> 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: Sergey Senozhatsky <senozhatsky@chromium.org>
Pardon sent my RB from the wrong a/c
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-05-26 15:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-26 6:29 [PATCHv4] media: venus: provide ctx queue lock for ioctl synchronization Sergey Senozhatsky
2023-05-26 7:28 ` Vikash Garodia
2023-05-26 15:39 ` Bryan O'Donoghue
2023-05-26 15:40 ` Bryan O'Donoghue
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.