From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757345AbcLPLsr (ORCPT ); Fri, 16 Dec 2016 06:48:47 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:51944 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760687AbcLPLsD (ORCPT ); Fri, 16 Dec 2016 06:48:03 -0500 X-AuditID: cbfee61a-f79916d0000062de-45-5853d4012504 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 Cc: kyungmin.park@samsung.com, jtp.park@samsung.com, mchehab@kernel.org, mchehab@osg.samsung.com, hans.verkuil@cisco.com, krzk@kernel.org, kgene@kernel.org, javier@osg.samsung.com, Smitha T Murthy , Pankaj Dubey 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pankaj Dubey 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> References: <1481888915-19624-1-git-send-email-pankaj.dubey@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-reply-to: <1481888915-19624-1-git-send-email-pankaj.dubey@samsung.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 List-Id: linux-samsung-soc@vger.kernel.org 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); -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: pankaj.dubey@samsung.com (Pankaj Dubey) Date: Fri, 16 Dec 2016 17:18:35 +0530 Subject: [PATCH 2/2] media: s5p-mfc: fix MMAP of mfc buffer during reqbufs In-Reply-To: <1481888915-19624-1-git-send-email-pankaj.dubey@samsung.com> References: <1481888915-19624-1-git-send-email-pankaj.dubey@samsung.com> Message-ID: <1481888915-19624-3-git-send-email-pankaj.dubey@samsung.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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); -- 2.7.4