Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Fixes: 1ea2a07a532b ("iommu: Add DMA ownership management interfaces")
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220615154830.555422-1-steven.price@arm.com

authored by

Steven Price and committed by
Heiko Stuebner
8490cad4 1dbc790b

+17
+17
drivers/gpu/drm/rockchip/rockchip_drm_drv.c
··· 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" ··· 56 48 57 49 if (!private->domain) 58 50 return 0; 51 + 52 + if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) { 53 + struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev); 54 + 55 + if (mapping) { 56 + arm_iommu_detach_device(dev); 57 + arm_iommu_release_mapping(mapping); 58 + } 59 + } 59 60 60 61 ret = iommu_attach_device(private->domain, dev); 61 62 if (ret) {