diff options
author | Lu Baolu <baolu.lu@linux.intel.com> | 2023-10-26 10:49:42 +0200 |
---|---|---|
committer | Joerg Roedel <jroedel@suse.de> | 2023-10-27 08:57:09 +0200 |
commit | 6e6c6d6bc6c96c2477ddfea24a121eb5ee12b7a3 (patch) | |
tree | d76aa2991d69cbdf9790df77862f2445b05194c1 /drivers/iommu | |
parent | Linux 6.6-rc7 (diff) | |
download | linux-6e6c6d6bc6c96c2477ddfea24a121eb5ee12b7a3.tar.xz linux-6e6c6d6bc6c96c2477ddfea24a121eb5ee12b7a3.zip |
iommu: Avoid unnecessary cache invalidations
The iommu_create_device_direct_mappings() only needs to flush the caches
when the mappings are changed in the affected domain. This is not true
for non-DMA domains, or for devices attached to the domain that have no
reserved regions. To avoid unnecessary cache invalidations, add a check
before iommu_flush_iotlb_all().
Fixes: a48ce36e2786 ("iommu: Prevent RESV_DIRECT devices from blocking domains")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Tested-by: Henry Willard <henry.willard@oracle.com>
Link: https://lore.kernel.org/r/20231026084942.17387-1-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r-- | drivers/iommu/iommu.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 3bfc56df4f78..c146378c7d03 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1108,7 +1108,8 @@ map_end: } - iommu_flush_iotlb_all(domain); + if (!list_empty(&mappings) && iommu_is_dma_domain(domain)) + iommu_flush_iotlb_all(domain); out: iommu_put_resv_regions(dev, &mappings); |