mbox series

[00/18] Convert arch/arm to use iommu-dma

Message ID cover.1597931875.git.robin.murphy@arm.com
Headers show
Series Convert arch/arm to use iommu-dma | expand

Message

Robin Murphy Aug. 20, 2020, 3:08 p.m. UTC
Hi all,

After 5 years or so of intending to get round to this, finally the
time comes! The changes themselves actualy turn out to be relatively
mechanical; the bigger concern appears to be how to get everything
merged across about 5 diffferent trees given the dependencies.

I've lightly boot-tested things on Rockchip RK3288 and Exynos 4412
(Odroid-U3), to the degree that their display drivers should be using
IOMMU-backed buffers and don't explode (the Odroid doesn't manage to
send a working HDMI signal to the one monitor I have that it actually
detects, but that's a pre-existing condition...) Confirmation that the
Mediatek, OMAP and Tegra changes work will be most welcome.

Patches are based on 5.9-rc1, branch available here:

  git://linux-arm.org/linux-rm arm/dma


Robin.


Robin Murphy (18):
  ARM/dma-mapping: Drop .dma_supported for IOMMU ops
  ARM/dma-mapping: Consolidate IOMMU ops callbacks
  ARM/dma-mapping: Merge IOMMU ops
  iommu/dma: Add temporary hacks for arch/arm
  ARM/dma-mapping: Switch to iommu_dma_ops
  ARM/dma-mapping: Support IOMMU default domains
  iommu/arm-smmu: Remove arch/arm workaround
  iommu/renesas: Remove arch/arm workaround
  iommu/mediatek-v1: Add IOMMU_DOMAIN_DMA support
  iommu/msm: Add IOMMU_DOMAIN_DMA support
  iommu/omap: Add IOMMU_DOMAIN_DMA support
  iommu/tegra-gart: Add IOMMU_DOMAIN_DMA support
  iommu/tegra: Add IOMMU_DOMAIN_DMA support
  drm/exynos: Consolidate IOMMU mapping code
  drm/nouveau/tegra: Clean up IOMMU workaround
  staging/media/tegra-vde: Clean up IOMMU workaround
  media/omap3isp: Clean up IOMMU workaround
  ARM/dma-mapping: Remove legacy dma-iommu API

 arch/arm/Kconfig                              |   28 +-
 arch/arm/common/dmabounce.c                   |    1 -
 arch/arm/include/asm/device.h                 |    9 -
 arch/arm/include/asm/dma-iommu.h              |   37 -
 arch/arm/mm/dma-mapping.c                     | 1198 +----------------
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |    5 +-
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    |    5 +-
 drivers/gpu/drm/exynos/exynos_drm_dma.c       |   61 +-
 drivers/gpu/drm/exynos/exynos_drm_drv.h       |    6 +-
 drivers/gpu/drm/exynos/exynos_drm_fimc.c      |    5 +-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      |    5 +-
 drivers/gpu/drm/exynos/exynos_drm_g2d.c       |    5 +-
 drivers/gpu/drm/exynos/exynos_drm_gsc.c       |    5 +-
 drivers/gpu/drm/exynos/exynos_drm_rotator.c   |    5 +-
 drivers/gpu/drm/exynos/exynos_drm_scaler.c    |    6 +-
 drivers/gpu/drm/exynos/exynos_mixer.c         |    7 +-
 .../drm/nouveau/nvkm/engine/device/tegra.c    |   13 -
 drivers/iommu/Kconfig                         |    8 -
 drivers/iommu/arm/arm-smmu/arm-smmu.c         |   10 -
 drivers/iommu/ipmmu-vmsa.c                    |   69 -
 drivers/iommu/msm_iommu.c                     |    7 +-
 drivers/iommu/mtk_iommu.h                     |    2 -
 drivers/iommu/mtk_iommu_v1.c                  |  153 +--
 drivers/iommu/omap-iommu.c                    |   22 +-
 drivers/iommu/tegra-gart.c                    |   17 +-
 drivers/iommu/tegra-smmu.c                    |   37 +-
 drivers/media/platform/Kconfig                |    1 -
 drivers/media/platform/omap3isp/isp.c         |   68 +-
 drivers/media/platform/omap3isp/isp.h         |    3 -
 drivers/staging/media/tegra-vde/iommu.c       |   12 -
 30 files changed, 150 insertions(+), 1660 deletions(-)
 delete mode 100644 arch/arm/include/asm/dma-iommu.h

Comments

Yong Wu (吴勇) Aug. 29, 2020, 9:54 a.m. UTC | #1
On Thu, 2020-08-20 at 16:08 +0100, Robin Murphy wrote:
> Now that arch/arm is wired up for default domains and iommu-dma,

> implement the corresponding driver-side support for groups and DMA

> domains to replace the shared mapping workaround.

> 

> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

> ---

>  drivers/iommu/mtk_iommu.h    |   2 -

>  drivers/iommu/mtk_iommu_v1.c | 153 +++++++++++------------------------

>  2 files changed, 48 insertions(+), 107 deletions(-)


Hi Robin,

Thanks very much for this patch, It makes the code much cleaner.

Please help squash the little change in this patch,

--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -555,6 +555,7 @@ static int mtk_iommu_probe(struct platform_device
*pdev)
 		return ret;
 
 	iommu_device_set_ops(&data->iommu, &mtk_iommu_ops);
+	iommu_device_set_fwnode(&data->iommu, &dev->of_node->fwnode);
 
 	ret = iommu_device_register(&data->iommu);
 	if (ret)


Then,
Tested-by: Yong Wu <yong.wu@mediatek.com>


> 

> diff --git a/drivers/iommu/mtk_iommu.h b/drivers/iommu/mtk_iommu.h

> index 122925dbe547..6253e98d810c 100644

> --- a/drivers/iommu/mtk_iommu.h

> +++ b/drivers/iommu/mtk_iommu.h

> @@ -67,8 +67,6 @@ struct mtk_iommu_data {

>  	struct iommu_device		iommu;

>  	const struct mtk_iommu_plat_data *plat_data;

>  

> -	struct dma_iommu_mapping	*mapping; /* For mtk_iommu_v1.c */

> -

>  	struct list_head		list;

>  	struct mtk_smi_larb_iommu	larb_imu[MTK_LARB_NR_MAX];

>  };

> diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c

> index 82ddfe9170d4..40c89b8d3ac4 100644

> --- a/drivers/iommu/mtk_iommu_v1.c

> +++ b/drivers/iommu/mtk_iommu_v1.c

> @@ -28,7 +28,6 @@

>  #include <linux/slab.h>

>  #include <linux/spinlock.h>

>  #include <asm/barrier.h>

> -#include <asm/dma-iommu.h>

>  #include <linux/init.h>

>  #include <dt-bindings/memory/mt2701-larb-port.h>

>  #include <soc/mediatek/smi.h>

> @@ -240,13 +239,18 @@ static struct iommu_domain *mtk_iommu_domain_alloc(unsigned type)

>  {

>  	struct mtk_iommu_domain *dom;

>  

> -	if (type != IOMMU_DOMAIN_UNMANAGED)

> +	if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_DMA)

>  		return NULL;

>  

>  	dom = kzalloc(sizeof(*dom), GFP_KERNEL);

>  	if (!dom)

>  		return NULL;

>  

> +	if (type == IOMMU_DOMAIN_DMA && iommu_get_dma_cookie(&dom->domain)) {

> +		kfree(dom);

> +		return NULL;

> +	}

> +

>  	return &dom->domain;

>  }

>  

> @@ -257,6 +261,7 @@ static void mtk_iommu_domain_free(struct iommu_domain *domain)

>  

>  	dma_free_coherent(data->dev, M2701_IOMMU_PGT_SIZE,

>  			dom->pgt_va, dom->pgt_pa);

> +	iommu_put_dma_cookie(domain);

>  	kfree(to_mtk_domain(domain));

>  }

>  

> @@ -265,14 +270,8 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain,

>  {

>  	struct mtk_iommu_data *data = dev_iommu_priv_get(dev);

>  	struct mtk_iommu_domain *dom = to_mtk_domain(domain);

> -	struct dma_iommu_mapping *mtk_mapping;

>  	int ret;

>  

> -	/* Only allow the domain created internally. */

> -	mtk_mapping = data->mapping;

> -	if (mtk_mapping->domain != domain)

> -		return 0;

> -

>  	if (!data->m4u_dom) {

>  		data->m4u_dom = dom;

>  		ret = mtk_iommu_domain_finalise(data);

> @@ -358,18 +357,39 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain,

>  

>  static const struct iommu_ops mtk_iommu_ops;

>  

> -/*

> - * MTK generation one iommu HW only support one iommu domain, and all the client

> - * sharing the same iova address space.

> - */

> -static int mtk_iommu_create_mapping(struct device *dev,

> -				    struct of_phandle_args *args)

> +static struct iommu_device *mtk_iommu_probe_device(struct device *dev)

>  {

>  	struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);

>  	struct mtk_iommu_data *data;

> +

> +	if (!fwspec || fwspec->ops != &mtk_iommu_ops)

> +		return ERR_PTR(-ENODEV); /* Not a iommu client device */

> +

> +	data = dev_iommu_priv_get(dev);

> +

> +	return &data->iommu;

> +}

> +

> +static void mtk_iommu_release_device(struct device *dev)

> +{

> +	struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);

> +

> +	if (!fwspec || fwspec->ops != &mtk_iommu_ops)

> +		return;

> +

> +	iommu_fwspec_free(dev);

> +}

> +

> +static struct iommu_group *mtk_iommu_device_group(struct device *dev)

> +{

> +	struct mtk_iommu_data *data = dev_iommu_priv_get(dev);

> +

> +	return iommu_group_ref_get(data->m4u_group);

> +}

> +

> +static int mtk_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)

> +{

>  	struct platform_device *m4updev;

> -	struct dma_iommu_mapping *mtk_mapping;

> -	int ret;

>  

>  	if (args->args_count != 1) {

>  		dev_err(dev, "invalid #iommu-cells(%d) property for IOMMU\n",

> @@ -377,15 +397,6 @@ static int mtk_iommu_create_mapping(struct device *dev,

>  		return -EINVAL;

>  	}

>  

> -	if (!fwspec) {

> -		ret = iommu_fwspec_init(dev, &args->np->fwnode, &mtk_iommu_ops);

> -		if (ret)

> -			return ret;

> -		fwspec = dev_iommu_fwspec_get(dev);

> -	} else if (dev_iommu_fwspec_get(dev)->ops != &mtk_iommu_ops) {

> -		return -EINVAL;

> -	}

> -

>  	if (!dev_iommu_priv_get(dev)) {

>  		/* Get the m4u device */

>  		m4updev = of_find_device_by_node(args->np);

> @@ -395,83 +406,7 @@ static int mtk_iommu_create_mapping(struct device *dev,

>  		dev_iommu_priv_set(dev, platform_get_drvdata(m4updev));

>  	}

>  

> -	ret = iommu_fwspec_add_ids(dev, args->args, 1);

> -	if (ret)

> -		return ret;

> -

> -	data = dev_iommu_priv_get(dev);

> -	mtk_mapping = data->mapping;

> -	if (!mtk_mapping) {

> -		/* MTK iommu support 4GB iova address space. */

> -		mtk_mapping = arm_iommu_create_mapping(&platform_bus_type,

> -						0, 1ULL << 32);

> -		if (IS_ERR(mtk_mapping))

> -			return PTR_ERR(mtk_mapping);

> -

> -		data->mapping = mtk_mapping;

> -	}

> -

> -	return 0;

> -}

> -

> -static int mtk_iommu_def_domain_type(struct device *dev)

> -{

> -	return IOMMU_DOMAIN_UNMANAGED;

> -}

> -

> -static struct iommu_device *mtk_iommu_probe_device(struct device *dev)

> -{

> -	struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);

> -	struct of_phandle_args iommu_spec;

> -	struct of_phandle_iterator it;

> -	struct mtk_iommu_data *data;

> -	int err;

> -

> -	of_for_each_phandle(&it, err, dev->of_node, "iommus",

> -			"#iommu-cells", -1) {

> -		int count = of_phandle_iterator_args(&it, iommu_spec.args,

> -					MAX_PHANDLE_ARGS);

> -		iommu_spec.np = of_node_get(it.node);

> -		iommu_spec.args_count = count;

> -

> -		mtk_iommu_create_mapping(dev, &iommu_spec);

> -

> -		/* dev->iommu_fwspec might have changed */

> -		fwspec = dev_iommu_fwspec_get(dev);

> -

> -		of_node_put(iommu_spec.np);

> -	}

> -

> -	if (!fwspec || fwspec->ops != &mtk_iommu_ops)

> -		return ERR_PTR(-ENODEV); /* Not a iommu client device */

> -

> -	data = dev_iommu_priv_get(dev);

> -

> -	return &data->iommu;

> -}

> -

> -static void mtk_iommu_probe_finalize(struct device *dev)

> -{

> -	struct dma_iommu_mapping *mtk_mapping;

> -	struct mtk_iommu_data *data;

> -	int err;

> -

> -	data        = dev_iommu_priv_get(dev);

> -	mtk_mapping = data->mapping;

> -

> -	err = arm_iommu_attach_device(dev, mtk_mapping);

> -	if (err)

> -		dev_err(dev, "Can't create IOMMU mapping - DMA-OPS will not work\n");

> -}

> -

> -static void mtk_iommu_release_device(struct device *dev)

> -{

> -	struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);

> -

> -	if (!fwspec || fwspec->ops != &mtk_iommu_ops)

> -		return;

> -

> -	iommu_fwspec_free(dev);

> +	return iommu_fwspec_add_ids(dev, args->args, 1);

>  }

>  

>  static int mtk_iommu_hw_init(const struct mtk_iommu_data *data)

> @@ -524,10 +459,9 @@ static const struct iommu_ops mtk_iommu_ops = {

>  	.unmap		= mtk_iommu_unmap,

>  	.iova_to_phys	= mtk_iommu_iova_to_phys,

>  	.probe_device	= mtk_iommu_probe_device,

> -	.probe_finalize = mtk_iommu_probe_finalize,

>  	.release_device	= mtk_iommu_release_device,

> -	.def_domain_type = mtk_iommu_def_domain_type,

> -	.device_group	= generic_device_group,

> +	.device_group	= mtk_iommu_device_group,

> +	.of_xlate	= mtk_iommu_of_xlate,

>  	.pgsize_bitmap	= ~0UL << MT2701_IOMMU_PAGE_SHIFT,

>  };

>  

> @@ -626,6 +560,14 @@ static int mtk_iommu_probe(struct platform_device *pdev)

>  	if (ret)

>  		return ret;

>  

> +	/*

> +	 * MTK generation one iommu HW only support one iommu domain,

> +	 * and all the client sharing the same iova address space.

> +	 */

> +	data->m4u_group = iommu_group_alloc();

> +	if (IS_ERR(data->m4u_group))

> +		return PTR_ERR(data->m4u_group);

> +

>  	if (!iommu_present(&platform_bus_type))

>  		bus_set_iommu(&platform_bus_type,  &mtk_iommu_ops);

>  

> @@ -636,6 +578,7 @@ static int mtk_iommu_remove(struct platform_device *pdev)

>  {

>  	struct mtk_iommu_data *data = platform_get_drvdata(pdev);

>  

> +	iommu_group_put(data->m4u_group);

>  	iommu_device_sysfs_remove(&data->iommu);

>  	iommu_device_unregister(&data->iommu);

>
Marek Szyprowski Sept. 18, 2020, 2:30 p.m. UTC | #2
Hi Robin,

On 20.08.2020 17:08, Robin Murphy wrote:
> Now that arch/arm is wired up for default domains and iommu-dma, we can

> consolidate the shared mapping code onto the generic IOMMU API version,

> and retire the arch-specific implementation.

>

> Signed-off-by: Robin Murphy <robin.murphy@arm.com>

>

> ---

> This is a cheeky revert of 07dc3678bacc ("drm/exynos: Fix cleanup of

> IOMMU related objects"), plus removal of the remaining arm_iommu_*

> references on top.


I have one more suggestion to this patch. Please rename 
exynos_drm_private->mapping to exynos_drm_private->domain and change its 
type from "void *" to "struct iommu_domain *". The "void *" was there to 
support both old-ARM and ARM64 IOMMU/DMA-mapping frameworks, but now we 
can use the proper pointer types.

> ---

>   drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  5 +-

>   drivers/gpu/drm/exynos/exynos7_drm_decon.c    |  5 +-

>   drivers/gpu/drm/exynos/exynos_drm_dma.c       | 61 +++----------------

>   drivers/gpu/drm/exynos/exynos_drm_drv.h       |  6 +-

>   drivers/gpu/drm/exynos/exynos_drm_fimc.c      |  5 +-

>   drivers/gpu/drm/exynos/exynos_drm_fimd.c      |  5 +-

>   drivers/gpu/drm/exynos/exynos_drm_g2d.c       |  5 +-

>   drivers/gpu/drm/exynos/exynos_drm_gsc.c       |  5 +-

>   drivers/gpu/drm/exynos/exynos_drm_rotator.c   |  5 +-

>   drivers/gpu/drm/exynos/exynos_drm_scaler.c    |  6 +-

>   drivers/gpu/drm/exynos/exynos_mixer.c         |  7 +--

>   11 files changed, 29 insertions(+), 86 deletions(-)

>

> diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c

> index 1f79bc2a881e..8428ae12dfa5 100644

> --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c

> +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c

> @@ -55,7 +55,6 @@ static const char * const decon_clks_name[] = {

>   struct decon_context {

>   	struct device			*dev;

>   	struct drm_device		*drm_dev;

> -	void				*dma_priv;

>   	struct exynos_drm_crtc		*crtc;

>   	struct exynos_drm_plane		planes[WINDOWS_NR];

>   	struct exynos_drm_plane_config	configs[WINDOWS_NR];

> @@ -645,7 +644,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data)

>   

>   	decon_clear_channels(ctx->crtc);

>   

> -	return exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);

> +	return exynos_drm_register_dma(drm_dev, dev);

>   }

>   

>   static void decon_unbind(struct device *dev, struct device *master, void *data)

> @@ -655,7 +654,7 @@ static void decon_unbind(struct device *dev, struct device *master, void *data)

>   	decon_atomic_disable(ctx->crtc);

>   

>   	/* detach this sub driver from iommu mapping if supported. */

> -	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev, &ctx->dma_priv);

> +	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev);

>   }

>   

>   static const struct component_ops decon_component_ops = {

> diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c

> index f2d87a7445c7..e7b58097ccdc 100644

> --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c

> +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c

> @@ -40,7 +40,6 @@

>   struct decon_context {

>   	struct device			*dev;

>   	struct drm_device		*drm_dev;

> -	void				*dma_priv;

>   	struct exynos_drm_crtc		*crtc;

>   	struct exynos_drm_plane		planes[WINDOWS_NR];

>   	struct exynos_drm_plane_config	configs[WINDOWS_NR];

> @@ -128,13 +127,13 @@ static int decon_ctx_initialize(struct decon_context *ctx,

>   

>   	decon_clear_channels(ctx->crtc);

>   

> -	return exynos_drm_register_dma(drm_dev, ctx->dev, &ctx->dma_priv);

> +	return exynos_drm_register_dma(drm_dev, ctx->dev);

>   }

>   

>   static void decon_ctx_remove(struct decon_context *ctx)

>   {

>   	/* detach this sub driver from iommu mapping if supported. */

> -	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev, &ctx->dma_priv);

> +	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev);

>   }

>   

>   static u32 decon_calc_clkdiv(struct decon_context *ctx,

> diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exynos/exynos_drm_dma.c

> index 58b89ec11b0e..fd5f9bcf1857 100644

> --- a/drivers/gpu/drm/exynos/exynos_drm_dma.c

> +++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c

> @@ -14,19 +14,6 @@

>   

>   #include "exynos_drm_drv.h"

>   

> -#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

> -

> -#if !defined(CONFIG_IOMMU_DMA)

> -#define iommu_dma_init_domain(...) ({ -EINVAL; })

> -#endif

>   

>   #define EXYNOS_DEV_ADDR_START	0x20000000

>   #define EXYNOS_DEV_ADDR_SIZE	0x40000000

> @@ -58,7 +45,7 @@ static inline void clear_dma_max_seg_size(struct device *dev)

>    * mapping.

>    */

>   static int drm_iommu_attach_device(struct drm_device *drm_dev,

> -				struct device *subdrv_dev, void **dma_priv)

> +				struct device *subdrv_dev)

>   {

>   	struct exynos_drm_private *priv = drm_dev->dev_private;

>   	int ret = 0;

> @@ -73,22 +60,7 @@ static int drm_iommu_attach_device(struct drm_device *drm_dev,

>   	if (ret)

>   		return ret;

>   

> -	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {

> -		/*

> -		 * Keep the original DMA mapping of the sub-device and

> -		 * restore it on Exynos DRM detach, otherwise the DMA

> -		 * framework considers it as IOMMU-less during the next

> -		 * probe (in case of deferred probe or modular build)

> -		 */

> -		*dma_priv = to_dma_iommu_mapping(subdrv_dev);

> -		if (*dma_priv)

> -			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);

> -	}

> -

> +	ret = iommu_attach_device(priv->mapping, subdrv_dev);

>   	if (ret)

>   		clear_dma_max_seg_size(subdrv_dev);

>   

> @@ -105,21 +77,15 @@ static int drm_iommu_attach_device(struct drm_device *drm_dev,

>    * mapping

>    */

>   static void drm_iommu_detach_device(struct drm_device *drm_dev,

> -				    struct device *subdrv_dev, void **dma_priv)

> +				struct device *subdrv_dev)

>   {

>   	struct exynos_drm_private *priv = drm_dev->dev_private;

>   

> -	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {

> -		arm_iommu_detach_device(subdrv_dev);

> -		arm_iommu_attach_device(subdrv_dev, *dma_priv);

> -	} else if (IS_ENABLED(CONFIG_IOMMU_DMA))

> -		iommu_detach_device(priv->mapping, subdrv_dev);

> -

> +	iommu_detach_device(priv->mapping, subdrv_dev);

>   	clear_dma_max_seg_size(subdrv_dev);

>   }

>   

> -int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,

> -			    void **dma_priv)

> +int exynos_drm_register_dma(struct drm_device *drm, struct device *dev)

>   {

>   	struct exynos_drm_private *priv = drm->dev_private;

>   

> @@ -133,27 +99,20 @@ int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,

>   		return 0;

>   

>   	if (!priv->mapping) {

> -		void *mapping;

> -

> -		if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))

> -			mapping = arm_iommu_create_mapping(&platform_bus_type,

> -				EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE);

> -		else if (IS_ENABLED(CONFIG_IOMMU_DMA))

> -			mapping = iommu_get_domain_for_dev(priv->dma_dev);

> +		void *mapping = iommu_get_domain_for_dev(priv->dma_dev);

>   

>   		if (IS_ERR(mapping))

>   			return PTR_ERR(mapping);

>   		priv->mapping = mapping;

>   	}

>   

> -	return drm_iommu_attach_device(drm, dev, dma_priv);

> +	return drm_iommu_attach_device(drm, dev);

>   }

>   

> -void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev,

> -			       void **dma_priv)

> +void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev)

>   {

>   	if (IS_ENABLED(CONFIG_EXYNOS_IOMMU))

> -		drm_iommu_detach_device(drm, dev, dma_priv);

> +		drm_iommu_detach_device(drm, dev);

>   }

>   

>   void exynos_drm_cleanup_dma(struct drm_device *drm)

> @@ -163,7 +122,5 @@ void exynos_drm_cleanup_dma(struct drm_device *drm)

>   	if (!IS_ENABLED(CONFIG_EXYNOS_IOMMU))

>   		return;

>   

> -	arm_iommu_release_mapping(priv->mapping);

> -	priv->mapping = NULL;

>   	priv->dma_dev = NULL;

>   }

> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h

> index 6ae9056e7a18..d4d21d8cfb90 100644

> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h

> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h

> @@ -223,10 +223,8 @@ static inline bool is_drm_iommu_supported(struct drm_device *drm_dev)

>   	return priv->mapping ? true : false;

>   }

>   

> -int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,

> -			    void **dma_priv);

> -void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev,

> -			       void **dma_priv);

> +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

> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c

> index 29ab8be8604c..8ea2e1d77802 100644

> --- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c

> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c

> @@ -97,7 +97,6 @@ struct fimc_scaler {

>   struct fimc_context {

>   	struct exynos_drm_ipp ipp;

>   	struct drm_device *drm_dev;

> -	void		*dma_priv;

>   	struct device	*dev;

>   	struct exynos_drm_ipp_task	*task;

>   	struct exynos_drm_ipp_formats	*formats;

> @@ -1134,7 +1133,7 @@ static int fimc_bind(struct device *dev, struct device *master, void *data)

>   

>   	ctx->drm_dev = drm_dev;

>   	ipp->drm_dev = drm_dev;

> -	exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);

> +	exynos_drm_register_dma(drm_dev, dev);

>   

>   	exynos_drm_ipp_register(dev, ipp, &ipp_funcs,

>   			DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |

> @@ -1154,7 +1153,7 @@ static void fimc_unbind(struct device *dev, struct device *master,

>   	struct exynos_drm_ipp *ipp = &ctx->ipp;

>   

>   	exynos_drm_ipp_unregister(dev, ipp);

> -	exynos_drm_unregister_dma(drm_dev, dev, &ctx->dma_priv);

> +	exynos_drm_unregister_dma(drm_dev, dev);

>   }

>   

>   static const struct component_ops fimc_component_ops = {

> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c

> index bb67cad8371f..21aec38702fc 100644

> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c

> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c

> @@ -167,7 +167,6 @@ static struct fimd_driver_data exynos5420_fimd_driver_data = {

>   struct fimd_context {

>   	struct device			*dev;

>   	struct drm_device		*drm_dev;

> -	void				*dma_priv;

>   	struct exynos_drm_crtc		*crtc;

>   	struct exynos_drm_plane		planes[WINDOWS_NR];

>   	struct exynos_drm_plane_config	configs[WINDOWS_NR];

> @@ -1091,7 +1090,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 exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);

> +	return exynos_drm_register_dma(drm_dev, dev);

>   }

>   

>   static void fimd_unbind(struct device *dev, struct device *master,

> @@ -1101,7 +1100,7 @@ static void fimd_unbind(struct device *dev, struct device *master,

>   

>   	fimd_atomic_disable(ctx->crtc);

>   

> -	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev, &ctx->dma_priv);

> +	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev);

>   

>   	if (ctx->encoder)

>   		exynos_dpi_remove(ctx->encoder);

> diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c

> index 03be31427181..256ceafd9945 100644

> --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c

> +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c

> @@ -232,7 +232,6 @@ struct g2d_runqueue_node {

>   

>   struct g2d_data {

>   	struct device			*dev;

> -	void				*dma_priv;

>   	struct clk			*gate_clk;

>   	void __iomem			*regs;

>   	int				irq;

> @@ -1410,7 +1409,7 @@ static int g2d_bind(struct device *dev, struct device *master, void *data)

>   		return ret;

>   	}

>   

> -	ret = exynos_drm_register_dma(drm_dev, dev, &g2d->dma_priv);

> +	ret = exynos_drm_register_dma(drm_dev, dev);

>   	if (ret < 0) {

>   		dev_err(dev, "failed to enable iommu.\n");

>   		g2d_fini_cmdlist(g2d);

> @@ -1435,7 +1434,7 @@ static void g2d_unbind(struct device *dev, struct device *master, void *data)

>   	priv->g2d_dev = NULL;

>   

>   	cancel_work_sync(&g2d->runqueue_work);

> -	exynos_drm_unregister_dma(g2d->drm_dev, dev, &g2d->dma_priv);

> +	exynos_drm_unregister_dma(g2d->drm_dev, dev);

>   }

>   

>   static const struct component_ops g2d_component_ops = {

> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c

> index 45e9aee8366a..88b6fcaa20be 100644

> --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c

> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c

> @@ -97,7 +97,6 @@ struct gsc_scaler {

>   struct gsc_context {

>   	struct exynos_drm_ipp ipp;

>   	struct drm_device *drm_dev;

> -	void		*dma_priv;

>   	struct device	*dev;

>   	struct exynos_drm_ipp_task	*task;

>   	struct exynos_drm_ipp_formats	*formats;

> @@ -1170,7 +1169,7 @@ static int gsc_bind(struct device *dev, struct device *master, void *data)

>   

>   	ctx->drm_dev = drm_dev;

>   	ctx->drm_dev = drm_dev;

> -	exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);

> +	exynos_drm_register_dma(drm_dev, dev);

>   

>   	exynos_drm_ipp_register(dev, ipp, &ipp_funcs,

>   			DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |

> @@ -1190,7 +1189,7 @@ static void gsc_unbind(struct device *dev, struct device *master,

>   	struct exynos_drm_ipp *ipp = &ctx->ipp;

>   

>   	exynos_drm_ipp_unregister(dev, ipp);

> -	exynos_drm_unregister_dma(drm_dev, dev, &ctx->dma_priv);

> +	exynos_drm_unregister_dma(drm_dev, dev);

>   }

>   

>   static const struct component_ops gsc_component_ops = {

> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c

> index 2d94afba031e..f22fa0d2621a 100644

> --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c

> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c

> @@ -56,7 +56,6 @@ struct rot_variant {

>   struct rot_context {

>   	struct exynos_drm_ipp ipp;

>   	struct drm_device *drm_dev;

> -	void		*dma_priv;

>   	struct device	*dev;

>   	void __iomem	*regs;

>   	struct clk	*clock;

> @@ -244,7 +243,7 @@ static int rotator_bind(struct device *dev, struct device *master, void *data)

>   

>   	rot->drm_dev = drm_dev;

>   	ipp->drm_dev = drm_dev;

> -	exynos_drm_register_dma(drm_dev, dev, &rot->dma_priv);

> +	exynos_drm_register_dma(drm_dev, dev);

>   

>   	exynos_drm_ipp_register(dev, ipp, &ipp_funcs,

>   			   DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE,

> @@ -262,7 +261,7 @@ static void rotator_unbind(struct device *dev, struct device *master,

>   	struct exynos_drm_ipp *ipp = &rot->ipp;

>   

>   	exynos_drm_ipp_unregister(dev, ipp);

> -	exynos_drm_unregister_dma(rot->drm_dev, rot->dev, &rot->dma_priv);

> +	exynos_drm_unregister_dma(rot->drm_dev, rot->dev);

>   }

>   

>   static const struct component_ops rotator_component_ops = {

> diff --git a/drivers/gpu/drm/exynos/exynos_drm_scaler.c b/drivers/gpu/drm/exynos/exynos_drm_scaler.c

> index ce1857138f89..0c560566bd2e 100644

> --- a/drivers/gpu/drm/exynos/exynos_drm_scaler.c

> +++ b/drivers/gpu/drm/exynos/exynos_drm_scaler.c

> @@ -39,7 +39,6 @@ struct scaler_data {

>   struct scaler_context {

>   	struct exynos_drm_ipp		ipp;

>   	struct drm_device		*drm_dev;

> -	void				*dma_priv;

>   	struct device			*dev;

>   	void __iomem			*regs;

>   	struct clk			*clock[SCALER_MAX_CLK];

> @@ -451,7 +450,7 @@ static int scaler_bind(struct device *dev, struct device *master, void *data)

>   

>   	scaler->drm_dev = drm_dev;

>   	ipp->drm_dev = drm_dev;

> -	exynos_drm_register_dma(drm_dev, dev, &scaler->dma_priv);

> +	exynos_drm_register_dma(drm_dev, dev);

>   

>   	exynos_drm_ipp_register(dev, ipp, &ipp_funcs,

>   			DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |

> @@ -471,8 +470,7 @@ static void scaler_unbind(struct device *dev, struct device *master,

>   	struct exynos_drm_ipp *ipp = &scaler->ipp;

>   

>   	exynos_drm_ipp_unregister(dev, ipp);

> -	exynos_drm_unregister_dma(scaler->drm_dev, scaler->dev,

> -				  &scaler->dma_priv);

> +	exynos_drm_unregister_dma(scaler->drm_dev, scaler->dev);

>   }

>   

>   static const struct component_ops scaler_component_ops = {

> diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c

> index af192e5a16ef..18972e605c5d 100644

> --- a/drivers/gpu/drm/exynos/exynos_mixer.c

> +++ b/drivers/gpu/drm/exynos/exynos_mixer.c

> @@ -94,7 +94,6 @@ struct mixer_context {

>   	struct platform_device *pdev;

>   	struct device		*dev;

>   	struct drm_device	*drm_dev;

> -	void			*dma_priv;

>   	struct exynos_drm_crtc	*crtc;

>   	struct exynos_drm_plane	planes[MIXER_WIN_NR];

>   	unsigned long		flags;

> @@ -895,14 +894,12 @@ static int mixer_initialize(struct mixer_context *mixer_ctx,

>   		}

>   	}

>   

> -	return exynos_drm_register_dma(drm_dev, mixer_ctx->dev,

> -				       &mixer_ctx->dma_priv);

> +	return exynos_drm_register_dma(drm_dev, mixer_ctx->dev);

>   }

>   

>   static void mixer_ctx_remove(struct mixer_context *mixer_ctx)

>   {

> -	exynos_drm_unregister_dma(mixer_ctx->drm_dev, mixer_ctx->dev,

> -				  &mixer_ctx->dma_priv);

> +	exynos_drm_unregister_dma(mixer_ctx->drm_dev, mixer_ctx->dev);

>   }

>   

>   static int mixer_enable_vblank(struct exynos_drm_crtc *crtc)


Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland
대인기/Tizen Platform Lab(SR)/삼성전자 Sept. 21, 2020, 2:09 a.m. UTC | #3
20. 8. 21. 오전 12:08에 Robin Murphy 이(가) 쓴 글:
> Now that arch/arm is wired up for default domains and iommu-dma, we can
> consolidate the shared mapping code onto the generic IOMMU API version,
> and retire the arch-specific implementation.
> 
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> 
> ---
> This is a cheeky revert of 07dc3678bacc ("drm/exynos: Fix cleanup of
> IOMMU related objects"), plus removal of the remaining arm_iommu_*
> references on top.

Thanks for cleanup.

Acked-by: Inki Dae <inki.dae@samsung.com>

Thanks,
Inki Dae

> ---
>  drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  5 +-
>  drivers/gpu/drm/exynos/exynos7_drm_decon.c    |  5 +-
>  drivers/gpu/drm/exynos/exynos_drm_dma.c       | 61 +++----------------
>  drivers/gpu/drm/exynos/exynos_drm_drv.h       |  6 +-
>  drivers/gpu/drm/exynos/exynos_drm_fimc.c      |  5 +-
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c      |  5 +-
>  drivers/gpu/drm/exynos/exynos_drm_g2d.c       |  5 +-
>  drivers/gpu/drm/exynos/exynos_drm_gsc.c       |  5 +-
>  drivers/gpu/drm/exynos/exynos_drm_rotator.c   |  5 +-
>  drivers/gpu/drm/exynos/exynos_drm_scaler.c    |  6 +-
>  drivers/gpu/drm/exynos/exynos_mixer.c         |  7 +--
>  11 files changed, 29 insertions(+), 86 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> index 1f79bc2a881e..8428ae12dfa5 100644
> --- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> +++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
> @@ -55,7 +55,6 @@ static const char * const decon_clks_name[] = {
>  struct decon_context {
>  	struct device			*dev;
>  	struct drm_device		*drm_dev;
> -	void				*dma_priv;
>  	struct exynos_drm_crtc		*crtc;
>  	struct exynos_drm_plane		planes[WINDOWS_NR];
>  	struct exynos_drm_plane_config	configs[WINDOWS_NR];
> @@ -645,7 +644,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data)
>  
>  	decon_clear_channels(ctx->crtc);
>  
> -	return exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);
> +	return exynos_drm_register_dma(drm_dev, dev);
>  }
>  
>  static void decon_unbind(struct device *dev, struct device *master, void *data)
> @@ -655,7 +654,7 @@ static void decon_unbind(struct device *dev, struct device *master, void *data)
>  	decon_atomic_disable(ctx->crtc);
>  
>  	/* detach this sub driver from iommu mapping if supported. */
> -	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev, &ctx->dma_priv);
> +	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev);
>  }
>  
>  static const struct component_ops decon_component_ops = {
> diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
> index f2d87a7445c7..e7b58097ccdc 100644
> --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
> +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
> @@ -40,7 +40,6 @@
>  struct decon_context {
>  	struct device			*dev;
>  	struct drm_device		*drm_dev;
> -	void				*dma_priv;
>  	struct exynos_drm_crtc		*crtc;
>  	struct exynos_drm_plane		planes[WINDOWS_NR];
>  	struct exynos_drm_plane_config	configs[WINDOWS_NR];
> @@ -128,13 +127,13 @@ static int decon_ctx_initialize(struct decon_context *ctx,
>  
>  	decon_clear_channels(ctx->crtc);
>  
> -	return exynos_drm_register_dma(drm_dev, ctx->dev, &ctx->dma_priv);
> +	return exynos_drm_register_dma(drm_dev, ctx->dev);
>  }
>  
>  static void decon_ctx_remove(struct decon_context *ctx)
>  {
>  	/* detach this sub driver from iommu mapping if supported. */
> -	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev, &ctx->dma_priv);
> +	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev);
>  }
>  
>  static u32 decon_calc_clkdiv(struct decon_context *ctx,
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_dma.c b/drivers/gpu/drm/exynos/exynos_drm_dma.c
> index 58b89ec11b0e..fd5f9bcf1857 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_dma.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_dma.c
> @@ -14,19 +14,6 @@
>  
>  #include "exynos_drm_drv.h"
>  
> -#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
> -
> -#if !defined(CONFIG_IOMMU_DMA)
> -#define iommu_dma_init_domain(...) ({ -EINVAL; })
> -#endif
>  
>  #define EXYNOS_DEV_ADDR_START	0x20000000
>  #define EXYNOS_DEV_ADDR_SIZE	0x40000000
> @@ -58,7 +45,7 @@ static inline void clear_dma_max_seg_size(struct device *dev)
>   * mapping.
>   */
>  static int drm_iommu_attach_device(struct drm_device *drm_dev,
> -				struct device *subdrv_dev, void **dma_priv)
> +				struct device *subdrv_dev)
>  {
>  	struct exynos_drm_private *priv = drm_dev->dev_private;
>  	int ret = 0;
> @@ -73,22 +60,7 @@ static int drm_iommu_attach_device(struct drm_device *drm_dev,
>  	if (ret)
>  		return ret;
>  
> -	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
> -		/*
> -		 * Keep the original DMA mapping of the sub-device and
> -		 * restore it on Exynos DRM detach, otherwise the DMA
> -		 * framework considers it as IOMMU-less during the next
> -		 * probe (in case of deferred probe or modular build)
> -		 */
> -		*dma_priv = to_dma_iommu_mapping(subdrv_dev);
> -		if (*dma_priv)
> -			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);
> -	}
> -
> +	ret = iommu_attach_device(priv->mapping, subdrv_dev);
>  	if (ret)
>  		clear_dma_max_seg_size(subdrv_dev);
>  
> @@ -105,21 +77,15 @@ static int drm_iommu_attach_device(struct drm_device *drm_dev,
>   * mapping
>   */
>  static void drm_iommu_detach_device(struct drm_device *drm_dev,
> -				    struct device *subdrv_dev, void **dma_priv)
> +				struct device *subdrv_dev)
>  {
>  	struct exynos_drm_private *priv = drm_dev->dev_private;
>  
> -	if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
> -		arm_iommu_detach_device(subdrv_dev);
> -		arm_iommu_attach_device(subdrv_dev, *dma_priv);
> -	} else if (IS_ENABLED(CONFIG_IOMMU_DMA))
> -		iommu_detach_device(priv->mapping, subdrv_dev);
> -
> +	iommu_detach_device(priv->mapping, subdrv_dev);
>  	clear_dma_max_seg_size(subdrv_dev);
>  }
>  
> -int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,
> -			    void **dma_priv)
> +int exynos_drm_register_dma(struct drm_device *drm, struct device *dev)
>  {
>  	struct exynos_drm_private *priv = drm->dev_private;
>  
> @@ -133,27 +99,20 @@ int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,
>  		return 0;
>  
>  	if (!priv->mapping) {
> -		void *mapping;
> -
> -		if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU))
> -			mapping = arm_iommu_create_mapping(&platform_bus_type,
> -				EXYNOS_DEV_ADDR_START, EXYNOS_DEV_ADDR_SIZE);
> -		else if (IS_ENABLED(CONFIG_IOMMU_DMA))
> -			mapping = iommu_get_domain_for_dev(priv->dma_dev);
> +		void *mapping = iommu_get_domain_for_dev(priv->dma_dev);
>  
>  		if (IS_ERR(mapping))
>  			return PTR_ERR(mapping);
>  		priv->mapping = mapping;
>  	}
>  
> -	return drm_iommu_attach_device(drm, dev, dma_priv);
> +	return drm_iommu_attach_device(drm, dev);
>  }
>  
> -void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev,
> -			       void **dma_priv)
> +void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev)
>  {
>  	if (IS_ENABLED(CONFIG_EXYNOS_IOMMU))
> -		drm_iommu_detach_device(drm, dev, dma_priv);
> +		drm_iommu_detach_device(drm, dev);
>  }
>  
>  void exynos_drm_cleanup_dma(struct drm_device *drm)
> @@ -163,7 +122,5 @@ void exynos_drm_cleanup_dma(struct drm_device *drm)
>  	if (!IS_ENABLED(CONFIG_EXYNOS_IOMMU))
>  		return;
>  
> -	arm_iommu_release_mapping(priv->mapping);
> -	priv->mapping = NULL;
>  	priv->dma_dev = NULL;
>  }
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> index 6ae9056e7a18..d4d21d8cfb90 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> @@ -223,10 +223,8 @@ static inline bool is_drm_iommu_supported(struct drm_device *drm_dev)
>  	return priv->mapping ? true : false;
>  }
>  
> -int exynos_drm_register_dma(struct drm_device *drm, struct device *dev,
> -			    void **dma_priv);
> -void exynos_drm_unregister_dma(struct drm_device *drm, struct device *dev,
> -			       void **dma_priv);
> +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
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
> index 29ab8be8604c..8ea2e1d77802 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
> @@ -97,7 +97,6 @@ struct fimc_scaler {
>  struct fimc_context {
>  	struct exynos_drm_ipp ipp;
>  	struct drm_device *drm_dev;
> -	void		*dma_priv;
>  	struct device	*dev;
>  	struct exynos_drm_ipp_task	*task;
>  	struct exynos_drm_ipp_formats	*formats;
> @@ -1134,7 +1133,7 @@ static int fimc_bind(struct device *dev, struct device *master, void *data)
>  
>  	ctx->drm_dev = drm_dev;
>  	ipp->drm_dev = drm_dev;
> -	exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);
> +	exynos_drm_register_dma(drm_dev, dev);
>  
>  	exynos_drm_ipp_register(dev, ipp, &ipp_funcs,
>  			DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |
> @@ -1154,7 +1153,7 @@ static void fimc_unbind(struct device *dev, struct device *master,
>  	struct exynos_drm_ipp *ipp = &ctx->ipp;
>  
>  	exynos_drm_ipp_unregister(dev, ipp);
> -	exynos_drm_unregister_dma(drm_dev, dev, &ctx->dma_priv);
> +	exynos_drm_unregister_dma(drm_dev, dev);
>  }
>  
>  static const struct component_ops fimc_component_ops = {
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> index bb67cad8371f..21aec38702fc 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> @@ -167,7 +167,6 @@ static struct fimd_driver_data exynos5420_fimd_driver_data = {
>  struct fimd_context {
>  	struct device			*dev;
>  	struct drm_device		*drm_dev;
> -	void				*dma_priv;
>  	struct exynos_drm_crtc		*crtc;
>  	struct exynos_drm_plane		planes[WINDOWS_NR];
>  	struct exynos_drm_plane_config	configs[WINDOWS_NR];
> @@ -1091,7 +1090,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 exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);
> +	return exynos_drm_register_dma(drm_dev, dev);
>  }
>  
>  static void fimd_unbind(struct device *dev, struct device *master,
> @@ -1101,7 +1100,7 @@ static void fimd_unbind(struct device *dev, struct device *master,
>  
>  	fimd_atomic_disable(ctx->crtc);
>  
> -	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev, &ctx->dma_priv);
> +	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev);
>  
>  	if (ctx->encoder)
>  		exynos_dpi_remove(ctx->encoder);
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
> index 03be31427181..256ceafd9945 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c
> @@ -232,7 +232,6 @@ struct g2d_runqueue_node {
>  
>  struct g2d_data {
>  	struct device			*dev;
> -	void				*dma_priv;
>  	struct clk			*gate_clk;
>  	void __iomem			*regs;
>  	int				irq;
> @@ -1410,7 +1409,7 @@ static int g2d_bind(struct device *dev, struct device *master, void *data)
>  		return ret;
>  	}
>  
> -	ret = exynos_drm_register_dma(drm_dev, dev, &g2d->dma_priv);
> +	ret = exynos_drm_register_dma(drm_dev, dev);
>  	if (ret < 0) {
>  		dev_err(dev, "failed to enable iommu.\n");
>  		g2d_fini_cmdlist(g2d);
> @@ -1435,7 +1434,7 @@ static void g2d_unbind(struct device *dev, struct device *master, void *data)
>  	priv->g2d_dev = NULL;
>  
>  	cancel_work_sync(&g2d->runqueue_work);
> -	exynos_drm_unregister_dma(g2d->drm_dev, dev, &g2d->dma_priv);
> +	exynos_drm_unregister_dma(g2d->drm_dev, dev);
>  }
>  
>  static const struct component_ops g2d_component_ops = {
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> index 45e9aee8366a..88b6fcaa20be 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> @@ -97,7 +97,6 @@ struct gsc_scaler {
>  struct gsc_context {
>  	struct exynos_drm_ipp ipp;
>  	struct drm_device *drm_dev;
> -	void		*dma_priv;
>  	struct device	*dev;
>  	struct exynos_drm_ipp_task	*task;
>  	struct exynos_drm_ipp_formats	*formats;
> @@ -1170,7 +1169,7 @@ static int gsc_bind(struct device *dev, struct device *master, void *data)
>  
>  	ctx->drm_dev = drm_dev;
>  	ctx->drm_dev = drm_dev;
> -	exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);
> +	exynos_drm_register_dma(drm_dev, dev);
>  
>  	exynos_drm_ipp_register(dev, ipp, &ipp_funcs,
>  			DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |
> @@ -1190,7 +1189,7 @@ static void gsc_unbind(struct device *dev, struct device *master,
>  	struct exynos_drm_ipp *ipp = &ctx->ipp;
>  
>  	exynos_drm_ipp_unregister(dev, ipp);
> -	exynos_drm_unregister_dma(drm_dev, dev, &ctx->dma_priv);
> +	exynos_drm_unregister_dma(drm_dev, dev);
>  }
>  
>  static const struct component_ops gsc_component_ops = {
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> index 2d94afba031e..f22fa0d2621a 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> @@ -56,7 +56,6 @@ struct rot_variant {
>  struct rot_context {
>  	struct exynos_drm_ipp ipp;
>  	struct drm_device *drm_dev;
> -	void		*dma_priv;
>  	struct device	*dev;
>  	void __iomem	*regs;
>  	struct clk	*clock;
> @@ -244,7 +243,7 @@ static int rotator_bind(struct device *dev, struct device *master, void *data)
>  
>  	rot->drm_dev = drm_dev;
>  	ipp->drm_dev = drm_dev;
> -	exynos_drm_register_dma(drm_dev, dev, &rot->dma_priv);
> +	exynos_drm_register_dma(drm_dev, dev);
>  
>  	exynos_drm_ipp_register(dev, ipp, &ipp_funcs,
>  			   DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE,
> @@ -262,7 +261,7 @@ static void rotator_unbind(struct device *dev, struct device *master,
>  	struct exynos_drm_ipp *ipp = &rot->ipp;
>  
>  	exynos_drm_ipp_unregister(dev, ipp);
> -	exynos_drm_unregister_dma(rot->drm_dev, rot->dev, &rot->dma_priv);
> +	exynos_drm_unregister_dma(rot->drm_dev, rot->dev);
>  }
>  
>  static const struct component_ops rotator_component_ops = {
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_scaler.c b/drivers/gpu/drm/exynos/exynos_drm_scaler.c
> index ce1857138f89..0c560566bd2e 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_scaler.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_scaler.c
> @@ -39,7 +39,6 @@ struct scaler_data {
>  struct scaler_context {
>  	struct exynos_drm_ipp		ipp;
>  	struct drm_device		*drm_dev;
> -	void				*dma_priv;
>  	struct device			*dev;
>  	void __iomem			*regs;
>  	struct clk			*clock[SCALER_MAX_CLK];
> @@ -451,7 +450,7 @@ static int scaler_bind(struct device *dev, struct device *master, void *data)
>  
>  	scaler->drm_dev = drm_dev;
>  	ipp->drm_dev = drm_dev;
> -	exynos_drm_register_dma(drm_dev, dev, &scaler->dma_priv);
> +	exynos_drm_register_dma(drm_dev, dev);
>  
>  	exynos_drm_ipp_register(dev, ipp, &ipp_funcs,
>  			DRM_EXYNOS_IPP_CAP_CROP | DRM_EXYNOS_IPP_CAP_ROTATE |
> @@ -471,8 +470,7 @@ static void scaler_unbind(struct device *dev, struct device *master,
>  	struct exynos_drm_ipp *ipp = &scaler->ipp;
>  
>  	exynos_drm_ipp_unregister(dev, ipp);
> -	exynos_drm_unregister_dma(scaler->drm_dev, scaler->dev,
> -				  &scaler->dma_priv);
> +	exynos_drm_unregister_dma(scaler->drm_dev, scaler->dev);
>  }
>  
>  static const struct component_ops scaler_component_ops = {
> diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
> index af192e5a16ef..18972e605c5d 100644
> --- a/drivers/gpu/drm/exynos/exynos_mixer.c
> +++ b/drivers/gpu/drm/exynos/exynos_mixer.c
> @@ -94,7 +94,6 @@ struct mixer_context {
>  	struct platform_device *pdev;
>  	struct device		*dev;
>  	struct drm_device	*drm_dev;
> -	void			*dma_priv;
>  	struct exynos_drm_crtc	*crtc;
>  	struct exynos_drm_plane	planes[MIXER_WIN_NR];
>  	unsigned long		flags;
> @@ -895,14 +894,12 @@ static int mixer_initialize(struct mixer_context *mixer_ctx,
>  		}
>  	}
>  
> -	return exynos_drm_register_dma(drm_dev, mixer_ctx->dev,
> -				       &mixer_ctx->dma_priv);
> +	return exynos_drm_register_dma(drm_dev, mixer_ctx->dev);
>  }
>  
>  static void mixer_ctx_remove(struct mixer_context *mixer_ctx)
>  {
> -	exynos_drm_unregister_dma(mixer_ctx->drm_dev, mixer_ctx->dev,
> -				  &mixer_ctx->dma_priv);
> +	exynos_drm_unregister_dma(mixer_ctx->drm_dev, mixer_ctx->dev);
>  }
>  
>  static int mixer_enable_vblank(struct exynos_drm_crtc *crtc)
>