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: 4030831 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7D9EC9F391 for ; Tue, 22 Apr 2014 11:03:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C7D6201FE for ; Tue, 22 Apr 2014 11:03:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 092EC20219 for ; Tue, 22 Apr 2014 11:02:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932133AbaDVLC5 (ORCPT ); Tue, 22 Apr 2014 07:02:57 -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-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }