From patchwork Wed Jul 11 09:39:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1181311 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id A0644DF25A for ; Wed, 11 Jul 2012 10:31:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C2E3A0937 for ; Wed, 11 Jul 2012 03:31:29 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org 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) X-AuditID: cbfee61a-b7f616d000004b7e-76-4ffd46ae4df9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 8C.71.19326.EA64DFF4; 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) From: Prathyush K To: dri-devel@lists.freedesktop.org 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> X-Mailer: git-send-email 1.7.0.4 In-reply-to: <1341999603-28316-1-git-send-email-prathyush.k@samsung.com> References: <1341999603-28316-1-git-send-email-prathyush.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jAd11bn/9Df7P1bS48vU9mwOjx/3u 40wBjFFcNimpOZllqUX6dglcGYuesxUslq5Y93wxYwPjTvEuRk4OCQETieXbNrFB2GISF+6t B7K5OIQEFjFKNP3cxgzhrGaSOHRoDTtIFZuAtsSvOXdZQWwRAWWJvxNXMYLYzAKZEle+bgGz hQVcJG4+P8IMYrMIqErc+vCPCcTmFXCX2Nu3nhVim4JE67JDYDM5BTwkts79ANYrBFRzf9tK 9gmMvAsYGVYxiqYWJBcUJ6XnGuoVJ+YWl+al6yXn525iBPv8mdQOxpUNFocYBTgYlXh4HVz/ +guxJpYVV+YeYpTgYFYS4f3qCBTiTUmsrEotyo8vKs1JLT7EKM3BoiTOa+z91V9IID2xJDU7 NbUgtQgmy8TBKdXAOD01d9umE7c0f65NP6hqfsRkubSeV13SAtPrd6ZdaO446/t86r3vYVNt ZfVe+xeU6Wg9eJi/RlDpSOycPLF+Fs/iC/HHN5vG81ZXpF1mYxb5e//vo7kWCYu322vcVY4u m7XRLsbpwpNXEVKfmoscOc5Y9E4R+Pm8bFKStNMUGbm4iE3MD9ILlViKMxINtZiLihMBPEqd RPUBAAA= X-TM-AS-MML: No X-Mailman-Approved-At: Wed, 11 Jul 2012 03:27:41 -0700 Cc: inki.dae@samsung.com, subash.ramaswamy@linaro.org, m.szyprowski@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@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