Re: [PATCH] dma-mapping: reliably inform about DMA support for IOMMU

From: Robin Murphy
Date: Wed Sep 11 2024 - 08:55:00 EST


On 2024-09-11 11:15 am, Leon Romanovsky wrote:
From: Leon Romanovsky <leonro@xxxxxxxxxx>

If the DMA IOMMU path is going to be used, the appropriate check should
return that DMA is supported.

Oof, indeed the significance of what iommu_dma_ops *didn't* implement is a subtle one...

Reviewed-by: Robin Murphy <robin.murphy@xxxxxxx>

Fixes: b5c58b2fdc42 ("dma-mapping: direct calls for dma-iommu")
Closes: https://lore.kernel.org/all/181e06ff-35a3-434f-b505-672f430bd1cb@notapiano
Reported-by: Nícolas F. R. A. Prado <nfraprado@xxxxxxxxxxxxx> #KernelCI
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
---
kernel/dma/mapping.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index 1a7de37bd643..38d7b3239dbb 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -824,6 +824,9 @@ static int dma_supported(struct device *dev, u64 mask)
if (WARN_ON(ops && use_dma_iommu(dev)))
return false;
+
+ if (use_dma_iommu(dev))
+ return true;
/*
* ->dma_supported sets the bypass flag, so we must always call
* into the method here unless the device is truly direct mapped.