From patchwork Fri Dec 16 11:48:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Dubey X-Patchwork-Id: 9477803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EC440607EE for ; Fri, 16 Dec 2016 11:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E127C285EB for ; Fri, 16 Dec 2016 11:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D5F932862A; Fri, 16 Dec 2016 11:48:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EFA6A285EB for ; Fri, 16 Dec 2016 11:48:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cHqya-0005i3-TU; Fri, 16 Dec 2016 11:47:00 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cHqy8-0005Xz-Ky for linux-arm-kernel@lists.infradead.org; Fri, 16 Dec 2016 11:46:34 +0000 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OIA02RMS0OTTAE0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 16 Dec 2016 20:46:09 +0900 (KST) X-AuditID: cbfee61a-f79916d0000062de-45-5853d4012504 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 71.01.25310.104D3585; Fri, 16 Dec 2016 20:46:09 +0900 (KST) Received: from pankaj.sisodomain.com ([107.108.83.125]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OIA005QB0OMSDA0@mmp2.samsung.com>; Fri, 16 Dec 2016 20:46:09 +0900 (KST) From: Pankaj Dubey To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] media: s5p-mfc: fix MMAP of mfc buffer during reqbufs Date: Fri, 16 Dec 2016 17:18:35 +0530 Message-id: <1481888915-19624-3-git-send-email-pankaj.dubey@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1481888915-19624-1-git-send-email-pankaj.dubey@samsung.com> References: <1481888915-19624-1-git-send-email-pankaj.dubey@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRmVeSWpSXmKPExsVy+t9jQV3GK8ERBs/7dC2W/NzFZPHm7Rom iyNrrzJZ9D9+zWxx/vwGdouzTW/YLTY9vsZqcXnXHDaLng1bWS1mnN/HZLFs0x8mi9XPKiwW bf3CbnF3zzZGBz6PKb83snpsWtXJ5rF5Sb3Hlv677B59W1YxenzeJBfAFuVmk5GamJJapJCa l5yfkpmXbqsUGuKma6GkkJeYm2qrFKHrGxKkpFCWmFMK5BkZoAEH5wD3YCV9uwS3jElNXxgL 5qpW7Lx/grmBcZN8FyMnh4SAicS+a+fYIWwxiQv31rN1MXJxCAnMYpSYePc/lPOTUeL2vb2s IFVsAroST97PZQZJiAh0MEpc7mgCa2cW6GKS6L+cC2ILC3hJ/G6cBRTn4GARUJU48CQPJMwr 4CFx7fA6FohtchI3z3Uyg9icAp4SS1fcYwYpFwKqud2pOYGRdwEjwypGidSC5ILipPRcw7zU cr3ixNzi0rx0veT83E2M4Ph4JrWD8eAu90OMAhyMSjy8C7YERQixJpYVV+YeYpTgYFYS4V16 KThCiDclsbIqtSg/vqg0J7X4EKMp0FkTmaVEk/OBsZtXEm9oYm5ibmxgYW5paWKkJM7bOPtZ uJBAemJJanZqakFqEUwfEwenVAOjwvY4zgZX0/98InOOpll2Rgv1fbtk9eN168XU967/bPj3 n0sKD5nIsOjB60d79/Jz/cjkyPqW+319ZWjAt4r2WQ0LSniLItO2+5g5/D7r9ds+K7SuMunw hLLgyZI7LjFF/N54/UnRlqAjzU43l9vwMcv/f1Yx5+y2FtuNV4VqLvfXSfXNWVOhxFKckWio xVxUnAgAxr/5RKUCAAA= X-MTR: 20000000000000000@CPGS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161216_034632_951008_A8028D84 X-CRM114-Status: GOOD ( 15.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: javier@osg.samsung.com, mchehab@osg.samsung.com, Smitha T Murthy , krzk@kernel.org, jtp.park@samsung.com, kyungmin.park@samsung.com, kgene@kernel.org, hans.verkuil@cisco.com, Pankaj Dubey , mchehab@kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Smitha T Murthy It has been observed on ARM64 based Exynos SoC, if IOMMU is not enabled and we try to use reserved memory for MFC, reqbufs fails with below mentioned error --------------------------------------------------------------------------- V4L2 Codec decoding example application Kamil Debski Copyright 2012 Samsung Electronics Co., Ltd. Opening MFC. (mfc.c:mfc_open:58): MFC Info (/dev/video0): driver="s5p-mfc" \ bus_info="platform:12c30000.mfc0" card="s5p-mfc-dec" fd=0x4[ 42.339165] Remapping memory failed, error: -6 MFC Open Success. (main.c:main:711): Successfully opened all necessary files and devices (mfc.c:mfc_dec_setup_output:103): Setup MFC decoding OUTPUT buffer \ size=4194304 (requested=4194304) (mfc.c:mfc_dec_setup_output:120): Number of MFC OUTPUT buffers is 2 \ (requested 2) [App] Out buf phy : 0x00000000, virt : 0xffffffff Output Length is = 0x300000 Error (mfc.c:mfc_dec_setup_output:145): Failed to MMAP MFC OUTPUT buffer ------------------------------------------------------------------------- This is because the device requesting for memory is mfc0.left not the parent mfc0. Hence setting of alloc_devs need to be done only if IOMMU is enabled and in that case both the left and right device is treated as mfc0 only. Signed-off-by: Smitha T Murthy [pankaj.dubey: debugging issue and formatting commit message] Signed-off-by: Pankaj Dubey --- drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 17 ++++++++++------- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 18 +++++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c index 52081dd..9cfca5d 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c @@ -30,6 +30,7 @@ #include "s5p_mfc_intr.h" #include "s5p_mfc_opr.h" #include "s5p_mfc_pm.h" +#include "s5p_mfc_iommu.h" static struct s5p_mfc_fmt formats[] = { { @@ -930,16 +931,18 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq, vq->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { psize[0] = ctx->luma_size; psize[1] = ctx->chroma_size; - - if (IS_MFCV6_PLUS(dev)) - alloc_devs[0] = ctx->dev->mem_dev_l; - else - alloc_devs[0] = ctx->dev->mem_dev_r; - alloc_devs[1] = ctx->dev->mem_dev_l; + if (exynos_is_iommu_available(&dev->plat_dev->dev)) { + if (IS_MFCV6_PLUS(dev)) + alloc_devs[0] = ctx->dev->mem_dev_l; + else + alloc_devs[0] = ctx->dev->mem_dev_r; + alloc_devs[1] = ctx->dev->mem_dev_l; + } } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && ctx->state == MFCINST_INIT) { psize[0] = ctx->dec_src_buf_size; - alloc_devs[0] = ctx->dev->mem_dev_l; + if (exynos_is_iommu_available(&dev->plat_dev->dev)) + alloc_devs[0] = ctx->dev->mem_dev_l; } else { mfc_err("This video node is dedicated to decoding. Decoding not initialized\n"); return -EINVAL; diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c index fcc2e05..eb8f06d 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_enc.c @@ -30,6 +30,7 @@ #include "s5p_mfc_enc.h" #include "s5p_mfc_intr.h" #include "s5p_mfc_opr.h" +#include "s5p_mfc_iommu.h" #define DEF_SRC_FMT_ENC V4L2_PIX_FMT_NV12M #define DEF_DST_FMT_ENC V4L2_PIX_FMT_H264 @@ -1832,7 +1833,8 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq, if (*buf_count > MFC_MAX_BUFFERS) *buf_count = MFC_MAX_BUFFERS; psize[0] = ctx->enc_dst_buf_size; - alloc_devs[0] = ctx->dev->mem_dev_l; + if (exynos_is_iommu_available(&dev->plat_dev->dev)) + alloc_devs[0] = ctx->dev->mem_dev_l; } else if (vq->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { if (ctx->src_fmt) *plane_count = ctx->src_fmt->num_planes; @@ -1847,12 +1849,14 @@ static int s5p_mfc_queue_setup(struct vb2_queue *vq, psize[0] = ctx->luma_size; psize[1] = ctx->chroma_size; - if (IS_MFCV6_PLUS(dev)) { - alloc_devs[0] = ctx->dev->mem_dev_l; - alloc_devs[1] = ctx->dev->mem_dev_l; - } else { - alloc_devs[0] = ctx->dev->mem_dev_r; - alloc_devs[1] = ctx->dev->mem_dev_r; + if (exynos_is_iommu_available(&dev->plat_dev->dev)) { + if (IS_MFCV6_PLUS(dev)) { + alloc_devs[0] = ctx->dev->mem_dev_l; + alloc_devs[1] = ctx->dev->mem_dev_l; + } else { + alloc_devs[0] = ctx->dev->mem_dev_r; + alloc_devs[1] = ctx->dev->mem_dev_r; + } } } else { mfc_err("invalid queue type: %d\n", vq->type);