From patchwork Tue Apr 22 11:02:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Kumar K X-Patchwork-Id: 23756 X-Patchwork-Delegate: kamil@wypas.org Received: from mailbox.tu-berlin.de ([130.149.7.33] helo=mail.tu-berlin.de) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1WcYU6-0002ci-Kx; Tue, 22 Apr 2014 13:03:30 +0200 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-6) with esmtp id 1WcYU4-0005ML-3v; Tue, 22 Apr 2014 13:03:30 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932166AbaDVLC4 (ORCPT + 1 other); Tue, 22 Apr 2014 07:02:56 -0400 Received: from mail-pb0-f54.google.com ([209.85.160.54]:59352 "EHLO mail-pb0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932150AbaDVLCy (ORCPT ); Tue, 22 Apr 2014 07:02:54 -0400 Received: by mail-pb0-f54.google.com with SMTP id ma3so4816253pbc.41 for ; Tue, 22 Apr 2014 04:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=ZeCJv1+zKnV4Wz/l7kb+z1hLHxLpsOu3s3Ivyfp80tQ=; b=pAYFqz2IMAaupuKY1NoWr84xvEJwMEoS5BVpMJZYGbq7hIyfXgSMlAwJ1KGtpxaZLQ E+kRdq4cpNkdueCuGlCRSxQQ9rM1V5AjAuLRkGGN+G/SgcH+c38uv/+hwPtXIPV0CVau eyfrIkrspVC3s9HZ5UcQbhPidjp6/3wMCt2cWEKeGqQWyDgSI+1+w9VM13RrDqEfvAX+ iSEDKPo4NR9ZcFZbL72/lL6H6SOB3GzygiIbqejmpEtonRLZjbUvZhwe3bdEhFwjrqlk MheNWarBd4Y3HL7GTNG0yy89bvHj0Z5q2MeTfDYpiRJvks+aIorkxA5/6Osuvsyp1F2a WBnA== X-Received: by 10.68.136.41 with SMTP id px9mr43906407pbb.14.1398164573824; Tue, 22 Apr 2014 04:02:53 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPSA id gj9sm84179580pbc.7.2014.04.22.04.02.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Apr 2014 04:02:53 -0700 (PDT) From: Arun Kumar K To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: k.debski@samsung.com, s.nawrocki@samsung.com, arunkk.samsung@gmail.com Subject: [PATCH] [media] s5p-mfc: Add IOMMU support Date: Tue, 22 Apr 2014 16:32:48 +0530 Message-Id: <1398164568-6048-1-git-send-email-arun.kk@samsung.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2014.4.22.104818 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DKIM_SIGNATURE 0, FROM_NAME_PHRASE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_URI_IN_BODY 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' The patch adds IOMMU support for MFC driver. Signed-off-by: Arun Kumar K --- This patch is tested on IOMMU support series [1] posted by KyonHo Cho. [1] https://lkml.org/lkml/2014/3/14/9 --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 89356ae..1f248ba 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -32,11 +32,18 @@ #include "s5p_mfc_opr.h" #include "s5p_mfc_cmd.h" #include "s5p_mfc_pm.h" +#ifdef CONFIG_EXYNOS_IOMMU +#include +#endif #define S5P_MFC_NAME "s5p-mfc" #define S5P_MFC_DEC_NAME "s5p-mfc-dec" #define S5P_MFC_ENC_NAME "s5p-mfc-enc" +#ifdef CONFIG_EXYNOS_IOMMU +static struct dma_iommu_mapping *mapping; +#endif + int debug; module_param(debug, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "Debug level - higher value produces more verbose messages"); @@ -1013,6 +1020,23 @@ static void *mfc_get_drv_data(struct platform_device *pdev); static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) { +#ifdef CONFIG_EXYNOS_IOMMU + struct device *mdev = &dev->plat_dev->dev; + + mapping = arm_iommu_create_mapping(&platform_bus_type, 0x20000000, + SZ_256M); + if (mapping == NULL) { + mfc_err("IOMMU mapping failed\n"); + return -EFAULT; + } + mdev->dma_parms = devm_kzalloc(&dev->plat_dev->dev, + sizeof(*mdev->dma_parms), GFP_KERNEL); + dma_set_max_seg_size(mdev, 0xffffffffu); + arm_iommu_attach_device(mdev, mapping); + + dev->mem_dev_l = dev->mem_dev_r = mdev; + return 0; +#else unsigned int mem_info[2] = { }; dev->mem_dev_l = devm_kzalloc(&dev->plat_dev->dev, @@ -1049,6 +1073,7 @@ static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev) return -ENOMEM; } return 0; +#endif } /* MFC probe function */ @@ -1228,6 +1253,10 @@ err_mem_init_ctx_1: vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]); err_res: s5p_mfc_final_pm(dev); +#ifdef CONFIG_EXYNOS_IOMMU + if (mapping) + arm_iommu_release_mapping(mapping); +#endif pr_debug("%s-- with error\n", __func__); return ret; @@ -1256,6 +1285,10 @@ static int s5p_mfc_remove(struct platform_device *pdev) put_device(dev->mem_dev_r); } +#ifdef CONFIG_EXYNOS_IOMMU + if (mapping) + arm_iommu_release_mapping(mapping); +#endif s5p_mfc_final_pm(dev); return 0; }