diff --git a/patches.suse/iommu-mediatek-Flush-IOTLB-completely-only-if-domain.patch b/patches.suse/iommu-mediatek-Flush-IOTLB-completely-only-if-domain.patch new file mode 100644 index 0000000..a9a1d39 --- /dev/null +++ b/patches.suse/iommu-mediatek-Flush-IOTLB-completely-only-if-domain.patch @@ -0,0 +1,58 @@ +From b3fc95709c54ffbe80f16801e0a792a4d2b3d55e Mon Sep 17 00:00:00 2001 +From: Chen-Yu Tsai +Date: Fri, 26 May 2023 16:53:59 +0800 +Subject: [PATCH] iommu/mediatek: Flush IOTLB completely only if domain has + been attached +Git-commit: b3fc95709c54ffbe80f16801e0a792a4d2b3d55e +Patch-mainline: v6.4-rc5 +References: git-fixes + +If an IOMMU domain was never attached, it lacks any linkage to the +actual IOMMU hardware. Attempting to do flush_iotlb_all() on it will +result in a NULL pointer dereference. This seems to happen after the +recent IOMMU core rework in v6.4-rc1. + + Unable to handle kernel read from unreadable memory at virtual address 0000000000000018 + Call trace: + mtk_iommu_flush_iotlb_all+0x20/0x80 + iommu_create_device_direct_mappings.part.0+0x13c/0x230 + iommu_setup_default_domain+0x29c/0x4d0 + iommu_probe_device+0x12c/0x190 + of_iommu_configure+0x140/0x208 + of_dma_configure_id+0x19c/0x3c0 + platform_dma_configure+0x38/0x88 + really_probe+0x78/0x2c0 + +Check if the "bank" field has been filled in before actually attempting +the IOTLB flush to avoid it. The IOTLB is also flushed when the device +comes out of runtime suspend, so it should have a clean initial state. + +Fixes: 08500c43d4f7 ("iommu/mediatek: Adjust the structure") +Signed-off-by: Chen-Yu Tsai +Reviewed-by: Yong Wu +Reviewed-by: AngeloGioacchino Del Regno +Link: https://lore.kernel.org/r/20230526085402.394239-1-wenst@chromium.org +Signed-off-by: Joerg Roedel +Acked-by: Vasant Karasulli + +--- + drivers/iommu/mtk_iommu.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c +index aecc7d154f28..e93906d6e112 100644 +--- a/drivers/iommu/mtk_iommu.c ++++ b/drivers/iommu/mtk_iommu.c +@@ -781,7 +781,8 @@ static void mtk_iommu_flush_iotlb_all(struct iommu_domain *domain) + { + struct mtk_iommu_domain *dom = to_mtk_domain(domain); + +- mtk_iommu_tlb_flush_all(dom->bank->parent_data); ++ if (dom->bank) ++ mtk_iommu_tlb_flush_all(dom->bank->parent_data); + } + + static void mtk_iommu_iotlb_sync(struct iommu_domain *domain, +-- +2.34.1 + diff --git a/series.conf b/series.conf index 5e30f32..c18eeb8 100644 --- a/series.conf +++ b/series.conf @@ -42146,6 +42146,7 @@ patches.suse/iommu-rockchip-Fix-unwind-goto-issue.patch patches.suse/iommu-amd-Don-t-block-updates-to-GATag-if-guest-mode.patch patches.suse/iommu-amd-Fix-domain-flush-size-when-syncing-iotlb.patch + patches.suse/iommu-mediatek-Flush-IOTLB-completely-only-if-domain.patch patches.suse/mmc-vub300-fix-invalid-response-handling.patch patches.suse/md-raid5-fix-miscalculation-of-end_sector-in-raid5_r-8557.patch patches.suse/block-fix-revalidate-performance-regression.patch