diff options
author | Laurentiu Tudor <[email protected]> | 2023-09-26 18:26:00 +0300 |
---|---|---|
committer | Joerg Roedel <[email protected]> | 2023-11-27 10:22:46 +0100 |
commit | f1aad9df93f39267e890836a28d22511f23474e1 (patch) | |
tree | 0ed71f5570dba0a118ff42d4a8ba50f72fbbf8ff | |
parent | 2cc14f52aeb78ce3f29677c2de1f06c0e91471ab (diff) |
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 <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Acked-by: Thierry Reding <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Joerg Roedel <[email protected]>
-rw-r--r-- | drivers/iommu/of_iommu.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 157b286e36bf..5b3631ba5a45 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); |