[RFC PATCH 2/3] skip swiotlb pre copy if the device does full buffer write.

Jianxiong Gao jxgao at google.com
Tue Feb 4 15:36:29 PST 2025


In cases that the device is known to do a full buffer write, we
can skip the pre copy of the swiotlb buffer.

Signed-off-by: Jianxiong Gao <jxgao at google.com>
---
 kernel/dma/swiotlb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
index abcf3fa63a56..12124d4fd44f 100644
--- a/kernel/dma/swiotlb.c
+++ b/kernel/dma/swiotlb.c
@@ -1436,7 +1436,8 @@ phys_addr_t swiotlb_tbl_map_single(struct device *dev, phys_addr_t orig_addr,
 	 * hardware behavior.  Use of swiotlb is supposed to be transparent,
 	 * i.e. swiotlb must not corrupt memory by clobbering unwritten bytes.
 	 */
-	swiotlb_bounce(dev, tlb_addr, mapping_size, DMA_TO_DEVICE, pool);
+	if ((dir == DMA_TO_DEVICE) || !dma_is_full_buffer_write(dev))
+		swiotlb_bounce(dev, tlb_addr, mapping_size, DMA_TO_DEVICE, pool);
 	return tlb_addr;
 }
 
-- 
2.48.1.362.g079036d154-goog




More information about the Linux-nvme mailing list