drm/exynos: simplify DMA mapping
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/6 drm/exynos: simplify DMA mapping
Moving DMA mapping creation to drm_iommu_attach_device allows to avoid looping through all components and maintaining DMA device flags.
v2: take care of configurations without IOMMU
--- drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 2 +- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_drv.c | 71 +++++++------------ drivers/gpu/drm/exynos/exynos_drm_drv.h | 2 + drivers/gpu/drm/exynos/exynos_drm_fimc.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_gsc.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_rotator.c | 2 +- drivers/gpu/drm/exynos/exynos_drm_scaler.c | 2 +- drivers/gpu/drm/exynos/exynos_mixer.c | 2 +- 11 files changed, 37 insertions(+), 54 deletions(-)
drivers/gpu/drm/exynos/exynos5433_drm_decon.c +1 -1
@@ -578,7 +578,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data)decon_clear_channels (ctx->crtc); -return drm_iommu_attach_device (drm_dev, dev); +return exynos_drm_register_dma (drm_dev, dev); }static void decon_unbind (struct device *dev,struct device *master,void *data)
drivers/gpu/drm/exynos/exynos7_drm_decon.c +1 -1
@@ -133,7 +133,7 @@ static int decon_ctx_initialize(struct decon_context *ctx,decon_clear_channels (ctx->crtc); -return drm_iommu_attach_device (drm_dev, ctx->dev); +return exynos_drm_register_dma (drm_dev, ctx->dev); }static void decon_ctx_remove (struct decon_context *ctx)
drivers/gpu/drm/exynos/exynos_drm_drv.c +26 -45
113 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_drv.h +2 -0
@@ -214,6 +214,8 @@ static inline struct device *to_dma_dev(struct drm_device *dev)return priv->dma_dev; } +int exynos_drm_register_dma (struct drm_device *drm,struct device *dev); +#ifdef CONFIG_DRM_EXYNOS_DPI struct drm_encoder *exynos_dpi_probe (struct device *dev);int exynos_dpi_remove (struct drm_encoder *encoder);
drivers/gpu/drm/exynos/exynos_drm_fimc.c +1 -1
@@ -1129,7 +1129,7 @@ static int fimc_bind(struct device *dev, struct device *master, void *data)struct exynos_drm_ipp *ipp = &ctx->ipp; ctx->drm_dev = drm_dev; -drm_iommu_attach_device (drm_dev, dev); +exynos_drm_register_dma (drm_dev, dev); exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs, DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -1
@@ -1011,7 +1011,7 @@ static int fimd_bind(struct device *dev, struct device *master, void *data)if (is_drm_iommu_supported (drm_dev))fimd_clear_channels (ctx->crtc); -return drm_iommu_attach_device (drm_dev, dev); +return exynos_drm_register_dma (drm_dev, dev); } static void fimd_unbind(struct device *dev, struct device *master,
drivers/gpu/drm/exynos/exynos_drm_g2d.c +1 -1
@@ -1405,7 +1405,7 @@ static int g2d_bind(struct device *dev, struct device *master, void *data)return ret; } - ret =drm_iommu_attach_device (drm_dev, dev); + ret =exynos_drm_register_dma (drm_dev, dev);if (ret <0 ) {dev_err (dev,"failed to enable iommu.\n" );g2d_fini_cmdlist (g2d);
drivers/gpu/drm/exynos/exynos_drm_gsc.c +1 -1
@@ -1164,7 +1164,7 @@ static int gsc_bind(struct device *dev, struct device *master, void *data)struct exynos_drm_ipp *ipp = &ctx->ipp; ctx->drm_dev = drm_dev; -drm_iommu_attach_device (drm_dev, dev); +exynos_drm_register_dma (drm_dev, dev); exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs, DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |
drivers/gpu/drm/exynos/exynos_drm_rotator.c +1 -1
@@ -244,7 +244,7 @@ static int rotator_bind(struct device *dev, struct device *master, void *data)struct exynos_drm_ipp *ipp = &rot->ipp; rot->drm_dev = drm_dev; -drm_iommu_attach_device (drm_dev, dev); +exynos_drm_register_dma (drm_dev, dev); exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs, DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE,
drivers/gpu/drm/exynos/exynos_drm_scaler.c +1 -1
@@ -455,7 +455,7 @@ static int scaler_bind(struct device *dev, struct device *master, void *data)struct exynos_drm_ipp *ipp = &scaler->ipp; scaler->drm_dev = drm_dev; -drm_iommu_attach_device (drm_dev, dev); +exynos_drm_register_dma (drm_dev, dev); exynos_drm_ipp_register(drm_dev, ipp, &ipp_funcs, DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |
drivers/gpu/drm/exynos/exynos_mixer.c +1 -1
@@ -856,7 +856,7 @@ static int mixer_initialize(struct mixer_context *mixer_ctx, } } -return drm_iommu_attach_device (drm_dev, mixer_ctx->dev); +return exynos_drm_register_dma (drm_dev, mixer_ctx->dev); }static void mixer_ctx_remove (struct mixer_context *mixer_ctx)
Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/6 drm/exynos/iommu: remove DRM_EXYNOS_IOMMU Kconfig symbol
In reply to a message not in the archiveDRM_EXYNOS_IOMMU symbol is not configurable, it is always equal to EXYNOS_IOMMU.
--- drivers/gpu/drm/exynos/Kconfig | 5 ----- drivers/gpu/drm/exynos/Makefile | 2 +- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/exynos/Kconfig +0 -5
@@ -10,11 +10,6 @@ config DRM_EXYNOS if DRM_EXYNOS -config DRM_EXYNOS_IOMMU - bool - depends on EXYNOS_IOMMU - default y - comment "CRTCs" config DRM_EXYNOS_FIMD
drivers/gpu/drm/exynos/Makefile +1 -1
@@ -7,7 +7,7 @@ exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \ exynos_drm_gem.o exynos_drm_plane.o exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o -exynosdrm-$(CONFIG_DRM_EXYNOS_IOMMU) += exynos_drm_iommu.o +exynosdrm-$(CONFIG_EXYNOS_IOMMU) += exynos_drm_iommu.o exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD) += exynos_drm_fimd.o exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON) += exynos5433_drm_decon.o exynosdrm-$(CONFIG_DRM_EXYNOS7_DECON) += exynos7_drm_decon.o
drivers/gpu/drm/exynos/exynos_drm_iommu.h +1 -1
@@ -15,7 +15,7 @@#define EXYNOS_DEV_ADDR_START 0x20000000#define EXYNOS_DEV_ADDR_SIZE 0x40000000 -#ifdef CONFIG_DRM_EXYNOS_IOMMU +#ifdef CONFIG_EXYNOS_IOMMU #if defined(CONFIG_ARM_DMA_USE_IOMMU )#include <asm/dma-iommu.h>
Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/6 drm/exynos/iommu: integrate IOMMU/DMA internal API
In reply to a message not in the archiveExynos 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.
--- drivers/gpu/drm/exynos/Makefile | 2 +- drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 3 +- drivers/gpu/drm/exynos/exynos7_drm_decon.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_dma.c | 40 +++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_drv.c | 26 +----------- drivers/gpu/drm/exynos/exynos_drm_drv.h | 9 +++++ drivers/gpu/drm/exynos/exynos_drm_fb.c | 1 - drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 1 - drivers/gpu/drm/exynos/exynos_drm_fimc.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_gem.c | 1 - drivers/gpu/drm/exynos/exynos_drm_gsc.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 12 ------ drivers/gpu/drm/exynos/exynos_drm_rotator.c | 3 +- drivers/gpu/drm/exynos/exynos_drm_scaler.c | 3 +- drivers/gpu/drm/exynos/exynos_mixer.c | 3 +- 17 files changed, 61 insertions(+), 58 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_dma.c
drivers/gpu/drm/exynos/Makefile +1 -1
@@ -4,7 +4,7 @@ # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \ - exynos_drm_gem.o exynos_drm_plane.o + exynos_drm_gem.o exynos_drm_plane.o exynos_drm_dma.o exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o exynosdrm-$(CONFIG_EXYNOS_IOMMU) += exynos_drm_iommu.o
drivers/gpu/drm/exynos/exynos5433_drm_decon.c +1 -2
@@ -25,7 +25,6 @@#include "exynos_drm_crtc.h" #include "exynos_drm_fb.h" #include "exynos_drm_plane.h" -#include "exynos_drm_iommu.h" #include "regs-decon5433.h" #define DSD_CFG_MUX 0x1004
@@ -588,7 +587,7 @@ static void decon_unbind(struct device *dev, struct device *master, void *data)decon_disable (ctx->crtc);/* detach this sub driver from iommu mapping if supported. */ -drm_iommu_detach_device (ctx->drm_dev, ctx->dev); +exynos_drm_unregister_dma (ctx->drm_dev, ctx->dev); }static const struct component_ops decon_component_ops = {
drivers/gpu/drm/exynos/exynos7_drm_decon.c +1 -2
@@ -30,7 +30,6 @@#include "exynos_drm_plane.h" #include "exynos_drm_drv.h" #include "exynos_drm_fb.h" -#include "exynos_drm_iommu.h" #include "regs-decon7.h" /*
@@ -139,7 +138,7 @@ static int decon_ctx_initialize(struct decon_context *ctx,static void decon_ctx_remove (struct decon_context *ctx) {/* detach this sub driver from iommu mapping if supported. */ -drm_iommu_detach_device (ctx->drm_dev, ctx->dev); +exynos_drm_unregister_dma (ctx->drm_dev, ctx->dev); } static u32 decon_calc_clkdiv(struct decon_context *ctx,
drivers/gpu/drm/exynos/exynos_drm_dma.c new file +40 -0
@@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// Author: Andrzej Hajda <[email protected]> + +#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); +}
drivers/gpu/drm/exynos/exynos_drm_drv.c +2 -24
@@ -30,7 +30,6 @@#include "exynos_drm_ipp.h" #include "exynos_drm_vidi.h" #include "exynos_drm_g2d.h" -#include "exynos_drm_iommu.h" #define DRIVER_NAME "exynos"#define DRIVER_DESC "Samsung SoC DRM"
@@ -45,27 +44,6 @@#define DRIVER_MAJOR 1#define DRIVER_MINOR 1 -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); -} -static int exynos_drm_open (struct drm_device *dev,struct drm_file *file) {struct drm_exynos_file_private *file_priv;
@@ -389,7 +367,7 @@ static int exynos_drm_bind(struct device *dev)component_unbind_all (drm->dev, drm); err_mode_config_cleanup:drm_mode_config_cleanup (drm); -drm_release_iommu_mapping (drm); +exynos_drm_cleanup_dma (drm);kfree (private); err_free_drm:drm_dev_put (drm);
@@ -408,7 +386,7 @@ static void exynos_drm_unbind(struct device *dev)component_unbind_all (drm->dev, drm);drm_mode_config_cleanup (drm); -drm_release_iommu_mapping (drm); +exynos_drm_cleanup_dma (drm);kfree (drm->dev_private); drm->dev_private =NULL ;
drivers/gpu/drm/exynos/exynos_drm_drv.h +9 -0
@@ -214,7 +214,16 @@ static inline struct device *to_dma_dev(struct drm_device *dev)return priv->dma_dev; } +static inline bool is_drm_iommu_supported (struct drm_device *drm_dev) +{ +struct exynos_drm_private *priv = drm_dev->dev_private; + +return priv->mapping ? true : false; +} +int exynos_drm_register_dma (struct drm_device *drm,struct device *dev); +void exynos_drm_unregister_dma (struct drm_device *drm,struct device *dev); +void exynos_drm_cleanup_dma (struct drm_device *drm);#ifdef CONFIG_DRM_EXYNOS_DPI struct drm_encoder *exynos_dpi_probe (struct device *dev);
drivers/gpu/drm/exynos/exynos_drm_fb.c +0 -1
@@ -24,7 +24,6 @@#include "exynos_drm_drv.h" #include "exynos_drm_fb.h" #include "exynos_drm_fbdev.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_crtc.h" static int check_fb_gem_memory_type(struct drm_device *drm_dev,
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +0 -1
@@ -23,7 +23,6 @@#include "exynos_drm_drv.h" #include "exynos_drm_fb.h" #include "exynos_drm_fbdev.h" -#include "exynos_drm_iommu.h" #define MAX_CONNECTOR 4#define PREFERRED_BPP 32
drivers/gpu/drm/exynos/exynos_drm_fimc.c +1 -2
@@ -25,7 +25,6 @@#include <drm/exynos_drm.h> #include "regs-fimc.h" #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_ipp.h" /*
@@ -1149,7 +1148,7 @@ static void fimc_unbind(struct device *dev, struct device *master,struct exynos_drm_ipp *ipp = &ctx->ipp;exynos_drm_ipp_unregister (drm_dev, ipp); -drm_iommu_detach_device (drm_dev, dev); +exynos_drm_unregister_dma (drm_dev, dev); }static const struct component_ops fimc_component_ops = {
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -2
@@ -32,7 +32,6 @@#include "exynos_drm_fb.h" #include "exynos_drm_crtc.h" #include "exynos_drm_plane.h" -#include "exynos_drm_iommu.h" /* * FIMD stands for Fully Interactive Mobile Display and
@@ -1021,7 +1020,7 @@ static void fimd_unbind(struct device *dev, struct device *master,fimd_disable (ctx->crtc); -drm_iommu_detach_device (ctx->drm_dev, ctx->dev); +exynos_drm_unregister_dma (ctx->drm_dev, ctx->dev);if (ctx->encoder)exynos_dpi_remove (ctx->encoder);
drivers/gpu/drm/exynos/exynos_drm_g2d.c +1 -2
@@ -25,7 +25,6 @@#include "exynos_drm_drv.h" #include "exynos_drm_g2d.h" #include "exynos_drm_gem.h" -#include "exynos_drm_iommu.h" #define G2D_HW_MAJOR_VER 4#define G2D_HW_MINOR_VER 1
@@ -1430,7 +1429,7 @@ static void g2d_unbind(struct device *dev, struct device *master, void *data) priv->g2d_dev =NULL ;cancel_work_sync (&g2d->runqueue_work); -drm_iommu_detach_device (g2d->drm_dev, dev); +exynos_drm_unregister_dma (g2d->drm_dev, dev); }static const struct component_ops g2d_component_ops = {
drivers/gpu/drm/exynos/exynos_drm_gem.c +0 -1
@@ -19,7 +19,6 @@#include "exynos_drm_drv.h" #include "exynos_drm_gem.h" -#include "exynos_drm_iommu.h" static int exynos_drm_alloc_buf (struct exynos_drm_gem *exynos_gem) {
drivers/gpu/drm/exynos/exynos_drm_gsc.c +1 -2
@@ -24,7 +24,6 @@#include <drm/exynos_drm.h> #include "regs-gsc.h" #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_ipp.h" /*
@@ -1184,7 +1183,7 @@ static void gsc_unbind(struct device *dev, struct device *master,struct exynos_drm_ipp *ipp = &ctx->ipp;exynos_drm_ipp_unregister (drm_dev, ipp); -drm_iommu_detach_device (drm_dev, dev); +exynos_drm_unregister_dma (drm_dev, dev); }static const struct component_ops gsc_component_ops = {
drivers/gpu/drm/exynos/exynos_drm_iommu.h +0 -12
@@ -118,13 +118,6 @@ int drm_iommu_attach_device(struct drm_device *drm_dev,void drm_iommu_detach_device (struct drm_device *dev_dev,struct device *subdrv_dev); -static inline bool is_drm_iommu_supported (struct drm_device *drm_dev) -{ -struct exynos_drm_private *priv = drm_dev->dev_private; - -return priv->mapping ? true : false; -} -#else static inline int drm_create_iommu_mapping (struct drm_device *drm_dev)
@@ -147,10 +140,5 @@ static inline void drm_iommu_detach_device(struct drm_device *drm_dev, { } -static inline bool is_drm_iommu_supported (struct drm_device *drm_dev) -{ -return false; -} -#endif #endif
drivers/gpu/drm/exynos/exynos_drm_rotator.c +1 -2
@@ -23,7 +23,6 @@#include <drm/exynos_drm.h> #include "regs-rotator.h" #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_ipp.h" /*
@@ -263,7 +262,7 @@ static void rotator_unbind(struct device *dev, struct device *master,struct exynos_drm_ipp *ipp = &rot->ipp;exynos_drm_ipp_unregister (drm_dev, ipp); -drm_iommu_detach_device (rot->drm_dev, rot->dev); +exynos_drm_unregister_dma (rot->drm_dev, rot->dev); }static const struct component_ops rotator_component_ops = {
drivers/gpu/drm/exynos/exynos_drm_scaler.c +1 -2
@@ -23,7 +23,6 @@#include "regs-scaler.h" #include "exynos_drm_fb.h" #include "exynos_drm_drv.h" -#include "exynos_drm_iommu.h" #include "exynos_drm_ipp.h" #define scaler_read (offset) readl(scaler->regs + (offset))
@@ -476,7 +475,7 @@ static void scaler_unbind(struct device *dev, struct device *master,struct exynos_drm_ipp *ipp = &scaler->ipp;exynos_drm_ipp_unregister (drm_dev, ipp); -drm_iommu_detach_device (scaler->drm_dev, scaler->dev); +exynos_drm_unregister_dma (scaler->drm_dev, scaler->dev); }static const struct component_ops scaler_component_ops = {
drivers/gpu/drm/exynos/exynos_mixer.c +1 -2
@@ -40,7 +40,6 @@#include "exynos_drm_crtc.h" #include "exynos_drm_fb.h" #include "exynos_drm_plane.h" -#include "exynos_drm_iommu.h" #define MIXER_WIN_NR 3#define VP_DEFAULT_WIN 2
@@ -861,7 +860,7 @@ static int mixer_initialize(struct mixer_context *mixer_ctx,static void mixer_ctx_remove (struct mixer_context *mixer_ctx) { -drm_iommu_detach_device (mixer_ctx->drm_dev, mixer_ctx->dev); +exynos_drm_unregister_dma (mixer_ctx->drm_dev, mixer_ctx->dev); }static int mixer_enable_vblank (struct exynos_drm_crtc *crtc)
Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/6 drm/exynos/iommu: move IOMMU specific stuff into exynos_drm_iommu.c
In reply to a message not in the archiveSince __exynos_iommu* functions are used only in exynos_drm_iommu.c we can move them there.
--- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 94 +++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_iommu.h | 94 ----------------------- 2 files changed, 94 insertions(+), 94 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_iommu.c +94 -0
@@ -18,6 +18,100 @@#include "exynos_drm_drv.h" #include "exynos_drm_iommu.h" +#define EXYNOS_DEV_ADDR_START 0x20000000 +#define EXYNOS_DEV_ADDR_SIZE 0x40000000 + +#if defined(CONFIG_ARM_DMA_USE_IOMMU ) +#include <asm/dma-iommu.h> + +static inline int __exynos_iommu_create_mapping (struct exynos_drm_private *priv, +unsigned long start,unsigned long size) +{ + priv->mapping =arm_iommu_create_mapping (&platform_bus_type, start, + size); +return IS_ERR (priv->mapping); +} + +static inline void +__exynos_iommu_release_mapping (struct exynos_drm_private *priv) +{ +arm_iommu_release_mapping (priv->mapping); +} + +static inline int __exynos_iommu_attach (struct exynos_drm_private *priv, +struct device *dev) +{ +if (dev->archdata.mapping) +arm_iommu_detach_device (dev); + +return arm_iommu_attach_device (dev, priv->mapping); +} + +static inline void __exynos_iommu_detach (struct exynos_drm_private *priv, +struct device *dev) +{ +arm_iommu_detach_device (dev); +} + +#elif defined(CONFIG_IOMMU_DMA ) +#include <linux/dma-iommu.h> + +static inline int __exynos_iommu_create_mapping (struct exynos_drm_private *priv, +unsigned long start,unsigned long size) +{ +struct iommu_domain *domain; +int ret; + + domain =iommu_domain_alloc (priv->dma_dev->bus); +if (!domain) +return -ENOMEM ; + + ret =iommu_get_dma_cookie (domain); +if (ret) + goto free_domain; + + ret =iommu_dma_init_domain (domain, start, size,NULL ); +if (ret) + goto put_cookie; + + priv->mapping = domain; +return 0 ; + +put_cookie: +iommu_put_dma_cookie (domain); +free_domain: +iommu_domain_free (domain); +return ret; +} + +static inline void __exynos_iommu_release_mapping (struct exynos_drm_private *priv) +{ +struct iommu_domain *domain = priv->mapping; + +iommu_put_dma_cookie (domain); +iommu_domain_free (domain); + priv->mapping =NULL ; +} + +static inline int __exynos_iommu_attach (struct exynos_drm_private *priv, +struct device *dev) +{ +struct iommu_domain *domain = priv->mapping; + +return iommu_attach_device (domain, dev); +} + +static inline void __exynos_iommu_detach (struct exynos_drm_private *priv, +struct device *dev) +{ +struct iommu_domain *domain = priv->mapping; + +iommu_detach_device (domain, dev); +} +#else +#error Unsupported architecture and IOMMU/DMA-mapping glue code +#endif +static inline int configure_dma_max_seg_size (struct device *dev) {if (!dev->dma_parms)
drivers/gpu/drm/exynos/exynos_drm_iommu.h +0 -94
102 lines not on this page · raw message
Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/6 drm/exynos/iommu: replace preprocessor conditionals with C conditionals
In reply to a message not in the archiveUsing C conditionals is preferred solution - it provides better code coverage, makes code more clear.
--- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 114 +++++++++------------- 1 file changed, 47 insertions(+), 67 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_iommu.c +47 -67
@@ -12,59 +12,39 @@#include <drm/drmP.h> #include <drm/exynos_drm.h> +#include <linux/dma-iommu.h> #include <linux/dma-mapping.h> #include <linux/iommu.h> #include "exynos_drm_drv.h" #include "exynos_drm_iommu.h" -#define EXYNOS_DEV_ADDR_START 0x20000000 -#define EXYNOS_DEV_ADDR_SIZE 0x40000000 -#if defined(CONFIG_ARM_DMA_USE_IOMMU )#include <asm/dma-iommu.h> +#else +#define arm_iommu_create_mapping (...) ({ NULL; }) +#define arm_iommu_attach_device (...) ({ -ENODEV; }) +#define arm_iommu_release_mapping (...) ({ }) +#define arm_iommu_detach_device (...) ({ }) +#define to_dma_iommu_mapping (dev) NULL +#endif -static inline int __exynos_iommu_create_mapping (struct exynos_drm_private *priv, -unsigned long start,unsigned long size) -{ - priv->mapping =arm_iommu_create_mapping (&platform_bus_type, start, - size); -return IS_ERR (priv->mapping); -} - -static inline void -__exynos_iommu_release_mapping (struct exynos_drm_private *priv) -{ -arm_iommu_release_mapping (priv->mapping); -} - -static inline int __exynos_iommu_attach (struct exynos_drm_private *priv, -struct device *dev) -{ -if (dev->archdata.mapping) -arm_iommu_detach_device (dev); - -return arm_iommu_attach_device (dev, priv->mapping); -} - -static inline void __exynos_iommu_detach (struct exynos_drm_private *priv, -struct device *dev) -{ -arm_iommu_detach_device (dev); -} +#if !defined(CONFIG_IOMMU_DMA ) +#define iommu_dma_init_domain (...) ({ -EINVAL; }) +#endif -#elif defined(CONFIG_IOMMU_DMA ) -#include <linux/dma-iommu.h> +#define EXYNOS_DEV_ADDR_START 0x20000000 +#define EXYNOS_DEV_ADDR_SIZE 0x40000000 -static inline int __exynos_iommu_create_mapping (struct exynos_drm_private *priv, -unsigned long start,unsigned long size) +static void *iommu_dma_create_mapping (struct exynos_drm_private *priv, +unsigned long start,unsigned long size) {struct iommu_domain *domain;int ret; domain =iommu_domain_alloc (priv->dma_dev->bus);if (!domain) -return -ENOMEM ; +return ERR_PTR (-ENOMEM ); ret =iommu_get_dma_cookie (domain);if (ret)
@@ -74,43 +54,20 @@ static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv,if (ret) goto put_cookie; - priv->mapping = domain; -return 0 ; +return domain; put_cookie:iommu_put_dma_cookie (domain); free_domain:iommu_domain_free (domain); -return ret; +return ERR_PTR (ret); } -static inline void __exynos_iommu_release_mapping (struct exynos_drm_private *priv) +static inline void iommu_dma_release_mapping (struct iommu_domain *domain) { -struct iommu_domain *domain = priv->mapping; -iommu_put_dma_cookie (domain);iommu_domain_free (domain); - priv->mapping =NULL ; -} - -static inline int __exynos_iommu_attach (struct exynos_drm_private *priv, -struct device *dev) -{ -struct iommu_domain *domain = priv->mapping; - -return iommu_attach_device (domain, dev); -} - -static inline void __exynos_iommu_detach (struct exynos_drm_private *priv, -struct device *dev) -{ -struct iommu_domain *domain = priv->mapping; - -iommu_detach_device (domain, dev); } -#else -#error Unsupported architecture and IOMMU/DMA-mapping glue code -#endif static inline int configure_dma_max_seg_size (struct device *dev) {
@@ -138,8 +95,14 @@ int drm_create_iommu_mapping(struct drm_device *drm_dev) {struct exynos_drm_private *priv = drm_dev->dev_private; -return __exynos_iommu_create_mapping (priv,EXYNOS_DEV_ADDR_START , -EXYNOS_DEV_ADDR_SIZE ); +if (IS_ENABLED (CONFIG_ARM_DMA_USE_IOMMU )) + priv->mapping =arm_iommu_create_mapping (&platform_bus_type, +EXYNOS_DEV_ADDR_START ,EXYNOS_DEV_ADDR_SIZE ); +else if (IS_ENABLED (CONFIG_IOMMU_DMA )) + priv->mapping =iommu_dma_create_mapping (priv, +EXYNOS_DEV_ADDR_START ,EXYNOS_DEV_ADDR_SIZE ); + +return IS_ERR (priv->mapping); }/*
@@ -151,7 +114,12 @@ void drm_release_iommu_mapping(struct drm_device *drm_dev) {struct exynos_drm_private *priv = drm_dev->dev_private; -__exynos_iommu_release_mapping (priv); +if (IS_ENABLED (CONFIG_ARM_DMA_USE_IOMMU )) +arm_iommu_release_mapping (priv->mapping); +else if (IS_ENABLED (CONFIG_IOMMU_DMA )) +iommu_dma_release_mapping (priv->mapping); + + priv->mapping =NULL ; }/*
@@ -179,7 +147,15 @@ int drm_iommu_attach_device(struct drm_device *drm_dev,if (ret)return ret; - ret =__exynos_iommu_attach (priv, subdrv_dev); +if (IS_ENABLED (CONFIG_ARM_DMA_USE_IOMMU )) { +if (to_dma_iommu_mapping (subdrv_dev)) +arm_iommu_detach_device (subdrv_dev); + + ret =arm_iommu_attach_device (subdrv_dev, priv->mapping); + }else if (IS_ENABLED (CONFIG_IOMMU_DMA )) { + ret =iommu_attach_device (priv->mapping, subdrv_dev); + } +if (ret)clear_dma_max_seg_size (subdrv_dev);
@@ -200,6 +176,10 @@ void drm_iommu_detach_device(struct drm_device *drm_dev, {struct exynos_drm_private *priv = drm_dev->dev_private; -__exynos_iommu_detach (priv, subdrv_dev); +if (IS_ENABLED (CONFIG_ARM_DMA_USE_IOMMU )) +arm_iommu_detach_device (subdrv_dev); +else if (IS_ENABLED (CONFIG_IOMMU_DMA )) +iommu_detach_device (priv->mapping, subdrv_dev); +clear_dma_max_seg_size (subdrv_dev); }
Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/6 drm/exynos/iommu: merge IOMMU and DMA code
In reply to a message not in the archiveAs DMA code is the only user of IOMMU code both files can be merged. It allows to remove stub functions, after slight adjustment of exynos_drm_register_dma. Since IOMMU functions are used locally they can be marked static.
--- drivers/gpu/drm/exynos/Makefile | 1 - drivers/gpu/drm/exynos/exynos_drm_dma.c | 191 +++++++++++++++++++++- drivers/gpu/drm/exynos/exynos_drm_iommu.c | 185 --------------------- drivers/gpu/drm/exynos/exynos_drm_iommu.h | 50 ------ 4 files changed, 183 insertions(+), 244 deletions(-) delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_iommu.c delete mode 100644 drivers/gpu/drm/exynos/exynos_drm_iommu.h
drivers/gpu/drm/exynos/Makefile +0 -1
@@ -7,7 +7,6 @@ exynosdrm-y := exynos_drm_drv.o exynos_drm_crtc.o exynos_drm_fb.o \ exynos_drm_gem.o exynos_drm_plane.o exynos_drm_dma.o exynosdrm-$(CONFIG_DRM_FBDEV_EMULATION) += exynos_drm_fbdev.o -exynosdrm-$(CONFIG_EXYNOS_IOMMU) += exynos_drm_iommu.o exynosdrm-$(CONFIG_DRM_EXYNOS_FIMD) += exynos_drm_fimd.o exynosdrm-$(CONFIG_DRM_EXYNOS5433_DECON) += exynos5433_drm_decon.o exynosdrm-$(CONFIG_DRM_EXYNOS7_DECON) += exynos7_drm_decon.o
drivers/gpu/drm/exynos/exynos_drm_dma.c +183 -8
209 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_iommu.c deleted +0 -185
185 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_iommu.h deleted +0 -50
50 lines not on this page · raw message
Signature · 6 lines
2.18.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel