From: Prathyush K Subject: [PATCH 1/7] drm/exynos: create common IOMMU mapping for DRM Date: Wed, 11 Jul 2012 15:09:57 +0530 Message-ID: <1341999603-28316-2-git-send-email-prathyush.k@samsung.com> References: <1341999603-28316-1-git-send-email-prathyush.k@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 6C352A0DB3 for ; Wed, 11 Jul 2012 02:26:07 -0700 (PDT) Received: from epcpsbgm1.samsung.com (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M6Z002Z9OV6NI30@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 11 Jul 2012 18:26:06 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M6Z007HWOV41490@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 11 Jul 2012 18:26:06 +0900 (KST) In-reply-to: <1341999603-28316-1-git-send-email-prathyush.k@samsung.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: dri-devel@lists.freedesktop.org Cc: inki.dae@samsung.com, subash.ramaswamy@linaro.org, m.szyprowski@samsung.com List-Id: dri-devel@lists.freedesktop.org This patch creates an IOMMU mapping during drm init. This is used by all the drm devices including the exynos drm virtual device. This ensures that when drm creates a buffer using the dma-mapping framework, this buffer is accessible by all the drm devices like hdmi/fimd. Signed-off-by: Prathyush K --- drivers/gpu/drm/exynos/exynos_drm_core.c | 3 +++ drivers/gpu/drm/exynos/exynos_drm_drv.c | 21 +++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_drv.h | 10 ++++++++++ 3 files changed, 34 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_core.c b/drivers/gpu/drm/exynos/exynos_drm_core.c index eaf630d..13ecca6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_core.c +++ b/drivers/gpu/drm/exynos/exynos_drm_core.c @@ -34,6 +34,9 @@ static LIST_HEAD(exynos_drm_subdrv_list); static struct drm_device *drm_dev; +#ifdef CONFIG_EXYNOS_IOMMU +struct dma_iommu_mapping *exynos_drm_common_mapping; +#endif static int exynos_drm_subdrv_probe(struct drm_device *dev, struct exynos_drm_subdrv *subdrv) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index d6de2e0..c3ad87e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -307,6 +307,18 @@ static int __init exynos_drm_init(void) DRM_DEBUG_DRIVER("%s\n", __FILE__); +#ifdef CONFIG_EXYNOS_IOMMU + exynos_drm_common_mapping = arm_iommu_create_mapping(&platform_bus_type, + EXYNOS_DRM_DMA_ADDR, + EXYNOS_DRM_IOMMU_SIZE, + EXYNOS_DRM_IOMMU_ORDER); + if (IS_ERR_OR_NULL(exynos_drm_common_mapping)) { + DRM_ERROR("failed to created IOMMU mapping\n"); + ret = PTR_ERR(exynos_drm_common_mapping); + goto out_iommu; + } +#endif + #ifdef CONFIG_DRM_EXYNOS_FIMD ret = platform_driver_register(&fimd_driver); if (ret < 0) @@ -367,6 +379,11 @@ out_hdmi: platform_driver_unregister(&fimd_driver); out_fimd: #endif +#ifdef CONFIG_EXYNOS_IOMMU + arm_iommu_release_mapping(exynos_drm_common_mapping); + exynos_drm_common_mapping = NULL; +out_iommu: +#endif return ret; } @@ -393,6 +410,10 @@ static void __exit exynos_drm_exit(void) #ifdef CONFIG_DRM_EXYNOS_FIMD platform_driver_unregister(&fimd_driver); #endif +#ifdef CONFIG_EXYNOS_IOMMU + arm_iommu_release_mapping(exynos_drm_common_mapping); + exynos_drm_common_mapping = NULL; +#endif } module_init(exynos_drm_init); diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index c82c90c..bd12ee2 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -31,11 +31,18 @@ #include #include "drm.h" +#ifdef CONFIG_EXYNOS_IOMMU +#include +#include +#endif #define MAX_CRTC 3 #define MAX_PLANE 5 #define MAX_FB_BUFFER 4 #define DEFAULT_ZPOS -1 +#define EXYNOS_DRM_DMA_ADDR 0x20000000 +#define EXYNOS_DRM_IOMMU_SIZE SZ_128M +#define EXYNOS_DRM_IOMMU_ORDER 4 struct drm_device; struct exynos_drm_overlay; @@ -304,4 +311,7 @@ extern struct platform_driver mixer_driver; extern struct platform_driver exynos_drm_common_hdmi_driver; extern struct platform_driver vidi_driver; extern struct platform_driver g2d_driver; +#ifdef CONFIG_EXYNOS_IOMMU +extern struct dma_iommu_mapping *exynos_drm_common_mapping; +#endif #endif -- 1.7.0.4