From: Laurentiu Tudor Date: Tue, 26 Sep 2023 15:26:00 +0000 (+0300) Subject: iommu: Map reserved memory as cacheable if device is coherent X-Git-Tag: v6.8-rc1~49^2^8~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f1aad9df93f39267e890836a28d22511f23474e1;p=thirdparty%2Fkernel%2Flinux.git iommu: Map reserved memory as cacheable if device is coherent Check if the device is marked as DMA coherent in the DT and if so, map its reserved memory as cacheable in the IOMMU. This fixes the recently added IOMMU reserved memory support which uses IOMMU_RESV_DIRECT without properly building the PROT for the mapping. Fixes: a5bf3cfce8cb ("iommu: Implement of_iommu_get_resv_regions()") Signed-off-by: Laurentiu Tudor Reviewed-by: Jason Gunthorpe Acked-by: Thierry Reding Link: https://lore.kernel.org/r/20230926152600.8749-1-laurentiu.tudor@nxp.com Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 157b286e36bf3..5b3631ba5a451 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -254,6 +254,9 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list) phys_addr_t iova; size_t length; + if (of_dma_is_coherent(dev->of_node)) + prot |= IOMMU_CACHE; + maps = of_translate_dma_region(np, maps, &iova, &length); type = iommu_resv_region_get_type(dev, &phys, iova, length);