diff options
| -rw-r--r-- | drivers/vfio/mdev/mdev_core.c | 18 | ||||
| -rw-r--r-- | drivers/vfio/mdev/mdev_private.h | 1 | ||||
| -rw-r--r-- | include/linux/mdev.h | 14 |
3 files changed, 33 insertions, 0 deletions
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c index b96fedc77ee5..1b6435529166 100644 --- a/drivers/vfio/mdev/mdev_core.c +++ b/drivers/vfio/mdev/mdev_core.c | |||
| @@ -390,6 +390,24 @@ int mdev_device_remove(struct device *dev, bool force_remove) | |||
| 390 | return 0; | 390 | return 0; |
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | int mdev_set_iommu_device(struct device *dev, struct device *iommu_device) | ||
| 394 | { | ||
| 395 | struct mdev_device *mdev = to_mdev_device(dev); | ||
| 396 | |||
| 397 | mdev->iommu_device = iommu_device; | ||
| 398 | |||
| 399 | return 0; | ||
| 400 | } | ||
| 401 | EXPORT_SYMBOL(mdev_set_iommu_device); | ||
| 402 | |||
| 403 | struct device *mdev_get_iommu_device(struct device *dev) | ||
| 404 | { | ||
| 405 | struct mdev_device *mdev = to_mdev_device(dev); | ||
| 406 | |||
| 407 | return mdev->iommu_device; | ||
| 408 | } | ||
| 409 | EXPORT_SYMBOL(mdev_get_iommu_device); | ||
| 410 | |||
| 393 | static int __init mdev_init(void) | 411 | static int __init mdev_init(void) |
| 394 | { | 412 | { |
| 395 | return mdev_bus_register(); | 413 | return mdev_bus_register(); |
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h index 379758c52b1b..f4eba723fea5 100644 --- a/drivers/vfio/mdev/mdev_private.h +++ b/drivers/vfio/mdev/mdev_private.h | |||
| @@ -33,6 +33,7 @@ struct mdev_device { | |||
| 33 | struct kref ref; | 33 | struct kref ref; |
| 34 | struct list_head next; | 34 | struct list_head next; |
| 35 | struct kobject *type_kobj; | 35 | struct kobject *type_kobj; |
| 36 | struct device *iommu_device; | ||
| 36 | bool active; | 37 | bool active; |
| 37 | }; | 38 | }; |
| 38 | 39 | ||
diff --git a/include/linux/mdev.h b/include/linux/mdev.h index d7aee90e5da5..df2ea39f47ee 100644 --- a/include/linux/mdev.h +++ b/include/linux/mdev.h | |||
| @@ -15,6 +15,20 @@ | |||
| 15 | 15 | ||
| 16 | struct mdev_device; | 16 | struct mdev_device; |
| 17 | 17 | ||
| 18 | /* | ||
| 19 | * Called by the parent device driver to set the device which represents | ||
| 20 | * this mdev in iommu protection scope. By default, the iommu device is | ||
| 21 | * NULL, that indicates using vendor defined isolation. | ||
| 22 | * | ||
| 23 | * @dev: the mediated device that iommu will isolate. | ||
| 24 | * @iommu_device: a pci device which represents the iommu for @dev. | ||
| 25 | * | ||
| 26 | * Return 0 for success, otherwise negative error value. | ||
| 27 | */ | ||
| 28 | int mdev_set_iommu_device(struct device *dev, struct device *iommu_device); | ||
| 29 | |||
| 30 | struct device *mdev_get_iommu_device(struct device *dev); | ||
| 31 | |||
| 18 | /** | 32 | /** |
| 19 | * struct mdev_parent_ops - Structure to be registered for each parent device to | 33 | * struct mdev_parent_ops - Structure to be registered for each parent device to |
| 20 | * register the device to mdev module. | 34 | * register the device to mdev module. |
