[PATCH v2] habanalabs: Stop using iommu_present()

Robin Murphy posted 1 patch 4 years, 2 months ago
drivers/misc/habanalabs/common/debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] habanalabs: Stop using iommu_present()
Posted by Robin Murphy 4 years, 2 months ago
Even if an IOMMU might be present for some PCI segment in the system,
that doesn't necessarily mean it provides translation for the device
we care about. Replace iommu_present() with a more appropriate check.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---

v2: Rebase on habanalabs-next

 drivers/misc/habanalabs/common/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/habanalabs/common/debugfs.c b/drivers/misc/habanalabs/common/debugfs.c
index 7c4a4d504e4c..a94f01713efd 100644
--- a/drivers/misc/habanalabs/common/debugfs.c
+++ b/drivers/misc/habanalabs/common/debugfs.c
@@ -722,7 +722,7 @@ static int hl_access_mem(struct hl_device *hdev, u64 addr, u64 *val,
 	if (found)
 		return 0;
 
-	if (!user_address || iommu_present(&pci_bus_type)) {
+	if (!user_address || device_iommu_mapped(&hdev->pdev->dev)) {
 		rc = -EINVAL;
 		goto err;
 	}
-- 
2.28.0.dirty
Re: [PATCH v2] habanalabs: Stop using iommu_present()
Posted by Oded Gabbay 4 years, 2 months ago
On Mon, Apr 11, 2022 at 3:36 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> Even if an IOMMU might be present for some PCI segment in the system,
> that doesn't necessarily mean it provides translation for the device
> we care about. Replace iommu_present() with a more appropriate check.
>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>
> v2: Rebase on habanalabs-next
>
>  drivers/misc/habanalabs/common/debugfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/habanalabs/common/debugfs.c b/drivers/misc/habanalabs/common/debugfs.c
> index 7c4a4d504e4c..a94f01713efd 100644
> --- a/drivers/misc/habanalabs/common/debugfs.c
> +++ b/drivers/misc/habanalabs/common/debugfs.c
> @@ -722,7 +722,7 @@ static int hl_access_mem(struct hl_device *hdev, u64 addr, u64 *val,
>         if (found)
>                 return 0;
>
> -       if (!user_address || iommu_present(&pci_bus_type)) {
> +       if (!user_address || device_iommu_mapped(&hdev->pdev->dev)) {
>                 rc = -EINVAL;
>                 goto err;
>         }
> --
> 2.28.0.dirty
>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Applied to -next.
Thanks,
Oded