drm/exynos: Properly release default ARM DMA-IOMMU mapping

Message ID 1490601872-17369-1-git-send-email-m.szyprowski@samsung.com
State New
Headers show

Commit Message

Marek Szyprowski March 27, 2017, 8:04 a.m.
Exynos DRM on ARM architecture creates its own DMA-IOMMU mapping, shared
between all devices that builds the Exynos DRM subsystem. Thus, the
default DMA-IOMMU mapping structure created by platform init code can be
released to avoid leaking resources, because after exynos_iommu_attach()
the default mapping is no longer accessible.

Reported-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

 drivers/gpu/drm/exynos/exynos_drm_iommu.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)


To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


diff --git a/drivers/gpu/drm/exynos/exynos_drm_iommu.h b/drivers/gpu/drm/exynos/exynos_drm_iommu.h
index 87f6b5672e11..7a4528461bba 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_iommu.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_iommu.h
@@ -37,8 +37,13 @@  static inline int __exynos_iommu_create_mapping(struct exynos_drm_private *priv,
 static inline int __exynos_iommu_attach(struct exynos_drm_private *priv,
 					struct device *dev)
-	if (dev->archdata.mapping)
+	struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
+	/* release device from the default DMA-IOMMU mapping */
+	if (mapping) {
+		arm_iommu_release_mapping(mapping);
+	}
 	return arm_iommu_attach_device(dev, priv->mapping);