aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/exynos/exynos_drm_dma.c
diff options
context:
space:
mode:
authorAndrzej Hajda <a.hajda@samsung.com>2018-10-12 12:53:43 +0200
committerInki Dae <inki.dae@samsung.com>2018-12-04 13:23:17 +0900
commit237556962e51150f89bdc8d04171a3619bfeaf8d (patch)
treefcca6f2ffb2247f3143022cb206db129f11af13a /drivers/gpu/drm/exynos/exynos_drm_dma.c
parentdrm/exynos/iommu: remove DRM_EXYNOS_IOMMU Kconfig symbol (diff)
downloadlinux-dev-237556962e51150f89bdc8d04171a3619bfeaf8d.tar.xz
linux-dev-237556962e51150f89bdc8d04171a3619bfeaf8d.zip
drm/exynos/iommu: integrate IOMMU/DMA internal API
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 <a.hajda@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
Diffstat (limited to 'drivers/gpu/drm/exynos/exynos_drm_dma.c')
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_dma.c40
1 files changed, 40 insertions, 0 deletions
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 <a.hajda@samsung.com>
+
+#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);
+}