From patchwork Wed Sep 7 10:32:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Smitha T Murthy X-Patchwork-Id: 12968993 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 D2F42C38145 for ; Wed, 7 Sep 2022 13:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=2Yq9i/Ps5adFJqbEci5fNQWaBfTRcGQxWUQACGS3Dk0=; b=3pp24yISHM4vO/ BjFGRSvu624N2AhjS+5Tk6Momm6I/ncE2jYoRiJLfZnpdvIQNQP2PdGiLj546GopJIX1/TPq+XH95 LNJfAJUsSK3/JsxvFQKWyeNxsVZxkIY7CaW0HCkB2/TAZLGKxVVSwC0Y4AY1HNp+cDI7tW3bRtimV LhukAJMhGhzdHEZTyfMgcVGzXoOhotO7B0amMTfdoGC3qCWI0bJ9v0haKnRjfwdtPhgB+bzFhN879 a4dnO9yiDwrrgFoK7Hj7kzXpeb9YOm0igw4pXQD7ZNaTHOxg4YHV8fiqwkDlN4xq1Hdf7xNR34+Y6 gcqWxey5AE/TwR0S3aZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVvKh-006Zz2-KM; Wed, 07 Sep 2022 13:43:11 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVvKK-006ZpC-VI for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2022 13:42:52 +0000 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20220907134240epoutp025f216f1b05f0a2b13b0e8a8ddd8d3f04~Sl9azbSx-1739917399epoutp020 for ; Wed, 7 Sep 2022 13:42:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20220907134240epoutp025f216f1b05f0a2b13b0e8a8ddd8d3f04~Sl9azbSx-1739917399epoutp020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662558160; bh=gSif8NMM6wosPp4czbq6ghp4X8l/PNF06f6zjCg20J4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RUoIN0gYAYDxiz5CleIJWbt4VTmlZ3C52vCoX/1tMQwElBD0mj8NTYnItpsdkCGFi Rb+Dvbn6VV6Q83MDYaEibf2O+0Z7rdz5kgmCQmr3SCv/T/nJvm9qA9S+b4KTsAIKmQ QMwnbvdMUn9Mk8DTOMv8SQbshIH7r9D0mU4Px4VQ= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220907134240epcas5p28b2f86dd0e4f0da92c4e47ffd09a1eba~Sl9aPlwok0998509985epcas5p2c; Wed, 7 Sep 2022 13:42:40 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.175]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4MN3NF5gpLz4x9Pp; Wed, 7 Sep 2022 13:42:37 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 5E.69.53458.DCF98136; Wed, 7 Sep 2022 22:42:37 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220907101827epcas5p2afa088ce5a591040094d2b49b928f3c2~SjLHHpNUm2030720307epcas5p20; Wed, 7 Sep 2022 10:18:27 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220907101827epsmtrp1e3eff56e01088162beff031f9e566d64~SjLHGv0t40915809158epsmtrp1s; Wed, 7 Sep 2022 10:18:27 +0000 (GMT) X-AuditID: b6c32a4a-a5bff7000000d0d2-e3-63189fcd52b7 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 9C.B8.18644.3FF68136; Wed, 7 Sep 2022 19:18:27 +0900 (KST) Received: from Jaguar.sa.corp.samsungelectronics.net (unknown [107.109.115.6]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220907101825epsmtip154204b88be3cf7dd290da6f4ee1397bd~SjLFJqolx3175831758epsmtip1p; Wed, 7 Sep 2022 10:18:25 +0000 (GMT) From: Smitha T Murthy To: linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: m.szyprowski@samsung.com, andrzej.hajda@intel.com, mchehab@kernel.org, alim.akhtar@samsung.com, aswani.reddy@samsung.com, pankaj.dubey@samsung.com, linux-fsd@tesla.com, aakarsh.jain@samsung.com, Smitha T Murthy , stable@vger.kernel.org Subject: [PATCH 3/3] media: s5p-mfc: Fix to handle reference queue during finishing Date: Wed, 7 Sep 2022 16:02:27 +0530 Message-Id: <20220907103227.61088-3-smitha.t@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220907103227.61088-1-smitha.t@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgk+LIzCtJLcpLzFFi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CNj8ON3YcpKQLsOLNV1PbV93Fsxad8vqW/9zsSP5SizF GYmGWsxFxYkA1MJTBMkCAAA= X-CMS-MailID: 20220907101827epcas5p2afa088ce5a591040094d2b49b928f3c2 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220907101827epcas5p2afa088ce5a591040094d2b49b928f3c2 References: <20220907103227.61088-1-smitha.t@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220907_064249_389585_8FA15114 X-CRM114-Status: GOOD ( 17.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On receiving last buffer driver puts MFC to MFCINST_FINISHING state which in turn skips transferring of frame from SRC to REF queue. This causes driver to stop MFC encoding and last frame is lost. This patch guarantees safe handling of frames during MFCINST_FINISHING and correct clearing of workbit to avoid early stopping of encoding. Fixes: af93574678108 ("[media] MFC: Add MFC 5.1 V4L2 driver") Cc: stable@vger.kernel.org Cc: linux-fsd@tesla.com Signed-off-by: Smitha T Murthy --- drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c index b65e506665af..e064bdd74f2e 100644 --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c @@ -1218,6 +1218,7 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx) unsigned long mb_y_addr, mb_c_addr; int slice_type; unsigned int strm_size; + bool src_ready; slice_type = s5p_mfc_hw_call(dev->mfc_ops, get_enc_slice_type, dev); strm_size = s5p_mfc_hw_call(dev->mfc_ops, get_enc_strm_size, dev); @@ -1257,7 +1258,8 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx) } } } - if ((ctx->src_queue_cnt > 0) && (ctx->state == MFCINST_RUNNING)) { + if ((ctx->src_queue_cnt > 0) && (ctx->state == MFCINST_RUNNING || + ctx->state == MFCINST_FINISHING)) { mb_entry = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); if (mb_entry->flags & MFC_BUF_FLAG_USED) { @@ -1288,7 +1290,13 @@ static int enc_post_frame_start(struct s5p_mfc_ctx *ctx) vb2_set_plane_payload(&mb_entry->b->vb2_buf, 0, strm_size); vb2_buffer_done(&mb_entry->b->vb2_buf, VB2_BUF_STATE_DONE); } - if ((ctx->src_queue_cnt == 0) || (ctx->dst_queue_cnt == 0)) + + src_ready = true; + if ((ctx->state == MFCINST_RUNNING) && (ctx->src_queue_cnt == 0)) + src_ready = false; + if ((ctx->state == MFCINST_FINISHING) && (ctx->ref_queue_cnt == 0)) + src_ready = false; + if ((!src_ready) || (ctx->dst_queue_cnt == 0)) clear_work_bit(ctx); return 0;