From 185f7978bf971ce0cfee4e614463e38f133098e9 Mon Sep 17 00:00:00 2001 From: Vitalij Borissow <250549977+vitalijborissow@users.noreply.github.com> Date: Sun, 15 Feb 2026 21:36:32 +0100 Subject: [PATCH] Add IOMMU GFP_DMA32 patch for RK3568 8GB systems Force GFP_DMA32 allocation for Rockchip IOMMU v2 page tables to fix NPU operation on systems with >4GB RAM. Without this patch, IOMMU allocates page tables above 4GB which the NPU cannot access, causing DMA mapping failures. Tested on ODROID-M1 with 8GB RAM, kernel 6.18.9-current-rockchip64. --- ...chip-force-DMA32-for-rk3568-iommu-v2.patch | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 patch/kernel/rockchip64-current/0001-iommu-rockchip-force-DMA32-for-rk3568-iommu-v2.patch diff --git a/patch/kernel/rockchip64-current/0001-iommu-rockchip-force-DMA32-for-rk3568-iommu-v2.patch b/patch/kernel/rockchip64-current/0001-iommu-rockchip-force-DMA32-for-rk3568-iommu-v2.patch new file mode 100644 index 0000000000..3532ef1cc1 --- /dev/null +++ b/patch/kernel/rockchip64-current/0001-iommu-rockchip-force-DMA32-for-rk3568-iommu-v2.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Vitalij Borissow <250549977+vitalijborissow@users.noreply.github.com> +Date: Sat, 15 Feb 2026 21:30:00 +0100 +Subject: iommu/rockchip: Force GFP_DMA32 for rk3568-iommu v2 + +On systems with >4GB RAM, the RK3568 IOMMU v2 allocates page tables from +high memory (above 4GB). While the IOMMU claims 40-bit address support, +some devices like the NPU cannot properly handle page tables located +above 4GB, resulting in DMA mapping failures and NPU timeouts. + +This patch forces GFP_DMA32 allocation for IOMMU v2 page tables, +ensuring all allocations are within the first 4GB of physical memory. + +Tested on ODROID-M1 with 8GB RAM running kernel 6.18.9-current-rockchip64. +Without this patch, NPU inference fails with IOMMU page table access errors. +With this patch, NPU operates correctly with full IOMMU support enabled. + +Signed-off-by: Vitalij Borissow <250549977+vitalijborissow@users.noreply.github.com> +--- + drivers/iommu/rockchip-iommu.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c +index 111111111111..222222222222 100644 +--- a/drivers/iommu/rockchip-iommu.c ++++ b/drivers/iommu/rockchip-iommu.c +@@ -1349,7 +1349,7 @@ static struct rk_iommu_ops iommu_data_ops_v2 = { + .mk_dtentries = &rk_mk_dte_v2, + .mk_ptentries = &rk_mk_pte_v2, + .dma_bit_mask = DMA_BIT_MASK(40), +- .gfp_flags = 0, ++ .gfp_flags = GFP_DMA32, + }; + + static const struct of_device_id rk_iommu_dt_ids[] = { +-- +Armbian