From patchwork Tue Sep 25 08:23:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10613615 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 CED666CB for ; Tue, 25 Sep 2018 08:23:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEB1D29A39 for ; Tue, 25 Sep 2018 08:23:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADF3129A02; Tue, 25 Sep 2018 08:23:19 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C105229A02 for ; Tue, 25 Sep 2018 08:23:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726963AbeIYO3l (ORCPT ); Tue, 25 Sep 2018 10:29:41 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:55670 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727507AbeIYO3l (ORCPT ); Tue, 25 Sep 2018 10:29:41 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180925082316euoutp029ff1abcb3fead6bf76b6e3c83f370ea6~XlvmoZoBn0788707887euoutp02T for ; Tue, 25 Sep 2018 08:23:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180925082316euoutp029ff1abcb3fead6bf76b6e3c83f370ea6~XlvmoZoBn0788707887euoutp02T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537863796; bh=0tUSUsL9i/LnYbR/2IGHRzp3YtmkW7EEQA+bjPrRwi8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fThC3Grh1x0HuzpDWnX/2ZnraEyTZGEfLT1aW49yvVuDV6hD94uQAtYZhhz0qsXM/ HSnf7QfYY0p7N2OFpA9ty1B2XJYj8+19adHI+66j4VIVG3FhrUfBgae71h/S5/yQDl HM4l/tyfdubCStn0FbD+pQTUCdtTAvFF3NVF8+w8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180925082316eucas1p1db54a7bac0ea982f35d61fc9ec21e416~XlvmCwo1g1260012600eucas1p1Y; Tue, 25 Sep 2018 08:23:16 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 51.D7.04294.370F9AB5; Tue, 25 Sep 2018 09:23:15 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180925082315eucas1p1dbf1de0fcc7a51e42fe48dbb4b630a27~XlvlGymcH0543005430eucas1p1A; Tue, 25 Sep 2018 08:23:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180925082315eusmtrp1bb857680967a6e26339a248408a17b16~XlvlFo0Ok2383123831eusmtrp11; Tue, 25 Sep 2018 08:23:15 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-e8-5ba9f0738135 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 1B.26.04128.370F9AB5; Tue, 25 Sep 2018 09:23:15 +0100 (BST) Received: from AMDC2768.DIGITAL.local (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180925082314eusmtip17e719932b40e234e60ee1bb2be53ef68~XlvkwD2PI1347613476eusmtip1T; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) From: Andrzej Hajda To: Inki Dae Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 6/6] drm/exynos/iommu: merge IOMMU and DMA code Date: Tue, 25 Sep 2018 10:23:08 +0200 X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180925082308.1388-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djPc7rFH1ZGG3yfY2Bxa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBzFZZOSmpNZllqkb5fA ldE6bx5Twdu8iuMbzrE2MPbFdjFyckgImEjMv3WJuYuRi0NIYAWjxLwvR9ghnC+MEgunTWCF cD4zSny/fZwdpmXdn4lsEInljBJ3Ti1khmu5e/82K0gVm4CmxN/NN9lAbBEBZYlV+9rB5jIL XGKUeH2ymxEkISxgL7Hi7WuwIhYBVYkf1/+wQKyQl3h4vB2shlPAQuJyw1VGkGYJgetsEn+b 5jB1MXJw8AqUSVzdFgxR7yKx/PhFZghbWOLV8S1Qp8pInJ7cAzWzXqJp5hVmiDkdjBInFi9n g0hYSxw+fpEVZCYz0NXrd+lDhB0l3r5fxQ4SlhDgk7jxVhAkzAxkTto2nRkizCvR0SYEUa0o cf/sVqgLxCWWXvjKBlHiIXFlrjokeLoZJR7cv848gVF+FsKuBYyMqxjFU0uLc9NTi43yUsv1 ihNzi0vz0vWS83M3MQLTwOl/x7/sYNz1J+kQowAHoxIPr8HLFdFCrIllxZW5hxglOJiVRHib dFdGC/GmJFZWpRblxxeV5qQWH2KU5mBREufl00qLFhJITyxJzU5NLUgtgskycXBKNTDmqzLu u6HVcKRfMPSmwbu1Vnu2Cjm4pS8756qi4D/ZUu17Ycnuv71qdZFpmTGnA9eYJJo0Fj9iWifD n8p//kWAEk9zVYTtmRbXi7e3XuK8ITP1zjfGq1d+i+exLl1zdG60s2BXyf+Q3NnptaEh5oK7 F+QVPjgY+4p5beyapsot5bckdv2vaVJiKc5INNRiLipOBAB17luo/wIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t/xu7rFH1ZGG3ybwGJxa905VouNM9az Wlz5+p7NYtJ9oNiM8/uYLNYeucvuwOZxv/s4k0ffllWMHp83yQUwR+nZFOWXlqQqZOQXl9gq RRtaGOkZWlroGZlY6hkam8daGZkq6dvZpKTmZJalFunbJehltM6bx1TwNq/i+IZzrA2MfbFd jJwcEgImEuv+TGTrYuTiEBJYyihx//xnJoiEuMTu+W+ZIWxhiT/XuqCKPjFKHD91ix0kwSag KfF38002EFtEQFli1b52dpAiZoFrjBL7131iAUkIC9hLrHj7GqyIRUBV4sf1P2BxXgFzickX frBBbJCXeHi8nRHE5hSwkLjccBXMFgKqOdJ7gXkCI98CRoZVjCKppcW56bnFRnrFibnFpXnp esn5uZsYgYG57djPLTsYu94FH2IU4GBU4uE1eLkiWog1say4MvcQowQHs5IIb5Puymgh3pTE yqrUovz4otKc1OJDjKZAR01klhJNzgdGTV5JvKGpobmFpaG5sbmxmYWSOO95g8ooIYH0xJLU 7NTUgtQimD4mDk6pBsbNHHY/yrbcVNvA/shS2cGCOeC9gEl8HQfrzu078uaEO79/Ld4duOR2 TezNKIm1gT8fmvnwPxPPmH5OSr+/rPOMXZFyAPfNKA6rGYWdqz0Tqy/4FRidTPOXbbte/Tmi K5z39dXehntq7vnJqr25B5j6mExl27Qu77S33PTksJ7Mx9jQc+vOKrEUZyQaajEXFScCAEDW miFiAgAA Message-Id: <20180925082315eucas1p1dbf1de0fcc7a51e42fe48dbb4b630a27~XlvlGymcH0543005430eucas1p1A@eucas1p1.samsung.com> X-CMS-MailID: 20180925082315eucas1p1dbf1de0fcc7a51e42fe48dbb4b630a27 X-Msg-Generator: CA X-RootMTR: 20180925082315eucas1p1dbf1de0fcc7a51e42fe48dbb4b630a27 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180925082315eucas1p1dbf1de0fcc7a51e42fe48dbb4b630a27 References: <20180925082308.1388-1-a.hajda@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As DMA code is the only user of IOMMU code both files can be merged. It allows to remove stub functions, after slight adjustment of exynos_drm_register_dma. Since IOMMU functions are used locally they can be marked static. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/Makefile | 1 - drivers/gpu/drm/exynos/exynos_drm_dma.c | 191 +++++++++++++++++++++- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 185 --------------------- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 50 ------ 4 files changed, 183 insertions(+), 244 deletions(-) delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_iommu.c delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_iommu.h diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile index 94433838445f..2fd2f3ee4fcf 100644 --- a/drivers/gpu/drm/exynos/Makefile +++ b/drivers/gpu/drm/exynos/Makefile @@ -7,7 +7,6 @@ exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \ exynos_drm_gem.o exynos_drm_plane.o exynos_drm_dma.o exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o -exynosdrm-$(CONFIG_EXYNOS_IOMMU) += exynos_drm_iommu.o exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD) += exynos_drm_fimd.o exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON) += exynos5433_drm_decon.o exynosdrm-$(CONFIG_DRM_EXYNOS7_DECON) += exynos7_drm_decon.o diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exynos/exynos_drm_dma.c index f01cb102956d..5a120ea90a71 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dma.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c @@ -1,10 +1,181 @@ // SPDX-License-Identifier: GPL-2.0 // // Copyright (c) 2012 Samsung Electronics Co., Ltd. +// Author: Inki Dae // Author: Andrzej Hajda +#include +#include +#include +#include +#include + #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" + +#if defined(CONFIG_ARM_DMA_USE_IOMMU) +#include +#else +#define arm_iommu_create_mapping(...) ({ NULL; }) +#define arm_iommu_attach_device(...) ({ -ENODEV; }) +#define arm_iommu_release_mapping(...) ({ }) +#define arm_iommu_detach_device(...) ({ }) +#define to_dma_iommu_mapping(dev) NULL +#endif + +#if !defined(CONFIG_IOMMU_DMA) +#define iommu_dma_init_domain(...) ({ -EINVAL; }) +#endif + +#define EXYNOS_DEV_ADDR_START 0x20000000 +#define EXYNOS_DEV_ADDR_SIZE 0x40000000 + +static void *iommu_dma_create_mapping(struct exynos_drm_private *priv, + unsigned long start, unsigned long size) +{ + struct iommu_domain *domain; + int ret; + + domain = iommu_domain_alloc(priv->dma_dev->bus); + if (!domain) + return ERR_PTR(-ENOMEM); + + ret = iommu_get_dma_cookie(domain); + if (ret) + goto free_domain; + + ret = iommu_dma_init_domain(domain, start, size, NULL); + if (ret) + goto put_cookie; + + return domain; + +put_cookie: + iommu_put_dma_cookie(domain); +free_domain: + iommu_domain_free(domain); + return ERR_PTR(ret); +} + +static inline void iommu_dma_release_mapping(struct iommu_domain *domain) +{ + iommu_put_dma_cookie(domain); + iommu_domain_free(domain); +} + +static inline int configure_dma_max_seg_size(struct device *dev) +{ + if (!dev->dma_parms) + dev->dma_parms = kzalloc(sizeof(*dev->dma_parms), GFP_KERNEL); + if (!dev->dma_parms) + return -ENOMEM; + + dma_set_max_seg_size(dev, DMA_BIT_MASK(32)); + return 0; +} + +static inline void clear_dma_max_seg_size(struct device *dev) +{ + kfree(dev->dma_parms); + dev->dma_parms = NULL; +} + +/* + * drm_create_iommu_mapping - create a mapping structure + * + * @drm_dev: DRM device + */ +static int drm_create_iommu_mapping(struct drm_device *drm_dev) +{ + struct exynos_drm_private *priv = drm_dev->dev_private; + + if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) + priv->mapping = arm_iommu_create_mapping(&platform_bus_type, + EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); + else if (IS_ENABLED(CONFIG_IOMMU_DMA)) + priv->mapping = iommu_dma_create_mapping(priv, + EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); + + return PTR_ERR_OR_ZERO(priv->mapping); +} + +/* + * drm_release_iommu_mapping - release iommu mapping structure + * + * @drm_dev: DRM device + */ +static void drm_release_iommu_mapping(struct drm_device *drm_dev) +{ + struct exynos_drm_private *priv = drm_dev->dev_private; + + if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) + arm_iommu_release_mapping(priv->mapping); + else if (IS_ENABLED(CONFIG_IOMMU_DMA)) + iommu_dma_release_mapping(priv->mapping); + + priv->mapping = NULL; +} + +/* + * drm_iommu_attach_device- attach device to iommu mapping + * + * @drm_dev: DRM device + * @subdrv_dev: device to be attach + * + * This function should be called by sub drivers to attach it to iommu + * mapping. + */ +static int drm_iommu_attach_device(struct drm_device *drm_dev, + struct device *subdrv_dev) +{ + struct exynos_drm_private *priv = drm_dev->dev_private; + int ret; + + if (get_dma_ops(priv->dma_dev) != get_dma_ops(subdrv_dev)) { + DRM_ERROR("Device %s lacks support for IOMMU\n", + dev_name(subdrv_dev)); + return -EINVAL; + } + + ret = configure_dma_max_seg_size(subdrv_dev); + if (ret) + return ret; + + if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) { + if (to_dma_iommu_mapping(subdrv_dev)) + arm_iommu_detach_device(subdrv_dev); + + ret = arm_iommu_attach_device(subdrv_dev, priv->mapping); + } else if (IS_ENABLED(CONFIG_IOMMU_DMA)) { + ret = iommu_attach_device(priv->mapping, subdrv_dev); + } + + if (ret) + clear_dma_max_seg_size(subdrv_dev); + + return 0; +} + +/* + * drm_iommu_detach_device -detach device address space mapping from device + * + * @drm_dev: DRM device + * @subdrv_dev: device to be detached + * + * This function should be called by sub drivers to detach it from iommu + * mapping + */ +static void drm_iommu_detach_device(struct drm_device *drm_dev, + struct device *subdrv_dev) +{ + struct exynos_drm_private *priv = drm_dev->dev_private; + + if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) + arm_iommu_detach_device(subdrv_dev); + else if (IS_ENABLED(CONFIG_IOMMU_DMA)) + iommu_detach_device(priv->mapping, subdrv_dev); + + clear_dma_max_seg_size(subdrv_dev); +} int exynos_drm_register_dma(struct drm_device *drm, struct device *dev) { @@ -15,16 +186,20 @@ int exynos_drm_register_dma(struct drm_device *drm, struct device *dev) priv->dma_dev = dev; DRM_INFO("Exynos DRM: using %s device for DMA mapping operations\n", dev_name(dev)); - /* create common IOMMU mapping for all Exynos DRM devices */ - ret = drm_create_iommu_mapping(drm); - if (ret < 0) { - priv->dma_dev = NULL; - DRM_ERROR("failed to create iommu mapping.\n"); - return -EINVAL; + if (IS_ENABLED(CONFIG_EXYNOS_IOMMU)) { + ret = drm_create_iommu_mapping(drm); + if (ret < 0) { + priv->dma_dev = NULL; + DRM_ERROR("failed to create iommu mapping.\n"); + return -EINVAL; + } } } - return drm_iommu_attach_device(drm, dev); + if (IS_ENABLED(CONFIG_EXYNOS_IOMMU)) + return drm_iommu_attach_device(drm, dev); + else + return 0; } void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.c b/drivers/gpu/drm/exynos/exynos_drm_iommu.c deleted file mode 100644 index 54ac262a95aa..000000000000 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ /dev/null @@ -1,185 +0,0 @@ -/* exynos_drm_iommu.c - * - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * Author: Inki Dae - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#include -#include - -#include -#include -#include - -#include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" - -#if defined(CONFIG_ARM_DMA_USE_IOMMU) -#include -#else -#define arm_iommu_create_mapping(...) ({ NULL; }) -#define arm_iommu_attach_device(...) ({ -ENODEV; }) -#define arm_iommu_release_mapping(...) ({ }) -#define arm_iommu_detach_device(...) ({ }) -#define to_dma_iommu_mapping(dev) NULL -#endif - -#if !defined(CONFIG_IOMMU_DMA) -#define iommu_dma_init_domain(...) ({ -EINVAL; }) -#endif - -#define EXYNOS_DEV_ADDR_START 0x20000000 -#define EXYNOS_DEV_ADDR_SIZE 0x40000000 - -static void *iommu_dma_create_mapping(struct exynos_drm_private *priv, - unsigned long start, unsigned long size) -{ - struct iommu_domain *domain; - int ret; - - domain = iommu_domain_alloc(priv->dma_dev->bus); - if (!domain) - return ERR_PTR(-ENOMEM); - - ret = iommu_get_dma_cookie(domain); - if (ret) - goto free_domain; - - ret = iommu_dma_init_domain(domain, start, size, NULL); - if (ret) - goto put_cookie; - - return domain; - -put_cookie: - iommu_put_dma_cookie(domain); -free_domain: - iommu_domain_free(domain); - return ERR_PTR(ret); -} - -static inline void iommu_dma_release_mapping(struct iommu_domain *domain) -{ - iommu_put_dma_cookie(domain); - iommu_domain_free(domain); -} - -static inline int configure_dma_max_seg_size(struct device *dev) -{ - if (!dev->dma_parms) - dev->dma_parms = kzalloc(sizeof(*dev->dma_parms), GFP_KERNEL); - if (!dev->dma_parms) - return -ENOMEM; - - dma_set_max_seg_size(dev, DMA_BIT_MASK(32)); - return 0; -} - -static inline void clear_dma_max_seg_size(struct device *dev) -{ - kfree(dev->dma_parms); - dev->dma_parms = NULL; -} - -/* - * drm_create_iommu_mapping - create a mapping structure - * - * @drm_dev: DRM device - */ -int drm_create_iommu_mapping(struct drm_device *drm_dev) -{ - struct exynos_drm_private *priv = drm_dev->dev_private; - - if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) - priv->mapping = arm_iommu_create_mapping(&platform_bus_type, - EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); - else if (IS_ENABLED(CONFIG_IOMMU_DMA)) - priv->mapping = iommu_dma_create_mapping(priv, - EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); - - return IS_ERR(priv->mapping); -} - -/* - * drm_release_iommu_mapping - release iommu mapping structure - * - * @drm_dev: DRM device - */ -void drm_release_iommu_mapping(struct drm_device *drm_dev) -{ - struct exynos_drm_private *priv = drm_dev->dev_private; - - if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) - arm_iommu_release_mapping(priv->mapping); - else if (IS_ENABLED(CONFIG_IOMMU_DMA)) - iommu_dma_release_mapping(priv->mapping); - - priv->mapping = NULL; -} - -/* - * drm_iommu_attach_device- attach device to iommu mapping - * - * @drm_dev: DRM device - * @subdrv_dev: device to be attach - * - * This function should be called by sub drivers to attach it to iommu - * mapping. - */ -int drm_iommu_attach_device(struct drm_device *drm_dev, - struct device *subdrv_dev) -{ - struct exynos_drm_private *priv = drm_dev->dev_private; - int ret; - - if (get_dma_ops(priv->dma_dev) != get_dma_ops(subdrv_dev)) { - DRM_ERROR("Device %s lacks support for IOMMU\n", - dev_name(subdrv_dev)); - return -EINVAL; - } - - ret = configure_dma_max_seg_size(subdrv_dev); - if (ret) - return ret; - - if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) { - if (to_dma_iommu_mapping(subdrv_dev)) - arm_iommu_detach_device(subdrv_dev); - - ret = arm_iommu_attach_device(subdrv_dev, priv->mapping); - } else if (IS_ENABLED(CONFIG_IOMMU_DMA)) { - ret = iommu_attach_device(priv->mapping, subdrv_dev); - } - - if (ret) - clear_dma_max_seg_size(subdrv_dev); - - return 0; -} - -/* - * drm_iommu_detach_device -detach device address space mapping from device - * - * @drm_dev: DRM device - * @subdrv_dev: device to be detached - * - * This function should be called by sub drivers to detach it from iommu - * mapping - */ -void drm_iommu_detach_device(struct drm_device *drm_dev, - struct device *subdrv_dev) -{ - struct exynos_drm_private *priv = drm_dev->dev_private; - - if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) - arm_iommu_detach_device(subdrv_dev); - else if (IS_ENABLED(CONFIG_IOMMU_DMA)) - iommu_detach_device(priv->mapping, subdrv_dev); - - clear_dma_max_seg_size(subdrv_dev); -} diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.h b/drivers/gpu/drm/exynos/exynos_drm_iommu.h deleted file mode 100644 index 5eaec41514b4..000000000000 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h +++ /dev/null @@ -1,50 +0,0 @@ -/* exynos_drm_iommu.h - * - * Copyright (c) 2012 Samsung Electronics Co., Ltd. - * Authoer: Inki Dae - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. - */ - -#ifndef _EXYNOS_DRM_IOMMU_H_ -#define _EXYNOS_DRM_IOMMU_H_ - -#ifdef CONFIG_EXYNOS_IOMMU - -int drm_create_iommu_mapping(struct drm_device *drm_dev); - -void drm_release_iommu_mapping(struct drm_device *drm_dev); - -int drm_iommu_attach_device(struct drm_device *drm_dev, - struct device *subdrv_dev); - -void drm_iommu_detach_device(struct drm_device *dev_dev, - struct device *subdrv_dev); - -#else - -static inline int drm_create_iommu_mapping(struct drm_device *drm_dev) -{ - return 0; -} - -static inline void drm_release_iommu_mapping(struct drm_device *drm_dev) -{ -} - -static inline int drm_iommu_attach_device(struct drm_device *drm_dev, - struct device *subdrv_dev) -{ - return 0; -} - -static inline void drm_iommu_detach_device(struct drm_device *drm_dev, - struct device *subdrv_dev) -{ -} - -#endif -#endif