diff mbox series

[v10,04/10] iommu/vt-d: Support IOMMU_DEV_FEAT_IOPF

Message ID 20210121123623.2060416-5-jean-philippe@linaro.org (mailing list archive)
State New, archived
Headers show
Series iommu: I/O page faults for SMMUv3 | expand

Commit Message

Jean-Philippe Brucker Jan. 21, 2021, 12:36 p.m. UTC
Allow drivers to query and enable IOMMU_DEV_FEAT_IOPF, which amounts to
checking whether PRI is enabled.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/iommu/intel/iommu.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Lu Baolu Jan. 22, 2021, 1:54 a.m. UTC | #1
Hi Jean,

On 1/21/21 8:36 PM, Jean-Philippe Brucker wrote:
> Allow drivers to query and enable IOMMU_DEV_FEAT_IOPF, which amounts to
> checking whether PRI is enabled.
> 
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>

Best regards,
baolu

> ---
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>   drivers/iommu/intel/iommu.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index f665322a0991..c777bd94df5d 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -5330,6 +5330,8 @@ static int siov_find_pci_dvsec(struct pci_dev *pdev)
>   static bool
>   intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat)
>   {
> +	struct device_domain_info *info = get_domain_info(dev);
> +
>   	if (feat == IOMMU_DEV_FEAT_AUX) {
>   		int ret;
>   
> @@ -5344,13 +5346,13 @@ intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat)
>   		return !!siov_find_pci_dvsec(to_pci_dev(dev));
>   	}
>   
> -	if (feat == IOMMU_DEV_FEAT_SVA) {
> -		struct device_domain_info *info = get_domain_info(dev);
> +	if (feat == IOMMU_DEV_FEAT_IOPF)
> +		return info && info->pri_supported;
>   
> +	if (feat == IOMMU_DEV_FEAT_SVA)
>   		return info && (info->iommu->flags & VTD_FLAG_SVM_CAPABLE) &&
>   			info->pasid_supported && info->pri_supported &&
>   			info->ats_supported;
> -	}
>   
>   	return false;
>   }
> @@ -5361,6 +5363,9 @@ intel_iommu_dev_enable_feat(struct device *dev, enum iommu_dev_features feat)
>   	if (feat == IOMMU_DEV_FEAT_AUX)
>   		return intel_iommu_enable_auxd(dev);
>   
> +	if (feat == IOMMU_DEV_FEAT_IOPF)
> +		return intel_iommu_dev_has_feat(dev, feat) ? 0 : -ENODEV;
> +
>   	if (feat == IOMMU_DEV_FEAT_SVA) {
>   		struct device_domain_info *info = get_domain_info(dev);
>   
>
diff mbox series

Patch

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index f665322a0991..c777bd94df5d 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -5330,6 +5330,8 @@  static int siov_find_pci_dvsec(struct pci_dev *pdev)
 static bool
 intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat)
 {
+	struct device_domain_info *info = get_domain_info(dev);
+
 	if (feat == IOMMU_DEV_FEAT_AUX) {
 		int ret;
 
@@ -5344,13 +5346,13 @@  intel_iommu_dev_has_feat(struct device *dev, enum iommu_dev_features feat)
 		return !!siov_find_pci_dvsec(to_pci_dev(dev));
 	}
 
-	if (feat == IOMMU_DEV_FEAT_SVA) {
-		struct device_domain_info *info = get_domain_info(dev);
+	if (feat == IOMMU_DEV_FEAT_IOPF)
+		return info && info->pri_supported;
 
+	if (feat == IOMMU_DEV_FEAT_SVA)
 		return info && (info->iommu->flags & VTD_FLAG_SVM_CAPABLE) &&
 			info->pasid_supported && info->pri_supported &&
 			info->ats_supported;
-	}
 
 	return false;
 }
@@ -5361,6 +5363,9 @@  intel_iommu_dev_enable_feat(struct device *dev, enum iommu_dev_features feat)
 	if (feat == IOMMU_DEV_FEAT_AUX)
 		return intel_iommu_enable_auxd(dev);
 
+	if (feat == IOMMU_DEV_FEAT_IOPF)
+		return intel_iommu_dev_has_feat(dev, feat) ? 0 : -ENODEV;
+
 	if (feat == IOMMU_DEV_FEAT_SVA) {
 		struct device_domain_info *info = get_domain_info(dev);