From patchwork Fri Oct 12 10:53:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10638457 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 464CC933 for ; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36ADB2BB2F for ; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B44B2BB4E; Fri, 12 Oct 2018 10:53:56 +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 52F462BB2F for ; Fri, 12 Oct 2018 10:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728257AbeJLSZp (ORCPT ); Fri, 12 Oct 2018 14:25:45 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:58060 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728009AbeJLSZp (ORCPT ); Fri, 12 Oct 2018 14:25:45 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181012105352euoutp0112e3cf4d6de2d4af8cfe537675c1a3ce~c1w8wRqrQ0035000350euoutp01S; Fri, 12 Oct 2018 10:53:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181012105352euoutp0112e3cf4d6de2d4af8cfe537675c1a3ce~c1w8wRqrQ0035000350euoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539341632; bh=7vnbgMyYqlgrfOAEnESJ+ZlWnKfjBZAF55UDijcGgqc=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=R8hJaFx/f3/K0In1fcbU4R1RcmRVEZaCNJfPiTG+ZepNqRbrR9MO9/YynMY1YcrOu fTp6dJcOnhKycGbOTDf4LneFMdvfrG6aAsb9A/O40GGL6g3QFtXzYevuFlQjajc/2b dNX4BV1yZFDeOpTnup+7ypIe9T2NK0H44Cccke28= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181012105352eucas1p28ed291707f37b85d563bfaaa1b2178f2~c1w8SoMcy2829528295eucas1p23; Fri, 12 Oct 2018 10:53:52 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 34.A0.04294.04D70CB5; Fri, 12 Oct 2018 11:53:52 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105351eucas1p189cdf7fe2e5a738584fc3c29db99b418~c1w7jkU1f1532715327eucas1p1z; Fri, 12 Oct 2018 10:53:51 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-4a-5bc07d4007fb Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 92.DA.04284.F3D70CB5; Fri, 12 Oct 2018 11:53:51 +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:51 +0100 (BST) 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 1/6] drm/exynos: simplify DMA mapping Date: Fri, 12 Oct 2018 12:53:41 +0200 Message-id: <20181012105346.3754-2-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+NgFprJIsWRmVeSWpSXmKPExsWy7djPc7oOtQeiDR5uYre4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg yvjw8ihrwc/gihsdG9gbGE+5dzFyckgImEg83LCGvYuRi0NIYAWjxMazO5khnM+MEvf3b2OG qWq8u4wRIrGMUWLp0n1QLf8ZJXbM3skIUsUmoCnxd/NNNhBbREBZYtW+drAiZoFLjBKvT3YD FXFwCAuYSry96QdSwyKgKnGs9xALSJhXwFzicn8dxDJ5iYfH28FGcgpYSCy7d5AFIv6RVeLQ V1kI20Xi2p1uRghbWOLV8S3sELaMRGfHQSYIu16iaeYVsG8kBDoYJU4sXs4GkbCWOHz8IiuI zSzAJzFp23RmkBskBHglOtqEIEo8JN58ugT1YzejxJZbL9knMEouYGRYxSieWlqcm55abJSX Wq5XnJhbXJqXrpecn7uJERhhp/8d/7KDcdefpEOMAhyMSjy8C/r3RwuxJpYVV+YeYpTgYFYS 4V2QdSBaiDclsbIqtSg/vqg0J7X4EKM0B4uSOO+yeRujhQTSE0tSs1NTC1KLYLJMHJxSDYya 57ZMjXzfvTVjqsaGW/3f3u0Uv6V5KHj6+haXCW8PRu7hjw353hBRYnXZz21S3kLRwwfWChi+ si2WZVkQ/GpW7sqi9XN3ZFyqXXgz7rprcLtXWozGlrgvM+9m7mCwcJvK9vdYIsfKaGHdJWuF J8QtO+urtiBl8Y91mt9cAv/Mf2lxV4Fv4/OtSizFGYmGWsxFxYkAlcb4bawCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsVy+t/xq7r2tQeiDU5dE7G4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg yvjw8ihrwc/gihsdG9gbGE+5dzFyckgImEg03l3G2MXIxSEksIRR4sv1u1BOI5PExDuPmECq 2AQ0Jf5uvskGYosIKEus2tfODlLELHCFUaL9WxeQw8EhLGAq8famH0gNi4CqxLHeQywgYV4B c4nL/XUQy+QlHh5vZwSxOQUsJJbdO8gCYgsBlRycd5llAiPPAkaGVYwiqaXFuem5xYZ6xYm5 xaV56XrJ+bmbGIHBse3Yz807GC9tDD7EKMDBqMTD+2Pi/mgh1sSy4srcQ4wSHMxKIrwLsg5E C/GmJFZWpRblxxeV5qQWH2KU5mBREuc9b1AZJSSQnliSmp2aWpBaBJNl4uCUamDM6p+h1O7X VW/27urKe+rqV5ZOPNbvvT28Z2GqjciCpUt/WFy3XK/YuzToicN6m9NzDZjyOO9Vh8tEXFlf urq/55J+SeDpYiamze1qR87vErgw6d6KM1sDdrdc+CxUcXPDXZGHC0+UvjBTCg1s/nvgZseN mRyzrGIv+t2Jfssf73tlK0/76zUPlViKMxINtZiLihMBjt/DNgoCAAA= X-CMS-MailID: 20181012105351eucas1p189cdf7fe2e5a738584fc3c29db99b418 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181012105351eucas1p189cdf7fe2e5a738584fc3c29db99b418 References: <20181012105346.3754-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 Moving DMA mapping creation to drm_iommu_attach_device allows to avoid looping through all components and maintaining DMA device flags. v2: take care of configurations without IOMMU Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 2 +- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_drv.c | 71 +++++++------------ drivers/gpu/drm/exynos/exynos_drm_drv.h | 2 + drivers/gpu/drm/exynos/exynos_drm_fimc.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_gsc.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_scaler.c | 2 +- drivers/gpu/drm/exynos/exynos_mixer.c | 2 +- 11 files changed, 37 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c index 94529aa82339..b0d80e17ab85 100644 --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c @@ -578,7 +578,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data) decon_clear_channels(ctx->crtc); - return drm_iommu_attach_device(drm_dev, dev); + return exynos_drm_register_dma(drm_dev, dev); } static void decon_unbind(struct device *dev, struct device *master, void *data) diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index 88cbd000eb09..e78978eea5cb 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -133,7 +133,7 @@ static int decon_ctx_initialize(struct decon_context *ctx, decon_clear_channels(ctx->crtc); - return drm_iommu_attach_device(drm_dev, ctx->dev); + return exynos_drm_register_dma(drm_dev, ctx->dev); } static void decon_ctx_remove(struct decon_context *ctx) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 6f76baf4550a..3cf21d84a3d9 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -45,6 +45,27 @@ #define DRIVER_MAJOR 1 #define DRIVER_MINOR 1 +int exynos_drm_register_dma(struct drm_device *drm, struct device *dev) +{ + struct exynos_drm_private *priv = drm->dev_private; + int ret; + + if (!priv->dma_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; + } + } + + return drm_iommu_attach_device(drm, dev); +} + static int exynos_drm_open(struct drm_device *dev, struct drm_file *file) { struct drm_exynos_file_private *file_priv; @@ -175,8 +196,7 @@ struct exynos_drm_driver_info { #define DRM_COMPONENT_DRIVER BIT(0) /* supports component framework */ #define DRM_VIRTUAL_DEVICE BIT(1) /* create virtual platform device */ -#define DRM_DMA_DEVICE BIT(2) /* can be used for dma allocations */ -#define DRM_FIMC_DEVICE BIT(3) /* devices shared with V4L2 subsystem */ +#define DRM_FIMC_DEVICE BIT(2) /* devices shared with V4L2 subsystem */ #define DRV_PTR(drv, cond) (IS_ENABLED(cond) ? &drv : NULL) @@ -187,16 +207,16 @@ struct exynos_drm_driver_info { static struct exynos_drm_driver_info exynos_drm_drivers[] = { { DRV_PTR(fimd_driver, CONFIG_DRM_EXYNOS_FIMD), - DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE + DRM_COMPONENT_DRIVER }, { DRV_PTR(exynos5433_decon_driver, CONFIG_DRM_EXYNOS5433_DECON), - DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE + DRM_COMPONENT_DRIVER }, { DRV_PTR(decon_driver, CONFIG_DRM_EXYNOS7_DECON), - DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE + DRM_COMPONENT_DRIVER }, { DRV_PTR(mixer_driver, CONFIG_DRM_EXYNOS_MIXER), - DRM_COMPONENT_DRIVER | DRM_DMA_DEVICE + DRM_COMPONENT_DRIVER }, { DRV_PTR(mic_driver, CONFIG_DRM_EXYNOS_MIC), DRM_COMPONENT_DRIVER @@ -267,27 +287,6 @@ static struct component_match *exynos_drm_match_add(struct device *dev) return match ?: ERR_PTR(-ENODEV); } -static struct device *exynos_drm_get_dma_device(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(exynos_drm_drivers); ++i) { - struct exynos_drm_driver_info *info = &exynos_drm_drivers[i]; - struct device *dev; - - if (!info->driver || !(info->flags & DRM_DMA_DEVICE)) - continue; - - while ((dev = bus_find_device(&platform_bus_type, NULL, - &info->driver->driver, - (void *)platform_bus_type.match))) { - put_device(dev); - return dev; - } - } - return NULL; -} - static int exynos_drm_bind(struct device *dev) { struct exynos_drm_private *private; @@ -312,23 +311,6 @@ static int exynos_drm_bind(struct device *dev) dev_set_drvdata(dev, drm); drm->dev_private = (void *)private; - /* the first real CRTC device is used for all dma mapping operations */ - private->dma_dev = exynos_drm_get_dma_device(); - if (!private->dma_dev) { - DRM_ERROR("no device found for DMA mapping operations.\n"); - ret = -ENODEV; - goto err_free_private; - } - DRM_INFO("Exynos DRM: using %s device for DMA mapping operations\n", - dev_name(private->dma_dev)); - - /* create common IOMMU mapping for all devices attached to Exynos DRM */ - ret = drm_create_iommu_mapping(drm); - if (ret < 0) { - DRM_ERROR("failed to create iommu mapping.\n"); - goto err_free_private; - } - drm_mode_config_init(drm); exynos_drm_mode_config_init(drm); @@ -386,7 +368,6 @@ static int exynos_drm_bind(struct device *dev) err_mode_config_cleanup: drm_mode_config_cleanup(drm); drm_release_iommu_mapping(drm); -err_free_private: kfree(private); err_free_drm: drm_dev_put(drm); diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index ec9604f1272b..f3f386ca3a2a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -215,6 +215,8 @@ static inline struct device *to_dma_dev(struct drm_device *dev) return priv->dma_dev; } +int exynos_drm_register_dma(struct drm_device *drm, struct device *dev); + #ifdef CONFIG_DRM_EXYNOS_DPI struct drm_encoder *exynos_dpi_probe(struct device *dev); int exynos_dpi_remove(struct drm_encoder *encoder); diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c index e8d0670bb5f8..68bfe2cd76d6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c @@ -1129,7 +1129,7 @@ static int fimc_bind(struct device *dev, struct device *master, void *data) struct exynos_drm_ipp *ipp = &ctx->ipp; ctx->drm_dev = drm_dev; - drm_iommu_attach_device(drm_dev, dev); + exynos_drm_register_dma(drm_dev, dev); exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs, DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE | diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index b7f56935a46b..5b3d51460294 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -1011,7 +1011,7 @@ static int fimd_bind(struct device *dev, struct device *master, void *data) if (is_drm_iommu_supported(drm_dev)) fimd_clear_channels(ctx->crtc); - return drm_iommu_attach_device(drm_dev, dev); + return exynos_drm_register_dma(drm_dev, dev); } static void fimd_unbind(struct device *dev, struct device *master, diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index f2481a2014bb..86624ec20cde 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -1405,7 +1405,7 @@ static int g2d_bind(struct device *dev, struct device *master, void *data) return ret; } - ret = drm_iommu_attach_device(drm_dev, dev); + ret = exynos_drm_register_dma(drm_dev, dev); if (ret < 0) { dev_err(dev, "failed to enable iommu.\n"); g2d_fini_cmdlist(g2d); diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c index ce15d46bfce8..d2607da9f3d3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c @@ -1170,7 +1170,7 @@ static int gsc_bind(struct device *dev, struct device *master, void *data) struct exynos_drm_ipp *ipp = &ctx->ipp; ctx->drm_dev = drm_dev; - drm_iommu_attach_device(drm_dev, dev); + exynos_drm_register_dma(drm_dev, dev); exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs, DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE | diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c index a820a68429b9..7d4b5a136a18 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c @@ -244,7 +244,7 @@ static int rotator_bind(struct device *dev, struct device *master, void *data) struct exynos_drm_ipp *ipp = &rot->ipp; rot->drm_dev = drm_dev; - drm_iommu_attach_device(drm_dev, dev); + exynos_drm_register_dma(drm_dev, dev); exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs, DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE, diff --git a/drivers/gpu/drm/exynos/exynos_drm_scaler.c b/drivers/gpu/drm/exynos/exynos_drm_scaler.c index cd66774e817d..74e761c162dd 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_scaler.c +++ b/drivers/gpu/drm/exynos/exynos_drm_scaler.c @@ -452,7 +452,7 @@ static int scaler_bind(struct device *dev, struct device *master, void *data) struct exynos_drm_ipp *ipp = &scaler->ipp; scaler->drm_dev = drm_dev; - drm_iommu_attach_device(drm_dev, dev); + exynos_drm_register_dma(drm_dev, dev); exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs, DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE | diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index e3a4ecbc503b..52193de577d2 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -878,7 +878,7 @@ static int mixer_initialize(struct mixer_context *mixer_ctx, } } - return drm_iommu_attach_device(drm_dev, mixer_ctx->dev); + return exynos_drm_register_dma(drm_dev, mixer_ctx->dev); } static void mixer_ctx_remove(struct mixer_context *mixer_ctx) From patchwork Fri Oct 12 10:53:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10638455 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 1366C5CAF for ; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02A9A2BB49 for ; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB1162BB50; Fri, 12 Oct 2018 10:53:55 +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 8D8FA2BB49 for ; Fri, 12 Oct 2018 10:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728009AbeJLSZp (ORCPT ); Fri, 12 Oct 2018 14:25:45 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:52642 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728086AbeJLSZp (ORCPT ); Fri, 12 Oct 2018 14:25:45 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181012105353euoutp02ad6a33ac1de7db438b8bfe3141ff94e2~c1w9TNtB60655906559euoutp02j; Fri, 12 Oct 2018 10:53:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181012105353euoutp02ad6a33ac1de7db438b8bfe3141ff94e2~c1w9TNtB60655906559euoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539341633; bh=6FfLQVYPA7FgllgLKoufUe1LMqBEHtwuy0WfGpkiDRA=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=uainuw0SBm/p/ezfPFpJoMdT8O1VDzZddca48VSIr/rUi/G49Zex2cJVpCvBW/w8e v+4KX3oNpUfxj9kzSlEtiv3Amn8REAt7XHCXUx7eyJNqOzhfEJxVtPx4AyR9r+2HBw LroF07iDnOi2g7H336yMDZZZS0NtsLbpjRJrknso= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181012105352eucas1p2b4e8abef5e540030a92319d896f6fcbb~c1w8fHYEa0376803768eucas1p2_; Fri, 12 Oct 2018 10:53:52 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 24.A0.04294.04D70CB5; Fri, 12 Oct 2018 11:53:52 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105351eucas1p17eae01902839c7687260080feb21ef60~c1w7qb4LL1269412694eucas1p1Q; Fri, 12 Oct 2018 10:53:51 +0000 (GMT) X-AuditID: cbfec7f4-835ff700000010c6-49-5bc07d40f1b2 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 23.DA.04284.F3D70CB5; Fri, 12 Oct 2018 11:53:51 +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:51 +0100 (BST) 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 2/6] drm/exynos/iommu: remove DRM_EXYNOS_IOMMU Kconfig symbol Date: Fri, 12 Oct 2018 12:53:42 +0200 Message-id: <20181012105346.3754-3-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+NgFprFIsWRmVeSWpSXmKPExsWy7djP87oOtQeiDT584LS4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg yjj4/xpzQQt/RcvckywNjB28XYycHBICJhKdL14xdzFycQgJrGCU2N7wkBHC+cwoMfHVbCaY qh+LLrBBJJYxSqxb2gPV8p9RYsfsnYwgVWwCmhJ/N99kA7FFBJQlVu1rZwcpYha4xCjx+mQ3 UBEHh7CAv8SaA7ogNSwCqhKT1n9nBbF5Bcwlnl2czgyxTV7i4fF2sJmcAhYSy+4dZAGZIyHw kVVicecpRogiF4lZBxpZIWxhiVfHt7BD2DISnR0Hoc6ul2iaeYUZormDUeLE4uVsEAlricPH L4I1MwvwSUzaBrKZAyjOK9HRJgRhekj0PHWEeLKbUWLNqfksExglFzAyrGIUTy0tzk1PLTbK Sy3XK07MLS7NS9dLzs/dxAiMsdP/jn/ZwbjrT9IhRgEORiUe3gX9+6OFWBPLiitzDzFKcDAr ifAuyDoQLcSbklhZlVqUH19UmpNafIhRmoNFSZx32byN0UIC6YklqdmpqQWpRTBZJg5OqQbG FRWtf2Y7lqqpi869e+DE+oncWh9OhsdkZv5z223L4DPDozMvd4dl8MStIl+6a7Y/PrL9tsrG gNmnHoTt3HFzytVJLHvfL1+ypFVrY1Vy1jLZv5tP76lfV9zw5XrdzJj3NwrjL/5qesfOYd55 OnLqWc79bQYznFb5zj204lRdwJTeRZqmP2VXuCqxFGckGmoxFxUnAgAPe5QtrQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsVy+t/xq7r2tQeiDX4/1bC4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg yjj4/xpzQQt/RcvckywNjB28XYycHBICJhI/Fl1gA7GFBJYwSix+KNfFyAVkNzJJTLzziAkk wSagKfF3802wIhEBZYlV+9rZQYqYBa4wSrR/6wJyODiEBXwllj63BqlhEVCVmLT+OyuIzStg LvHs4nRmiGXyEg+PtzOC2JwCFhLL7h1kgVhsLnFw3mWWCYw8CxgZVjGKpJYW56bnFhvqFSfm Fpfmpesl5+duYgQGx7ZjPzfvYLy0MfgQowAHoxIP74+J+6OFWBPLiitzDzFKcDArifAuyDoQ LcSbklhZlVqUH19UmpNafIhRmoNFSZz3vEFllJBAemJJanZqakFqEUyWiYNTqoGRQ0Yif/fZ R+x7S+5pb73yMt16z1Q//zVpQfcWJWmuNAhhq5zOHad5UMfp0ae1p6yf+S23ul318l6sHd+z 3fUHdrsF/2CctyY+aoXulWlnONZ8Y3gz2WvyTY8pwuvTPzRLZ2z0bP/arME2zbRAXiVN+37M Sv6w2XFRncttJy+N1TThuXLYcTavEktxRqKhFnNRcSIAw72tNgoCAAA= X-CMS-MailID: 20181012105351eucas1p17eae01902839c7687260080feb21ef60 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181012105351eucas1p17eae01902839c7687260080feb21ef60 References: <20181012105346.3754-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 DRM_EXYNOS_IOMMU symbol is not configurable, it is always equal to EXYNOS_IOMMU. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/Kconfig | 5 ----- drivers/gpu/drm/exynos/Makefile | 2 +- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig index 208bc27be3cc..3691a140c950 100644 --- a/drivers/gpu/drm/exynos/Kconfig +++ b/drivers/gpu/drm/exynos/Kconfig @@ -10,11 +10,6 @@ config DRM_EXYNOS if DRM_EXYNOS -config DRM_EXYNOS_IOMMU - bool - depends on EXYNOS_IOMMU - default y - comment "CRTCs" config DRM_EXYNOS_FIMD diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile index 2ad146bbf4f5..ab763977ab28 100644 --- a/drivers/gpu/drm/exynos/Makefile +++ b/drivers/gpu/drm/exynos/Makefile @@ -7,7 +7,7 @@ exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \ exynos_drm_gem.o exynos_drm_plane.o exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o -exynosdrm-$(CONFIG_DRM_EXYNOS_IOMMU) += exynos_drm_iommu.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_iommu.h b/drivers/gpu/drm/exynos/exynos_drm_iommu.h index 797d9ee5f15a..c9e9c6647903 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h @@ -15,7 +15,7 @@ #define EXYNOS_DEV_ADDR_START 0x20000000 #define EXYNOS_DEV_ADDR_SIZE 0x40000000 -#ifdef CONFIG_DRM_EXYNOS_IOMMU +#ifdef CONFIG_EXYNOS_IOMMU #if defined(CONFIG_ARM_DMA_USE_IOMMU) #include From patchwork Fri Oct 12 10:53:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10638461 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 9E03B933 for ; Fri, 12 Oct 2018 10:53:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E0022BB2F for ; Fri, 12 Oct 2018 10:53:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8297F2BB51; Fri, 12 Oct 2018 10:53:57 +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 7D5822BB2F for ; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728108AbeJLSZq (ORCPT ); Fri, 12 Oct 2018 14:25:46 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:58065 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727758AbeJLSZq (ORCPT ); Fri, 12 Oct 2018 14:25:46 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20181012105353euoutp0177d966d6d92db8cdd8907137021d057b~c1w9Ux1vD3234732347euoutp014; Fri, 12 Oct 2018 10:53:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20181012105353euoutp0177d966d6d92db8cdd8907137021d057b~c1w9Ux1vD3234732347euoutp014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539341633; bh=0CtvnqL1osM4b4bhb8upee+vVaevY/twIQRl6asLH9w=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=jy0sN9jW20mnZPlwXOcTWNRQT5OuksHHEpglmQdB6SELv8QawIRss2llKf25+OblN jExENyt3rr7f2+PuMVnGjwtM1uNlfUtEzIZzVYGMbW/hAoVfCt4Y7D942y3D+amTPL /AvF/eX+lIz6Ywzlo0vY6jQZ4h0e3l44hgA9hKJY= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105353eucas1p17720536f3bbcb603bd9f4c914479a51e~c1w83e43p1269412694eucas1p1S; 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 C7.82.04806.04D70CB5; Fri, 12 Oct 2018 11:53:52 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105352eucas1p19cef6070271b6b3d81c1dc69f2ab94a7~c1w7-u-WI1269812698eucas1p1h; Fri, 12 Oct 2018 10:53:52 +0000 (GMT) X-AuditID: cbfec7f5-34dff700000012c6-ea-5bc07d40a97b Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 93.DA.04284.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 Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 3/6] drm/exynos/iommu: integrate IOMMU/DMA internal API Date: Fri, 12 Oct 2018 12:53:43 +0200 Message-id: <20181012105346.3754-4-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+NgFprFIsWRmVeSWpSXmKPExsWy7djP87oOtQeiDW62aFvcWneO1WLjjPWs Fle+vmezmHR/AovFjPP7mCzWHrnL7sDmcb/7OJNH35ZVjB6fN8kFMEdx2aSk5mSWpRbp2yVw ZexZ6VJwobzizNPNzA2Mv9K6GDk5JARMJF7svc/UxcjFISSwglHi37RnLBDOZ0aJ3U9+scBU rXj/CiqxjFFiwtq5jBDOf0aJ7+8OgVWxCWhK/N18kw3EFhFQlli1r50dpIhZ4BKjxOuT3Ywg CWEBd4mbZ46CNbAIqEq8vLoNrIFXwFxiyuzdTBDr5CUeHm8Hq+cUsJBYdu8g2GoJgY+sEhve n2GEKHKRmD/vPNR9whKvjm9hh7BlJDo7DkINqpdomnmFGaK5g1HixOLlbBAJa4nDxy+ygtjM AnwSk7ZNByriAIrzSnS0CUGUeEjMOrUWrERIoJtRYsPy2gmMkgsYGVYxiqeWFuempxYb56WW 6xUn5haX5qXrJefnbmIExtjpf8e/7mDc9yfpEKMAB6MSD++PifujhVgTy4orcw8xSnAwK4nw Lsg6EC3Em5JYWZValB9fVJqTWnyIUZqDRUmcd9m8jdFCAumJJanZqakFqUUwWSYOTqkGxrrL q86e3nHk8qIvlzsOepxzYv66pOvFBvMvGaV9j2tr43eqfeme1fbILOYHc9/nV8+v6Sa/92Oc fDiX+/t7p9jggCwHHYdn6+7sPqBx7cWrpzobnzatULzFZKbX8vfQmm/b+qaneBl2ZHxZP/fs n7cpnKKL1K9M25Zd+r5RMMzn9d3zZ93XBOxUYinOSDTUYi4qTgQAT4B0RK0CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsVy+t/xq7oOtQeiDQ7+ZbK4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg ytiz0qXgQnnFmaebmRsYf6V1MXJySAiYSKx4/4qli5GLQ0hgCaPE2j9L2EESQgKNTBJXV5mB 2GwCmhJ/N99kA7FFBJQlVu1rZwdpYBa4wijR/q0LrEFYwF3i5pmjLCA2i4CqxMur28AaeAXM JabM3s0EsU1e4uHxdkYQm1PAQmLZvYMsEMvMJQ7Ou8wygZFnASPDKkaR1NLi3PTcYkO94sTc 4tK8dL3k/NxNjMDg2Hbs5+YdjJc2Bh9iFOBgVOLh/TFxf7QQa2JZcWXuIUYJDmYlEd4FWQei hXhTEiurUovy44tKc1KLDzFKc7AoifOeN6iMEhJITyxJzU5NLUgtgskycXBKNTDOt3g+63NP wUsLC53Lc30n+QeyT46OPnouy9l3zURvhp8VU+a3b0xO+JB65sky1Rxm74qPvXtu2V3qiVjz 8TPDlJV21bMnzbwiqTR5u3+39/ITOzvmvgtgrH3gvyBs3TGmJT5qzfYvFEXW+EnXGTQuUZ53 KybcbsqyWtU8P+OFJ6X/XTDofXpCiaU4I9FQi7moOBEAV4ZNmAoCAAA= X-CMS-MailID: 20181012105352eucas1p19cef6070271b6b3d81c1dc69f2ab94a7 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181012105352eucas1p19cef6070271b6b3d81c1dc69f2ab94a7 References: <20181012105346.3754-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 Exynos DRM drivers should work with and without IOMMU. Providing common API generic to both scenarios should make code cleaner and allow further code improvements. The patch removes including of exynos_drm_iommu.h as the file contains mostly IOMMU specific stuff, instead it exposes exynos_drm_*_dma functions and puts them into exynos_drm_dma.c. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/Makefile | 2 +- drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 3 +- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_dma.c | 40 +++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_drv.c | 26 +----------- drivers/gpu/drm/exynos/exynos_drm_drv.h | 9 +++++ drivers/gpu/drm/exynos/exynos_drm_fb.c | 1 - drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 1 - drivers/gpu/drm/exynos/exynos_drm_fimc.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 1 - drivers/gpu/drm/exynos/exynos_drm_gsc.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 12 ------ drivers/gpu/drm/exynos/exynos_drm_rotator.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_scaler.c | 3 +- drivers/gpu/drm/exynos/exynos_mixer.c | 3 +- 17 files changed, 61 insertions(+), 58 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_dma.c diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile index ab763977ab28..94433838445f 100644 --- a/drivers/gpu/drm/exynos/Makefile +++ b/drivers/gpu/drm/exynos/Makefile @@ -4,7 +4,7 @@ # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \ - exynos_drm_gem.o exynos_drm_plane.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 diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c index b0d80e17ab85..6c821a16e95e 100644 --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c @@ -25,7 +25,6 @@ #include "exynos_drm_crtc.h" #include "exynos_drm_fb.h" #include "exynos_drm_plane.h" -#include "exynos_drm_iommu.h" #include "regs-decon5433.h" #define DSD_CFG_MUX 0x1004 @@ -588,7 +587,7 @@ static void decon_unbind(struct device *dev, struct device *master, void *data) decon_disable(ctx->crtc); /* detach this sub driver from iommu mapping if supported. */ - drm_iommu_detach_device(ctx->drm_dev, ctx->dev); + exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev); } static const struct component_ops decon_component_ops = { diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c index e78978eea5cb..381aa3d60e37 100644 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c @@ -30,7 +30,6 @@ #include "exynos_drm_plane.h" #include "exynos_drm_drv.h" #include "exynos_drm_fb.h" -#include "exynos_drm_iommu.h" #include "regs-decon7.h" /* @@ -139,7 +138,7 @@ static int decon_ctx_initialize(struct decon_context *ctx, static void decon_ctx_remove(struct decon_context *ctx) { /* detach this sub driver from iommu mapping if supported. */ - drm_iommu_detach_device(ctx->drm_dev, ctx->dev); + exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev); } static u32 decon_calc_clkdiv(struct decon_context *ctx, diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exynos/exynos_drm_dma.c new file mode 100644 index 000000000000..f01cb102956d --- /dev/null +++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// Author: Andrzej Hajda + +#include "exynos_drm_drv.h" +#include "exynos_drm_iommu.h" + +int exynos_drm_register_dma(struct drm_device *drm, struct device *dev) +{ + struct exynos_drm_private *priv = drm->dev_private; + int ret; + + if (!priv->dma_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; + } + } + + return drm_iommu_attach_device(drm, dev); +} + +void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev) +{ + if (IS_ENABLED(CONFIG_EXYNOS_IOMMU)) + drm_iommu_detach_device(drm, dev); +} + +void exynos_drm_cleanup_dma(struct drm_device *drm) +{ + if (IS_ENABLED(CONFIG_EXYNOS_IOMMU)) + drm_release_iommu_mapping(drm); +} diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index 3cf21d84a3d9..2c75e789b2a7 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -30,7 +30,6 @@ #include "exynos_drm_ipp.h" #include "exynos_drm_vidi.h" #include "exynos_drm_g2d.h" -#include "exynos_drm_iommu.h" #define DRIVER_NAME "exynos" #define DRIVER_DESC "Samsung SoC DRM" @@ -45,27 +44,6 @@ #define DRIVER_MAJOR 1 #define DRIVER_MINOR 1 -int exynos_drm_register_dma(struct drm_device *drm, struct device *dev) -{ - struct exynos_drm_private *priv = drm->dev_private; - int ret; - - if (!priv->dma_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; - } - } - - return drm_iommu_attach_device(drm, dev); -} - static int exynos_drm_open(struct drm_device *dev, struct drm_file *file) { struct drm_exynos_file_private *file_priv; @@ -367,7 +345,7 @@ static int exynos_drm_bind(struct device *dev) component_unbind_all(drm->dev, drm); err_mode_config_cleanup: drm_mode_config_cleanup(drm); - drm_release_iommu_mapping(drm); + exynos_drm_cleanup_dma(drm); kfree(private); err_free_drm: drm_dev_put(drm); @@ -386,7 +364,7 @@ static void exynos_drm_unbind(struct device *dev) component_unbind_all(drm->dev, drm); drm_mode_config_cleanup(drm); - drm_release_iommu_mapping(drm); + exynos_drm_cleanup_dma(drm); kfree(drm->dev_private); drm->dev_private = NULL; diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index f3f386ca3a2a..e02450c270c3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -215,7 +215,16 @@ static inline struct device *to_dma_dev(struct drm_device *dev) return priv->dma_dev; } +static inline bool is_drm_iommu_supported(struct drm_device *drm_dev) +{ + struct exynos_drm_private *priv = drm_dev->dev_private; + + return priv->mapping ? true : false; +} + int exynos_drm_register_dma(struct drm_device *drm, struct device *dev); +void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev); +void exynos_drm_cleanup_dma(struct drm_device *drm); #ifdef CONFIG_DRM_EXYNOS_DPI struct drm_encoder *exynos_dpi_probe(struct device *dev); diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index 9f52382e19ee..31eb538a44ae 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c @@ -24,7 +24,6 @@ #include "exynos_drm_drv.h" #include "exynos_drm_fb.h" #include "exynos_drm_fbdev.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_crtc.h" static int check_fb_gem_memory_type(struct drm_device *drm_dev, diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index 918dd2c82209..6cd94829ff3f 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c @@ -23,7 +23,6 @@ #include "exynos_drm_drv.h" #include "exynos_drm_fb.h" #include "exynos_drm_fbdev.h" -#include "exynos_drm_iommu.h" #define MAX_CONNECTOR 4 #define PREFERRED_BPP 32 diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c index 68bfe2cd76d6..90dfea0aec4d 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c @@ -25,7 +25,6 @@ #include #include "regs-fimc.h" #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_ipp.h" /* @@ -1149,7 +1148,7 @@ static void fimc_unbind(struct device *dev, struct device *master, struct exynos_drm_ipp *ipp = &ctx->ipp; exynos_drm_ipp_unregister(drm_dev, ipp); - drm_iommu_detach_device(drm_dev, dev); + exynos_drm_unregister_dma(drm_dev, dev); } static const struct component_ops fimc_component_ops = { diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 5b3d51460294..e3d6a8584715 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -32,7 +32,6 @@ #include "exynos_drm_fb.h" #include "exynos_drm_crtc.h" #include "exynos_drm_plane.h" -#include "exynos_drm_iommu.h" /* * FIMD stands for Fully Interactive Mobile Display and @@ -1021,7 +1020,7 @@ static void fimd_unbind(struct device *dev, struct device *master, fimd_disable(ctx->crtc); - drm_iommu_detach_device(ctx->drm_dev, ctx->dev); + exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev); if (ctx->encoder) exynos_dpi_remove(ctx->encoder); diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index 86624ec20cde..24c536d6d9cf 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -25,7 +25,6 @@ #include "exynos_drm_drv.h" #include "exynos_drm_g2d.h" #include "exynos_drm_gem.h" -#include "exynos_drm_iommu.h" #define G2D_HW_MAJOR_VER 4 #define G2D_HW_MINOR_VER 1 @@ -1430,7 +1429,7 @@ static void g2d_unbind(struct device *dev, struct device *master, void *data) priv->g2d_dev = NULL; cancel_work_sync(&g2d->runqueue_work); - drm_iommu_detach_device(g2d->drm_dev, dev); + exynos_drm_unregister_dma(g2d->drm_dev, dev); } static const struct component_ops g2d_component_ops = { diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c index 34ace85feb68..df66c383a877 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c @@ -19,7 +19,6 @@ #include "exynos_drm_drv.h" #include "exynos_drm_gem.h" -#include "exynos_drm_iommu.h" static int exynos_drm_alloc_buf(struct exynos_drm_gem *exynos_gem) { diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c index d2607da9f3d3..f048d97fe9e2 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c @@ -24,7 +24,6 @@ #include #include "regs-gsc.h" #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_ipp.h" /* @@ -1190,7 +1189,7 @@ static void gsc_unbind(struct device *dev, struct device *master, struct exynos_drm_ipp *ipp = &ctx->ipp; exynos_drm_ipp_unregister(drm_dev, ipp); - drm_iommu_detach_device(drm_dev, dev); + exynos_drm_unregister_dma(drm_dev, dev); } static const struct component_ops gsc_component_ops = { diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.h b/drivers/gpu/drm/exynos/exynos_drm_iommu.h index c9e9c6647903..5aaece0a3a29 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h @@ -96,13 +96,6 @@ int drm_iommu_attach_device(struct drm_device *drm_dev, void drm_iommu_detach_device(struct drm_device *dev_dev, struct device *subdrv_dev); -static inline bool is_drm_iommu_supported(struct drm_device *drm_dev) -{ - struct exynos_drm_private *priv = drm_dev->dev_private; - - return priv->mapping ? true : false; -} - #else static inline int drm_create_iommu_mapping(struct drm_device *drm_dev) @@ -125,10 +118,5 @@ static inline void drm_iommu_detach_device(struct drm_device *drm_dev, { } -static inline bool is_drm_iommu_supported(struct drm_device *drm_dev) -{ - return false; -} - #endif #endif diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c index 7d4b5a136a18..8d67b2a54be3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c @@ -23,7 +23,6 @@ #include #include "regs-rotator.h" #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_ipp.h" /* @@ -263,7 +262,7 @@ static void rotator_unbind(struct device *dev, struct device *master, struct exynos_drm_ipp *ipp = &rot->ipp; exynos_drm_ipp_unregister(drm_dev, ipp); - drm_iommu_detach_device(rot->drm_dev, rot->dev); + exynos_drm_unregister_dma(rot->drm_dev, rot->dev); } static const struct component_ops rotator_component_ops = { diff --git a/drivers/gpu/drm/exynos/exynos_drm_scaler.c b/drivers/gpu/drm/exynos/exynos_drm_scaler.c index 74e761c162dd..71270efa64f3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_scaler.c +++ b/drivers/gpu/drm/exynos/exynos_drm_scaler.c @@ -23,7 +23,6 @@ #include "regs-scaler.h" #include "exynos_drm_fb.h" #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_ipp.h" #define scaler_read(offset) readl(scaler->regs + (offset)) @@ -473,7 +472,7 @@ static void scaler_unbind(struct device *dev, struct device *master, struct exynos_drm_ipp *ipp = &scaler->ipp; exynos_drm_ipp_unregister(drm_dev, ipp); - drm_iommu_detach_device(scaler->drm_dev, scaler->dev); + exynos_drm_unregister_dma(scaler->drm_dev, scaler->dev); } static const struct component_ops scaler_component_ops = { diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 52193de577d2..5a47af8e76c0 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -40,7 +40,6 @@ #include "exynos_drm_crtc.h" #include "exynos_drm_fb.h" #include "exynos_drm_plane.h" -#include "exynos_drm_iommu.h" #define MIXER_WIN_NR 3 #define VP_DEFAULT_WIN 2 @@ -883,7 +882,7 @@ static int mixer_initialize(struct mixer_context *mixer_ctx, static void mixer_ctx_remove(struct mixer_context *mixer_ctx) { - drm_iommu_detach_device(mixer_ctx->drm_dev, mixer_ctx->dev); + exynos_drm_unregister_dma(mixer_ctx->drm_dev, mixer_ctx->dev); } static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) 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: 10638459 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 71E1569B4 for ; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61EB82BB2F for ; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5605E2BB49; Fri, 12 Oct 2018 10:53:56 +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 B802D2BB4D for ; Fri, 12 Oct 2018 10:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728086AbeJLSZq (ORCPT ); Fri, 12 Oct 2018 14:25:46 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:52646 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728108AbeJLSZp (ORCPT ); Fri, 12 Oct 2018 14:25:45 -0400 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539341633; bh=5n0hJ57zmVgnRbuguwGJjO+V+LpbBnEpfs4JfLk657I=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=siDFIcacWHQaHzoK7tcmv5yF8f9sBXr013D+cNKosiYjeHoc1G2F52VP2zjI8StU8 Nv6jcrBgWDceN85ODwDflXf1TROKaC3TMQMtfU0tgc+N36oWyqFrC0+hs+HWdrM9o/ 9vUzbUqJkeYBosv9PA98lY4lzZiGrtNx1ww7rm+M= 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 Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org 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+NgFprNIsWRmVeSWpSXmKPExsWy7djP87oOtQeiDR5eMLe4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg ynj58DtTwWf1ivVX5zE3MP5U7GLk5JAQMJHofnSFtYuRi0NIYAWjxJuVfWwQzmdGiTMX97LD VD3+85UJIrGMUWLnjb+MEM5/Ronv7w6xgFSxCWhK/N18kw3EFhFQlli1r50dpIhZ4BKjxOuT 3YwgCWGBKIkvzSeYQGwWAVWJex2nWEFsXgFziUMLP7NBrJOXeHi8HayeU8BCYtm9gywggyQE vrJKfJkxjxWiyEVi++1WJghbWOLV8S1Qt8pIXJ7czQJh10s0zbzCDNHcwShxYvFyqA3WEoeP XwQbxCzAJzFp23SgIg6gOK9ER5sQhOkhsWxnBcSX3YwSW77uZ5nAKLmAkWEVo3hqaXFuemqx cV5quV5xYm5xaV66XnJ+7iZGYJSd/nf86w7GfX+SDjEKcDAq8fD+mLg/Wog1say4MvcQowQH s5II74KsA9FCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeZfN2xgtJJCeWJKanZpakFoEk2Xi4JRq YOTo8RSdMGXehqqfvA7KH1itLAuf/khcOWGmYKe/jva+n5qyGqcKeibc3tgg8IXdzmDJF77L Mxa47Dg+falmEx+nXMPjzRqhcRZbOTJfxhYtLzfRE400D4v1cbNRPGCiEOnff2nuHRmfjJTs WP7/CtUFzsVJf+14rv+1aOX52zWhofXH8UYpJZbijERDLeai4kQAGqyfOq4CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBJMWRmVeSWpSXmKPExsVy+t/xq7oOtQeiDT6eF7e4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg ynj58DtTwWf1ivVX5zE3MP5U7GLk5JAQMJF4/OcrUxcjF4eQwBJGifcTH7KBJIQEGpkkrq4y A7HZBDQl/m6+CRYXEVCWWLWvnR2kgVngCqNE+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> 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 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); From patchwork Fri Oct 12 10:53:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10638463 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 07AA85CAF for ; Fri, 12 Oct 2018 10:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBBAB2BB2F for ; Fri, 12 Oct 2018 10:53:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E070B2BB51; Fri, 12 Oct 2018 10:53:57 +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 F1DCC2BB4D for ; Fri, 12 Oct 2018 10:53:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727758AbeJLSZr (ORCPT ); Fri, 12 Oct 2018 14:25:47 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:52648 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728191AbeJLSZr (ORCPT ); Fri, 12 Oct 2018 14:25:47 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181012105354euoutp021ddd759291ba4a5ca9bfb4518e8db0ac~c1w94Dsx00711907119euoutp02u; Fri, 12 Oct 2018 10:53:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181012105354euoutp021ddd759291ba4a5ca9bfb4518e8db0ac~c1w94Dsx00711907119euoutp02u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539341634; bh=3n7Yjvyk85U9Lz8IlG6Nmrx19LBd4aNBOGELsOJt9K0=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=YO6/JHZX7PcqZhiV/KnIICLRlL01j85F8rWr54epu+TlY6AWHFVe7kNNfsrYebWm9 lYK8H6VU4JjVRU+qCe0/PcThTVP+Dp8QkfJaLjmDMq1WWOo98RO3QgwxFEhXDQES7E 1ABy1Z/iCYq7BfxZd6AOQGVBjZVPAzNQ4JJWxz7k= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105353eucas1p1530cb9c8c4475b3ded9bddf41a6159af~c1w9YwXKZ1270512705eucas1p1M; Fri, 12 Oct 2018 10:53:53 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id BC.74.04441.14D70CB5; Fri, 12 Oct 2018 11:53:53 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105352eucas1p1632502a2266a59a5db820ed43b4954a8~c1w8qOYYE1270512705eucas1p1J; Fri, 12 Oct 2018 10:53:52 +0000 (GMT) X-AuditID: cbfec7f2-a1ae89c000001159-b9-5bc07d41d485 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 58.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 Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 5/6] drm/exynos/iommu: replace preprocessor conditionals with C conditionals Date: Fri, 12 Oct 2018 12:53:45 +0200 Message-id: <20181012105346.3754-6-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+NgFprOIsWRmVeSWpSXmKPExsWy7djPc7qOtQeiDT6vFLa4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg yjhxN7Dgh1rF9QMH2BsY+xW7GDk5JARMJJpn3mUBsYUEVjBKPL7u1cXIBWR/ZpSYd/EyO0zR vumHWSGKljFK7HrGB1H0n1Hi+7tDYN1sApoSfzffZAOxRQSUJVbta2cHKWIWuMQo8fpkNyNI QlggTqLt7xywqSwCqhJvViwHi/MKmEscnruBDWKbvMTD4+1gcU4BC4ll9w6ygAySEPjIKrFu +gwWiCIXia71H6AahCVeHd8CdaqMxOXJ3VA19RJNM68wQzR3MEqcWLwcqsFa4vDxi2D/MAvw SUzaNh2oiAMozivR0SYEYXpIrN9jBvFxN6PEyrfmExglFzAyrGIUTy0tzk1PLTbMSy3XK07M LS7NS9dLzs/dxAiMrtP/jn/awfj1UtIhRgEORiUe3gX9+6OFWBPLiitzDzFKcDArifAuyDoQ LcSbklhZlVqUH19UmpNafIhRmoNFSZx32byN0UIC6YklqdmpqQWpRTBZJg5OqQbGgNetktcX hnKqrXtosOHpAV7eHUWlX0Tbpk7d4nnGvkNxCaOdbO6BdImU7JxYmYaf8i9Fotz3Xipd6/vb mnnR4i8GzdLOKeIr5l+y+e3+7m8oy9EFbHucykUMLAu+mBTa6J9xWLzH7u63D7d5LjQtcmU5 +DXn/Mrl+4TOelyW1JknM9FPPOqjEktxRqKhFnNRcSIAJQBOH6oCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsVy+t/xq7oOtQeiDXbN1La4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg yjhxN7Dgh1rF9QMH2BsY+xW7GDk5JARMJPZNP8zaxcjFISSwhFFiV89fRpCEkEAjk8TVVWYg NpuApsTfzTfZQGwRAWWJVfva2UEamAWuMEq0f+tiB0kIC8RJfFn2B8xmEVCVeLNiOdggXgFz icNzN7BBbJOXeHi8HSzOKWAhsezeQRaIZeYSB+ddZpnAyLOAkWEVo0hqaXFuem6xkV5xYm5x aV66XnJ+7iZGYHBsO/Zzyw7GrnfBhxgFOBiVeHh/TNwfLcSaWFZcmXuIUYKDWUmEd0HWgWgh 3pTEyqrUovz4otKc1OJDjNIcLErivOcNKqOEBNITS1KzU1MLUotgskwcnFINjDEWZb9ZDrN/ 6VuSYxry72rh5OLTWyuuJ53t5a6/WqB7ocec88CRQ4pzrYqmPntrEZx2eFqF+sI+ff/iHb/W tM3/WLGD4RfjAQWTKUmq8w47rm7VfMZpc/3flGD3mEn2U79XRH+1s5jvb6/jterrYU+NE8r7 Gk6+Fn89u1Tg+tTTnOsj/HRu1yqxFGckGmoxFxUnAgAmUbZWCgIAAA== X-CMS-MailID: 20181012105352eucas1p1632502a2266a59a5db820ed43b4954a8 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181012105352eucas1p1632502a2266a59a5db820ed43b4954a8 References: <20181012105346.3754-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 Using C conditionals is preferred solution - it provides better code coverage, makes code more clear. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 108 ++++++++-------------- 1 file changed, 36 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.c b/drivers/gpu/drm/exynos/exynos_drm_iommu.c index 564f1529d77e..14558dedc043 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.c @@ -12,84 +12,30 @@ #include #include +#include #include #include #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 +#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 inline int configure_dma_max_seg_size(struct device *dev) { if (!dev->dma_parms) @@ -116,8 +62,13 @@ int drm_create_iommu_mapping(struct drm_device *drm_dev) { struct exynos_drm_private *priv = drm_dev->dev_private; - return __exynos_iommu_create_mapping(priv, EXYNOS_DEV_ADDR_START, - EXYNOS_DEV_ADDR_SIZE); + 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_get_domain_for_dev(priv->dma_dev); + + return IS_ERR(priv->mapping); } /* @@ -129,7 +80,8 @@ void drm_release_iommu_mapping(struct drm_device *drm_dev) { struct exynos_drm_private *priv = drm_dev->dev_private; - __exynos_iommu_release_mapping(priv); + arm_iommu_release_mapping(priv->mapping); + priv->mapping = NULL; } /* @@ -157,7 +109,15 @@ int drm_iommu_attach_device(struct drm_device *drm_dev, if (ret) return ret; - ret = __exynos_iommu_attach(priv, subdrv_dev); + 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); @@ -178,6 +138,10 @@ void drm_iommu_detach_device(struct drm_device *drm_dev, { struct exynos_drm_private *priv = drm_dev->dev_private; - __exynos_iommu_detach(priv, subdrv_dev); + 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); } From patchwork Fri Oct 12 10:53:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10638465 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 5F5AF69B1 for ; Fri, 12 Oct 2018 10:53:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EE092BB2F for ; Fri, 12 Oct 2018 10:53:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42C032BB4D; Fri, 12 Oct 2018 10:53:58 +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 5726C2BB4E for ; Fri, 12 Oct 2018 10:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728191AbeJLSZr (ORCPT ); Fri, 12 Oct 2018 14:25:47 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:52652 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728247AbeJLSZr (ORCPT ); Fri, 12 Oct 2018 14:25:47 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181012105354euoutp0294299b2c3d3aaec65b13111e16a46074~c1w_DOQbD0655906559euoutp02k; Fri, 12 Oct 2018 10:53:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181012105354euoutp0294299b2c3d3aaec65b13111e16a46074~c1w_DOQbD0655906559euoutp02k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539341634; bh=Gc2JVfVaPPVGk0hX2sTaCEsnRIvUue88zqyIpU7PziQ=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=CvEguTHJmVsXyWNeBTeJkBVFN5lUu9PSlxzP6boqqQIaDWTVunV6k+ySrMICAsdXO NhrpkwNbvVdX1LTyqX8nU233z91G2Gg3G25cU06wTo7GHCj2pGpH73NoCV6vu8fykj TsXJ3FF8bWMjeWSjFNd3736RGeGtRYfMSLyh993k= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105353eucas1p1d684b5e87f9b971b806e478cf734a2b2~c1w9mP0JD1269812698eucas1p1l; Fri, 12 Oct 2018 10:53:53 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 5D.74.04441.14D70CB5; Fri, 12 Oct 2018 11:53:53 +0100 (BST) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20181012105353eucas1p1ef92f1f906411cc4bb09be3825795bbf~c1w88O_hP1533115331eucas1p1H; Fri, 12 Oct 2018 10:53:53 +0000 (GMT) X-AuditID: cbfec7f2-a1ae89c000001159-bd-5bc07d4189d2 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id C8.0B.04128.14D70CB5; Fri, 12 Oct 2018 11:53:53 +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:53 +0100 (BST) 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: Fri, 12 Oct 2018 12:53:46 +0200 Message-id: <20181012105346.3754-7-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+NgFprFIsWRmVeSWpSXmKPExsWy7djPc7qOtQeiDe5NVbC4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg ylizrZW54HRsxfSvJ1kaGK/7dTFyckgImEjs/vSXrYuRi0NIYAWjxKZPe1ghnM+MEk++97HC VJ2etAKqahmjxOcJpxkhnP+MEt3zb7OAVLEJaEr83XyTDcQWEVCWWLWvnR2kiFngEqPE65Pd jCAJYQF7iRVvXwMVcXCwCKhKfFzBCGLyCphL3P8pA7FMXuLh8Xawak4BC4ll9w6ygIyREPjI KtHdt5AdoshFYuXbS4wQtrDEq+NboOIyEpcnd7NA2PUSTTOvMEM0dzBKnFi8nA0iYS1x+PhF sNeYBfgkJm2bzgxyhIQAr0RHmxBEiYdE34SlUE92M0pMW3iWbQKj5AJGhlWM4qmlxbnpqcWG eanlesWJucWleel6yfm5mxiBMXb63/FPOxi/Xko6xCjAwajEw7ugf3+0EGtiWXFl7iFGCQ5m JRHeBVkHooV4UxIrq1KL8uOLSnNSiw8xSnOwKInzLpu3MVpIID2xJDU7NbUgtQgmy8TBKdXA OMuqVO99RG2CUlVc0f0fxxI+P73TM/2o5SUhh3uftP9qlW6Okr3Csj255rH8XJtd4S8uLvvp tuvCpivOxTWt+6X2lKx4WLQ1cuUhczcWO68uk9UsjKuX2C78tudrD0PJ90XWM2MXmbA/vdbz rXPWWTdHgYKTt1rEld8vWPx619bnEcszni1b8FuJpTgj0VCLuag4EQC58YkVrQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOJMWRmVeSWpSXmKPExsVy+t/xq7qOtQeiDQ6sYrK4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7isklJzcksSy3St0vg ylizrZW54HRsxfSvJ1kaGK/7dTFyckgImEicnrSCrYuRi0NIYAmjxM7fq1ghnEYmif4rDxhB qtgENCX+br7JBmKLCChLrNrXzg5SxCxwhVGi/VsXO0hCWMBeYsXb10BFHBwsAqoSH1cwgpi8 AuYS93/KQCyTl3h4vB1sJKeAhcSyewdZQGwhoJKD8y6zTGDkWcDIsIpRJLW0ODc9t9hIrzgx t7g0L10vOT93EyMwOLYd+7llB2PXu+BDjAIcjEo8vD8m7o8WYk0sK67MPcQowcGsJMK7IOtA tBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHe8waVUUIC6YklqdmpqQWpRTBZJg5OqQbGSekORSIH 1nP/KDnBLtPSGBsgyVYQsM2iRFjfwefulMib6b11s9P2uC5j/JT9ettd966wRNdDWw46NR7h EKxatHH21GClW6uzpecK3PUwU+njuaUo32lU3W+4dX4uz+80+YmJ21ddfRPPLCsc5vKlquqr 8aXlaWs0+aIcXXje9z2/IOax2EGJpTgj0VCLuag4EQB20lm3CgIAAA== X-CMS-MailID: 20181012105353eucas1p1ef92f1f906411cc4bb09be3825795bbf X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181012105353eucas1p1ef92f1f906411cc4bb09be3825795bbf References: <20181012105346.3754-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 | 139 ++++++++++++++++++-- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 147 ---------------------- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 50 -------- 4 files changed, 128 insertions(+), 209 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..3432c5ee9f0c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dma.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c @@ -1,27 +1,138 @@ // 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 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_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) { struct exynos_drm_private *priv = drm->dev_private; - int ret; if (!priv->dma_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)) + return 0; + + if (!priv->mapping) { + void *mapping; + + if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) + mapping = arm_iommu_create_mapping(&platform_bus_type, + EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); + else if (IS_ENABLED(CONFIG_IOMMU_DMA)) + mapping = iommu_get_domain_for_dev(priv->dma_dev); + + if (IS_ERR(mapping)) + return PTR_ERR(mapping); + priv->mapping = mapping; } return drm_iommu_attach_device(drm, dev); @@ -35,6 +146,12 @@ void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev) void exynos_drm_cleanup_dma(struct drm_device *drm) { - if (IS_ENABLED(CONFIG_EXYNOS_IOMMU)) - drm_release_iommu_mapping(drm); + struct exynos_drm_private *priv = drm->dev_private; + + if (!IS_ENABLED(CONFIG_EXYNOS_IOMMU)) + return; + + arm_iommu_release_mapping(priv->mapping); + priv->mapping = NULL; + priv->dma_dev = NULL; } 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 14558dedc043..000000000000 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ /dev/null @@ -1,147 +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 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_get_domain_for_dev(priv->dma_dev); - - 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; - - arm_iommu_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