diff --git a/target/linux/rockchip/patches-6.18/142-iommu-rockchip-translate-DMA-for-IOMMU-masters.patch b/target/linux/rockchip/patches-6.18/142-iommu-rockchip-translate-DMA-for-IOMMU-masters.patch new file mode 100644 index 00000000000..044a6257263 --- /dev/null +++ b/target/linux/rockchip/patches-6.18/142-iommu-rockchip-translate-DMA-for-IOMMU-masters.patch @@ -0,0 +1,47 @@ +From f69d2a3b86e90f4141d45be7d234f9a5ab464fe8 Mon Sep 17 00:00:00 2001 +From: Daniel Golle +Date: Thu, 24 Sep 2026 17:39:45 +0100 +Subject: [PATCH] iommu/rockchip: use a translated domain for IOMMU masters + +The masters behind rockchip-iommu are media blocks: the display +controller, the video codecs, the ISP and the 2D engine. They are wired +to the IOMMU so that their buffers do not have to be physically +contiguous. With a system-wide passthrough default, which is what +IOMMU_DEFAULT_PASSTHROUGH gives, those masters are handed an identity +domain instead, and every buffer has to come from CMA. A 4K frame needs +15.8 MiB of it, so hardware decoding fails the allocation and falls back +to software. + +Return IOMMU_DOMAIN_DMA from def_domain_type so these masters get a +translated domain whatever the system default is, the way apple-dart +does for its no-bypass configurations. Masters behind other IOMMUs are +untouched, so a PCIe root port behind an SMMU keeps the system default +and its performance. + +Signed-off-by: Daniel Golle +--- + drivers/iommu/rockchip-iommu.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +--- a/drivers/iommu/rockchip-iommu.c ++++ b/drivers/iommu/rockchip-iommu.c +@@ -1174,12 +1174,19 @@ static int rk_iommu_of_xlate(struct devi + return 0; + } + ++/* An identity domain would put these media masters back onto CMA. */ ++static int rk_iommu_def_domain_type(struct device *dev) ++{ ++ return IOMMU_DOMAIN_DMA; ++} ++ + static const struct iommu_ops rk_iommu_ops = { + .identity_domain = &rk_identity_domain, + .domain_alloc_paging = rk_iommu_domain_alloc_paging, + .probe_device = rk_iommu_probe_device, + .release_device = rk_iommu_release_device, + .device_group = generic_single_device_group, ++ .def_domain_type = rk_iommu_def_domain_type, + .of_xlate = rk_iommu_of_xlate, + .default_domain_ops = &(const struct iommu_domain_ops) { + .attach_dev = rk_iommu_attach_device,