Commit cf5f86a7 authored by Dave Jiang's avatar Dave Jiang Committed by Vinod Koul

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: default avatarDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/161894440621.3202472.17644507396206848134.stgit@djiang5-desk3.ch.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 8241571f
...@@ -501,11 +501,18 @@ static int idxd_probe(struct idxd_device *idxd) ...@@ -501,11 +501,18 @@ static int idxd_probe(struct idxd_device *idxd)
dev_dbg(dev, "IDXD reset complete\n"); dev_dbg(dev, "IDXD reset complete\n");
if (IS_ENABLED(CONFIG_INTEL_IDXD_SVM) && sva) { if (IS_ENABLED(CONFIG_INTEL_IDXD_SVM) && sva) {
rc = idxd_enable_system_pasid(idxd); rc = iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA);
if (rc < 0) if (rc == 0) {
dev_warn(dev, "Failed to enable PASID. No SVA support: %d\n", rc); rc = idxd_enable_system_pasid(idxd);
else if (rc < 0) {
set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags); iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_SVA);
dev_warn(dev, "Failed to enable PASID. No SVA support: %d\n", rc);
} else {
set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags);
}
} else {
dev_warn(dev, "Unable to turn on SVA feature.\n");
}
} else if (!sva) { } else if (!sva) {
dev_warn(dev, "User forced SVA off via module param.\n"); dev_warn(dev, "User forced SVA off via module param.\n");
} }
...@@ -539,6 +546,7 @@ static int idxd_probe(struct idxd_device *idxd) ...@@ -539,6 +546,7 @@ static int idxd_probe(struct idxd_device *idxd)
err: err:
if (device_pasid_enabled(idxd)) if (device_pasid_enabled(idxd))
idxd_disable_system_pasid(idxd); idxd_disable_system_pasid(idxd);
iommu_dev_disable_feature(dev, IOMMU_DEV_FEAT_SVA);
return rc; return rc;
} }
...@@ -699,6 +707,7 @@ static void idxd_remove(struct pci_dev *pdev) ...@@ -699,6 +707,7 @@ static void idxd_remove(struct pci_dev *pdev)
if (device_pasid_enabled(idxd)) if (device_pasid_enabled(idxd))
idxd_disable_system_pasid(idxd); idxd_disable_system_pasid(idxd);
idxd_unregister_devices(idxd); idxd_unregister_devices(idxd);
iommu_dev_disable_feature(&pdev->dev, IOMMU_DEV_FEAT_SVA);
} }
static struct pci_driver idxd_pci_driver = { static struct pci_driver idxd_pci_driver = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment