Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH] swiotlb: add the missing dynamic swiotlb check in is_swiotlb_buffer
@ 2023-09-05  6:44 Christoph Hellwig
  2023-09-08 12:44 ` Petr Tesařík
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2023-09-05  6:44 UTC (permalink / raw)
  To: m.szyprowski, robin.murphy, petr.tesarik.ext; +Cc: iommu, Jonathan Corbet

Commit 1395706a1490 ("swiotlb: search the software IO TLB only if the
device makes use of it") claims to avoid the dynamic swiotlb lookup
unless dynamic allocations are actually used.  And while it adds all
the infrastructure for doing that, it misses the final bit of actually
checking the flag.  Actually add the check for this functionality to
work.

Fixes: 1395706a1490 ("swiotlb: search the software IO TLB only if the device makes use of it")
Reported-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 include/linux/swiotlb.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index b4536626f8ff35..a188025389836b 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -172,13 +172,17 @@ static inline bool is_swiotlb_buffer(struct device *dev, phys_addr_t paddr)
 	if (!mem)
 		return false;
 
-	if (IS_ENABLED(CONFIG_SWIOTLB_DYNAMIC)) {
-		/* Pairs with smp_wmb() in swiotlb_find_slots() and
+#ifdef CONFIG_SWIOTLB_DYNAMIC
+	if (dev->dma_uses_io_tlb) {
+		/*
+		 * Pairs with smp_wmb() in swiotlb_find_slots() and
 		 * swiotlb_dyn_alloc(), which modify the RCU lists.
 		 */
 		smp_rmb();
 		return swiotlb_find_pool(dev, paddr);
 	}
+#endif
+
 	return paddr >= mem->defpool.start && paddr < mem->defpool.end;
 }
 
-- 
2.39.2


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

end of thread, other threads:[~2023-09-13 11:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-05  6:44 [PATCH] swiotlb: add the missing dynamic swiotlb check in is_swiotlb_buffer Christoph Hellwig
2023-09-08 12:44 ` Petr Tesařík
2023-09-09  8:40   ` Christoph Hellwig
2023-09-13 11:10     ` Petr Tesařík

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