From patchwork Sat Nov 16 03:17:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13877477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5EDED68BE1 for ; Sat, 16 Nov 2024 03:22:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TBsyGT5u7i5dX+fiCypn0SHv3sva6z8TnaTcjDrIi0g=; b=Gs0YU4m9F9z06COxthLd2iotqB f8AcPxk7mA3jE490q95igvt9Gf/xoJap5C/Eb40Xw0B3Wv94yFJGkb8TffQO6cpL11SJ5bTwGYxZY cQAZS/8ALrg9nFYN+3k6GcstIUAnrDow2tqMPfKnd31qC/r2qXcm2JXBLIiQnG1Piq177gdHoXW3M 86rR4wcpYVkjFIq2W2iBrVdaOUgFIzgcf4wqAcnbEZBgeERdRwCsFR02oAWFxSmkbiYIH0ZTAD5v1 1MHPVLhSlAWbz4Zumfhh/T1G+FKBj0SC2z0pUmkefPN5ys0oKMTBr6sAgG+YLBpPlBw/vSgn4qrsJ EprE5kiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tC9Np-00000004s8w-3tXE; Sat, 16 Nov 2024 03:22:01 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tC9JX-00000004r8m-0pg7; Sat, 16 Nov 2024 03:17:36 +0000 X-UUID: 4f99bb84a3c911ef82ff63e91e7eb18c-20241115 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=TBsyGT5u7i5dX+fiCypn0SHv3sva6z8TnaTcjDrIi0g=; b=iiiQCKR/uHsaoKq7arNnc9M6yp0/Gj/0USmppo3BSNV0Hak/U//HfuqYGSIK6BcWWdZpi1Mfd9/LsjrKg8Q3SMktxnULNHKG1VyNsAlNRUqktUUjeowRxuwii1GspRHbxB9lDdEADg1Nz1bM2nPBr2fnc3kERawdjcHTimUUe08=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.43,REQID:e16a7019-87cf-45d5-869a-aaf013083cbf,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:ce19b8a,CLOUDID:58182a07-6ce0-4172-9755-bd2287e50583,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0,EDM:-3,IP :nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0, LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 4f99bb84a3c911ef82ff63e91e7eb18c-20241115 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1436631183; Fri, 15 Nov 2024 20:17:29 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Sat, 16 Nov 2024 11:17:26 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sat, 16 Nov 2024 11:17:25 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v7 1/5] media: mediatek: vcodec: support manual request completion Date: Sat, 16 Nov 2024 11:17:15 +0800 Message-ID: <20241116031724.15694-2-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241116031724.15694-1-yunfei.dong@mediatek.com> References: <20241116031724.15694-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241115_191735_279710_FEF95023 X-CRM114-Status: GOOD ( 14.68 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org There is only a buffer object for some codecs, the request is marked as completed if the buffer is set to done. Framework will add a new control handler object to the request with latest control values, will get below warning if the driver calling v4l2_ctrl_request_complete to set media request complete again. Using manual request completion to fix this issue. Workqueue: core-decoder vdec_msg_queue_core_work [mtk_vcodec_dec] pstate: 80c00089 (Nzcv daIf +PAN +UAO -TCO BTYPE=--) pc : media_request_object_bind+0xa8/0x124 lr : media_request_object_bind+0x50/0x124 sp : ffffffc011393be0 x29: ffffffc011393be0 x28: 0000000000000000 x27: ffffff890c280248 x26: ffffffe21a71ab88 x25: 0000000000000000 x24: ffffff890c280280 x23: ffffff890c280280 x22: 00000000fffffff0 x21: 0000000000000000 x20: ffffff890260d280 x19: ffffff890260d2e8 x18: 0000000000001000 x17: 0000000000000400 x16: ffffffe21a4584a0 x15: 000000000053361d x14: 0000000000000018 x13: 0000000000000004 x12: ffffffa82427d000 x11: ffffffe21ac3fce0 x10: 0000000000000001 x9 : 0000000000000000 x8 : 0000000000000003 x7 : 0000000000000000 x6 : 000000000000003f x5 : 0000000000000040 x4 : ffffff89052e7b98 x3 : 0000000000000000 x2 : 0000000000000001 x1 : 0000000000000000 x0 : 0000000000000000 Call trace: media_request_object_bind+0xa8/0x124 v4l2_ctrl_request_bind+0xc4/0x168 v4l2_ctrl_request_complete+0x198/0x1f4 mtk_vdec_stateless_cap_to_disp+0x58/0x8c [mtk_vcodec_dec 245a7c1e48ff1b2451a50e1dfcb174262b6b462c] vdec_vp9_slice_core_decode+0x1c0/0x268 [mtk_vcodec_dec 245a7c1e48ff1b2451a50e1dfcb174262b6b462c] vdec_msg_queue_core_work+0x60/0x11c [mtk_vcodec_dec 245a7c1e48ff1b2451a50e1dfcb174262b6b462c] process_one_work+0x140/0x480 worker_thread+0x12c/0x2f8 kthread+0x13c/0x1d8 ret_from_fork+0x10/0x30 Fixes: 7b182b8d9c852 ("media: mediatek: vcodec: Refactor get and put capture buffer flow") Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 8 +++++--- .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c index 98838217b97d..d2146724f5de 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c @@ -887,10 +887,12 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q) if (src_buf != &ctx->empty_flush_buf.vb) { struct media_request *req = src_buf->vb2_buf.req_obj.req; - v4l2_m2m_buf_done(src_buf, - VB2_BUF_STATE_ERROR); - if (req) + + v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); + if (req) { v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl); + media_request_manual_complete(req); + } } } return; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c index afa224da0f41..1e11c08d708f 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c @@ -264,8 +264,10 @@ static void mtk_vdec_stateless_cap_to_disp(struct mtk_vcodec_dec_ctx *ctx, int e mtk_v4l2_vdec_err(ctx, "dst buffer is NULL"); } - if (src_buf_req) + if (src_buf_req) { v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); + media_request_manual_complete(src_buf_req); + } } static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_dec_ctx *ctx) @@ -308,6 +310,7 @@ static void vb2ops_vdec_buf_request_complete(struct vb2_buffer *vb) struct mtk_vcodec_dec_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); v4l2_ctrl_request_complete(vb->req_obj.req, &ctx->ctrl_hdl); + media_request_manual_complete(vb->req_obj.req); } static void mtk_vdec_worker(struct work_struct *work) @@ -375,8 +378,10 @@ static void mtk_vdec_worker(struct work_struct *work) if (!IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch) || ctx->current_codec == V4L2_PIX_FMT_VP8_FRAME) { v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx, state); - if (src_buf_req) + if (src_buf_req) { v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); + media_request_manual_complete(src_buf_req); + } } else { if (ret != -EAGAIN) { v4l2_m2m_src_buf_remove(ctx->m2m_ctx); @@ -731,9 +736,15 @@ static int fops_media_request_validate(struct media_request *mreq) return vb2_request_validate(mreq); } +static void fops_media_request_queue(struct media_request *req) +{ + media_request_mark_manual_completion(req); + v4l2_m2m_request_queue(req); +} + const struct media_device_ops mtk_vcodec_media_ops = { .req_validate = fops_media_request_validate, - .req_queue = v4l2_m2m_request_queue, + .req_queue = fops_media_request_queue, }; static void mtk_vcodec_add_formats(unsigned int fourcc, From patchwork Sat Nov 16 03:17:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13877484 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6F22D68BE1 for ; Sat, 16 Nov 2024 03:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HHbwP/c82/8ptLWsKio1TU3AIOhVLAz+mmbbLDs6714=; b=49Z5OQBqqlckfYUE44fny7o+/g KhrMt97u2zi20mQXd7gP6F38zo5z34PQkYSQXGkKXkVX0alf5A/Zji1Lp2ICzR0SRu8mnMMFcNySA h1bTvXnOICHpdY6D3U7tU6YP+0ksQbDUsTjIdx7kI2zZxeLXiMxFcjiHqT04IrWHHkgJhD6MDLPBu VNC/ngTr+n+xt5Ss9ePlLXDtUHTHaCve87zff4JOBxQyjnHJuZvT68w9s7vdgEDjgqSsCe6ixg42W SoTgVl+ipVp3kSRxgwgwR1Yw/rCQMglWYSD781hfFdHiYsa0PYPu8TmJ8oDT+ei186bDD8Tat87ed SclZdVmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tC9Pe-00000004sO3-0YSI; Sat, 16 Nov 2024 03:23:54 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tC9JY-00000004r9Q-1NZk; Sat, 16 Nov 2024 03:17:37 +0000 X-UUID: 503664d4a3c911ef82ff63e91e7eb18c-20241115 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=HHbwP/c82/8ptLWsKio1TU3AIOhVLAz+mmbbLDs6714=; b=rTm0T9LzBf43c9bxCc5czBpXBwBDLaQ/OvNbOsIovwAZWaBtcFC76QaWX7uBbol7mGAtAznl8K28vQvscV5/D5CXgSnUzHxk13aY/jZhIOJ10b7O89b+XyPcVgsbe9a2Q5qf6PDQ1lX8snZTS43k50iPshCKTCiiXXr9Kx7NtO4=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.43,REQID:7a66b00c-741b-44fc-8b10-c96ced034a14,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:ce19b8a,CLOUDID:6bedb85c-f18b-4d56-b49c-93279ee09144,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0,EDM:-3,IP :nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0, LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 503664d4a3c911ef82ff63e91e7eb18c-20241115 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 988887159; Fri, 15 Nov 2024 20:17:30 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Sat, 16 Nov 2024 11:17:27 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sat, 16 Nov 2024 11:17:26 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v7 2/5] media: mediatek: vcodec: change flush decode order when stream off Date: Sat, 16 Nov 2024 11:17:16 +0800 Message-ID: <20241116031724.15694-3-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241116031724.15694-1-yunfei.dong@mediatek.com> References: <20241116031724.15694-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241115_191736_469032_B9D5387D X-CRM114-Status: GOOD ( 15.31 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The driver status is set to flush when flush_decoder is called. The order of STREAMOFF ioctl for OUTPUT and CAPTURE are randomly. If flush_decoder is called in STREAMOFF for capture queue always, leading to get NULL dst buffer when calling STREAMOFF for output queue before capture queue. Need to flush decoder when stream off no matter output or capture queue is called firstly. Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c index d2146724f5de..2ccdffbadcda 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c @@ -882,29 +882,11 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q) mtk_v4l2_vdec_dbg(3, ctx, "[%d] (%d) state=(%x) ctx->decoded_frame_cnt=%d", ctx->id, q->type, ctx->state, ctx->decoded_frame_cnt); - if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { - while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) { - if (src_buf != &ctx->empty_flush_buf.vb) { - struct media_request *req = - src_buf->vb2_buf.req_obj.req; - - v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); - if (req) { - v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl); - media_request_manual_complete(req); - } - } - } - return; - } - - if (ctx->state >= MTK_STATE_HEADER) { - - /* Until STREAMOFF is called on the CAPTURE queue - * (acknowledging the event), the driver operates - * as if the resolution hasn't changed yet, i.e. - * VIDIOC_G_FMT< etc. return previous resolution. - * So we update picinfo here + if (ctx->state >= MTK_STATE_HEADER && ctx->state != MTK_STATE_FLUSH) { + /* + * The resolution hasn't been changed when STREAMOFF is called. + * Update the picinfo here with previous resolution if VIDIOC_G_FMT + * is called. */ ctx->picinfo = ctx->last_decoded_picinfo; @@ -919,8 +901,25 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q) ret = ctx->dev->vdec_pdata->flush_decoder(ctx); if (ret) mtk_v4l2_vdec_err(ctx, "DecodeFinal failed, ret=%d", ret); + + ctx->state = MTK_STATE_FLUSH; + } + + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + while ((src_buf = v4l2_m2m_src_buf_remove(ctx->m2m_ctx))) { + if (src_buf != &ctx->empty_flush_buf.vb) { + struct media_request *req = + src_buf->vb2_buf.req_obj.req; + + v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); + if (req) { + v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl); + media_request_manual_complete(req); + } + } + } + return; } - ctx->state = MTK_STATE_FLUSH; while ((dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx))) { vb2_set_plane_payload(&dst_buf->vb2_buf, 0, 0); From patchwork Sat Nov 16 03:17:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13877485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06231D68BE3 for ; Sat, 16 Nov 2024 03:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XAFnqKkSwcF2bp8hcz0pbKeIV30/71cmFE96nXVmuJo=; b=H+BW//A0W7c7UoaI3Y5vdSWPo2 RxhixE1eBEWcNM0r4u+b/zfhvLe0XupgvaQvrPMQu7NPGLyV0svi5j+6FgFmomk6c5bzIPi67bLMz 1D3V96LT+7ERmUZoguRbLfwKnURISDjY/HiYiJnF9cYR/VbWs8Q3Tm/hF5TXlTTZZRaTirLa9xkj/ dy+R5aHfrUukk+CRLQ+drLjUvEn2S7Nyi4gZmAUtX3t59tSCYEpDmj4ZgBGxTrslUIdkY63FkW4da cbdA+NlplYqGMEodiBy6gaPpxBFbnWslkE2X3vaCcEbzBvhOob4ahMVGww2Q9EMGVd/tI3Xb5oBEO 4BrEQZzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tC9Qa-00000004sVn-0RLD; Sat, 16 Nov 2024 03:24:52 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tC9JZ-00000004r9N-1W8v; Sat, 16 Nov 2024 03:17:38 +0000 X-UUID: 5212d382a3c911ef9048ed6ed365623b-20241115 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=XAFnqKkSwcF2bp8hcz0pbKeIV30/71cmFE96nXVmuJo=; b=i8Yrs08il9zHxGXEZAMSEWq/+BpLs8D8V8JGJxaS0VKL8hR+9kzTT/jWAmPdjgLaeX/vbrRoKPjUKmxigCO6rmv0zv137bg8H7I49VIu74WCh1eUqsFE13XUy1ULB4vWfia0mIwsWJUSGkTeeMRG+DSHWqqftoqpATkQ4ctPYNA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.43,REQID:b2b53400-7c3b-4b9b-b5b3-997f1ba6f03e,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:ce19b8a,CLOUDID:92edb85c-f18b-4d56-b49c-93279ee09144,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0,EDM:-3,IP :nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0, LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 5212d382a3c911ef9048ed6ed365623b-20241115 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1799958950; Fri, 15 Nov 2024 20:17:33 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS14N2.mediatek.inc (172.21.101.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Sat, 16 Nov 2024 11:17:28 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sat, 16 Nov 2024 11:17:27 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , "Yunfei Dong" , , , , , , Subject: [PATCH v7 3/5] media: mediatek: vcodec: remove media request checking Date: Sat, 16 Nov 2024 11:17:17 +0800 Message-ID: <20241116031724.15694-4-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241116031724.15694-1-yunfei.dong@mediatek.com> References: <20241116031724.15694-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-AS-Result: No-10--10.511500-8.000000 X-TMASE-MatchedRID: s1WpmjjDH4dmcP5F4hatbcnlbo5l7mGFBLtx+64GFanjsTquy0JRi4ma Qfsqx1XAWKuGHPyQzf64VxGFQBNJeCY0eULsNBXlHPYwOJi6PLlu95mt47DzNlfXgfL55inv3oz JRX7b4NmFKg32b+87J0iJiJhvpf+911/bObp3yCgSEYfcJF0pRX0tCKdnhB589yM15V5aWpj6C0 ePs7A07SQvY0ueKrc1jwY/IrEBx9e6DRg6XX9fFprHtTGfESU7RckC8ZNwvw0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--10.511500-8.000000 X-TMASE-Version: SMEX-14.0.0.3152-9.1.1006-23728.005 X-TM-SNTS-SMTP: 33CBB420F46111ACF58A0B40F4B635AB9D396A27EC0949270CFDDDFE1F29847D2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241115_191737_628327_1699222B X-CRM114-Status: GOOD ( 10.53 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Setting the buffer status to error if the media request of each source buffer is NULL, then schedule the work to process again in case of access NULL pointer. Signed-off-by: Yunfei Dong --- .../mediatek/vcodec/decoder/mtk_vcodec_dec.c | 6 ++---- .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 17 +++++------------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c index 2ccdffbadcda..b16572d5cf54 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c @@ -912,10 +912,8 @@ void vb2ops_vdec_stop_streaming(struct vb2_queue *q) src_buf->vb2_buf.req_obj.req; v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); - if (req) { - v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl); - media_request_manual_complete(req); - } + v4l2_ctrl_request_complete(req, &ctx->ctrl_hdl); + media_request_manual_complete(req); } } return; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c index 1e11c08d708f..dd6ee694382e 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c @@ -264,10 +264,8 @@ static void mtk_vdec_stateless_cap_to_disp(struct mtk_vcodec_dec_ctx *ctx, int e mtk_v4l2_vdec_err(ctx, "dst buffer is NULL"); } - if (src_buf_req) { - v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); - media_request_manual_complete(src_buf_req); - } + v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); + media_request_manual_complete(src_buf_req); } static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_dec_ctx *ctx) @@ -356,10 +354,7 @@ static void mtk_vdec_worker(struct work_struct *work) ctx->id, bs_src->va, &bs_src->dma_addr, bs_src->size, vb2_src); /* Apply request controls. */ src_buf_req = vb2_src->req_obj.req; - if (src_buf_req) - v4l2_ctrl_request_setup(src_buf_req, &ctx->ctrl_hdl); - else - mtk_v4l2_vdec_err(ctx, "vb2 buffer media request is NULL"); + v4l2_ctrl_request_setup(src_buf_req, &ctx->ctrl_hdl); ret = vdec_if_decode(ctx, bs_src, NULL, &res_chg); if (ret && ret != -EAGAIN) { @@ -378,10 +373,8 @@ static void mtk_vdec_worker(struct work_struct *work) if (!IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch) || ctx->current_codec == V4L2_PIX_FMT_VP8_FRAME) { v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx, state); - if (src_buf_req) { - v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); - media_request_manual_complete(src_buf_req); - } + v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); + media_request_manual_complete(src_buf_req); } else { if (ret != -EAGAIN) { v4l2_m2m_src_buf_remove(ctx->m2m_ctx); From patchwork Sat Nov 16 03:17:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13877476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C4B99D68BE3 for ; Sat, 16 Nov 2024 03:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5hR1U01URkfIV8OzJInJq3u81PchDdE/y97YVoT6EL4=; b=pmPgPlk+GonuhGOhLQ7dQavqIc rfpLzON9mzK8t0CRaBdBW3KoJSYKlYd1T47sQgqVTJIbnfisfdqzQ4ImPO6M3JrsfjqEJBLIQO2dD eji/gasT4rawsww+/0ioRBMyoOu09JdoAGquUSv9+fbkHYIhKI37DQgQMicnmc30Gd5Jg7/hSJ3Fi Mv/xWhp/iA06ZYk+TwCgN0/6rEqlsy5MmOZ5qk8a7oXnjrub/JtrNcq6zQpM2PANTKqZKq/F7lvza fnQZ/TTR2y5L34W8L27Wx/Vo5Y9rIOOTF7jRS0ahpspKViCnrpJjz31Q5ysGfWpa3cVO0rHJqQ3l5 XuR+89pA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tC9Mw-00000004s1Q-3rGP; Sat, 16 Nov 2024 03:21:06 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tC9JW-00000004r8j-3wtX; Sat, 16 Nov 2024 03:17:36 +0000 X-UUID: 515b414aa3c911ef9048ed6ed365623b-20241115 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=5hR1U01URkfIV8OzJInJq3u81PchDdE/y97YVoT6EL4=; b=WcgG5qzN1lxjnl7/YDT3tttvbvvkWqqFBNp+tgvdLbkHPBcpG2VF0scoEilusrlyVbgM0QjLn4tHod9f7If7jQ0nf03aVMwOTb4WDVor2q3rVO2wa77vWNvZ4anYaGRAXtVChCxstqRvgOFcDCtSuwVfUvZjDwNRL0coySfu6os=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.43,REQID:3953874f-fb8a-40ea-87cf-3a2a7d5963f8,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:ce19b8a,CLOUDID:66182a07-6ce0-4172-9755-bd2287e50583,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0,EDM:-3,IP :nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0, LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 515b414aa3c911ef9048ed6ed365623b-20241115 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1605091547; Fri, 15 Nov 2024 20:17:32 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS09N2.mediatek.inc (172.21.101.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 15 Nov 2024 19:17:29 -0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sat, 16 Nov 2024 11:17:28 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v7 4/5] media: mediatek: vcodec: Get SRC buffer from bitstream instead of M2M Date: Sat, 16 Nov 2024 11:17:18 +0800 Message-ID: <20241116031724.15694-5-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241116031724.15694-1-yunfei.dong@mediatek.com> References: <20241116031724.15694-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241115_191735_013627_9170ACAB X-CRM114-Status: GOOD ( 12.17 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Getting the SRC buffer from M2M will pick a different than the one used for current decode operation when the SRC buffer is removed from ready list. Signed-off-by: Yunfei Dong Reviewed-by: Chen-Yu Tsai --- .../vcodec/decoder/vdec/vdec_av1_req_lat_if.c | 14 ++++++++------ .../vcodec/decoder/vdec/vdec_vp9_req_lat_if.c | 15 +++++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c index bf21f2467a0f..68e02c18a0af 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c @@ -1062,18 +1062,20 @@ static inline void vdec_av1_slice_vsi_to_remote(struct vdec_av1_slice_vsi *vsi, static int vdec_av1_slice_setup_lat_from_src_buf(struct vdec_av1_slice_instance *instance, struct vdec_av1_slice_vsi *vsi, + struct mtk_vcodec_mem *bs, struct vdec_lat_buf *lat_buf) { - struct vb2_v4l2_buffer *src; + struct mtk_video_dec_buf *src_buf_info; struct vb2_v4l2_buffer *dst; - src = v4l2_m2m_next_src_buf(instance->ctx->m2m_ctx); - if (!src) + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); + if (!src_buf_info) return -EINVAL; - lat_buf->src_buf_req = src->vb2_buf.req_obj.req; + lat_buf->src_buf_req = src_buf_info->m2m_buf.vb.vb2_buf.req_obj.req; + dst = &lat_buf->ts_info; - v4l2_m2m_buf_copy_metadata(src, dst, true); + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, dst, true); vsi->frame.cur_ts = dst->vb2_buf.timestamp; return 0; @@ -1723,7 +1725,7 @@ static int vdec_av1_slice_setup_lat(struct vdec_av1_slice_instance *instance, struct vdec_av1_slice_vsi *vsi = &pfc->vsi; int ret; - ret = vdec_av1_slice_setup_lat_from_src_buf(instance, vsi, lat_buf); + ret = vdec_av1_slice_setup_lat_from_src_buf(instance, vsi, bs, lat_buf); if (ret) return ret; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c index eea709d93820..54a9c1d2695f 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_vp9_req_lat_if.c @@ -712,19 +712,18 @@ int vdec_vp9_slice_setup_single_from_src_to_dst(struct vdec_vp9_slice_instance * } static int vdec_vp9_slice_setup_lat_from_src_buf(struct vdec_vp9_slice_instance *instance, + struct mtk_vcodec_mem *bs, struct vdec_lat_buf *lat_buf) { - struct vb2_v4l2_buffer *src; - struct vb2_v4l2_buffer *dst; + struct mtk_video_dec_buf *src_buf_info; - src = v4l2_m2m_next_src_buf(instance->ctx->m2m_ctx); - if (!src) + src_buf_info = container_of(bs, struct mtk_video_dec_buf, bs_buffer); + if (!src_buf_info) return -EINVAL; - lat_buf->src_buf_req = src->vb2_buf.req_obj.req; + lat_buf->src_buf_req = src_buf_info->m2m_buf.vb.vb2_buf.req_obj.req; + v4l2_m2m_buf_copy_metadata(&src_buf_info->m2m_buf.vb, &lat_buf->ts_info, true); - dst = &lat_buf->ts_info; - v4l2_m2m_buf_copy_metadata(src, dst, true); return 0; } @@ -1154,7 +1153,7 @@ static int vdec_vp9_slice_setup_lat(struct vdec_vp9_slice_instance *instance, struct vdec_vp9_slice_vsi *vsi = &pfc->vsi; int ret; - ret = vdec_vp9_slice_setup_lat_from_src_buf(instance, lat_buf); + ret = vdec_vp9_slice_setup_lat_from_src_buf(instance, bs, lat_buf); if (ret) goto err; From patchwork Sat Nov 16 03:17:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunfei Dong X-Patchwork-Id: 13877478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FFE8D68BE1 for ; Sat, 16 Nov 2024 03:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=U+Wa/gu1OcvAO05IVCtNhN7nadBhoIHWhdnKEeo81ds=; b=gtjRwpKjTLiBAvu30daSExCioq OgpP3U6TmrTw0xrldQoVsb356i9CHu1g4wdQhiC9jgFs8UsTi9HhD+AoApyxqQnWHAgTIeGohMm1n pX6cgfTqel/Eo3QnkHAQYBG73fFB3ogUEMTxfUroXxvkY5dqFPvB+c+KUghH+PFdo6fw5AYvtV+B1 uwVDJ7aqXDBRiuorErdFS8NGaKXtjwPAOIv3e2p4o8290RcIs9gtyYGLEZC4uUQn4rDd9Synd4fdY kkhRl5qbQCMwY6wjPHQfFwNiaZpdS7DGNwEnyExu+W9XE2G+Dsh1VSGFNQBTqfRBpEuszdDKHimlD mRv/vPtQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tC9Ok-00000004sGt-0oaW; Sat, 16 Nov 2024 03:22:58 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tC9JY-00000004r9N-0KeN; Sat, 16 Nov 2024 03:17:37 +0000 X-UUID: 51fbb396a3c911ef9048ed6ed365623b-20241115 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=U+Wa/gu1OcvAO05IVCtNhN7nadBhoIHWhdnKEeo81ds=; b=DYnHFFyT20avBK4E/ZfZc4GZxVQ5wCjtO3OaCD/aIgLDbVYl+jqcU6A4F5QBE0+nKIcgOJCVHNfunJma9TgceEW0+8G+G+D3rn0Nwktm51V7fvgQuDs0PparT6ouaqS30wlxiQ55qPvtPnSAf4arBepqJ5EDyFOMo2XIYj65J5k=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.43,REQID:f583d017-73c8-4eb0-a637-03a992065027,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:ce19b8a,CLOUDID:7aedb85c-f18b-4d56-b49c-93279ee09144,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0,EDM:-3,IP :nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0, LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 51fbb396a3c911ef9048ed6ed365623b-20241115 Received: from mtkmbs09n2.mediatek.inc [(172.21.101.94)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1159758329; Fri, 15 Nov 2024 20:17:33 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Sat, 16 Nov 2024 11:17:30 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Sat, 16 Nov 2024 11:17:29 +0800 From: Yunfei Dong To: =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_Prado?= , Sebastian Fricke , Nicolas Dufresne , Hans Verkuil , AngeloGioacchino Del Regno , Benjamin Gaignard , Nathan Hebert , Daniel Almeida CC: Hsin-Yi Wang , Fritz Koenig , Daniel Vetter , Steve Cho , Yunfei Dong , , , , , , Subject: [PATCH v7 5/5] media: mediatek: vcodec: store current vb2 buffer to decode again Date: Sat, 16 Nov 2024 11:17:19 +0800 Message-ID: <20241116031724.15694-6-yunfei.dong@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241116031724.15694-1-yunfei.dong@mediatek.com> References: <20241116031724.15694-1-yunfei.dong@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241115_191736_196767_732E71CF X-CRM114-Status: GOOD ( 14.57 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org All the src vb2 buffer are removed from ready list when STREAMOFF capture queue, may remove a non exist vb2 buffer if lat is working currently. The driver also need to use current vb2 buffer to decode again to wait for enough resource when lat decode error. Signed-off-by: Yunfei Dong --- .../vcodec/decoder/mtk_vcodec_dec_drv.h | 2 ++ .../vcodec/decoder/mtk_vcodec_dec_stateless.c | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h index ac568ed14fa2..e70e97e401ba 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_drv.h @@ -155,6 +155,7 @@ struct mtk_vcodec_dec_pdata { * @last_decoded_picinfo: pic information get from latest decode * @empty_flush_buf: a fake size-0 capture buffer that indicates flush. Used * for stateful decoder. + * @cur_src_buffer: current vb2 buffer for the latest decode. * @is_flushing: set to true if flushing is in progress. * * @current_codec: current set input codec, in V4L2 pixel format @@ -201,6 +202,7 @@ struct mtk_vcodec_dec_ctx { struct work_struct decode_work; struct vdec_pic_info last_decoded_picinfo; struct v4l2_m2m_buffer empty_flush_buf; + struct vb2_v4l2_buffer *cur_src_buffer; bool is_flushing; u32 current_codec; diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c index dd6ee694382e..ad3c585e339d 100644 --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec_stateless.c @@ -316,7 +316,7 @@ static void mtk_vdec_worker(struct work_struct *work) struct mtk_vcodec_dec_ctx *ctx = container_of(work, struct mtk_vcodec_dec_ctx, decode_work); struct mtk_vcodec_dec_dev *dev = ctx->dev; - struct vb2_v4l2_buffer *vb2_v4l2_src; + struct vb2_v4l2_buffer *vb2_v4l2_src = ctx->cur_src_buffer; struct vb2_buffer *vb2_src; struct mtk_vcodec_mem *bs_src; struct mtk_video_dec_buf *dec_buf_src; @@ -325,7 +325,7 @@ static void mtk_vdec_worker(struct work_struct *work) bool res_chg = false; int ret; - vb2_v4l2_src = v4l2_m2m_next_src_buf(ctx->m2m_ctx); + vb2_v4l2_src = vb2_v4l2_src ? vb2_v4l2_src : v4l2_m2m_src_buf_remove(ctx->m2m_ctx); if (!vb2_v4l2_src) { v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); mtk_v4l2_vdec_dbg(1, ctx, "[%d] no available source buffer", ctx->id); @@ -375,13 +375,26 @@ static void mtk_vdec_worker(struct work_struct *work) v4l2_m2m_buf_done_and_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx, state); v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); media_request_manual_complete(src_buf_req); - } else { - if (ret != -EAGAIN) { - v4l2_m2m_src_buf_remove(ctx->m2m_ctx); - v4l2_m2m_buf_done(vb2_v4l2_src, state); - } - v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); + + return; } + + /* + * If each codec return -EAGAIN to decode again, need to backup current source + * buffer, then the driver will get this buffer next time. + * + * If each codec decode error, must to set buffer done with error status for + * this buffer have been removed from ready list. + */ + ctx->cur_src_buffer = (ret != -EAGAIN) ? NULL : vb2_v4l2_src; + if (ret && ret != -EAGAIN) { + v4l2_ctrl_request_complete(src_buf_req, &ctx->ctrl_hdl); + media_request_manual_complete(src_buf_req); + } + + if (ret != -EAGAIN) + v4l2_m2m_buf_done(vb2_v4l2_src, state); + v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); } static void vb2ops_vdec_stateless_buf_queue(struct vb2_buffer *vb)