From patchwork Fri Oct 12 10:53:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10638473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6CB4413AD for ; Fri, 12 Oct 2018 10:54:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A1B12BB2F for ; Fri, 12 Oct 2018 10:54:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EA7E2BB4D; Fri, 12 Oct 2018 10:54:12 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 567412BB2F for ; Fri, 12 Oct 2018 10:54:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A386289B01; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id E7736894D7 for ; Fri, 12 Oct 2018 10:53:54 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181012105353euoutp02292343465eaac69ca4771b1657e1e0f9~c1w9eqrzy0750207502euoutp02R; Fri, 12 Oct 2018 10:53:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181012105353euoutp02292343465eaac69ca4771b1657e1e0f9~c1w9eqrzy0750207502euoutp02R Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105353eucas1p100da4fc387c2e426d28d6ad8b415dd8c~c1w9E90Ki2595725957eucas1p1l; Fri, 12 Oct 2018 10:53:53 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 38.82.04806.04D70CB5; Fri, 12 Oct 2018 11:53:52 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105352eucas1p13627181190c88d0f295411082be12af2~c1w8YZkCn1532715327eucas1p10; Fri, 12 Oct 2018 10:53:52 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-eb-5bc07d403555 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E7.0B.04128.04D70CB5; Fri, 12 Oct 2018 11:53:52 +0100 (BST) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PGH00F8SFLQDI70@eusync3.samsung.com>; Fri, 12 Oct 2018 11:53:52 +0100 (BST) From: Andrzej Hajda To: Inki Dae Subject: [PATCH 4/6] drm/exynos/iommu: move IOMMU specific stuff into exynos_drm_iommu.c Date: Fri, 12 Oct 2018 12:53:44 +0200 Message-id: <20181012105346.3754-5-a.hajda@samsung.com> X-Mailer: git-send-email 2.18.0 In-reply-to: <20181012105346.3754-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+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LWvnR2kgVngCqNE+7cudpCEsECUxJfmE0wgNouAqsS9jlOsIDav gLnEoYWf2SC2yUs8PN7OCGJzClhILLt3kAVimbnEwXmXWSYw8ixgZFjFKJJaWpybnltspFec mFtcmpeul5yfu4kRGB7bjv3csoOx613wIUYBDkYlHt4fE/dHC7EmlhVX5h5ilOBgVhLhXZB1 IFqINyWxsiq1KD++qDQntfgQozQHi5I473mDyighgfTEktTs1NSC1CKYLBMHp1QDo80UDunO Uuf3P8Vu+BYf+rS2YmLok+r7jOGVLx8nrry/7fd0LZfQA00z7lQ1XH1vOo1Bf3n0BrETr0rU 7JMi9z6SOb77/4O05xXKD2uiD955ovVhxV7R3DtHr3Iv2tSSuH9hj/+165OW6G/dJln7y2FZ 2TNlxcRjjq3l+a8d5nNLLY7zPcGyylyJpTgj0VCLuag4EQAO6yc8CwIAAA== X-CMS-MailID: 20181012105352eucas1p13627181190c88d0f295411082be12af2 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181012105352eucas1p13627181190c88d0f295411082be12af2 References: <20181012105346.3754-1-a.hajda@samsung.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc@vger.kernel.org, Marek Szyprowski , dri-devel@lists.freedesktop.org, Bartlomiej Zolnierkiewicz MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since __exynos_iommu* functions are used only in exynos_drm_iommu.c we can move them there. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 72 +++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_iommu.h | 72 ----------------------- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.c b/drivers/gpu/drm/exynos/exynos_drm_iommu.c index 0f373702414e..564f1529d77e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.c @@ -18,6 +18,78 @@ #include "exynos_drm_drv.h" #include "exynos_drm_iommu.h" +#define EXYNOS_DEV_ADDR_START 0x20000000 +#define EXYNOS_DEV_ADDR_SIZE 0x40000000 + +#if defined(CONFIG_ARM_DMA_USE_IOMMU) +#include + +static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, + unsigned long start, unsigned long size) +{ + priv->mapping = arm_iommu_create_mapping(&platform_bus_type, start, + size); + return IS_ERR(priv->mapping); +} + +static inline void +__exynos_iommu_release_mapping(struct exynos_drm_private *priv) +{ + arm_iommu_release_mapping(priv->mapping); +} + +static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, + struct device *dev) +{ + if (dev->archdata.mapping) + arm_iommu_detach_device(dev); + + return arm_iommu_attach_device(dev, priv->mapping); +} + +static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, + struct device *dev) +{ + arm_iommu_detach_device(dev); +} + +#elif defined(CONFIG_IOMMU_DMA) +#include + +static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, + unsigned long start, unsigned long size) +{ + priv->mapping = iommu_get_domain_for_dev(priv->dma_dev); + return 0; +} + +static inline void __exynos_iommu_release_mapping(struct exynos_drm_private *priv) +{ + priv->mapping = NULL; +} + +static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, + struct device *dev) +{ + struct iommu_domain *domain = priv->mapping; + + if (dev != priv->dma_dev) + return iommu_attach_device(domain, dev); + return 0; +} + +static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, + struct device *dev) +{ + struct iommu_domain *domain = priv->mapping; + + if (dev != priv->dma_dev) + iommu_detach_device(domain, dev); +} +#else +#error Unsupported architecture and IOMMU/DMA-mapping glue code +#endif + static inline int configure_dma_max_seg_size(struct device *dev) { if (!dev->dma_parms) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.h b/drivers/gpu/drm/exynos/exynos_drm_iommu.h index 5aaece0a3a29..5eaec41514b4 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h @@ -12,80 +12,8 @@ #ifndef _EXYNOS_DRM_IOMMU_H_ #define _EXYNOS_DRM_IOMMU_H_ -#define EXYNOS_DEV_ADDR_START 0x20000000 -#define EXYNOS_DEV_ADDR_SIZE 0x40000000 - #ifdef CONFIG_EXYNOS_IOMMU -#if defined(CONFIG_ARM_DMA_USE_IOMMU) -#include - -static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, - unsigned long start, unsigned long size) -{ - priv->mapping = arm_iommu_create_mapping(&platform_bus_type, start, - size); - return IS_ERR(priv->mapping); -} - -static inline void -__exynos_iommu_release_mapping(struct exynos_drm_private *priv) -{ - arm_iommu_release_mapping(priv->mapping); -} - -static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, - struct device *dev) -{ - if (dev->archdata.mapping) - arm_iommu_detach_device(dev); - - return arm_iommu_attach_device(dev, priv->mapping); -} - -static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, - struct device *dev) -{ - arm_iommu_detach_device(dev); -} - -#elif defined(CONFIG_IOMMU_DMA) -#include - -static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, - unsigned long start, unsigned long size) -{ - priv->mapping = iommu_get_domain_for_dev(priv->dma_dev); - return 0; -} - -static inline void __exynos_iommu_release_mapping(struct exynos_drm_private *priv) -{ - priv->mapping = NULL; -} - -static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, - struct device *dev) -{ - struct iommu_domain *domain = priv->mapping; - - if (dev != priv->dma_dev) - return iommu_attach_device(domain, dev); - return 0; -} - -static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, - struct device *dev) -{ - struct iommu_domain *domain = priv->mapping; - - if (dev != priv->dma_dev) - iommu_detach_device(domain, dev); -} -#else -#error Unsupported architecture and IOMMU/DMA-mapping glue code -#endif - int drm_create_iommu_mapping(struct drm_device *drm_dev); void drm_release_iommu_mapping(struct drm_device *drm_dev);