Commit f1aad9df authored by Laurentiu Tudor's avatar Laurentiu Tudor Committed by Joerg Roedel

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: a5bf3cfc ("iommu: Implement of_iommu_get_resv_regions()")
Signed-off-by: default avatarLaurentiu Tudor <laurentiu.tudor@nxp.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Acked-by: default avatarThierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20230926152600.8749-1-laurentiu.tudor@nxp.comSigned-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 2cc14f52
...@@ -254,6 +254,9 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list) ...@@ -254,6 +254,9 @@ void of_iommu_get_resv_regions(struct device *dev, struct list_head *list)
phys_addr_t iova; phys_addr_t iova;
size_t length; size_t length;
if (of_dma_is_coherent(dev->of_node))
prot |= IOMMU_CACHE;
maps = of_translate_dma_region(np, maps, &iova, &length); maps = of_translate_dma_region(np, maps, &iova, &length);
type = iommu_resv_region_get_type(dev, &phys, iova, length); type = iommu_resv_region_get_type(dev, &phys, iova, length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment