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.
Unified · Split
| @@ -23,6 +23,14 @@ · 22 unmodified lines | ||
| 23 | 23 | #include <drm/drm_probe_helper.h> |
| 24 | 24 | #include <drm/drm_vblank.h> |
| 25 | 25 | |
| 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 | + | |
| 26 | 34 | #include "rockchip_drm_drv.h" |
| 27 | 35 | #include "rockchip_drm_fb.h" |
| 28 | 36 | #include "rockchip_drm_gem.h" |
| @@ -49,6 +57,15 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, · 20 unmodified lines | ||
| 49 | 57 | if (!private->domain) |
| 50 | 58 | return 0; |
| 51 | 59 | |
| 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 | + | |
| 52 | 69 | ret = iommu_attach_device(private->domain, dev); |
| 53 | 70 | if (ret) { |
| 54 | 71 | DRM_DEV_ERROR(dev, "Failed to attach iommu device\n"); |