Skip to content

Commit

Permalink
media: mediatek: vcodec: add core decode done event
Browse files Browse the repository at this point in the history
[ Upstream commit d227af8 ]

Need to make sure core decode done before current instance is free.

Fixes: 365e4ba ("media: mtk-vcodec: Add work queue for core hardware decode")
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
yunfei-mtk authored and gregkh committed May 11, 2023
1 parent 4a62d8f commit e422f76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/media/platform/mediatek/vcodec/vdec_msg_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue)
spin_unlock(&core_ctx->ready_lock);

timeout_jiff = msecs_to_jiffies(1000 * (NUM_BUFFER_COUNT + 2));
ret = wait_event_timeout(msg_queue->lat_ctx.ready_to_use,
ret = wait_event_timeout(msg_queue->ctx->msg_queue.core_dec_done,
msg_queue->lat_ctx.ready_num == NUM_BUFFER_COUNT,
timeout_jiff);
if (ret) {
Expand Down Expand Up @@ -257,6 +257,7 @@ static void vdec_msg_queue_core_work(struct work_struct *work)
mtk_vcodec_dec_disable_hardware(ctx, MTK_VDEC_CORE);
vdec_msg_queue_qbuf(&ctx->msg_queue.lat_ctx, lat_buf);

wake_up_all(&ctx->msg_queue.core_dec_done);
if (atomic_read(&lat_buf->ctx->msg_queue.core_list_cnt)) {
mtk_v4l2_debug(3, "re-schedule to decode for core: %d",
dev->msg_queue_core_ctx.ready_num);
Expand All @@ -281,6 +282,7 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,

atomic_set(&msg_queue->lat_list_cnt, 0);
atomic_set(&msg_queue->core_list_cnt, 0);
init_waitqueue_head(&msg_queue->core_dec_done);

msg_queue->wdma_addr.size =
vde_msg_queue_get_trans_size(ctx->picinfo.buf_w,
Expand Down
2 changes: 2 additions & 0 deletions drivers/media/platform/mediatek/vcodec/vdec_msg_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ struct vdec_lat_buf {
*
* @lat_list_cnt: used to record each instance lat list count
* @core_list_cnt: used to record each instance core list count
* @core_dec_done: core work queue decode done event
*/
struct vdec_msg_queue {
struct vdec_lat_buf lat_buf[NUM_BUFFER_COUNT];
Expand All @@ -90,6 +91,7 @@ struct vdec_msg_queue {

atomic_t lat_list_cnt;
atomic_t core_list_cnt;
wait_queue_head_t core_dec_done;
};

/**
Expand Down

0 comments on commit e422f76

Please sign in to comment.