From patchwork Fri Sep 21 08:58:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10609377 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 9899D112B for ; Fri, 21 Sep 2018 08:59:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8843C2B174 for ; Fri, 21 Sep 2018 08:59:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BB992D874; Fri, 21 Sep 2018 08:59:03 +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 B701E2B174 for ; Fri, 21 Sep 2018 08:59:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388909AbeIUOqy (ORCPT ); Fri, 21 Sep 2018 10:46:54 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:36717 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732768AbeIUOqx (ORCPT ); Fri, 21 Sep 2018 10:46:53 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180921085859euoutp02dc3b60a14d30ab37f48eaa5bd46c99dc~WXppcCCCj1192611926euoutp02s for ; Fri, 21 Sep 2018 08:58:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180921085859euoutp02dc3b60a14d30ab37f48eaa5bd46c99dc~WXppcCCCj1192611926euoutp02s DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537520339; bh=LtuXpNOPNR2wRodPQwwU7fsEYij967Wtbwc1gbX+Cns=; h=From:To:Cc:Subject:Date:References:From; b=Sas5F/NGQMAZvThFRazxvoD+n2y/c4/njPOI4e4aUZekfb6h4LI00PDfxTKQnz2Ei 5cHrJt7BtjwwjCLGJTjtWS1KjV1erQ6K8lzDeK4sP6XCWYhqK2MyojEoUu+Ddyma3O JYqh/Ienyypp2elUQwvuDrL8rJBhH02pb88Ww+HA= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180921085858eucas1p1a0a8198409c687be44a3ff16b8169e68~WXpolrnwP2442824428eucas1p1s; Fri, 21 Sep 2018 08:58:58 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id DB.45.04441.2D2B4AB5; Fri, 21 Sep 2018 09:58:58 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180921085858eucas1p25807116d04d37d11a5296f44131c23f4~WXpntr8zL1932219322eucas1p2T; Fri, 21 Sep 2018 08:58:58 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180921085857eusmtrp2443d9c5ec7fb0a748a30fd3703c5b2f8~WXpncvbD92159021590eusmtrp2g; Fri, 21 Sep 2018 08:58:57 +0000 (GMT) X-AuditID: cbfec7f2-5e3ff70000001159-37-5ba4b2d2c57b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 14.DC.04128.1D2B4AB5; Fri, 21 Sep 2018 09:58:57 +0100 (BST) Received: from AMDC2768.DIGITAL.local (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180921085857eusmtip1848fab2ad2fb763f306d7ce62d164129~WXpnFfWLi0043700437eusmtip1u; Fri, 21 Sep 2018 08:58:57 +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] drm/exynos: simplify DMA mapping Date: Fri, 21 Sep 2018 10:58:40 +0200 X-Mailer: git-send-email 2.18.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsWy7djP87qXNi2JNujaqGxxa905VouNM9az Wlz5+p7NYtL9CSwWM87vY7JYe+QuuwObx/3u40wefVtWMXp83iQXwBzFZZOSmpNZllqkb5fA lbH84wyWgrUqFQ0nNBoYl8p1MXJySAiYSLxbd4u9i5GLQ0hgBaPE/ykfoJwvjBIXz19ihHA+ M0r8/d3DBtPy58VpFojEckaJma8/M4IkwFrufOYGsdkENCX+br4J1iAioCyxal872FhmgUuM Eq9PdoM1CAsYSjxecYYFxGYRUJX4vWkHE8QGeYmHx9vBVksIHGCTOLj2KVgRr0CZxO3OA1BF LhLNcx6zQtjCEq+Ob2GHsGUk/u+cD1VTL9E08wozxKAORokTi5dD/WAtcfj4RaBmDqCTNCXW 79KHCDtKTD6+iwUkLCHAJ3HjrSBImBnInLRtOjNEmFeio00IolpR4v7ZrcwQtrjE0gtfoYZ7 SLz5PJ0VEiaxEjuPLWefwCg3C2HXAkbGVYziqaXFuempxYZ5qeV6xYm5xaV56XrJ+bmbGIHR fvrf8U87GL9eSjrEKMDBqMTDa7B4cbQQa2JZcWXuIUYJDmYlEd59XUuihXhTEiurUovy44tK c1KLDzFKc7AoifPyaaVFCwmkJ5akZqemFqQWwWSZODilG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T@eucas1p2.samsung.com> X-CMS-MailID: 20180921085858eucas1p25807116d04d37d11a5296f44131c23f4 X-Msg-Generator: CA X-RootMTR: 20180921085858eucas1p25807116d04d37d11a5296f44131c23f4 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180921085858eucas1p25807116d04d37d11a5296f44131c23f4 References: 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. Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/exynos/exynos_drm_drv.c | 50 +++-------------------- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 13 +++++- 2 files changed, 17 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index b599f74692e5..c83437d8a595 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -197,8 +197,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 +208,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 +288,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 +312,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 +369,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_iommu.c b/drivers/gpu/drm/exynos/exynos_drm_iommu.c index 0f373702414e..bb8b800a9fba 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_iommu.c +++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.c @@ -75,7 +75,18 @@ int drm_iommu_attach_device(struct drm_device *drm_dev, struct exynos_drm_private *priv = drm_dev->dev_private; int ret; - if (get_dma_ops(priv->dma_dev) != get_dma_ops(subdrv_dev)) { + if (!priv->dma_dev) { + priv->dma_dev = subdrv_dev; + DRM_INFO("Exynos DRM: using %s device for DMA mapping operations\n", + dev_name(subdrv_dev)); + /* create common IOMMU mapping for all Exynos DRM devices */ + ret = drm_create_iommu_mapping(drm_dev); + if (ret < 0) { + priv->dma_dev = NULL; + DRM_ERROR("failed to create iommu mapping.\n"); + return -EINVAL; + } + } else 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;