Skip to content

Commit cf5f86a

Browse files
davejiangvinodkoul
authored andcommitted
dmaengine: idxd: enable SVA feature for IOMMU
Enable IOMMU_DEV_FEAT_SVA before attempt to bind pasid. This is needed according to iommu_sva_bind_device() comment. Currently Intel IOMMU code does this before bind call. It really needs to be controlled by the driver. Signed-off-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/161894440621.3202472.17644507396206848134.stgit@djiang5-desk3.ch.intel.com Signed-off-by: Vinod Koul <[email protected]>
1 parent 8241571 commit cf5f86a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

drivers/dma/idxd/init.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,18 @@ static int idxd_probe(struct idxd_device *idxd)
501501
dev_dbg(dev, "IDXD reset complete\n");
502502

503503
if (IS_ENABLED(CONFIG_INTEL_IDXD_SVM) && sva) {
504-
rc = idxd_enable_system_pasid(idxd);
505-
if (rc < 0)
506-
dev_warn(dev, "Failed to enable PASID. No SVA support: %d\n", rc);
507-
else
508-
set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags);
504+
rc = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA);
505+
if (rc == 0) {
506+
rc = idxd_enable_system_pasid(idxd);
507+
if (rc < 0) {
508+
iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_SVA);
509+
dev_warn(dev, "Failed to enable PASID. No SVA support: %d\n", rc);
510+
} else {
511+
set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags);
512+
}
513+
} else {
514+
dev_warn(dev, "Unable to turn on SVA feature.\n");
515+
}
509516
} else if (!sva) {
510517
dev_warn(dev, "User forced SVA off via module param.\n");
511518
}
@@ -539,6 +546,7 @@ static int idxd_probe(struct idxd_device *idxd)
539546
err:
540547
if (device_pasid_enabled(idxd))
541548
idxd_disable_system_pasid(idxd);
549+
iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_SVA);
542550
return rc;
543551
}
544552

@@ -699,6 +707,7 @@ static void idxd_remove(struct pci_dev *pdev)
699707
if (device_pasid_enabled(idxd))
700708
idxd_disable_system_pasid(idxd);
701709
idxd_unregister_devices(idxd);
710+
iommu_dev_disable_feature(&pdev->dev, IOMMU_DEV_FEAT_SVA);
702711
}
703712

704713
static struct pci_driver idxd_pci_driver = {

0 commit comments

Comments
 (0)