[PATCH 1/7] drm/exynos: create common IOMMU mapping for DRM

Prathyush K prathyush.k at samsung.com
Wed Jul 11 02:39:57 PDT 2012


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 <prathyush.k at samsung.com>
---
 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 <linux/module.h>
 #include "drm.h"
+#ifdef CONFIG_EXYNOS_IOMMU
+#include <asm/dma-iommu.h>
+#include <mach/sysmmu.h>
+#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



More information about the dri-devel mailing list