From patchwork Tue Sep 25 08:23:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10613621 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 818D91805 for ; Tue, 25 Sep 2018 08:23:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 734BE29A1C for ; Tue, 25 Sep 2018 08:23:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6797429A23; Tue, 25 Sep 2018 08:23:20 +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 76B7C29A34 for ; Tue, 25 Sep 2018 08:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726660AbeIYO3m (ORCPT ); Tue, 25 Sep 2018 10:29:42 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:45456 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726031AbeIYO3l (ORCPT ); Tue, 25 Sep 2018 10:29:41 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180925082315euoutp01cb276269e74737095f4bde3bbdfe0b04~XlvlLPOhq2110221102euoutp01V for ; Tue, 25 Sep 2018 08:23:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180925082315euoutp01cb276269e74737095f4bde3bbdfe0b04~XlvlLPOhq2110221102euoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537863795; bh=TAg6N48phcgoWToc/Sl3U6H0n2IhhiRGK0KUlhUkfoQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jeAzbBhG0PggKUNmtq4KbawJ8+n+DQ1L8mt2OKRfbdKO1A3S4NP4diqOcKjWE1e6q JO/GmcdrHTz5nBGGSrPw4ZNGrfMooYPl0h4i4ZqK0DppoDbF3mDFymHDms6H3oX4ok tEv7N67JTyQbLEYzFpocw4c6sewuzdXXZT+ZyYEg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180925082314eucas1p2c8ec70895a603890fbb547e8ceaa7c28~XlvkhC5Ao0683206832eucas1p23; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 78.0A.04441.270F9AB5; Tue, 25 Sep 2018 09:23:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180925082313eucas1p158f750a4ee64b09cb9e15d6f65749ef5~Xlvjritai0653506535eucas1p1m; Tue, 25 Sep 2018 08:23:13 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180925082313eusmtrp17bde2d443bfbbe45bb0efcabf62ddef4~XlvjaYZis2406924069eusmtrp1U; Tue, 25 Sep 2018 08:23:13 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-3c-5ba9f0720172 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C0.D8.04284.170F9AB5; Tue, 25 Sep 2018 09:23:13 +0100 (BST) Received: from AMDC2768.DIGITAL.local (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180925082312eusmtip172e28c26e2c732e2d3df074a12a35113~XlvjGXgTV1179111791eusmtip1b; Tue, 25 Sep 2018 08:23:12 +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 1/6] drm/exynos: simplify DMA mapping Date: Tue, 25 Sep 2018 10:23:03 +0200 X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180925082308.1388-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFIsWRmVeSWpSXmKPExsWy7djP87pFH1ZGG0xdwWNxa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBzFZZOSmpNZllqkb5fA lTH/4y+2gp/BFbtPvmNpYDzl3sXIwSEhYCLRvL6qi5GLQ0hgBaNE755DbBDOF0aJ1mdbmSGc z4wSa5ZOZO9i5ATreLVhOwuILSSwnFFi0h4jCBuoY+UjUxCbTUBT4u/mm2wgtoiAssSqfe3s IIOYBS4xSrw+2c0IslpYwFTi7U0/kBoWAVWJm1OXsUHMl5d4eLydEcTmFLCQuNxwlRGkV0Lg NpvEl/61YEW8AmUS3XcPsUA0uEjcmnUO6jhhiVfHt0DZMhKnJ/dA1dRLNM28wgwxqINR4sTi 5VDbrCUOH7/ICnIQM9DV63fpQ4QdJZYs28YCCSI+iRtvBUHCzEDmpG3TmSHCvBIdbUIQ1YoS 98+CwgrEFpdYeuEr1HAPiSNr9jJCwrAbGIbrJrNOYJSfhbBsASPjKkbx1NLi3PTUYsO81HK9 4sTc4tK8dL3k/NxNjMAUcPrf8U87GL9eSjrEKMDBqMTDa/ByRbQQa2JZcWXuIUYJDmYlEd4m 3ZXRQrwpiZVVqUX58UWlOanFhxilOViUxHn5tNKihQTSE0tSs1NTC1KLYLJMHJxSDYxu9Ymt F0JvtM3asagvMc7lo2wrb7unb+W1aVeLT5yccO2A9+2KJX/P7pJSajzjVt6omv/laMzzZsdk Adf+rH2Olj88ciWnVqqtDg2uM7ks81FfKy+wIdHwFltes2rER93mGeX2ihoVBhmPZt3iy0z/ mNz+Ncbfjsmj4a6DqrlzsdXqvbsilFiKMxINtZiLihMBFwUFfP0CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHLMWRmVeSWpSXmKPExsVy+t/xu7qFH1ZGG+ztELK4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7SsynKLy1JVcjILy6x VYo2tDDSM7S00DMysdQzNDaPtTIyVdK3s0lJzcksSy3St0vQy5j/8Rdbwc/git0n37E0MJ5y 72Lk5JAQMJF4tWE7SxcjF4eQwFJGiY1dl1ghEuISu+e/ZYawhSX+XOtigyj6xCgxq+UJI0iC TUBT4u/mm2wgtoiAssSqfe3sIEXMAtcYJfav+wQ0loNDWMBU4u1NP5AaFgFViZtTl4HV8wqY Szz98pkJYoG8xMPj7WAzOQUsJC43XAWzhYBqjvReYJ7AyLeAkWEVo0hqaXFuem6xoV5xYm5x aV66XnJ+7iZGYFhuO/Zz8w7GSxuDDzEKcDAq8fDeeLYiWog1say4MvcQowQHs5IIb5Puymgh 3pTEyqrUovz4otKc1OJDjKZAR01klhJNzgfGTF5JvKGpobmFpaG5sbmxmYWSOO95g8ooIYH0 xJLU7NTUgtQimD4mDk6pBkYZcwUPnXMy21YF+V/fHFeRIZhy9YTV8c96Ec79ywRfqpyzYuRU DJ35cPGHkk01ayRkxX/E+oX5HS59whgvZC3t5/b4X+fNSU9FmZWnaywuXGnD3JTe5jb106el 9ZFa6kcWdAboyUtVeNY59J4zVJgz9czL02c89AxmHluz9JSSaWYyj9uN9UosxRmJhlrMRcWJ AHQtCVRhAgAA Message-Id: <20180925082313eucas1p158f750a4ee64b09cb9e15d6f65749ef5~Xlvjritai0653506535eucas1p1m@eucas1p1.samsung.com> X-CMS-MailID: 20180925082313eucas1p158f750a4ee64b09cb9e15d6f65749ef5 X-Msg-Generator: CA X-RootMTR: 20180925082313eucas1p158f750a4ee64b09cb9e15d6f65749ef5 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180925082313eucas1p158f750a4ee64b09cb9e15d6f65749ef5 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 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 b599f74692e5..bc20fb1b26e1 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; @@ -197,8 +218,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) @@ -209,16 +229,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 @@ -289,27 +309,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; @@ -334,23 +333,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); @@ -408,7 +390,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 c737c4bd2c19..583b7d794aca 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -214,6 +214,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 7ba414b52faa..b1e312c01195 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c @@ -1164,7 +1164,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 0ddb6eec7b11..40fe1abbdcb1 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_scaler.c +++ b/drivers/gpu/drm/exynos/exynos_drm_scaler.c @@ -455,7 +455,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 ffbf4a950f69..5baf7c39d901 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -856,7 +856,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 Tue Sep 25 08:23:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10613617 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 2D1781803 for ; Tue, 25 Sep 2018 08:23:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2193129A1C for ; Tue, 25 Sep 2018 08:23:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1628D29A43; Tue, 25 Sep 2018 08:23:20 +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 9889E29A3E for ; Tue, 25 Sep 2018 08:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726031AbeIYO3m (ORCPT ); Tue, 25 Sep 2018 10:29:42 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:55654 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726392AbeIYO3m (ORCPT ); Tue, 25 Sep 2018 10:29:42 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180925082315euoutp0218420d650cc36ec212df34bef223d893~XlvlRgilQ0788707887euoutp02R for ; Tue, 25 Sep 2018 08:23:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180925082315euoutp0218420d650cc36ec212df34bef223d893~XlvlRgilQ0788707887euoutp02R DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537863795; bh=b2WUxzsnADL5pctIj4OAP4oSvq7AafV5FXZUxdvbIec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tTgH6x0M69HP++asxGs2H5m42vmPqLHptovpfU5NP7q7/VIir5CqKEV+0NfFzkt3y U+GAfsyL6pl6JWgPOW98wTqZHHvSCNhwVST0XxanfmvSS0RrMnVXwwGLptxU6Wnc62 1O7Fo8crI6vz3GJ0CUfUpPFX/DBFUwGh4AS+wK7k= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180925082314eucas1p232ccd6c033d38f92fb49638e2a9aaa34~Xlvkt91yC0497704977eucas1p2B; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id CC.C7.04294.270F9AB5; Tue, 25 Sep 2018 09:23:14 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180925082313eucas1p1083f693e9e1bca5b921c9d3b26ffcac2~XlvjzWDNh0543005430eucas1p19; Tue, 25 Sep 2018 08:23:13 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180925082313eusmtrp15ce120c1dc732475f57582cb91b6bb19~XlvjyMQC12406924069eusmtrp1V; Tue, 25 Sep 2018 08:23:13 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-df-5ba9f0726670 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 31.D8.04284.170F9AB5; Tue, 25 Sep 2018 09:23:13 +0100 (BST) Received: from AMDC2768.DIGITAL.local (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180925082313eusmtip14897eb573630b306bc57650bfd9b674b~XlvjaEdZ31347313473eusmtip1X; Tue, 25 Sep 2018 08:23:13 +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 2/6] drm/exynos/iommu: remove DRM_EXYNOS_IOMMU Kconfig symbol Date: Tue, 25 Sep 2018 10:23:04 +0200 X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180925082308.1388-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsWy7djP87pFH1ZGG5w8Jm5xa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBzFZZOSmpNZllqkb5fA lbFo0yOmghb+ii8vRBsYO3i7GDk5JARMJF7teMDSxcjFISSwglHi8oQTzBDOF0aJnd1noZzP jBJz771kg2nZuesxG0RiOaPEq82rEVqO7D/KCFLFJqAp8XfzTbAOEQFliVX72tlBipgFLjFK vD7ZDVTEwSEs4C+x5oAuSA2LgKrE77YrUBvkJR4ebwebwylgIXG54SojSK+EwG02iVfff7CC 9PIKlEls6a6CqHeR+L1iHyuELSzx6vgWdghbRuL05B4WCLteomnmFWaIOR2MEicWL4daZi1x +PhFsJnMQEev36UPEXaUuPynhxkkLCHAJ3HjrSBImBnInLRtOlSYV6KjTQiiWlHi/tmtzBC2 uMTSC1+hhntILP+9lgkSPN2MEvsnTGafwCg/C2HZAkbGVYziqaXFuempxUZ5qeV6xYm5xaV5 6XrJ+bmbGIFJ4PS/4192MO76k3SIUYCDUYmH1+Dlimgh1sSy4srcQ4wSHMxKIrxNuiujhXhT EiurUovy44tKc1KLDzFKc7AoifPyaaVFCwmkJ5akZqemFqQWwWSZODilGhj9vhso3M9avaL7 /pfvMXezyk/MOafnruZ+Kkmb7VREUIDP31xOlUh918O1oddaj4XklIXGaj+9p90kcv/7fEfh 9j4dHj+WH7yMfW9u37V1rlxaO/Hu3vj589WuPiqV+3Dj2Y11uvwT/93aIN//xfhS4K4GC/Y1 k6U/2vb31j78dp7xl/nVwDQlluKMREMt5qLiRABbh2mr/gIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLLMWRmVeSWpSXmKPExsVy+t/xu7qFH1ZGG3T2qVncWneO1WLjjPWs Fle+vmezmHR/AovFjPP7mCzWHrnL7sDmcb/7OJNH35ZVjB6fN8kFMEfp2RTll5akKmTkF5fY KkUbWhjpGVpa6BmZWOoZGpvHWhmZKunb2aSk5mSWpRbp2yXoZSza9IipoIW/4ssL0QbGDt4u Rk4OCQETiZ27HrN1MXJxCAksZZTY/3UGK0RCXGL3/LfMELawxJ9rXVBFnxgl+jbuBStiE9CU +Lv5JhuILSKgLLFqXzs7SBGzwDWgSes+sXQxcnAIC/hKLH1uDVLDIqAq8bvtClg9r4C5xL2e xVDL5CUeHm9nBLE5BSwkLjdcBbOFgGqO9F5gnsDIt4CRYRWjSGppcW56brGhXnFibnFpXrpe cn7uJkZgUG479nPzDsZLG4MPMQpwMCrx8N54tiJaiDWxrLgy9xCjBAezkghvk+7KaCHelMTK qtSi/Pii0pzU4kOMpkBHTWSWEk3OB0ZMXkm8oamhuYWlobmxubGZhZI473mDyighgfTEktTs 1NSC1CKYPiYOTqkGRoGv+hoCnudmCF5OOPUz7qreXqY/qssEBa2Wi58q6Nt/lCV5WbR41MSL +pMzzVb2nrd5Lrr+aPedP1ZXzhSH/A3jmCAZ9fLaq0yXcHE+c7PH51+li865rvL/+KzD7Wsn z1Z+dzqopDf8mOizL+4vJvn+fbxNmP1IwLW4jVGxNxPz3tx3nLnESEiJpTgj0VCLuag4EQCP ohdiYAIAAA== Message-Id: <20180925082313eucas1p1083f693e9e1bca5b921c9d3b26ffcac2~XlvjzWDNh0543005430eucas1p19@eucas1p1.samsung.com> X-CMS-MailID: 20180925082313eucas1p1083f693e9e1bca5b921c9d3b26ffcac2 X-Msg-Generator: CA X-RootMTR: 20180925082313eucas1p1083f693e9e1bca5b921c9d3b26ffcac2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180925082313eucas1p1083f693e9e1bca5b921c9d3b26ffcac2 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 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 87f6b5672e11..84f4e6d23bc4 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 Tue Sep 25 08:23:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10613625 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 4C3DC13A4 for ; Tue, 25 Sep 2018 08:23:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EC3A298B3 for ; Tue, 25 Sep 2018 08:23:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 326DC29A34; Tue, 25 Sep 2018 08:23:21 +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 8948C298B3 for ; Tue, 25 Sep 2018 08:23:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727531AbeIYO3l (ORCPT ); Tue, 25 Sep 2018 10:29:41 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:45464 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbeIYO3l (ORCPT ); Tue, 25 Sep 2018 10:29:41 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180925082316euoutp01d74cbc9b384a587af7f75b5c1c034cfd~Xlvl8gmib2046120461euoutp01b for ; Tue, 25 Sep 2018 08:23:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180925082316euoutp01d74cbc9b384a587af7f75b5c1c034cfd~Xlvl8gmib2046120461euoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537863796; bh=m4uaaZJGZwelOi/v5wckP3rLcFQGT1UBFJ76AQngkss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SMOdN2g5z252WXLV7Ad64yz79jiXhKusf7I6d/AO5JYEZA8ZyihYkHaTQW9kSWkFr Vms3XJvJi+XDgtKRSge7jM4uQrjsXhBpwNMErZ4DAX7HkfPlRbx4UbybHnBAf73vVv Hg/LGuYWFyI6JA6tH9tquO6R5Gz+15ToSjn4McQM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180925082315eucas1p1a91166c610d61ffdcccca63258f65b13~XlvlW9PwN1260012600eucas1p1W; Tue, 25 Sep 2018 08:23:15 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 39.0A.04441.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 20180925082314eucas1p1056cf03877de6110a6b97f4652944d6f~XlvkbEK7P0327803278eucas1p1A; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180925082314eusmtrp12c2da62122b203e675d7045e99546e3e~XlvkKJhLH2383123831eusmtrp1v; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-40-5ba9f0732d48 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C1.D8.04284.270F9AB5; Tue, 25 Sep 2018 09:23:14 +0100 (BST) Received: from AMDC2768.DIGITAL.local (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180925082313eusmtip1e22ce05e66543013151704682f690104~XlvjyVyr61179111791eusmtip1d; Tue, 25 Sep 2018 08:23:13 +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 3/6] drm/exynos/iommu: integrate IOMMU/DMA internal API Date: Tue, 25 Sep 2018 10:23:05 +0200 X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180925082308.1388-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJIsWRmVeSWpSXmKPExsWy7djP87rFH1ZGGxzexWxxa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBzFZZOSmpNZllqkb5fA lXGt5xRLwaXyimWHLzA3MP5J62Lk4JAQMJGYdMq+i5GTQ0hgBaPElhbxLkYuIPsLo8SnC3/Z IZzPjBI7fjcwgVSBNBz7sJ8ZomM5o8SRCaFwHU9vdoIl2AQ0Jf5uvskGYosIKEus2tcONolZ 4BKjxOuT3YwgCWEBd4mbZ46ygNgsAqoS6/6tYIfYIC/x8Hg7WA2ngIXE5YarjCDNEgK32SQ2 /j3GBnI3r0CZxPULIRD1LhLzN22C6hWWeHV8C5QtI3F6cg8LhF0v0TTzCjPEnA5GiROLl7NB JKwlDh+/yAoykxno6vW79CHB4ihxAyIqIcAnceOtIEgxM5A5adt0Zogwr0RHmxDEDEWJ+2e3 MkPY4hJLL3yFmu0hsejRWWZI8HQzSrzZ8Il9AqP8LIRdCxgZVzGKp5YW56anFhvmpZbrFSfm Fpfmpesl5+duYgQmgNP/jn/awfj1UtIhRgEORiUeXoOXK6KFWBPLiitzDzFKcDArifA26a6M FuJNSaysSi3Kjy8qzUktPsQozcGiJM7Lp5UWLSSQnliSmp2aWpBaBJNl4uCUamB0LDpfeL2z PN6q+5mRndOGj5GsbKbBbXprDxUphP1LVJ1hFsLMs1D8qL129JR8T3kJ8ez/Ad7zmD45bF95 x/ZdwM1Sxd07gmdFWhxqt+fcfGx/xlq9y7x3Y6Tdz1gzCS2v3/V/VcoKvussvZ9e7piQ+FNp 9tekDr0zE47f0purt+5Wzrm+2flKLMUZiYZazEXFiQCErf2k/AIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t/xu7pFH1ZGG1x5yGxxa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBylZ1OUX1qSqpCRX1xi qxRtaGGkZ2hpoWdkYqlnaGwea2VkqqRvZ5OSmpNZllqkb5egl3Gt5xRLwaXyimWHLzA3MP5J 62Lk5JAQMJE49mE/cxcjF4eQwFJGiZOdh5khEuISu+e/hbKFJf5c62KDKPrEKHG0/zEbSIJN QFPi7+abYLaIgLLEqn3t7CBFzALXGCX2r/vEApIQFnCXuHnmKJjNIqAqse7fCnYQm1fAXGLL i4lsEBvkJR4eb2cEsTkFLCQuN1wFs4WAao70XmCewMi3gJFhFaNIamlxbnpusaFecWJucWle ul5yfu4mRmBgbjv2c/MOxksbgw8xCnAwKvHw3ni2IlqINbGsuDL3EKMEB7OSCG+T7spoId6U xMqq1KL8+KLSnNTiQ4ymQEdNZJYSTc4HRk1eSbyhqaG5haWhubG5sZmFkjjveYPKKCGB9MSS 1OzU1ILUIpg+Jg5OqQZG8bNPpz7w5L+ZzrMuV6e+f+Ela4srwstsDERKN0Zt7P3g7DGv5t3N Ryt1z/+OCH699/dpif4jj7/LH8ufzsMzK1JgseplvwN+K2bz1sW8eOXY8Na2at5Uj5KrlUmf N8UvVbF+VvJtE9faOpVfDOePlEz59DdLS3Zjr3D3XmneMga/W68V867IKrEUZyQaajEXFScC ACNXEo5iAgAA Message-Id: <20180925082314eucas1p1056cf03877de6110a6b97f4652944d6f~XlvkbEK7P0327803278eucas1p1A@eucas1p1.samsung.com> X-CMS-MailID: 20180925082314eucas1p1056cf03877de6110a6b97f4652944d6f X-Msg-Generator: CA X-RootMTR: 20180925082314eucas1p1056cf03877de6110a6b97f4652944d6f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180925082314eucas1p1056cf03877de6110a6b97f4652944d6f 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 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 bc20fb1b26e1..cb5d0e395883 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; @@ -389,7 +367,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); @@ -408,7 +386,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 583b7d794aca..e4b7f8f89058 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -214,7 +214,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 132dd52d0ac7..bd7e53064097 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 b1e312c01195..d3cf696b9057 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" /* @@ -1184,7 +1183,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 84f4e6d23bc4..95648b0c8327 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h @@ -118,13 +118,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) @@ -147,10 +140,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 40fe1abbdcb1..67b8a8986cd7 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)) @@ -476,7 +475,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 5baf7c39d901..1df2de62f718 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 @@ -861,7 +860,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 Tue Sep 25 08:23:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10613619 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 4308213A4 for ; Tue, 25 Sep 2018 08:23:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3366629A1C for ; Tue, 25 Sep 2018 08:23:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2855C29A49; Tue, 25 Sep 2018 08:23:20 +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 1B0D029A23 for ; Tue, 25 Sep 2018 08:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbeIYO3m (ORCPT ); Tue, 25 Sep 2018 10:29:42 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:55660 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727341AbeIYO3l (ORCPT ); Tue, 25 Sep 2018 10:29:41 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180925082315euoutp02a43a72a9144a213e6c12c1f64d7b15eb~Xlvl3AQPh0785607856euoutp02X for ; Tue, 25 Sep 2018 08:23:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180925082315euoutp02a43a72a9144a213e6c12c1f64d7b15eb~Xlvl3AQPh0785607856euoutp02X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537863795; bh=pjaXyudCRpwKvkYFuXQYSEelUH8phxt/VB9GfkukTEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ePfsyXL85lNTTPnZ18vLTkgzxWPY4e1b7YYUP0r+S7NMKxwvychqT2qb9fYBsmrGb /aZmxD5EuxtJRJTVJLDlkcgTxp5o/iiiEiB/5m629DZ03kunqEWWgkVGRfbID7E/XH uoAzowSD+Trghes0o0zde2T2EQGlhf2SSZw2Nrzk= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180925082315eucas1p1eaad81fdcbcca8a2e924526fc7c3349e~XlvlW_Vua0653506535eucas1p1o; Tue, 25 Sep 2018 08:23:15 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id FD.C7.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 20180925082314eucas1p1add4ccbe8fad7985c1d47098129cdc5c~XlvkdSE-C0768807688eucas1p1m; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180925082314eusmtrp155b28c1a6d657128259e69e80f0df73c~XlvkcAdqb2383123831eusmtrp1y; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) X-AuditID: cbfec7f4-84fff700000010c6-e4-5ba9f073368b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 52.D8.04284.270F9AB5; Tue, 25 Sep 2018 09:23:14 +0100 (BST) Received: from AMDC2768.DIGITAL.local (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180925082314eusmtip14ebfe562e9a4d7b1a68f4857e3fbd711~XlvkI9B1k1347613476eusmtip1S; 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 4/6] drm/exynos/iommu: move IOMMU specific stuff into exynos_drm_iommu.c Date: Tue, 25 Sep 2018 10:23:06 +0200 X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180925082308.1388-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNIsWRmVeSWpSXmKPExsWy7djP87rFH1ZGG7x5xGRxa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBzFZZOSmpNZllqkb5fA lfH61062gtN6FavanrA2MO5W72Lk4JAQMJHY9Ceii5GLQ0hgBaPElVOn2LsYOYGcL4wSqz55 QyQ+M0p0PVrFCJIAaVj66SwTRGI5o0TPyomMEA5QR+PjV2BVbAKaEn8332QDsUUElCVW7Wtn ByliFrjEKPH6ZDdYkbBAlMSX5hNMIDaLgKrE3ZXrWCFWyEs8PN4OVsMpYCFxueEq2AYJgfts Ekev3mUGOZxXoEzi02luiHoXiaZJ7ewQtrDEq+NboGwZidOTe1gg7HqJpplXmCHmdDBKnFi8 nA0iYS1x+PhFVpCZzEBXr9+lDxF2lOj9uY4ZEkZ8EjfeCoKEmYHMSdumQ4V5JTrahCCqFSXu n93KDGGLSyy98BVquIfEv9XToeHTzShx/koH+wRG+VkIyxYwMq5iFE8tLc5NTy02ykst1ytO zC0uzUvXS87P3cQITAKn/x3/soNx15+kQ4wCHIxKPLwGL1dEC7EmlhVX5h5ilOBgVhLhbdJd GS3Em5JYWZValB9fVJqTWnyIUZqDRUmcl08rLVpIID2xJDU7NbUgtQgmy8TBKdXAqGC1t/yK Scv3H0Kf/crPnr2YsObSLuN1KgHS7e7WgdrFefViXw6uYjZQnGr9yd3pmrt8sk53B4NR0HyR efvsalxzn2dlmyzhF9TiFTP0Oca97qoQ88u2OTZvuP6wWyi+eB0k/0FcOpj/oobXGckt7rqm WvKu9k4RrI4Bh49abV7v/mWPO5sSS3FGoqEWc1FxIgBmIOXA/gIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t/xu7pFH1ZGG5zslrS4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7SsynKLy1JVcjILy6x VYo2tDDSM7S00DMysdQzNDaPtTIyVdK3s0lJzcksSy3St0vQy3j9aydbwWm9ilVtT1gbGHer dzFyckgImEgs/XSWqYuRi0NIYCmjxJ6eeawQCXGJ3fPfMkPYwhJ/rnWxQRR9YpT483ItE0iC TUBT4u/mm2wgtoiAssSqfe3sIEXMAtcYJfav+8QCkhAWiJC40PMBrIFFQFXi7sp1YBt4Bcwl 5n3vYoTYIC/x8Hg7mM0pYCFxueEqmC0EVHOk9wLzBEa+BYwMqxhFUkuLc9Nziw31ihNzi0vz 0vWS83M3MQIDc9uxn5t3MF7aGHyIUYCDUYmH98azFdFCrIllxZW5hxglOJiVRHibdFdGC/Gm JFZWpRblxxeV5qQWH2I0BTpqIrOUaHI+MGrySuINTQ3NLSwNzY3Njc0slMR5zxtURgkJpCeW pGanphakFsH0MXFwSjUw2hsJLvuisLt/ZYtuSQWP1TdxrUd5rXlGc2+biAV/PvLii8OFHL6j iQ+UTBeYn/B8+uXG+7s9m0rKr8nJhDhc/PxlxRmX/VNu/vqY16a8e5XBifkfDvu7KwbV3590 uct4I+upph0Wutem1/xY1PvlS9hJjVX3Aipudax/sPjprdqVT/5LuFoeLFFiKc5INNRiLipO BABeZfKnYgIAAA== Message-Id: <20180925082314eucas1p1add4ccbe8fad7985c1d47098129cdc5c~XlvkdSE-C0768807688eucas1p1m@eucas1p1.samsung.com> X-CMS-MailID: 20180925082314eucas1p1add4ccbe8fad7985c1d47098129cdc5c X-Msg-Generator: CA X-RootMTR: 20180925082314eucas1p1add4ccbe8fad7985c1d47098129cdc5c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180925082314eucas1p1add4ccbe8fad7985c1d47098129cdc5c 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 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 | 94 +++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_iommu.h | 94 ----------------------- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.c b/drivers/gpu/drm/exynos/exynos_drm_iommu.c index 0f373702414e..96df5819fd52 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.c @@ -18,6 +18,100 @@ #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) +{ + struct iommu_domain *domain; + int ret; + + domain = iommu_domain_alloc(priv->dma_dev->bus); + if (!domain) + return -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; + + priv->mapping = domain; + return 0; + +put_cookie: + iommu_put_dma_cookie(domain); +free_domain: + iommu_domain_free(domain); + return ret; +} + +static inline void __exynos_iommu_release_mapping(struct exynos_drm_private *priv) +{ + struct iommu_domain *domain = priv->mapping; + + iommu_put_dma_cookie(domain); + iommu_domain_free(domain); + priv->mapping = NULL; +} + +static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, + struct device *dev) +{ + struct iommu_domain *domain = priv->mapping; + + return iommu_attach_device(domain, dev); +} + +static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, + struct device *dev) +{ + struct iommu_domain *domain = priv->mapping; + + 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 95648b0c8327..5eaec41514b4 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h @@ -12,102 +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) -{ - struct iommu_domain *domain; - int ret; - - domain = iommu_domain_alloc(priv->dma_dev->bus); - if (!domain) - return -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; - - priv->mapping = domain; - return 0; - -put_cookie: - iommu_put_dma_cookie(domain); -free_domain: - iommu_domain_free(domain); - return ret; -} - -static inline void __exynos_iommu_release_mapping(struct exynos_drm_private *priv) -{ - struct iommu_domain *domain = priv->mapping; - - iommu_put_dma_cookie(domain); - iommu_domain_free(domain); - priv->mapping = NULL; -} - -static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, - struct device *dev) -{ - struct iommu_domain *domain = priv->mapping; - - return iommu_attach_device(domain, dev); -} - -static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, - struct device *dev) -{ - struct iommu_domain *domain = priv->mapping; - - 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 Tue Sep 25 08:23:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10613627 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 857C3161F for ; Tue, 25 Sep 2018 08:23:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7999F298B3 for ; Tue, 25 Sep 2018 08:23:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E2CB29A02; Tue, 25 Sep 2018 08:23:21 +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 564A829A31 for ; Tue, 25 Sep 2018 08:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727341AbeIYO3m (ORCPT ); Tue, 25 Sep 2018 10:29:42 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:55666 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726660AbeIYO3l (ORCPT ); Tue, 25 Sep 2018 10:29:41 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180925082316euoutp02cc922f285e59fe3f2cd3688a32b0e071~XlvmNnXGs0785607856euoutp02Y for ; Tue, 25 Sep 2018 08:23:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180925082316euoutp02cc922f285e59fe3f2cd3688a32b0e071~XlvmNnXGs0785607856euoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537863796; bh=4lVXsHh05TpkDYM1BIQ8eiHkDhsG/pMydInVQ6+GSQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UR1WxYVD/M7ltNGHqxQQXK69UxBuXsPOl4j4qG9RQY5eUAbJhAq5AhJJNaLPqvxIw 0CNf03sl5dvL49gTpgz7iXuPYqUopYAa5PfWvak3oEy6dPmbcDiHTf9SgD76R6FlBT zy2l25aXFD0By2HkyrA6PnSNy1hkDREWVT9GNJ9Y= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180925082315eucas1p2e11aaa559011cb584e4fb7aa23a8654c~XlvlpsCMy0046300463eucas1p2a; Tue, 25 Sep 2018 08:23:15 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 4C.54.04806.370F9AB5; Tue, 25 Sep 2018 09:23:15 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180925082314eucas1p27428784088ab6ccd9d6d11ce0ab5063e~Xlvk04UDJ0684006840eucas1p2J; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180925082314eusmtrp10fcc92f33c7b61b26a65cbad37e48ff7~XlvkzwYac2406924069eusmtrp1b; Tue, 25 Sep 2018 08:23:14 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-b9-5ba9f07392b8 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F2.D8.04284.270F9AB5; Tue, 25 Sep 2018 09:23:14 +0100 (BST) Received: from AMDC2768.DIGITAL.local (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180925082314eusmtip1517b12dcda2a7574ce7f0b7dc19be6ab~Xlvkci7e11372213722eusmtip1C; 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 5/6] drm/exynos/iommu: replace preprocessor conditionals with C conditionals Date: Tue, 25 Sep 2018 10:23:07 +0200 X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180925082308.1388-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDIsWRmVeSWpSXmKPExsWy7djPc7rFH1ZGG3ycIGFxa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBzFZZOSmpNZllqkb5fA lfF3YwtrwVvdiuWbprA1ML5U62Lk5JAQMJH4dK6XvYuRi0NIYAWjxJN/x5khnC+MEvcX/GGD cD4zSkzuu8cM09LyYiZU1XJGibfPJ7HDtUzY2MwOUsUmoCnxd/NNNhBbREBZYtW+drAiZoFL jBKvT3YzgiSEBeIk2v7OAWtgEVCVuNrxnQ1ihbzEw+PtYDWcAhYSlxuuMkLEb7NJLF/P0cXI wcErUCax9YUrRNhF4t/EBawQtrDEq+Nb2CFsGYnTk3tYIOx6iaaZV8CulhDoYJQ4sXg51C5r icPHL7KCzGQGOnr9Ln2IsKPEictbwMISAnwSN94KgoSZgcxJ26YzQ4R5JTrahCCqFSXun90K DR9xiaUXvkIN95BY9OkZNKy6GSWm3F3GOIFRfhbCsgWMjKsYxVNLi3PTU4uN81LL9YoTc4tL 89L1kvNzNzEC08Dpf8e/7mDc9yfpEKMAB6MSD++NZyuihVgTy4orcw8xSnAwK4nwNumujBbi TUmsrEotyo8vKs1JLT7EKM3BoiTOy6eVFi0kkJ5YkpqdmlqQWgSTZeLglGpgtIhxypnek53V s6CqxUrmw0mR/erNXXoNNju3s+05+GqjsO6V4qbSb5ec1je0bNVYx73ZaNZX3VlF0eUcQuVC LFc6C4wnLwvqCwzcPLs4nKnact/sWfWOr7dwTVr7IKRXt6G3MKerVuUm41GFKN7ZRbb6y14w hGiuDfi4+GFjpdZ/xjw/5zglluKMREMt5qLiRABdXBIT/wIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsVy+t/xu7pFH1ZGG0zs0rW4te4cq8XGGetZ La58fc9mMen+BBaLGef3MVmsPXKX3YHN4373cSaPvi2rGD0+b5ILYI7SsynKLy1JVcjILy6x VYo2tDDSM7S00DMysdQzNDaPtTIyVdK3s0lJzcksSy3St0vQy/i7sYW14K1uxfJNU9gaGF+q dTFyckgImEi0vJjJ3MXIxSEksJRR4kDLNnaIhLjE7vlvmSFsYYk/17rYIIo+MUp8OHOJDSTB JqAp8XfzTTBbREBZYtW+dnaQImaBa4wS+9d9YgFJCAvESLR+3Qc2iUVAVeJqx3ewBl4Bc4nn P/awQWyQl3h4vJ0RxOYUsJC43HAVzBYCqjnSe4F5AiPfAkaGVYwiqaXFuem5xYZ6xYm5xaV5 6XrJ+bmbGIGBue3Yz807GC9tDD7EKMDBqMTDe+PZimgh1sSy4srcQ4wSHMxKIrxNuiujhXhT EiurUovy44tKc1KLDzGaAh01kVlKNDkfGDV5JfGGpobmFpaG5sbmxmYWSuK85w0qo4QE0hNL UrNTUwtSi2D6mDg4pRoYXQ6dLV6hrsjnsptr7tPLUfPUdaXeZWf1O/iX/NESN7t2tkr8VfvF Fxfn9imy13w7uOsR55NpYZcv/WVU6NXpNm3+WyATUTG5SHCSxqS3uTyXQ3KXVbldOLSsfuap UtU5eqUebwXPmP9InOlzlM/+JveVa8vSbwqzx/xgvG5dNce68IC/jMETJZbijERDLeai4kQA ACJL02ICAAA= Message-Id: <20180925082314eucas1p27428784088ab6ccd9d6d11ce0ab5063e~Xlvk04UDJ0684006840eucas1p2J@eucas1p2.samsung.com> X-CMS-MailID: 20180925082314eucas1p27428784088ab6ccd9d6d11ce0ab5063e X-Msg-Generator: CA X-RootMTR: 20180925082314eucas1p27428784088ab6ccd9d6d11ce0ab5063e X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180925082314eucas1p27428784088ab6ccd9d6d11ce0ab5063e 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 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 | 114 +++++++++------------- 1 file changed, 47 insertions(+), 67 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.c b/drivers/gpu/drm/exynos/exynos_drm_iommu.c index 96df5819fd52..54ac262a95aa 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.c @@ -12,59 +12,39 @@ #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 +#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 -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); -} +#if !defined(CONFIG_IOMMU_DMA) +#define iommu_dma_init_domain(...) ({ -EINVAL; }) +#endif -#elif defined(CONFIG_IOMMU_DMA) -#include +#define EXYNOS_DEV_ADDR_START 0x20000000 +#define EXYNOS_DEV_ADDR_SIZE 0x40000000 -static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, - unsigned long start, unsigned long size) +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 -ENOMEM; + return ERR_PTR(-ENOMEM); ret = iommu_get_dma_cookie(domain); if (ret) @@ -74,43 +54,20 @@ static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv, if (ret) goto put_cookie; - priv->mapping = domain; - return 0; + return domain; put_cookie: iommu_put_dma_cookie(domain); free_domain: iommu_domain_free(domain); - return ret; + return ERR_PTR(ret); } -static inline void __exynos_iommu_release_mapping(struct exynos_drm_private *priv) +static inline void iommu_dma_release_mapping(struct iommu_domain *domain) { - struct iommu_domain *domain = priv->mapping; - iommu_put_dma_cookie(domain); iommu_domain_free(domain); - priv->mapping = NULL; -} - -static inline int __exynos_iommu_attach(struct exynos_drm_private *priv, - struct device *dev) -{ - struct iommu_domain *domain = priv->mapping; - - return iommu_attach_device(domain, dev); -} - -static inline void __exynos_iommu_detach(struct exynos_drm_private *priv, - struct device *dev) -{ - struct iommu_domain *domain = priv->mapping; - - 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) { @@ -138,8 +95,14 @@ 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_dma_create_mapping(priv, + EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE); + + return IS_ERR(priv->mapping); } /* @@ -151,7 +114,12 @@ void drm_release_iommu_mapping(struct drm_device *drm_dev) { struct exynos_drm_private *priv = drm_dev->dev_private; - __exynos_iommu_release_mapping(priv); + 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; } /* @@ -179,7 +147,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); @@ -200,6 +176,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 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