From patchwork Wed Sep 7 06:47:14 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: 12968502 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 81B66C6FA86 for ; Wed, 7 Sep 2022 06:47:10 +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=CE6SIxw8sIw6AnDfqk3IWid+wMbYDTMRMbbMY6s38yM=; b=2t0PgRTski94az kOZAf3B7a87ZbhLXd6pTO9oLGHpSJWj4ZcXvyoIye8msw73/ITcn4kBWmW3Oboj2iCViUcBZBcGzQ XE78MuPgPCdK7utKpevAw2UvLN4e8kljOzVdksMjgBuXvgL9RdKeQnh0nD1Zky7j5nQVexItONJR/ Z6hiDC3iZDKZYL4GVcQFYPumDZQtr6/ufLnkUUBXoAbILY9J5E9E7RVeXUK3C+NLlRBJNvYtFESOp L5i1BinG1S4ywjCTMyF4EnXRwWJUtrG0CJivNe0qUD7rfTPvxRhaiBllOYptxdoVDJA9jnU07JB4a SjbZlZZw2dk0LKRWTPFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVooZ-003KkF-Mc; Wed, 07 Sep 2022 06:45:36 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVogr-003HM2-EI for linux-arm-kernel@lists.infradead.org; Wed, 07 Sep 2022 06:37:39 +0000 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220907063735epoutp0317bd7a7072b506a149f9b2393579534b~SgKQusid-2318823188epoutp03o for ; Wed, 7 Sep 2022 06:37:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220907063735epoutp0317bd7a7072b506a149f9b2393579534b~SgKQusid-2318823188epoutp03o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1662532655; bh=NYNVtJwc1Bayn3z6Bj59yHz3KYKrbxjKso4iH8BQb5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lqLcirbhFEquNIK+q3lbAskV6WxnvYDecF+Smpsc9EzoW4qWN3I8tLfV351bDwIRA Ym2pHwyp+zpy4fCROlIY/8xlA/z/7BHT5aihShIxLCtIQmNHMBXos5AyeLGc7/ccLF NlMUD+fatCsBuAKnrBnJZhO7A9CXv05wbmmRcuEw= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20220907063734epcas5p139b3c01b09bac81b772a2c1ab1ce3d57~SgKQSHV6f0397303973epcas5p1m; Wed, 7 Sep 2022 06:37:34 +0000 (GMT) Received: from epsmges5p2new.samsung.com (unknown [182.195.38.179]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4MMsxk2xqGz4x9QH; Wed, 7 Sep 2022 06:37:30 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id B1.C3.53458.A2C38136; Wed, 7 Sep 2022 15:37:30 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20220907063408epcas5p4285be9e4db0a64b396da8d66fb5ab2ad~SgHQfRqqt1751017510epcas5p4L; Wed, 7 Sep 2022 06:34:08 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220907063408epsmtrp28cf0b96460fe58e409622c9fa2d557cc~SgHQeODVf1916619166epsmtrp2f; Wed, 7 Sep 2022 06:34:08 +0000 (GMT) X-AuditID: b6c32a4a-caffb7000000d0d2-22-63183c2a0fed Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 5B.EC.14392.06B38136; Wed, 7 Sep 2022 15:34:08 +0900 (KST) Received: from Jaguar.sa.corp.samsungelectronics.net (unknown [107.109.115.6]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220907063404epsmtip1dcc688070decc938cb39160a4d9b2d27~SgHM7t-R12432724327epsmtip1h; Wed, 7 Sep 2022 06:34:04 +0000 (GMT) From: Smitha T Murthy To: linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: m.szyprowski@samsung.com, andrzej.hajda@intel.com, mchehab@kernel.org, hverkuil-cisco@xs4all.nl, ezequiel@vanguardiasur.com.ar, jernej.skrabec@gmail.com, benjamin.gaignard@collabora.com, stanimir.varbanov@linaro.org, dillon.minfei@gmail.com, david.plowman@raspberrypi.com, mark.rutland@arm.com, robh+dt@kernel.org, krzk+dt@kernel.org, andi@etezian.org, alim.akhtar@samsung.com, aswani.reddy@samsung.com, pankaj.dubey@samsung.com, linux-fsd@tesla.com, smitha.t@samsung.com, aakarsh.jain@samsung.com Subject: [Patch v2 14/15] media: s5p-mfc: DPB Count Independent of VIDIOC_REQBUF Date: Wed, 7 Sep 2022 12:17:14 +0530 Message-Id: <20220907064715.55778-15-smitha.t@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220907064715.55778-1-smitha.t@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WTe0xTVxzHOffe3haTspsWs7PGMtJMFzqBFku5GNicArmDLSMasoVMS1Pu CkIfactDZzImc9mqMDSgA6VugDM8itKXCNTxKNPx2MZWZBlUcE5RCG4DcQ4YW9uL23/f/L6f 3+P8zjkclDeFCzj5WhNt0CoLRfgmzDUQJY4WJ0GVpM/HJ+921rLIGYsLJxufzCLkdOMSRvbb nWzS4T2Lkhev97LI855vWeSVvl8wsuO+3x2r9WHk7Pl2QD6ou4WTtjs3WeTtubfIH7vO4eSJ y04WafX42OSFiTGE/NK2hpANzkds8pjbwyZ9PS5AfviRB9kFqTZLG6A6fU2AmmhaRKmrdT42 1djzAKFsLZ/g1NTNHpyyN71PHRtcwahKRwug1o/WsymzZwKnlmwR1NDyEjszLLsgKY9W5tKG SFqr0uXma9XJoox9ij2KeLlEGi1NJBNEkVqlhk4WpbyeGZ2WX+hfgyiyWFlY5A9lKo1GUezL SQZdkYmOzNMZTckiWp9bqJfpY4xKjbFIq47R0qadUokkLt4P5hTk/T1rRvVnhaWTVS5QBs5A MwjlQEIGbfMO1Aw2cXhEN4B95tNYwOARiwDOH1czxmMAL0ya/QYnmOFYBAzjBtBZm8Iw5Qj0 dczgAQMntsPHvw0HdTjxAYB3PjYFIJQox6BvZJUdMPjEXthlb0YDGiO2wuWfh4IJXGInrFqu R5jxnoetl3uDTKg/PlZ9gxUoBInyUDj6WS3CTJQC3Z9KGJ4P56472IwWwKWHbpzRaji9VA4Y rYf1ZY6N+q/AXu+54MFQIgpe6oplwkJYM9QeRFAiDFas/rqBc2Gn5akWwYaRGxutIBxfcLKY aSjYPZXC7KcCwPGG16pARN3/DT4HoAU8R+uNGjVtjNfHaemS/25MpdPYQPCZi9M7we2Z32P6 AcIB/QByUFE4N7czXMXj5ioPHaYNOoWhqJA29o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VIQxNPp+vB0uuCg5pBU+23 UAvAKGABkOKIvARJzV6JQkGSJDuHVZyOU2SlsUoL8KFw0WrBa83LOCEtlWSyqSwrZxX/U4zi rc3H2J+5AVKR5hI3JFDWpEs5POWZL0z0l2cXh6o8arbyc9RjV7aIpdNBwQcSfu9jK8RYtybu ZLXNc/T+Nb9OQxJw5qzob9He8X7q8pLPCWVd+1/46bb7OA0zsjy/E53ykfOWHdnJ8b67va8m qHwdhDmAxwyXuTqOdbdsqDKMPPTvVV93jW97NfpgZ55p5znv50d0qwv6yqODdfULkF/H0x8k omGMsr3DvDHWeGg4odyZGzn/59ScYFOJUVJe6L9QPdgXHjsXgS5HH3dKwK7hveJArZCPC1TU z1efx756P/4dMKVuPTO5tzXHI6soKPBo1VdZYdCFFJFInFBkiVglwpXJkrBgjkIp+Qe3jd5p KQMAAA== X-CMS-MailID: 20220907063408epcas5p4285be9e4db0a64b396da8d66fb5ab2ad X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220907063408epcas5p4285be9e4db0a64b396da8d66fb5ab2ad References: <20220907064715.55778-1-smitha.t@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220906_233737_862631_A0E42CE4 X-CRM114-Status: GOOD ( 19.11 ) 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 This patch allows allocation of DPB buffers based on MFC requirement so codec buffers allocations has been moved after state MFCINST_HEAD_PRODUCED. It is taken care that codec buffer allocation is performed in process context from userspace IOCTL call. Cc: linux-fsd@tesla.com Signed-off-by: Smitha T Murthy --- .../platform/samsung/s5p-mfc/s5p_mfc_enc.c | 17 ++--------------- .../platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c | 9 ++++++++- 2 files changed, 10 insertions(+), 16 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 404bce3641b9..9fdce20b69e2 100644 --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_enc.c @@ -1339,7 +1339,6 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx) struct s5p_mfc_dev *dev = ctx->dev; struct s5p_mfc_enc_params *p = &ctx->enc_params; struct s5p_mfc_buf *dst_mb; - unsigned int enc_pb_count; if (p->seq_hdr_mode == V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE) { if (!list_empty(&ctx->dst_queue)) { @@ -1361,10 +1360,8 @@ static int enc_post_seq_start(struct s5p_mfc_ctx *ctx) set_work_bit_irqsave(ctx); s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); } else { - enc_pb_count = s5p_mfc_hw_call(dev->mfc_ops, + ctx->pb_count = s5p_mfc_hw_call(dev->mfc_ops, get_enc_dpb_count, dev); - if (ctx->pb_count < enc_pb_count) - ctx->pb_count = enc_pb_count; if (FW_HAS_E_MIN_SCRATCH_BUF(dev)) { ctx->scratch_buf_size = s5p_mfc_hw_call(dev->mfc_ops, get_e_min_scratch_buf_size, dev); @@ -1730,14 +1727,6 @@ static int vidioc_reqbufs(struct file *file, void *priv, } ctx->capture_state = QUEUE_BUFS_REQUESTED; - ret = s5p_mfc_hw_call(ctx->dev->mfc_ops, - alloc_codec_buffers, ctx); - if (ret) { - mfc_err("Failed to allocate encoding buffers\n"); - reqbufs->count = 0; - ret = vb2_reqbufs(&ctx->vq_dst, reqbufs); - return -ENOMEM; - } } else if (reqbufs->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { if (reqbufs->count == 0) { mfc_debug(2, "Freeing buffers\n"); @@ -1753,15 +1742,13 @@ static int vidioc_reqbufs(struct file *file, void *priv, return -EINVAL; } - if (IS_MFCV6_PLUS(dev)) { + if (IS_MFCV6_PLUS(dev) && (!IS_MFCV12(dev))) { /* Check for min encoder buffers */ if (ctx->pb_count && (reqbufs->count < ctx->pb_count)) { reqbufs->count = ctx->pb_count; mfc_debug(2, "Minimum %d output buffers needed\n", ctx->pb_count); - } else { - ctx->pb_count = reqbufs->count; } } diff --git a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c index db06e3387d14..866cf44ef003 100644 --- a/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c +++ b/drivers/media/platform/samsung/s5p-mfc/s5p_mfc_opr_v6.c @@ -379,7 +379,6 @@ static int s5p_mfc_alloc_codec_buffers_v6(struct s5p_mfc_ctx *ctx) default: break; } - /* Allocate only if memory from bank 1 is necessary */ if (ctx->bank1.size > 0) { ret = s5p_mfc_alloc_generic_buf(dev, BANK_L_CTX, &ctx->bank1); @@ -2257,6 +2256,14 @@ static inline int s5p_mfc_run_init_enc_buffers(struct s5p_mfc_ctx *ctx) struct s5p_mfc_dev *dev = ctx->dev; int ret; + ret = s5p_mfc_hw_call(ctx->dev->mfc_ops, + alloc_codec_buffers, ctx); + if (ret) { + mfc_err("Failed to allocate encoding buffers\n"); + return -ENOMEM; + } + mfc_debug(2, "Allocated Internal Encoding Buffers\n"); + dev->curr_ctx = ctx->num; ret = s5p_mfc_set_enc_ref_buffer_v6(ctx); if (ret) {