On Thu, 2022-11-17 at 09:55 +0800, Baolu Lu wrote:
On 2022/11/17 1:16, Niklas Schnelle wrote:That's a good point. How about instead of unconditionally returning
When iommu.strict=1 is set or iommu_set_dma_strict() was called weIf any quirky device must work in IOMMU identity mapping mode, this
should use IOMMU_DOMAIN_DMA irrespective of ops->def_domain_type.
Signed-off-by: Niklas Schnelle<schnelle@xxxxxxxxxxxxx>
---
drivers/iommu/iommu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 65a3b3d886dc..d9bf94d198df 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1562,6 +1562,9 @@ static int iommu_get_def_domain_type(struct device *dev)
{
const struct iommu_ops *ops = dev_iommu_ops(dev);
+ if (iommu_dma_strict)
+ return IOMMU_DOMAIN_DMA;
might introduce functional regression. At least for VT-d platforms, some
devices do require IOMMU identity mapping mode for functionality.
IOMMU_DOMAIN_DMA we just do so if the domain type returned by ops-
def_domain_type uses a flush queue (i.e. the __IOMMU_DOMAIN_DMA_FQ bitis set). That way a device that only supports identity mapping gets to
set that but iommu_dma_strict at least always prevents use of an IOVA
flush queue.