public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] iommu: Avoid unnecessary cache invalidations
@ 2023-10-26  8:49 Lu Baolu
  2023-10-27  4:30 ` Henry Willard
  2023-10-27  6:57 ` Joerg Roedel
  0 siblings, 2 replies; 3+ messages in thread
From: Lu Baolu @ 2023-10-26  8:49 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Will Deacon, Robin Murphy, Jason Gunthorpe, Kevin Tian, iommu,
	linux-kernel, Lu Baolu

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>
---
 drivers/iommu/iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 00d0a2b5d7dc..0cb676590bfa 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1114,7 +1114,8 @@ static int iommu_create_device_direct_mappings(struct iommu_domain *domain,
 
 	}
 
-	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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-27  6:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-26  8:49 [PATCH 1/1] iommu: Avoid unnecessary cache invalidations Lu Baolu
2023-10-27  4:30 ` Henry Willard
2023-10-27  6:57 ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox