aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/vfio-mediated-device.txt3
-rw-r--r--drivers/gpu/drm/i915/gvt/kvmgt.c2
-rw-r--r--drivers/vfio/mdev/mdev_core.c6
-rw-r--r--drivers/vfio/mdev/mdev_private.h10
-rw-r--r--include/linux/mdev.h15
-rw-r--r--samples/vfio-mdev/mtty.c2
6 files changed, 23 insertions, 15 deletions
diff --git a/Documentation/vfio-mediated-device.txt b/Documentation/vfio-mediated-device.txt
index cfee106a3679..d226c7a5ba8b 100644
--- a/Documentation/vfio-mediated-device.txt
+++ b/Documentation/vfio-mediated-device.txt
@@ -223,6 +223,9 @@ Directories and files under the sysfs for Each Physical Device
223 223
224 sprintf(buf, "%s-%s", dev_driver_string(parent->dev), group->name); 224 sprintf(buf, "%s-%s", dev_driver_string(parent->dev), group->name);
225 225
226 (or using mdev_parent_dev(mdev) to arrive at the parent device outside
227 of the core mdev code)
228
226* device_api 229* device_api
227 230
228 This attribute should show which device API is being created, for example, 231 This attribute should show which device API is being created, for example,
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 081ada238107..38500329aa92 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -396,7 +396,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev)
396 struct device *pdev; 396 struct device *pdev;
397 void *gvt; 397 void *gvt;
398 398
399 pdev = mdev->parent->dev; 399 pdev = mdev_parent_dev(mdev);
400 gvt = kdev_to_i915(pdev)->gvt; 400 gvt = kdev_to_i915(pdev)->gvt;
401 401
402 type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj)); 402 type = intel_gvt_find_vgpu_type(gvt, kobject_name(kobj));
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index bf3b3b0b3d2b..30d05304241e 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -30,6 +30,12 @@ static struct class_compat *mdev_bus_compat_class;
30static LIST_HEAD(mdev_list); 30static LIST_HEAD(mdev_list);
31static DEFINE_MUTEX(mdev_list_lock); 31static DEFINE_MUTEX(mdev_list_lock);
32 32
33struct device *mdev_parent_dev(struct mdev_device *mdev)
34{
35 return mdev->parent->dev;
36}
37EXPORT_SYMBOL(mdev_parent_dev);
38
33static int _find_mdev_device(struct device *dev, void *data) 39static int _find_mdev_device(struct device *dev, void *data)
34{ 40{
35 struct mdev_device *mdev; 41 struct mdev_device *mdev;
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
index 0b72c2d9ee40..b05dd22fc9a6 100644
--- a/drivers/vfio/mdev/mdev_private.h
+++ b/drivers/vfio/mdev/mdev_private.h
@@ -16,6 +16,16 @@
16int mdev_bus_register(void); 16int mdev_bus_register(void);
17void mdev_bus_unregister(void); 17void mdev_bus_unregister(void);
18 18
19struct mdev_parent {
20 struct device *dev;
21 const struct mdev_parent_ops *ops;
22 struct kref ref;
23 struct mutex lock;
24 struct list_head next;
25 struct kset *mdev_types_kset;
26 struct list_head type_list;
27};
28
19struct mdev_type { 29struct mdev_type {
20 struct kobject kobj; 30 struct kobject kobj;
21 struct kobject *devices_kobj; 31 struct kobject *devices_kobj;
diff --git a/include/linux/mdev.h b/include/linux/mdev.h
index 853bb78e5866..f586222b6c25 100644
--- a/include/linux/mdev.h
+++ b/include/linux/mdev.h
@@ -13,19 +13,6 @@
13#ifndef MDEV_H 13#ifndef MDEV_H
14#define MDEV_H 14#define MDEV_H
15 15
16/* Parent device */
17struct mdev_parent {
18 struct device *dev;
19 const struct mdev_parent_ops *ops;
20
21 /* internal */
22 struct kref ref;
23 struct mutex lock;
24 struct list_head next;
25 struct kset *mdev_types_kset;
26 struct list_head type_list;
27};
28
29/* Mediated device */ 16/* Mediated device */
30struct mdev_device { 17struct mdev_device {
31 struct device dev; 18 struct device dev;
@@ -165,4 +152,6 @@ extern void mdev_unregister_device(struct device *dev);
165extern int mdev_register_driver(struct mdev_driver *drv, struct module *owner); 152extern int mdev_register_driver(struct mdev_driver *drv, struct module *owner);
166extern void mdev_unregister_driver(struct mdev_driver *drv); 153extern void mdev_unregister_driver(struct mdev_driver *drv);
167 154
155extern struct device *mdev_parent_dev(struct mdev_device *mdev);
156
168#endif /* MDEV_H */ 157#endif /* MDEV_H */
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 1a74f0e488da..5e13efc62bad 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -734,7 +734,7 @@ int mtty_create(struct kobject *kobj, struct mdev_device *mdev)
734 734
735 for (i = 0; i < 2; i++) { 735 for (i = 0; i < 2; i++) {
736 snprintf(name, MTTY_STRING_LEN, "%s-%d", 736 snprintf(name, MTTY_STRING_LEN, "%s-%d",
737 dev_driver_string(mdev->parent->dev), i + 1); 737 dev_driver_string(mdev_parent_dev(mdev)), i + 1);
738 if (!strcmp(kobj->name, name)) { 738 if (!strcmp(kobj->name, name)) {
739 nr_ports = i + 1; 739 nr_ports = i + 1;
740 break; 740 break;