2020-02-24 23:21:35

by Jacob Pan

[permalink] [raw]
Subject: [PATCH 1/2] iommu/vt-d: Report SVA feature with generic flag

Query Shared Virtual Address/Memory capability is a generic feature.
SVA feature check is the required first step before calling
iommu_sva_bind_device().

VT-d checks SVA feature enabling at per IOMMU level during this step,
SVA bind device will check and enable PCI ATS, PRS, and PASID capabilities
at device level.

This patch reports Intel SVM as SVA feature such that generic code
(e.g. Uacce [1]) can use it.

[1] https://lkml.org/lkml/2020/1/15/604

Signed-off-by: Jacob Pan <[email protected]>
---
drivers/iommu/intel-iommu.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 92c2f2e4197b..5eca6e10d2a4 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -6346,9 +6346,14 @@ intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat)
static int
intel_iommu_dev_enable_feat(struct device *dev, enum iommu_dev_features feat)
{
+ struct intel_iommu *intel_iommu = dev_to_intel_iommu(dev);
+
if (feat == IOMMU_DEV_FEAT_AUX)
return intel_iommu_enable_auxd(dev);

+ if (feat == IOMMU_DEV_FEAT_SVA)
+ return intel_iommu->flags & VTD_FLAG_SVM_CAPABLE;
+
return -ENODEV;
}

--
2.7.4


2020-03-20 09:32:41

by Jean-Philippe Brucker

[permalink] [raw]
Subject: Re: [PATCH 1/2] iommu/vt-d: Report SVA feature with generic flag

On Mon, Feb 24, 2020 at 03:26:36PM -0800, Jacob Pan wrote:
> Query Shared Virtual Address/Memory capability is a generic feature.
> SVA feature check is the required first step before calling
> iommu_sva_bind_device().
>
> VT-d checks SVA feature enabling at per IOMMU level during this step,
> SVA bind device will check and enable PCI ATS, PRS, and PASID capabilities
> at device level.
>
> This patch reports Intel SVM as SVA feature such that generic code
> (e.g. Uacce [1]) can use it.
>
> [1] https://lkml.org/lkml/2020/1/15/604
>
> Signed-off-by: Jacob Pan <[email protected]>

Don't you also need to have has_feat(), feat_enabled() and disable_feat()
return positive values?

Thanks,
Jean

> ---
> drivers/iommu/intel-iommu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 92c2f2e4197b..5eca6e10d2a4 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -6346,9 +6346,14 @@ intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat)
> static int
> intel_iommu_dev_enable_feat(struct device *dev, enum iommu_dev_features feat)
> {
> + struct intel_iommu *intel_iommu = dev_to_intel_iommu(dev);
> +
> if (feat == IOMMU_DEV_FEAT_AUX)
> return intel_iommu_enable_auxd(dev);
>
> + if (feat == IOMMU_DEV_FEAT_SVA)
> + return intel_iommu->flags & VTD_FLAG_SVM_CAPABLE;
> +
> return -ENODEV;
> }
>
> --
> 2.7.4
>