History

drm/rockchip: Detach from ARM DMA domain in attach_device

Since commit 1ea2a07a532b ("iommu: Add DMA ownership management interfaces") the Rockchip display driver on the Firefly RK3288 fails to initialise properly. This is because ARM DMA domain is still attached. Let's follow the lead of exynos and tegra and add code to explicitly remove the ARM domain before attaching a new one.

Steven Price committed 4 years ago

Commit 8490cad1 parent 1dbc7901 file · +17 −0Browse files

Unified · Split

drivers/gpu/drm/rockchip/rockchip_drm_drv.c+17−0
@@ -23,6 +23,14 @@ · 22 unmodified lines
2323 #include <drm/drm_probe_helper.h>
2424 #include <drm/drm_vblank.h>
2525
26+#if defined(CONFIG_ARM_DMA_USE_IOMMU)
27+#include <asm/dma-iommu.h>
28+#else
29+#define arm_iommu_detach_device(...) ({ })
30+#define arm_iommu_release_mapping(...) ({ })
31+#define to_dma_iommu_mapping(dev) NULL
32+#endif
33+
2634 #include "rockchip_drm_drv.h"
2735 #include "rockchip_drm_fb.h"
2836 #include "rockchip_drm_gem.h"
@@ -49,6 +57,15 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, · 20 unmodified lines
4957 if (!private->domain)
5058 return 0;
5159
60+ if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
61+ struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
62+
63+ if (mapping) {
64+ arm_iommu_detach_device(dev);
65+ arm_iommu_release_mapping(mapping);
66+ }
67+ }
68+
5269 ret = iommu_attach_device(private->domain, dev);
5370 if (ret) {
5471 DRM_DEV_ERROR(dev, "Failed to attach iommu device\n");