@@ -5346,6 +5346,23 @@ static struct iommu_group *intel_iommu_device_group(struct device *dev)
return ERR_PTR(-EINVAL);
}
+static int intel_iommu_set_bus(struct bus_type *bus, struct iommu_device *idev)
+{
+ struct intel_iommu *iommu;
+
+ iommu = container_of(idev, struct intel_iommu, iommu);
+ if (strcmp(bus->name, "mdev"))
+ return -EINVAL;
+
+ if (!sm_supported(iommu))
+ return -ENODEV;
+
+ bus_set_iommu(bus, &intel_iommu_ops);
+ bus_register_notifier(bus, &device_nb);
+
+ return 0;
+}
+
#ifdef CONFIG_INTEL_IOMMU_SVM
int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sdev)
{
@@ -5440,6 +5457,7 @@ const struct iommu_ops intel_iommu_ops = {
.remove_device = intel_iommu_remove_device,
.get_resv_regions = intel_iommu_get_resv_regions,
.put_resv_regions = intel_iommu_put_resv_regions,
+ .set_bus = intel_iommu_set_bus,
.device_group = intel_iommu_device_group,
.pgsize_bitmap = INTEL_IOMMU_PGSIZES,
};