Skip to content

Commit 3d4c7cc

Browse files
LuBaolujoergroedel
authored andcommitted
iommu/vt-d: Move iopf code from SVA to IOPF enabling path
Generally enabling IOMMU_DEV_FEAT_SVA requires IOMMU_DEV_FEAT_IOPF, but some devices manage I/O Page Faults themselves instead of relying on the IOMMU. Move IOPF related code from SVA to IOPF enabling path. For the device drivers that relies on the IOMMU for IOPF through PCI/PRI, IOMMU_DEV_FEAT_IOPF must be enabled before and disabled after IOMMU_DEV_FEAT_SVA. Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Link: https://lore.kernel.org/r/20230324120234.313643-4-baolu.lu@linux.intel.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent a86fb77 commit 3d4c7cc

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

drivers/iommu/intel/iommu.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4638,7 +4638,6 @@ static int intel_iommu_enable_sva(struct device *dev)
46384638
{
46394639
struct device_domain_info *info = dev_iommu_priv_get(dev);
46404640
struct intel_iommu *iommu;
4641-
int ret;
46424641

46434642
if (!info || dmar_disabled)
46444643
return -EINVAL;
@@ -4667,6 +4666,21 @@ static int intel_iommu_enable_sva(struct device *dev)
46674666
if (!info->pri_enabled)
46684667
return -EINVAL;
46694668

4669+
return 0;
4670+
}
4671+
4672+
static int intel_iommu_enable_iopf(struct device *dev)
4673+
{
4674+
struct device_domain_info *info = dev_iommu_priv_get(dev);
4675+
struct intel_iommu *iommu;
4676+
int ret;
4677+
4678+
if (!info || !info->ats_enabled || !info->pri_enabled)
4679+
return -ENODEV;
4680+
iommu = info->iommu;
4681+
if (!iommu)
4682+
return -EINVAL;
4683+
46704684
ret = iopf_queue_add_device(iommu->iopf_queue, dev);
46714685
if (ret)
46724686
return ret;
@@ -4678,7 +4692,7 @@ static int intel_iommu_enable_sva(struct device *dev)
46784692
return ret;
46794693
}
46804694

4681-
static int intel_iommu_disable_sva(struct device *dev)
4695+
static int intel_iommu_disable_iopf(struct device *dev)
46824696
{
46834697
struct device_domain_info *info = dev_iommu_priv_get(dev);
46844698
struct intel_iommu *iommu = info->iommu;
@@ -4695,16 +4709,6 @@ static int intel_iommu_disable_sva(struct device *dev)
46954709
return ret;
46964710
}
46974711

4698-
static int intel_iommu_enable_iopf(struct device *dev)
4699-
{
4700-
struct device_domain_info *info = dev_iommu_priv_get(dev);
4701-
4702-
if (info && info->pri_supported)
4703-
return 0;
4704-
4705-
return -ENODEV;
4706-
}
4707-
47084712
static int
47094713
intel_iommu_dev_enable_feat(struct device *dev, enum iommu_dev_features feat)
47104714
{
@@ -4725,10 +4729,10 @@ intel_iommu_dev_disable_feat(struct device *dev, enum iommu_dev_features feat)
47254729
{
47264730
switch (feat) {
47274731
case IOMMU_DEV_FEAT_IOPF:
4728-
return 0;
4732+
return intel_iommu_disable_iopf(dev);
47294733

47304734
case IOMMU_DEV_FEAT_SVA:
4731-
return intel_iommu_disable_sva(dev);
4735+
return 0;
47324736

47334737
default:
47344738
return -ENODEV;

0 commit comments

Comments
 (0)