summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2016-12-30 10:13:38 -0500
committerAlex Williamson <alex.williamson@redhat.com>2016-12-30 10:13:38 -0500
commit42930553a7c11f06351bc08b889808d0f6020f08 (patch)
tree673ea947ecaa5529f007fc0fc4bc9a302eeddb18
parent49550787a90b5bfa44d8dc424d11824dbe21473d (diff)
vfio-mdev: de-polute the namespace, rename parent_device & parent_ops
Add an mdev_ prefix so we're not poluting the namespace so much. Cc: Zhenyu Wang <zhenyuw@linux.intel.com> Cc: Zhi Wang <zhi.a.wang@intel.com> Cc: Jike Song <jike.song@intel.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Reviewed by: Kirti Wankhede <kwankhede@nvidia.com>
-rw-r--r--Documentation/vfio-mediated-device.txt24
-rw-r--r--drivers/gpu/drm/i915/gvt/kvmgt.c2
-rw-r--r--drivers/vfio/mdev/mdev_core.c28
-rw-r--r--drivers/vfio/mdev/mdev_private.h6
-rw-r--r--drivers/vfio/mdev/mdev_sysfs.c8
-rw-r--r--drivers/vfio/mdev/vfio_mdev.c12
-rw-r--r--include/linux/mdev.h16
-rw-r--r--samples/vfio-mdev/mtty.c2
8 files changed, 49 insertions, 49 deletions
diff --git a/Documentation/vfio-mediated-device.txt b/Documentation/vfio-mediated-device.txt
index b38afec35edc..cfee106a3679 100644
--- a/Documentation/vfio-mediated-device.txt
+++ b/Documentation/vfio-mediated-device.txt
@@ -127,22 +127,22 @@ the VFIO when devices are unbound from the driver.
127Physical Device Driver Interface 127Physical Device Driver Interface
128-------------------------------- 128--------------------------------
129 129
130The physical device driver interface provides the parent_ops[3] structure to 130The physical device driver interface provides the mdev_parent_ops[3] structure
131define the APIs to manage work in the mediated core driver that is related to 131to define the APIs to manage work in the mediated core driver that is related
132the physical device. 132to the physical device.
133 133
134The structures in the parent_ops structure are as follows: 134The structures in the mdev_parent_ops structure are as follows:
135 135
136* dev_attr_groups: attributes of the parent device 136* dev_attr_groups: attributes of the parent device
137* mdev_attr_groups: attributes of the mediated device 137* mdev_attr_groups: attributes of the mediated device
138* supported_config: attributes to define supported configurations 138* supported_config: attributes to define supported configurations
139 139
140The functions in the parent_ops structure are as follows: 140The functions in the mdev_parent_ops structure are as follows:
141 141
142* create: allocate basic resources in a driver for a mediated device 142* create: allocate basic resources in a driver for a mediated device
143* remove: free resources in a driver when a mediated device is destroyed 143* remove: free resources in a driver when a mediated device is destroyed
144 144
145The callbacks in the parent_ops structure are as follows: 145The callbacks in the mdev_parent_ops structure are as follows:
146 146
147* open: open callback of mediated device 147* open: open callback of mediated device
148* close: close callback of mediated device 148* close: close callback of mediated device
@@ -151,14 +151,14 @@ The callbacks in the parent_ops structure are as follows:
151* write: write emulation callback 151* write: write emulation callback
152* mmap: mmap emulation callback 152* mmap: mmap emulation callback
153 153
154A driver should use the parent_ops structure in the function call to register 154A driver should use the mdev_parent_ops structure in the function call to
155itself with the mdev core driver: 155register itself with the mdev core driver:
156 156
157extern int mdev_register_device(struct device *dev, 157extern int mdev_register_device(struct device *dev,
158 const struct parent_ops *ops); 158 const struct mdev_parent_ops *ops);
159 159
160However, the parent_ops structure is not required in the function call that a 160However, the mdev_parent_ops structure is not required in the function call
161driver should use to unregister itself with the mdev core driver: 161that a driver should use to unregister itself with the mdev core driver:
162 162
163extern void mdev_unregister_device(struct device *dev); 163extern void mdev_unregister_device(struct device *dev);
164 164
@@ -394,5 +394,5 @@ References
394 394
395[1] See Documentation/vfio.txt for more information on VFIO. 395[1] See Documentation/vfio.txt for more information on VFIO.
396[2] struct mdev_driver in include/linux/mdev.h 396[2] struct mdev_driver in include/linux/mdev.h
397[3] struct parent_ops in include/linux/mdev.h 397[3] struct mdev_parent_ops in include/linux/mdev.h
398[4] struct vfio_iommu_driver_ops in include/linux/vfio.h 398[4] struct vfio_iommu_driver_ops in include/linux/vfio.h
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index 4dd6722a7339..081ada238107 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1089,7 +1089,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
1089 return 0; 1089 return 0;
1090} 1090}
1091 1091
1092static const struct parent_ops intel_vgpu_ops = { 1092static const struct mdev_parent_ops intel_vgpu_ops = {
1093 .supported_type_groups = intel_vgpu_type_groups, 1093 .supported_type_groups = intel_vgpu_type_groups,
1094 .create = intel_vgpu_create, 1094 .create = intel_vgpu_create,
1095 .remove = intel_vgpu_remove, 1095 .remove = intel_vgpu_remove,
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index 6bb4d4c469ab..bf3b3b0b3d2b 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -45,7 +45,7 @@ static int _find_mdev_device(struct device *dev, void *data)
45 return 0; 45 return 0;
46} 46}
47 47
48static bool mdev_device_exist(struct parent_device *parent, uuid_le uuid) 48static bool mdev_device_exist(struct mdev_parent *parent, uuid_le uuid)
49{ 49{
50 struct device *dev; 50 struct device *dev;
51 51
@@ -59,9 +59,9 @@ static bool mdev_device_exist(struct parent_device *parent, uuid_le uuid)
59} 59}
60 60
61/* Should be called holding parent_list_lock */ 61/* Should be called holding parent_list_lock */
62static struct parent_device *__find_parent_device(struct device *dev) 62static struct mdev_parent *__find_parent_device(struct device *dev)
63{ 63{
64 struct parent_device *parent; 64 struct mdev_parent *parent;
65 65
66 list_for_each_entry(parent, &parent_list, next) { 66 list_for_each_entry(parent, &parent_list, next) {
67 if (parent->dev == dev) 67 if (parent->dev == dev)
@@ -72,8 +72,8 @@ static struct parent_device *__find_parent_device(struct device *dev)
72 72
73static void mdev_release_parent(struct kref *kref) 73static void mdev_release_parent(struct kref *kref)
74{ 74{
75 struct parent_device *parent = container_of(kref, struct parent_device, 75 struct mdev_parent *parent = container_of(kref, struct mdev_parent,
76 ref); 76 ref);
77 struct device *dev = parent->dev; 77 struct device *dev = parent->dev;
78 78
79 kfree(parent); 79 kfree(parent);
@@ -81,7 +81,7 @@ static void mdev_release_parent(struct kref *kref)
81} 81}
82 82
83static 83static
84inline struct parent_device *mdev_get_parent(struct parent_device *parent) 84inline struct mdev_parent *mdev_get_parent(struct mdev_parent *parent)
85{ 85{
86 if (parent) 86 if (parent)
87 kref_get(&parent->ref); 87 kref_get(&parent->ref);
@@ -89,7 +89,7 @@ inline struct parent_device *mdev_get_parent(struct parent_device *parent)
89 return parent; 89 return parent;
90} 90}
91 91
92static inline void mdev_put_parent(struct parent_device *parent) 92static inline void mdev_put_parent(struct mdev_parent *parent)
93{ 93{
94 if (parent) 94 if (parent)
95 kref_put(&parent->ref, mdev_release_parent); 95 kref_put(&parent->ref, mdev_release_parent);
@@ -98,7 +98,7 @@ static inline void mdev_put_parent(struct parent_device *parent)
98static int mdev_device_create_ops(struct kobject *kobj, 98static int mdev_device_create_ops(struct kobject *kobj,
99 struct mdev_device *mdev) 99 struct mdev_device *mdev)
100{ 100{
101 struct parent_device *parent = mdev->parent; 101 struct mdev_parent *parent = mdev->parent;
102 int ret; 102 int ret;
103 103
104 ret = parent->ops->create(kobj, mdev); 104 ret = parent->ops->create(kobj, mdev);
@@ -125,7 +125,7 @@ static int mdev_device_create_ops(struct kobject *kobj,
125 */ 125 */
126static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove) 126static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove)
127{ 127{
128 struct parent_device *parent = mdev->parent; 128 struct mdev_parent *parent = mdev->parent;
129 int ret; 129 int ret;
130 130
131 /* 131 /*
@@ -156,10 +156,10 @@ static int mdev_device_remove_cb(struct device *dev, void *data)
156 * Add device to list of registered parent devices. 156 * Add device to list of registered parent devices.
157 * Returns a negative value on error, otherwise 0. 157 * Returns a negative value on error, otherwise 0.
158 */ 158 */
159int mdev_register_device(struct device *dev, const struct parent_ops *ops) 159int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
160{ 160{
161 int ret; 161 int ret;
162 struct parent_device *parent; 162 struct mdev_parent *parent;
163 163
164 /* check for mandatory ops */ 164 /* check for mandatory ops */
165 if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups) 165 if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
@@ -232,7 +232,7 @@ EXPORT_SYMBOL(mdev_register_device);
232 232
233void mdev_unregister_device(struct device *dev) 233void mdev_unregister_device(struct device *dev)
234{ 234{
235 struct parent_device *parent; 235 struct mdev_parent *parent;
236 bool force_remove = true; 236 bool force_remove = true;
237 237
238 mutex_lock(&parent_list_lock); 238 mutex_lock(&parent_list_lock);
@@ -269,7 +269,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
269{ 269{
270 int ret; 270 int ret;
271 struct mdev_device *mdev; 271 struct mdev_device *mdev;
272 struct parent_device *parent; 272 struct mdev_parent *parent;
273 struct mdev_type *type = to_mdev_type(kobj); 273 struct mdev_type *type = to_mdev_type(kobj);
274 274
275 parent = mdev_get_parent(type->parent); 275 parent = mdev_get_parent(type->parent);
@@ -338,7 +338,7 @@ create_err:
338int mdev_device_remove(struct device *dev, bool force_remove) 338int mdev_device_remove(struct device *dev, bool force_remove)
339{ 339{
340 struct mdev_device *mdev, *tmp; 340 struct mdev_device *mdev, *tmp;
341 struct parent_device *parent; 341 struct mdev_parent *parent;
342 struct mdev_type *type; 342 struct mdev_type *type;
343 int ret; 343 int ret;
344 bool found = false; 344 bool found = false;
diff --git a/drivers/vfio/mdev/mdev_private.h b/drivers/vfio/mdev/mdev_private.h
index d35097cbf3d7..0b72c2d9ee40 100644
--- a/drivers/vfio/mdev/mdev_private.h
+++ b/drivers/vfio/mdev/mdev_private.h
@@ -19,7 +19,7 @@ void mdev_bus_unregister(void);
19struct mdev_type { 19struct mdev_type {
20 struct kobject kobj; 20 struct kobject kobj;
21 struct kobject *devices_kobj; 21 struct kobject *devices_kobj;
22 struct parent_device *parent; 22 struct mdev_parent *parent;
23 struct list_head next; 23 struct list_head next;
24 struct attribute_group *group; 24 struct attribute_group *group;
25}; 25};
@@ -29,8 +29,8 @@ struct mdev_type {
29#define to_mdev_type(_kobj) \ 29#define to_mdev_type(_kobj) \
30 container_of(_kobj, struct mdev_type, kobj) 30 container_of(_kobj, struct mdev_type, kobj)
31 31
32int parent_create_sysfs_files(struct parent_device *parent); 32int parent_create_sysfs_files(struct mdev_parent *parent);
33void parent_remove_sysfs_files(struct parent_device *parent); 33void parent_remove_sysfs_files(struct mdev_parent *parent);
34 34
35int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type); 35int mdev_create_sysfs_files(struct device *dev, struct mdev_type *type);
36void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type); 36void mdev_remove_sysfs_files(struct device *dev, struct mdev_type *type);
diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
index 1a53deb2ee10..802df210929b 100644
--- a/drivers/vfio/mdev/mdev_sysfs.c
+++ b/drivers/vfio/mdev/mdev_sysfs.c
@@ -92,7 +92,7 @@ static struct kobj_type mdev_type_ktype = {
92 .release = mdev_type_release, 92 .release = mdev_type_release,
93}; 93};
94 94
95struct mdev_type *add_mdev_supported_type(struct parent_device *parent, 95struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
96 struct attribute_group *group) 96 struct attribute_group *group)
97{ 97{
98 struct mdev_type *type; 98 struct mdev_type *type;
@@ -158,7 +158,7 @@ static void remove_mdev_supported_type(struct mdev_type *type)
158 kobject_put(&type->kobj); 158 kobject_put(&type->kobj);
159} 159}
160 160
161static int add_mdev_supported_type_groups(struct parent_device *parent) 161static int add_mdev_supported_type_groups(struct mdev_parent *parent)
162{ 162{
163 int i; 163 int i;
164 164
@@ -183,7 +183,7 @@ static int add_mdev_supported_type_groups(struct parent_device *parent)
183} 183}
184 184
185/* mdev sysfs functions */ 185/* mdev sysfs functions */
186void parent_remove_sysfs_files(struct parent_device *parent) 186void parent_remove_sysfs_files(struct mdev_parent *parent)
187{ 187{
188 struct mdev_type *type, *tmp; 188 struct mdev_type *type, *tmp;
189 189
@@ -196,7 +196,7 @@ void parent_remove_sysfs_files(struct parent_device *parent)
196 kset_unregister(parent->mdev_types_kset); 196 kset_unregister(parent->mdev_types_kset);
197} 197}
198 198
199int parent_create_sysfs_files(struct parent_device *parent) 199int parent_create_sysfs_files(struct mdev_parent *parent)
200{ 200{
201 int ret; 201 int ret;
202 202
diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c
index ffc36758cb84..fa848a701b8b 100644
--- a/drivers/vfio/mdev/vfio_mdev.c
+++ b/drivers/vfio/mdev/vfio_mdev.c
@@ -27,7 +27,7 @@
27static int vfio_mdev_open(void *device_data) 27static int vfio_mdev_open(void *device_data)
28{ 28{
29 struct mdev_device *mdev = device_data; 29 struct mdev_device *mdev = device_data;
30 struct parent_device *parent = mdev->parent; 30 struct mdev_parent *parent = mdev->parent;
31 int ret; 31 int ret;
32 32
33 if (unlikely(!parent->ops->open)) 33 if (unlikely(!parent->ops->open))
@@ -46,7 +46,7 @@ static int vfio_mdev_open(void *device_data)
46static void vfio_mdev_release(void *device_data) 46static void vfio_mdev_release(void *device_data)
47{ 47{
48 struct mdev_device *mdev = device_data; 48 struct mdev_device *mdev = device_data;
49 struct parent_device *parent = mdev->parent; 49 struct mdev_parent *parent = mdev->parent;
50 50
51 if (likely(parent->ops->release)) 51 if (likely(parent->ops->release))
52 parent->ops->release(mdev); 52 parent->ops->release(mdev);
@@ -58,7 +58,7 @@ static long vfio_mdev_unlocked_ioctl(void *device_data,
58 unsigned int cmd, unsigned long arg) 58 unsigned int cmd, unsigned long arg)
59{ 59{
60 struct mdev_device *mdev = device_data; 60 struct mdev_device *mdev = device_data;
61 struct parent_device *parent = mdev->parent; 61 struct mdev_parent *parent = mdev->parent;
62 62
63 if (unlikely(!parent->ops->ioctl)) 63 if (unlikely(!parent->ops->ioctl))
64 return -EINVAL; 64 return -EINVAL;
@@ -70,7 +70,7 @@ static ssize_t vfio_mdev_read(void *device_data, char __user *buf,
70 size_t count, loff_t *ppos) 70 size_t count, loff_t *ppos)
71{ 71{
72 struct mdev_device *mdev = device_data; 72 struct mdev_device *mdev = device_data;
73 struct parent_device *parent = mdev->parent; 73 struct mdev_parent *parent = mdev->parent;
74 74
75 if (unlikely(!parent->ops->read)) 75 if (unlikely(!parent->ops->read))
76 return -EINVAL; 76 return -EINVAL;
@@ -82,7 +82,7 @@ static ssize_t vfio_mdev_write(void *device_data, const char __user *buf,
82 size_t count, loff_t *ppos) 82 size_t count, loff_t *ppos)
83{ 83{
84 struct mdev_device *mdev = device_data; 84 struct mdev_device *mdev = device_data;
85 struct parent_device *parent = mdev->parent; 85 struct mdev_parent *parent = mdev->parent;
86 86
87 if (unlikely(!parent->ops->write)) 87 if (unlikely(!parent->ops->write))
88 return -EINVAL; 88 return -EINVAL;
@@ -93,7 +93,7 @@ static ssize_t vfio_mdev_write(void *device_data, const char __user *buf,
93static int vfio_mdev_mmap(void *device_data, struct vm_area_struct *vma) 93static int vfio_mdev_mmap(void *device_data, struct vm_area_struct *vma)
94{ 94{
95 struct mdev_device *mdev = device_data; 95 struct mdev_device *mdev = device_data;
96 struct parent_device *parent = mdev->parent; 96 struct mdev_parent *parent = mdev->parent;
97 97
98 if (unlikely(!parent->ops->mmap)) 98 if (unlikely(!parent->ops->mmap))
99 return -EINVAL; 99 return -EINVAL;
diff --git a/include/linux/mdev.h b/include/linux/mdev.h
index ec819e9a115a..853bb78e5866 100644
--- a/include/linux/mdev.h
+++ b/include/linux/mdev.h
@@ -14,9 +14,9 @@
14#define MDEV_H 14#define MDEV_H
15 15
16/* Parent device */ 16/* Parent device */
17struct parent_device { 17struct mdev_parent {
18 struct device *dev; 18 struct device *dev;
19 const struct parent_ops *ops; 19 const struct mdev_parent_ops *ops;
20 20
21 /* internal */ 21 /* internal */
22 struct kref ref; 22 struct kref ref;
@@ -29,7 +29,7 @@ struct parent_device {
29/* Mediated device */ 29/* Mediated device */
30struct mdev_device { 30struct mdev_device {
31 struct device dev; 31 struct device dev;
32 struct parent_device *parent; 32 struct mdev_parent *parent;
33 uuid_le uuid; 33 uuid_le uuid;
34 void *driver_data; 34 void *driver_data;
35 35
@@ -40,7 +40,7 @@ struct mdev_device {
40}; 40};
41 41
42/** 42/**
43 * struct parent_ops - Structure to be registered for each parent device to 43 * struct mdev_parent_ops - Structure to be registered for each parent device to
44 * register the device to mdev module. 44 * register the device to mdev module.
45 * 45 *
46 * @owner: The module owner. 46 * @owner: The module owner.
@@ -86,10 +86,10 @@ struct mdev_device {
86 * @mdev: mediated device structure 86 * @mdev: mediated device structure
87 * @vma: vma structure 87 * @vma: vma structure
88 * Parent device that support mediated device should be registered with mdev 88 * Parent device that support mediated device should be registered with mdev
89 * module with parent_ops structure. 89 * module with mdev_parent_ops structure.
90 **/ 90 **/
91 91
92struct parent_ops { 92struct mdev_parent_ops {
93 struct module *owner; 93 struct module *owner;
94 const struct attribute_group **dev_attr_groups; 94 const struct attribute_group **dev_attr_groups;
95 const struct attribute_group **mdev_attr_groups; 95 const struct attribute_group **mdev_attr_groups;
@@ -159,7 +159,7 @@ extern struct bus_type mdev_bus_type;
159#define dev_is_mdev(d) ((d)->bus == &mdev_bus_type) 159#define dev_is_mdev(d) ((d)->bus == &mdev_bus_type)
160 160
161extern int mdev_register_device(struct device *dev, 161extern int mdev_register_device(struct device *dev,
162 const struct parent_ops *ops); 162 const struct mdev_parent_ops *ops);
163extern void mdev_unregister_device(struct device *dev); 163extern void mdev_unregister_device(struct device *dev);
164 164
165extern int mdev_register_driver(struct mdev_driver *drv, struct module *owner); 165extern int mdev_register_driver(struct mdev_driver *drv, struct module *owner);
diff --git a/samples/vfio-mdev/mtty.c b/samples/vfio-mdev/mtty.c
index 6b633a4ea333..1a74f0e488da 100644
--- a/samples/vfio-mdev/mtty.c
+++ b/samples/vfio-mdev/mtty.c
@@ -1402,7 +1402,7 @@ struct attribute_group *mdev_type_groups[] = {
1402 NULL, 1402 NULL,
1403}; 1403};
1404 1404
1405struct parent_ops mdev_fops = { 1405struct mdev_parent_ops mdev_fops = {
1406 .owner = THIS_MODULE, 1406 .owner = THIS_MODULE,
1407 .dev_attr_groups = mtty_dev_groups, 1407 .dev_attr_groups = mtty_dev_groups,
1408 .mdev_attr_groups = mdev_dev_groups, 1408 .mdev_attr_groups = mdev_dev_groups,