[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240501201319.586289-1-tjmercier@google.com>
Date: Wed, 1 May 2024 20:13:18 +0000
From: "T.J. Mercier" <tjmercier@...gle.com>
To: tjmercier@...gle.com, Robin Murphy <robin.murphy@....com>,
Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>, Catalin Marinas <catalin.marinas@....com>
Cc: isaacmanjarres@...gle.com, iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org
Subject: [PATCH] iommu/dma: Respect SWIOTLB force_bounce
iommu_dma_map_page and iommu_dma_map_sg conditionally use SWIOTLB, but
checking if force_bounce is set for the device is not part of that
condition. Check if devices have requested to force SWIOTLB use as part
of deciding to take the existing SWIOTLB paths.
Fixes: 861370f49ce4 ("iommu/dma: force bouncing if the size is not cacheline-aligned")
Signed-off-by: T.J. Mercier <tjmercier@...gle.com>
---
drivers/iommu/dma-iommu.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
index e4cb26f6a943..755d66b49dff 100644
--- a/drivers/iommu/dma-iommu.c
+++ b/drivers/iommu/dma-iommu.c
@@ -606,7 +606,8 @@ static bool dev_use_swiotlb(struct device *dev, size_t size,
{
return IS_ENABLED(CONFIG_SWIOTLB) &&
(dev_is_untrusted(dev) ||
- dma_kmalloc_needs_bounce(dev, size, dir));
+ dma_kmalloc_needs_bounce(dev, size, dir) ||
+ is_swiotlb_force_bounce(dev));
}
static bool dev_use_sg_swiotlb(struct device *dev, struct scatterlist *sg,
@@ -632,7 +633,7 @@ static bool dev_use_sg_swiotlb(struct device *dev, struct scatterlist *sg,
return true;
}
- return false;
+ return is_swiotlb_force_bounce(dev);
}
/**
--
2.45.0.rc0.197.gbae5840b3b-goog
Powered by blists - more mailing lists