mdev based hardware virtio offloading support
Subsystems (16)
v4 cover mdev based hardware virtio offloading support
Hi all:
There are hardwares that can do virtio datapath offloading while having its own control path. This path tries to implement a mdev based unified API to support using kernel virtio driver to drive those devices. This is done by introducing a new mdev transport for virtio (virtio_mdev) and register itself as a new kind of mdev driver. Then it provides a unified way for kernel virtio driver to talk with mdev device implementation.
Though the series only contains kernel driver support, the goal is to make the transport generic enough to support userspace drivers. This means vhost-mdev[1] could be built on top as well by resuing the transport.
A sample driver is also implemented which simulate a virito-net loopback ethernet device on top of vringh + workqueue. This could be used as a reference implementation for real hardware driver.
Also a real ICF VF driver was also posted here[2] which is a good reference for vendors who is interested in their own virtio datapath offloading product.
Consider mdev framework only support VFIO device and driver right now, this series also extend it to support other types. This is done through introducing class id to the device and pairing it with id_talbe claimed by the driver. On top, this seris also decouple device specific parents ops out of the common ones.
Pktgen test was done with virito-net + mvnet loop back device.
Please review.
[1] https://lkml.org/lkml/2019/9/26/15
[2] https://lkml.org/lkml/2019/10/15/1226
Changes from V3:
- document that class id (device ops) must be specified in create()
- add WARN() when trying to set class_id when it has already set
- add WARN() when class_id is not specified in create() and correctly return an error in this case
- correct the prototype of mdev_set_class() in the doc
- add documention of mdev_set_class()
- remove the unnecessary "class_id_fail" label when class id is not specified in create()
- convert id_table in vfio_mdev to const
- move mdev_set_class and its friends after mdev_uuid()
- suqash the patch of bus uevent into patch of introducing class id
- tweak the words in the docs per Cornelia suggestion
- tie class_id and device ops through class specific initialization routine like mdev_set_vfio_ops()
- typos fixes in the docs of virtio-mdev callbacks
- document the usage of virtqueues in struct virtio_mdev_device
- remove the useless vqs array in struct virtio_mdev_device
- rename MDEV_ID_XXX to MDEV_CLASS_ID_XXX
Changes from V2:
- fail when class_id is not specified
- drop the vringh patch
- match the doc to the code
- tweak the commit log
- move device_ops from parent to mdev device
- remove the unused MDEV_ID_VHOST
Changes from V1:
- move virtio_mdev.c to drivers/virtio
- store class_id in mdev_device instead of mdev_parent
- store device_ops in mdev_device instead of mdev_parent
- reorder the patch, vringh fix comes first
- really silent compiling warnings
- really switch to use u16 for class_id
- uevent and modpost support for mdev class_id
- vraious tweaks per comments from Parav
Changes from RFC-V2:
- silent compile warnings on some specific configuration
- use u16 instead u8 for class id
- reseve MDEV_ID_VHOST for future vhost-mdev work
- introduce "virtio" type for mvnet and make "vhost" type for future work
- add entries in MAINTAINER
- tweak and typos fixes in commit log
Changes from RFC-V1:
- rename device id to class id
- add docs for class id and device specific ops (device_ops)
- split device_ops into seperate headers
- drop the mdev_set_dma_ops()
- use device_ops to implement the transport API, then it's not a part of UAPI any more
- use GFP_ATOMIC in mvnet sample device and other tweaks
- set_vring_base/get_vring_base support for mvnet device
Jason Wang (6):
mdev: class id support
modpost: add support for mdev class id
mdev: introduce device specific ops
mdev: introduce virtio device and its device ops
virtio: introduce a mdev based transport
docs: sample driver to demonstrate how to implement virtio-mdev
framework
.../driver-api/vfio-mediated-device.rst | 22 +- MAINTAINERS | 2 + drivers/gpu/drm/i915/gvt/kvmgt.c | 17 +- drivers/s390/cio/vfio_ccw_ops.c | 17 +- drivers/s390/crypto/vfio_ap_ops.c | 13 +- drivers/vfio/mdev/mdev_core.c | 38 + drivers/vfio/mdev/mdev_driver.c | 22 + drivers/vfio/mdev/mdev_private.h | 2 + drivers/vfio/mdev/vfio_mdev.c | 45 +- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++ include/linux/mdev.h | 55 +- include/linux/mod_devicetable.h | 8 + include/linux/vfio_mdev.h | 52 ++ include/linux/virtio_mdev.h | 151 ++++ samples/Kconfig | 7 + samples/vfio-mdev/Makefile | 1 + samples/vfio-mdev/mbochs.c | 19 +- samples/vfio-mdev/mdpy.c | 19 +- samples/vfio-mdev/mtty.c | 17 +- samples/vfio-mdev/mvnet.c | 691 ++++++++++++++++++ scripts/mod/devicetable-offsets.c | 3 + scripts/mod/file2alias.c | 10 + 24 files changed, 1541 insertions(+), 87 deletions(-) create mode 100644 drivers/virtio/virtio_mdev.c create mode 100644 include/linux/vfio_mdev.h create mode 100644 include/linux/virtio_mdev.h create mode 100644 samples/vfio-mdev/mvnet.c
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 1/6 mdev: class id support
Mdev bus only supports vfio driver right now, so it doesn't implement match method. But in the future, we may add drivers other than vfio, the first driver could be virtio-mdev. This means we need to add device class id support in bus match method to pair the mdev device and mdev driver correctly.
So this patch adds id_table to mdev_driver and class_id for mdev device with the match method for mdev bus.
--- .../driver-api/vfio-mediated-device.rst | 7 +++++- drivers/gpu/drm/i915/gvt/kvmgt.c | 1 + drivers/s390/cio/vfio_ccw_ops.c | 1 + drivers/s390/crypto/vfio_ap_ops.c | 1 + drivers/vfio/mdev/mdev_core.c | 18 +++++++++++++++ drivers/vfio/mdev/mdev_driver.c | 22 +++++++++++++++++++ drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 6 +++++ include/linux/mdev.h | 8 +++++++ include/linux/mod_devicetable.h | 8 +++++++ samples/vfio-mdev/mbochs.c | 1 + samples/vfio-mdev/mdpy.c | 1 + samples/vfio-mdev/mtty.c | 1 + 13 files changed, 75 insertions(+), 1 deletion(-)
Documentation/driver-api/vfio-mediated-device.rst +6 -1
@@ -102,12 +102,14 @@ structure to represent a mediated device's driver:: * @probe: called when new device created * @remove: called when device removed * @driver: device driver structure + * @id_table: the ids serviced by this driver */ struct mdev_driver { const char *name; int (*probe) (struct device *dev); void (*remove) (struct device *dev); struct device_driver driver; + const struct mdev_class_id *id_table; }; A mediated bus driver for mdev should use this structure in the function calls
@@ -165,12 +167,15 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); +It is also required to specify the class_id in create() callback through:: + + int mdev_set_class(struct mdev_device *mdev, u16 id); + However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver:: extern void mdev_unregister_device(struct device *dev); - Mediated Device Management Interface Through sysfs ==================================================
drivers/gpu/drm/i915/gvt/kvmgt.c +1 -0
@@ -678,6 +678,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) dev_name(mdev_dev(mdev))); ret =0 ; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); out:return ret; }
drivers/s390/cio/vfio_ccw_ops.c +1 -0
@@ -129,6 +129,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) private->sch->schid.ssid, private->sch->schid.sch_no); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }
drivers/s390/crypto/vfio_ap_ops.c +1 -0
@@ -343,6 +343,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev)list_add (&matrix_mdev->node, &matrix_dev->mdev_list);mutex_unlock (&matrix_dev->lock); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }
drivers/vfio/mdev/mdev_core.c +18 -0
@@ -45,6 +45,16 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); +/* Specify the class for the mdev device, this must be called during +* create() callback. +*/ +void mdev_set_class (struct mdev_device *mdev,u16 id) +{ +WARN_ON (mdev->class_id); + mdev->class_id = id; +} +EXPORT_SYMBOL (mdev_set_class); +struct device *mdev_dev (struct mdev_device *mdev) {return &mdev->dev;
@@ -135,6 +145,7 @@ static int mdev_device_remove_cb(struct device *dev, void *data)* mdev_register_device : Register a device * @dev: device structure representing parent device. * @ops: Parent device operation structure to be registered. +* @id: class id. * * Add device to list of registered parent devices. * Returns a negative value on error, otherwise 0.
@@ -324,6 +335,13 @@ int mdev_device_create(struct kobject *kobj,if (ret) goto ops_create_fail; +if (!mdev->class_id) { + ret = -EINVAL ; +WARN (1 ,"class id must be specified for device %s\n" , +dev_name (dev)); + goto add_fail; + } + ret =device_add (&mdev->dev);if (ret) goto add_fail;
drivers/vfio/mdev/mdev_driver.c +22 -0
@@ -69,8 +69,30 @@ static int mdev_remove(struct device *dev)return 0 ; } +static int mdev_match (struct device *dev,struct device_driver *drv) +{ +unsigned int i; +struct mdev_device *mdev =to_mdev_device (dev); +struct mdev_driver *mdrv =to_mdev_driver (drv); +const struct mdev_class_id *ids = mdrv->id_table; + +for (i =0 ; ids[i].id; i++) +if (ids[i].id == mdev->class_id) +return 1 ; +return 0 ; +} + +static int mdev_uevent (struct device *dev,struct kobj_uevent_env *env) +{ +struct mdev_device *mdev =to_mdev_device (dev); + +return add_uevent_var (env,"MODALIAS=mdev:c%02X" , mdev->class_id); +} +struct bus_type mdev_bus_type = { .name ="mdev" , + .match = mdev_match, + .uevent = mdev_uevent, .probe = mdev_probe, .remove = mdev_remove, };
drivers/vfio/mdev/mdev_private.h +1 -0
@@ -33,6 +33,7 @@ struct mdev_device {struct kobject *type_kobj;struct device *iommu_device;bool active; +u16 class_id; };#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev)
drivers/vfio/mdev/vfio_mdev.c +6 -0
@@ -120,10 +120,16 @@ static void vfio_mdev_remove(struct device *dev)vfio_del_group_dev (dev); } +static const struct mdev_class_id id_table[] = { + {MDEV_CLASS_ID_VFIO }, + {0 }, +}; +static struct mdev_driver vfio_mdev_driver = { .name ="vfio_mdev" , .probe = vfio_mdev_probe, .remove = vfio_mdev_remove, + .id_table = id_table, };static int __init vfio_mdev_init (void )
include/linux/mdev.h +8 -0
@@ -118,6 +118,7 @@ struct mdev_type_attribute mdev_type_attr_##_name = \* @probe: called when new device created * @remove: called when device removed * @driver: device driver structure +* @id_table: the ids serviced by this driver * **/ struct mdev_driver {
@@ -125,6 +126,7 @@ struct mdev_driver {int (*probe)(struct device *dev);void (*remove)(struct device *dev);struct device_driver driver; +const struct mdev_class_id *id_table; };#define to_mdev_driver (drv) container_of(drv, struct mdev_driver, driver)
@@ -132,6 +134,7 @@ struct mdev_driver {void *mdev_get_drvdata (struct mdev_device *mdev);void mdev_set_drvdata (struct mdev_device *mdev,void *data);const guid_t *mdev_uuid (struct mdev_device *mdev); +void mdev_set_class (struct mdev_device *mdev,u16 id);extern struct bus_type mdev_bus_type;
@@ -145,4 +148,9 @@ struct device *mdev_parent_dev(struct mdev_device *mdev);struct device *mdev_dev (struct mdev_device *mdev);struct mdev_device *mdev_from_dev (struct device *dev); +enum { +MDEV_CLASS_ID_VFIO =1 , +/* New entries must be added here */ +}; +#endif /* MDEV_H */
include/linux/mod_devicetable.h +8 -0
@@ -821,4 +821,12 @@ struct wmi_device_id { const void *context; }; +/** +* struct mdev_class_id - MDEV device class identifier +* @id: Used to identify a specific class of device, e.g vfio-mdev device. +*/ +struct mdev_class_id { +__u16 id; +}; +#endif /* LINUX_MOD_DEVICETABLE_H */
samples/vfio-mdev/mbochs.c +1 -0
@@ -561,6 +561,7 @@ static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)mbochs_reset (mdev); mbochs_used_mbytes += type->mbytes; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; err_mem:
samples/vfio-mdev/mdpy.c +1 -0
@@ -269,6 +269,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)mdpy_reset (mdev); mdpy_count++; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }
samples/vfio-mdev/mtty.c +1 -0
@@ -755,6 +755,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev)list_add (&mdev_state->next, &mdev_devices_list);mutex_unlock (&mdev_list_lock); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }
Signature · 1 line
2.19.1
RE: [PATCH V4 1/6] mdev: class id support
Quoted 338 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Jason Wang
Sent: Thursday, October 17, 2019 5:49 AM
To: [email protected]; [email protected]; linux- [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ido Shamay <[email protected]>; [email protected]; [email protected]; Parav Pandit <[email protected]>; [email protected]; [email protected]; [email protected]; Jason Wang <[email protected]>
Subject: [PATCH V4 1/6] mdev: class id supportMdev bus only supports vfio driver right now, so it doesn't implement match method. But in the future, we may add drivers other than vfio, the first driver could be virtio-mdev. This means we need to add device class id support in bus match method to pair the mdev device and mdev driver correctly.
So this patch adds
id_tabletomdev_driverandclass_idfor mdev device with the match method for mdev bus.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 7 +++++- drivers/gpu/drm/i915/gvt/kvmgt.c | 1 + drivers/s390/cio/vfio_ccw_ops.c | 1 + drivers/s390/crypto/vfio_ap_ops.c | 1 + drivers/vfio/mdev/mdev_core.c | 18 +++++++++++++++ drivers/vfio/mdev/mdev_driver.c | 22 +++++++++++++++++++ drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 6 +++++ include/linux/mdev.h | 8 +++++++ include/linux/mod_devicetable.h | 8 +++++++ samples/vfio-mdev/mbochs.c | 1 + samples/vfio-mdev/mdpy.c | 1 + samples/vfio-mdev/mtty.c | 1 + 13 files changed, 75 insertions(+), 1 deletion(-)Documentation/driver-api/vfio-mediated-device.rst +2
-0@@ -102,12 +102,14 @@ structure to represent a mediated device's driver:: * @probe: called when new device created * @remove: called when device removed * @driver: device driver structure + * @id_table: the ids serviced by this driver */ struct mdev_driver { const char *name; int (*probe) (struct device *dev); void (*remove) (struct device *dev); struct device_driver driver; + const struct mdev_class_id *id_table; }; A mediated bus driver for mdev should use this structure in the functioncalls @@ -165,12 +167,15 @@ register itself with the mdev core driver::
Documentation/driver-api/vfio-mediated-device.rst +4
-0extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); +It is also required to specify the class_id in create() callback through:: + + int mdev_set_class(struct mdev_device *mdev, u16 id); + However, the mdev_parent_ops structure is not required in the function callthat a driver should use to unregister itself with the mdev core driver::
Documentation/driver-api/vfio-mediated-device.rst +0
-1extern void mdev_unregister_device(struct device *dev); - Mediated Device Management Interface Through sysfs==================================================
drivers/gpu/drm/i915/gvt/kvmgt.c +1
-0@@ -678,6 +678,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) dev_name(mdev_dev(mdev))); ret =0 ; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); out:return ret;}
(quoted diff) +0
-0
b/drivers/s390/cio/vfio_ccw_ops.cindexf0d71ab77c50..cf2c013ae32f100644drivers/s390/cio/vfio_ccw_ops.c +1
-0@@ -129,6 +129,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) private->sch->schid.ssid, private->sch->schid.sch_no); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }drivers/s390/crypto/vfio_ap_ops.c +1
-0@@ -343,6 +343,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev) list_add(&matrix_mdev->node, &matrix_dev->mdev_list);mutex_unlock (&matrix_dev->lock); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }drivers/vfio/mdev/mdev_core.c +10
-0@@ -45,6 +45,16 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) } EXPORT_SYMBOL(mdev_set_drvdata); +/* Specify the class for the mdev device, this must be called during +* create() callback. +*/ +void mdev_set_class (struct mdev_device *mdev,u16 id) { +WARN_ON (mdev->class_id); + mdev->class_id = id; +} +EXPORT_SYMBOL (mdev_set_class); +struct device *mdev_dev (struct mdev_device *mdev) {return &mdev->dev;@@ -135,6 +145,7 @@ static int mdev_device_remove_cb(struct device *dev, void *data) * mdev_register_device : Register a device * @dev: device structure representing parent device. * @ops: Parent device operation structure to be registered. + * @id: class id. * * Add device to list of registered parent devices.* Returns a negative value on error, otherwise 0.
drivers/vfio/mdev/mdev_core.c +7
-0@@ -324,6 +335,13 @@ int mdev_device_create(struct kobject *kobj,if (ret) goto ops_create_fail; +if (!mdev->class_id) { + ret = -EINVAL ; +WARN (1 ,"class id must be specified for device %s\n" , +dev_name (dev)); + goto add_fail; + } + ret =device_add (&mdev->dev);if (ret) goto add_fail;(quoted diff) +0
-0
b/drivers/vfio/mdev/mdev_driver.cindex0d3223aee20b..319d886ffaf7100644drivers/vfio/mdev/mdev_driver.c +20
-0@@ -69,8 +69,30 @@ static int mdev_remove(struct device *dev)return 0 ; } +static int mdev_match (struct device *dev,struct device_driver *drv) { +unsigned int i; +struct mdev_device *mdev =to_mdev_device (dev); +struct mdev_driver *mdrv =to_mdev_driver (drv); +const struct mdev_class_id *ids = mdrv->id_table; + +for (i =0 ; ids[i].id; i++) +if (ids[i].id == mdev->class_id) +return 1 ; +return 0 ; +} + +static int mdev_uevent (struct device *dev,struct kobj_uevent_env *env) +{ +struct mdev_device *mdev =to_mdev_device (dev); + +return add_uevent_var (env,"MODALIAS=mdev:c%02X" , mdev- >class_id); } +struct bus_type mdev_bus_type = { .name ="mdev" , + .match = mdev_match, + .uevent = mdev_uevent, .probe = mdev_probe, .remove = mdev_remove, };drivers/vfio/mdev/mdev_private.h +1
-0@@ -33,6 +33,7 @@ struct mdev_device {struct kobject *type_kobj;struct device *iommu_device;bool active; +u16 class_id; };#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev)drivers/vfio/mdev/vfio_mdev.c +6
-0@@ -120,10 +120,16 @@ static void vfio_mdev_remove(struct device *dev)vfio_del_group_dev (dev); } +static const struct mdev_class_id id_table[] = { + {MDEV_CLASS_ID_VFIO }, + {0 }, +}; +static struct mdev_driver vfio_mdev_driver = { .name ="vfio_mdev" , .probe = vfio_mdev_probe, .remove = vfio_mdev_remove, + .id_table = id_table, };static int __init vfio_mdev_init (void )include/linux/mdev.h index renamed from include/linux/mdev.h +0
-0
0ce30ca78db0..78b69d09eb54100644include/linux/mdev.h +1
-0@@ -118,6 +118,7 @@ struct mdev_type_attributemdev_type_attr_##_name = \ * @probe: called when new device created * @remove: called when device removed * @driver: device driver structure +* @id_table: the ids serviced by this driver * **/ struct
mdev_driver{include/linux/mdev.h +7
-0@@ -125,6 +126,7 @@ struct mdev_driver {int (*probe)(struct device *dev);void (*remove)(struct device *dev);struct device_driver driver; +const struct mdev_class_id *id_table; };#define to_mdev_driver (drv) container_of(drv, struct mdev_driver, driver)@@ -132,6 +134,7 @@ struct mdev_driver { void *mdev_get_drvdata(struct mdev_device *mdev); void mdev_set_drvdata(struct mdev_device *mdev,void *data);const guid_t *mdev_uuid (struct mdev_device *mdev); +void mdev_set_class (struct mdev_device *mdev,u16 id);extern struct bus_type mdev_bus_type;@@ -145,4 +148,9 @@ struct device *mdev_parent_dev(struct mdev_device *mdev); struct device *mdev_dev(struct mdev_device *mdev); structmdev_device *mdev_from_dev (struct device *dev); +enum { +MDEV_CLASS_ID_VFIO =1 , +/* New entries must be added here */ +}; +#endif /* MDEV_H */ (quoted diff) +0
-0
b/include/linux/mod_devicetable.hindex5714fd35a83c..f32c6e44fb1a100644include/linux/mod_devicetable.h +8
-0@@ -821,4 +821,12 @@ struct wmi_device_id { const void *context; }; +/** +* struct mdev_class_id - MDEV device class identifier +* @id: Used to identify a specific class of device, e.g vfio-mdev device. +*/ +struct mdev_class_id { +__u16 id; +}; +#endif /* LINUX_MOD_DEVICETABLE_H */ samples/vfio-mdev/mbochs.c +1
-0@@ -561,6 +561,7 @@ static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)mbochs_reset (mdev ); mbochs_used_mbytes += type->mbytes; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ;
err_mem:samples/vfio-mdev/mdpy.c index renamed from samples/vfio-mdev/mdpy.c +0
-0
cc86bf6566e4..665614574d50100644samples/vfio-mdev/mdpy.c +1
-0@@ -269,6 +269,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)mdpy_reset (mdev ); mdpy_count++; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }samples/vfio-mdev/mtty.c index renamed from samples/vfio-mdev/mtty.c +0
-0
ce84a300a4da..90da12ff7fd9100644samples/vfio-mdev/mtty.c +1
-1@@ -755,6 +755,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev) list_add(&mdev_state->next, &mdev_devices_list);mutex_unlock (&mdev_list_lock); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; } --
Quoted 1 line
2.19.1
PATCH v4 1/6 mdev: class id support
In reply to Jason WangMdev bus only supports vfio driver right now, so it doesn't implement match method. But in the future, we may add drivers other than vfio, the first driver could be virtio-mdev. This means we need to add device class id support in bus match method to pair the mdev device and mdev driver correctly.
So this patch adds id_table to mdev_driver and class_id for mdev device with the match method for mdev bus.
--- .../driver-api/vfio-mediated-device.rst | 7 +++++- drivers/gpu/drm/i915/gvt/kvmgt.c | 1 + drivers/s390/cio/vfio_ccw_ops.c | 1 + drivers/s390/crypto/vfio_ap_ops.c | 1 + drivers/vfio/mdev/mdev_core.c | 18 +++++++++++++++ drivers/vfio/mdev/mdev_driver.c | 22 +++++++++++++++++++ drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 6 +++++ include/linux/mdev.h | 8 +++++++ include/linux/mod_devicetable.h | 8 +++++++ samples/vfio-mdev/mbochs.c | 1 + samples/vfio-mdev/mdpy.c | 1 + samples/vfio-mdev/mtty.c | 1 + 13 files changed, 75 insertions(+), 1 deletion(-)
Documentation/driver-api/vfio-mediated-device.rst +6 -1
@@ -102,12 +102,14 @@ structure to represent a mediated device's driver:: * @probe: called when new device created * @remove: called when device removed * @driver: device driver structure + * @id_table: the ids serviced by this driver */ struct mdev_driver { const char *name; int (*probe) (struct device *dev); void (*remove) (struct device *dev); struct device_driver driver; + const struct mdev_class_id *id_table; }; A mediated bus driver for mdev should use this structure in the function calls
@@ -165,12 +167,15 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); +It is also required to specify the class_id in create() callback through:: + + int mdev_set_class(struct mdev_device *mdev, u16 id); + However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver:: extern void mdev_unregister_device(struct device *dev); - Mediated Device Management Interface Through sysfs ==================================================
drivers/gpu/drm/i915/gvt/kvmgt.c +1 -0
@@ -678,6 +678,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) dev_name(mdev_dev(mdev))); ret =0 ; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); out:return ret; }
drivers/s390/cio/vfio_ccw_ops.c +1 -0
@@ -129,6 +129,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) private->sch->schid.ssid, private->sch->schid.sch_no); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }
drivers/s390/crypto/vfio_ap_ops.c +1 -0
@@ -343,6 +343,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev)list_add (&matrix_mdev->node, &matrix_dev->mdev_list);mutex_unlock (&matrix_dev->lock); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }
drivers/vfio/mdev/mdev_core.c +18 -0
@@ -45,6 +45,16 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); +/* Specify the class for the mdev device, this must be called during +* create() callback. +*/ +void mdev_set_class (struct mdev_device *mdev,u16 id) +{ +WARN_ON (mdev->class_id); + mdev->class_id = id; +} +EXPORT_SYMBOL (mdev_set_class); +struct device *mdev_dev (struct mdev_device *mdev) {return &mdev->dev;
@@ -135,6 +145,7 @@ static int mdev_device_remove_cb(struct device *dev, void *data)* mdev_register_device : Register a device * @dev: device structure representing parent device. * @ops: Parent device operation structure to be registered. +* @id: class id. * * Add device to list of registered parent devices. * Returns a negative value on error, otherwise 0.
@@ -324,6 +335,13 @@ int mdev_device_create(struct kobject *kobj,if (ret) goto ops_create_fail; +if (!mdev->class_id) { + ret = -EINVAL ; +WARN (1 ,"class id must be specified for device %s\n" , +dev_name (dev)); + goto add_fail; + } + ret =device_add (&mdev->dev);if (ret) goto add_fail;
drivers/vfio/mdev/mdev_driver.c +22 -0
@@ -69,8 +69,30 @@ static int mdev_remove(struct device *dev)return 0 ; } +static int mdev_match (struct device *dev,struct device_driver *drv) +{ +unsigned int i; +struct mdev_device *mdev =to_mdev_device (dev); +struct mdev_driver *mdrv =to_mdev_driver (drv); +const struct mdev_class_id *ids = mdrv->id_table; + +for (i =0 ; ids[i].id; i++) +if (ids[i].id == mdev->class_id) +return 1 ; +return 0 ; +} + +static int mdev_uevent (struct device *dev,struct kobj_uevent_env *env) +{ +struct mdev_device *mdev =to_mdev_device (dev); + +return add_uevent_var (env,"MODALIAS=mdev:c%02X" , mdev->class_id); +} +struct bus_type mdev_bus_type = { .name ="mdev" , + .match = mdev_match, + .uevent = mdev_uevent, .probe = mdev_probe, .remove = mdev_remove, };
drivers/vfio/mdev/mdev_private.h +1 -0
@@ -33,6 +33,7 @@ struct mdev_device {struct kobject *type_kobj;struct device *iommu_device;bool active; +u16 class_id; };#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev)
drivers/vfio/mdev/vfio_mdev.c +6 -0
@@ -120,10 +120,16 @@ static void vfio_mdev_remove(struct device *dev)vfio_del_group_dev (dev); } +static const struct mdev_class_id id_table[] = { + {MDEV_CLASS_ID_VFIO }, + {0 }, +}; +static struct mdev_driver vfio_mdev_driver = { .name ="vfio_mdev" , .probe = vfio_mdev_probe, .remove = vfio_mdev_remove, + .id_table = id_table, };static int __init vfio_mdev_init (void )
include/linux/mdev.h +8 -0
@@ -118,6 +118,7 @@ struct mdev_type_attribute mdev_type_attr_##_name = \* @probe: called when new device created * @remove: called when device removed * @driver: device driver structure +* @id_table: the ids serviced by this driver * **/ struct mdev_driver {
@@ -125,6 +126,7 @@ struct mdev_driver {int (*probe)(struct device *dev);void (*remove)(struct device *dev);struct device_driver driver; +const struct mdev_class_id *id_table; };#define to_mdev_driver (drv) container_of(drv, struct mdev_driver, driver)
@@ -132,6 +134,7 @@ struct mdev_driver {void *mdev_get_drvdata (struct mdev_device *mdev);void mdev_set_drvdata (struct mdev_device *mdev,void *data);const guid_t *mdev_uuid (struct mdev_device *mdev); +void mdev_set_class (struct mdev_device *mdev,u16 id);extern struct bus_type mdev_bus_type;
@@ -145,4 +148,9 @@ struct device *mdev_parent_dev(struct mdev_device *mdev);struct device *mdev_dev (struct mdev_device *mdev);struct mdev_device *mdev_from_dev (struct device *dev); +enum { +MDEV_CLASS_ID_VFIO =1 , +/* New entries must be added here */ +}; +#endif /* MDEV_H */
include/linux/mod_devicetable.h +8 -0
@@ -821,4 +821,12 @@ struct wmi_device_id { const void *context; }; +/** +* struct mdev_class_id - MDEV device class identifier +* @id: Used to identify a specific class of device, e.g vfio-mdev device. +*/ +struct mdev_class_id { +__u16 id; +}; +#endif /* LINUX_MOD_DEVICETABLE_H */
samples/vfio-mdev/mbochs.c +1 -0
@@ -561,6 +561,7 @@ static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)mbochs_reset (mdev); mbochs_used_mbytes += type->mbytes; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; err_mem:
samples/vfio-mdev/mdpy.c +1 -0
@@ -269,6 +269,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)mdpy_reset (mdev); mdpy_count++; +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }
samples/vfio-mdev/mtty.c +1 -0
@@ -755,6 +755,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev)list_add (&mdev_state->next, &mdev_devices_list);mutex_unlock (&mdev_list_lock); +mdev_set_class (mdev,MDEV_CLASS_ID_VFIO );return 0 ; }
Signature · 1 line
2.19.1
PATCH v4 2/6 modpost: add support for mdev class id
In reply to Jason WangAdd support to parse mdev class id table.
--- drivers/vfio/mdev/vfio_mdev.c | 2 ++ scripts/mod/devicetable-offsets.c | 3 +++ scripts/mod/file2alias.c | 10 ++++++++++ 3 files changed, 15 insertions(+)
drivers/vfio/mdev/vfio_mdev.c +2 -0
@@ -125,6 +125,8 @@ static const struct mdev_class_id id_table[] = { { 0 }, }; +MODULE_DEVICE_TABLE (mdev, id_table); +static struct mdev_driver vfio_mdev_driver = { .name ="vfio_mdev" , .probe = vfio_mdev_probe,
scripts/mod/devicetable-offsets.c +3 -0
@@ -231,5 +231,8 @@ int main(void)DEVID (wmi_device_id);DEVID_FIELD (wmi_device_id, guid_string); +DEVID (mdev_class_id); +DEVID_FIELD (mdev_class_id, id); +return 0 ; }
scripts/mod/file2alias.c +10 -0
@@ -1335,6 +1335,15 @@ static int do_wmi_entry(const char *filename, void *symval, char *alias)return 1 ; } +/* looks like: "mdev:cN" */ +static int do_mdev_entry (const char *filename,void *symval,char *alias) +{ +DEF_FIELD (symval, mdev_class_id, id); + +sprintf (alias,"mdev:c%02X" , id); +return 1 ; +} +/* Does namelen bytes of name exactly match the symbol? */ static bool sym_is (const char *name,unsigned namelen,const char *symbol) {
@@ -1407,6 +1416,7 @@ static const struct devtable devtable[] = { {"typec", SIZE_typec_device_id, do_typec_entry}, {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, + {"mdev", SIZE_mdev_class_id, do_mdev_entry}, };/* Create MODULE_ALIAS() statements.
Signature · 1 line
2.19.1
RE: [PATCH V4 2/6] modpost: add support for mdev class id
Quoted 92 lines
-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Thursday, October 17, 2019 5:49 AM
To: [email protected]; [email protected]; linux- [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ido Shamay <[email protected]>; [email protected]; [email protected]; Parav Pandit <[email protected]>; [email protected]; [email protected]; [email protected]; Jason Wang <[email protected]>
Subject: [PATCH V4 2/6] modpost: add support for mdev class idAdd support to parse mdev class id table.
Signed-off-by Jason Wang <[email protected]>--- drivers/vfio/mdev/vfio_mdev.c | 2 ++ scripts/mod/devicetable-offsets.c | 3 +++ scripts/mod/file2alias.c | 10 ++++++++++ 3 files changed, 15 insertions(+)drivers/vfio/mdev/vfio_mdev.c +2
-0@@ -125,6 +125,8 @@ static const struct mdev_class_id id_table[] = { { 0 }, }; +MODULE_DEVICE_TABLE (mdev, id_table); +static struct mdev_driver vfio_mdev_driver = { .name ="vfio_mdev" , .probe = vfio_mdev_probe,scripts/mod/devicetable- renamed from scripts/mod/devicetable-offsets.c +0
-0
offsets.c
index054405b90ba4..6cbb1062488a100644scripts/mod/devicetable-offsets.c +3
-0@@ -231,5 +231,8 @@ int main(void)DEVID (wmi_device_id);DEVID_FIELD (wmi_device_id, guid_string); +DEVID (mdev_class_id); +DEVID_FIELD (mdev_class_id, id); +return 0 ; }scripts/mod/file2alias.c index renamed from scripts/mod/file2alias.c +0
-0
c91eba751804..d365dfe7c718100644scripts/mod/file2alias.c +9
-0@@ -1335,6 +1335,15 @@ static int do_wmi_entry(const char *filename, void *symval, char *alias) return 1; } +/* looks like: "mdev:cN" */ +static int do_mdev_entry (const char *filename,void *symval,char +*alias) { +DEF_FIELD (symval, mdev_class_id, id); + +sprintf (alias,"mdev:c%02X" , id); +return 1 ; +} + /* Does namelen bytes of name exactly match the symbol? */ static bool
sym_is(const char *name, unsigned namelen, const char *symbol){ @@ - 1407,6 +1416,7 @@ static const struct devtable devtable[] = {scripts/mod/file2alias.c +1
-1{"typec", SIZE_typec_device_id, do_typec_entry}, {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, + {"mdev", SIZE_mdev_class_id, do_mdev_entry}, };/* Create MODULE_ALIAS() statements. --
Quoted 1 line
2.19.1
PATCH v4 2/6 modpost: add support for mdev class id
In reply to Jason WangAdd support to parse mdev class id table.
--- drivers/vfio/mdev/vfio_mdev.c | 2 ++ scripts/mod/devicetable-offsets.c | 3 +++ scripts/mod/file2alias.c | 10 ++++++++++ 3 files changed, 15 insertions(+)
drivers/vfio/mdev/vfio_mdev.c +2 -0
@@ -125,6 +125,8 @@ static const struct mdev_class_id id_table[] = { { 0 }, }; +MODULE_DEVICE_TABLE (mdev, id_table); +static struct mdev_driver vfio_mdev_driver = { .name ="vfio_mdev" , .probe = vfio_mdev_probe,
scripts/mod/devicetable-offsets.c +3 -0
@@ -231,5 +231,8 @@ int main(void)DEVID (wmi_device_id);DEVID_FIELD (wmi_device_id, guid_string); +DEVID (mdev_class_id); +DEVID_FIELD (mdev_class_id, id); +return 0 ; }
scripts/mod/file2alias.c +10 -0
@@ -1335,6 +1335,15 @@ static int do_wmi_entry(const char *filename, void *symval, char *alias)return 1 ; } +/* looks like: "mdev:cN" */ +static int do_mdev_entry (const char *filename,void *symval,char *alias) +{ +DEF_FIELD (symval, mdev_class_id, id); + +sprintf (alias,"mdev:c%02X" , id); +return 1 ; +} +/* Does namelen bytes of name exactly match the symbol? */ static bool sym_is (const char *name,unsigned namelen,const char *symbol) {
@@ -1407,6 +1416,7 @@ static const struct devtable devtable[] = { {"typec", SIZE_typec_device_id, do_typec_entry}, {"tee", SIZE_tee_client_device_id, do_tee_entry}, {"wmi", SIZE_wmi_device_id, do_wmi_entry}, + {"mdev", SIZE_mdev_class_id, do_mdev_entry}, };/* Create MODULE_ALIAS() statements.
Signature · 1 line
2.19.1
PATCH v4 3/6 mdev: introduce device specific ops
In reply to Jason WangCurrently, except for the create and remove, the rest of mdev_parent_ops is designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks inside mdev_device structure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.
--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644 include/linux/vfio_mdev.h
Documentation/driver-api/vfio-mediated-device.rst +16 -9
@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.) -The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create() +callback. E.g for vfio-mdev device it needs to be done through: + + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device +with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by +the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback
@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); -It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); - However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver::
MAINTAINERS +1 -0
@@ -17127,6 +17127,7 @@ S: Maintained F: Documentation/driver-api/vfio-mediated-device.rst F: drivers/vfio/mdev/ F: include/linux/mdev.h +F: include/linux/vfio_mdev.h F: samples/vfio-mdev/ VFIO PLATFORM DRIVER
drivers/gpu/drm/i915/gvt/kvmgt.c +11 -7
@@ -42,6 +42,7 @@#include <linux/kvm_host.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/debugfs.h> #include <linux/nospec.h>
@@ -643,6 +644,8 @@ static void kvmgt_put_vfio_device(void *vgpu)vfio_device_put (((struct intel_vgpu *)vgpu)->vdev.vfio_device); } +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops; +static int intel_vgpu_create (struct kobject *kobj,struct mdev_device *mdev) {struct intel_vgpu *vgpu =NULL ;
@@ -678,7 +681,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) dev_name(mdev_dev(mdev))); ret =0 ; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &intel_vfio_vgpu_dev_ops); out:return ret; }
@@ -1599,20 +1602,21 @@ static const struct attribute_group *intel_vgpu_groups[] = { NULL, }; -static struct mdev_parent_ops intel_vgpu_ops = { - .mdev_attr_groups = intel_vgpu_groups, - .create = intel_vgpu_create, - .remove = intel_vgpu_remove, - +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops = { .open = intel_vgpu_open, .release = intel_vgpu_release, - .read = intel_vgpu_read, .write = intel_vgpu_write, .mmap = intel_vgpu_mmap, .ioctl = intel_vgpu_ioctl, }; +static struct mdev_parent_ops intel_vgpu_ops = { + .mdev_attr_groups = intel_vgpu_groups, + .create = intel_vgpu_create, + .remove = intel_vgpu_remove, +}; +static int kvmgt_host_init (struct device *dev,void *gvt,const void *ops) {struct attribute **kvm_type_attrs;
drivers/s390/cio/vfio_ccw_ops.c +12 -6
@@ -12,6 +12,7 @@#include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/nospec.h> #include <linux/slab.h>
@@ -110,6 +111,8 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ccw_mdev_create (struct kobject *kobj,struct mdev_device *mdev) { struct vfio_ccw_private *private =
@@ -129,7 +132,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) private->sch->schid.ssid, private->sch->schid.sch_no); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }
@@ -575,11 +578,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, } } -static const struct mdev_parent_ops vfio_ccw_mdev_ops = { - .owner =THIS_MODULE , - .supported_type_groups = mdev_type_groups, - .create = vfio_ccw_mdev_create, - .remove = vfio_ccw_mdev_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = vfio_ccw_mdev_open, .release = vfio_ccw_mdev_release, .read = vfio_ccw_mdev_read,
@@ -587,6 +586,13 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = { .ioctl = vfio_ccw_mdev_ioctl, }; +static const struct mdev_parent_ops vfio_ccw_mdev_ops = { + .owner =THIS_MODULE , + .supported_type_groups = mdev_type_groups, + .create = vfio_ccw_mdev_create, + .remove = vfio_ccw_mdev_remove, +}; +int vfio_ccw_mdev_reg (struct subchannel *sch) {return mdev_register_device (&sch->dev, &vfio_ccw_mdev_ops);
drivers/s390/crypto/vfio_ap_ops.c +10 -4
@@ -16,6 +16,7 @@#include <linux/bitops.h> #include <linux/kvm_host.h> #include <linux/module.h> +#include <linux/vfio_mdev.h> #include <asm/kvm.h> #include <asm/zcrypt.h>
@@ -321,6 +322,8 @@ static void vfio_ap_matrix_init(struct ap_config_info *info, matrix->adm_max = info->apxa ? info->Nd :15 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ap_mdev_create (struct kobject *kobj,struct mdev_device *mdev) {struct ap_matrix_mdev *matrix_mdev;
@@ -343,7 +346,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev)list_add (&matrix_mdev->node, &matrix_dev->mdev_list);mutex_unlock (&matrix_dev->lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }
@@ -1281,15 +1284,18 @@ static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev,return ret; } +static const struct vfio_mdev_device_ops vfio_mdev_ops = { + .open = vfio_ap_mdev_open, + .release = vfio_ap_mdev_release, + .ioctl = vfio_ap_mdev_ioctl, +}; +static const struct mdev_parent_ops vfio_ap_matrix_ops = { .owner =THIS_MODULE , .supported_type_groups = vfio_ap_mdev_type_groups, .mdev_attr_groups = vfio_ap_mdev_attr_groups, .create = vfio_ap_mdev_create, .remove = vfio_ap_mdev_remove, - .open = vfio_ap_mdev_open, - .release = vfio_ap_mdev_release, - .ioctl = vfio_ap_mdev_ioctl, };int vfio_ap_mdev_register (void )
drivers/vfio/mdev/mdev_core.c +13 -5
@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ -void mdev_set_class (struct mdev_device *mdev,u16 id) +void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class); +EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) +{ +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);struct device *mdev_dev (struct mdev_device *mdev) {
drivers/vfio/mdev/mdev_private.h +1 -0
@@ -34,6 +34,7 @@ struct mdev_device {struct device *iommu_device;bool active;u16 class_id; +const void *device_ops; };#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev)
drivers/vfio/mdev/vfio_mdev.c +19 -18
@@ -14,6 +14,7 @@#include <linux/slab.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include "mdev_private.h"
@@ -24,16 +25,16 @@static int vfio_mdev_open (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev);int ret; -if (unlikely (!parent->ops->open)) +if (unlikely (!ops->open))return -EINVAL ;if (!try_module_get (THIS_MODULE ))return -ENODEV ; - ret = parent->ops->open (mdev); + ret = ops->open (mdev);if (ret)module_put (THIS_MODULE );
@@ -43,10 +44,10 @@ static int vfio_mdev_open(void *device_data)static void vfio_mdev_release (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (likely (parent->ops->release)) - parent->ops->release (mdev); +if (likely (ops->release)) + ops->release (mdev);module_put (THIS_MODULE ); }
@@ -55,47 +56,47 @@ static long vfio_mdev_unlocked_ioctl(void *device_data, unsigned int cmd, unsigned long arg) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->ioctl)) +if (unlikely (!ops->ioctl))return -EINVAL ; -return parent->ops->ioctl (mdev, cmd, arg); +return ops->ioctl (mdev, cmd, arg); }static ssize_t vfio_mdev_read (void *device_data,char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->read)) +if (unlikely (!ops->read))return -EINVAL ; -return parent->ops->read (mdev, buf, count, ppos); +return ops->read (mdev, buf, count, ppos); }static ssize_t vfio_mdev_write (void *device_data,const char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->write)) +if (unlikely (!ops->write))return -EINVAL ; -return parent->ops->write (mdev, buf, count, ppos); +return ops->write (mdev, buf, count, ppos); }static int vfio_mdev_mmap (void *device_data,struct vm_area_struct *vma) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->mmap)) +if (unlikely (!ops->mmap))return -EINVAL ; -return parent->ops->mmap (mdev, vma); +return ops->mmap (mdev, vma); }static const struct vfio_device_ops vfio_mdev_dev_ops = {
include/linux/mdev.h +11 -34
71 lines not on this page · raw message
include/linux/vfio_mdev.h new file +52 -0
52 lines not on this page · raw message
samples/vfio-mdev/mbochs.c +13 -7
@@ -30,6 +30,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/dma-buf.h> #include <linux/highmem.h>
@@ -516,6 +517,8 @@ static int mbochs_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mbochs_create (struct kobject *kobj,struct mdev_device *mdev) {const struct mbochs_type *type =mbochs_find_type (kobj);
@@ -561,7 +564,7 @@ static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)mbochs_reset (mdev); mbochs_used_mbytes += type->mbytes; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; err_mem:
@@ -1419,12 +1422,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mbochs_create, - .remove = mbochs_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mbochs_open, .release = mbochs_close, .read = mbochs_read,
@@ -1433,6 +1431,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mbochs_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mbochs_create, + .remove = mbochs_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE , };
samples/vfio-mdev/mdpy.c +13 -7
@@ -26,6 +26,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <drm/drm_fourcc.h> #include "mdpy-defs.h"
@@ -226,6 +227,8 @@ static int mdpy_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mdpy_create (struct kobject *kobj,struct mdev_device *mdev) {const struct mdpy_type *type =mdpy_find_type (kobj);
@@ -269,7 +272,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)mdpy_reset (mdev); mdpy_count++; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }
@@ -726,12 +729,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mdpy_create, - .remove = mdpy_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mdpy_open, .release = mdpy_close, .read = mdpy_read,
@@ -740,6 +738,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mdpy_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mdpy_create, + .remove = mdpy_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE , };
samples/vfio-mdev/mtty.c +12 -6
@@ -27,6 +27,7 @@#include <linux/ctype.h> #include <linux/file.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/serial.h> #include <uapi/linux/serial_reg.h>
@@ -708,6 +709,8 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count,return ret; } +static const struct vfio_mdev_device_ops vfio_dev_ops; +static int mtty_create (struct kobject *kobj,struct mdev_device *mdev) {struct mdev_state *mdev_state;
@@ -755,7 +758,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev)list_add (&mdev_state->next, &mdev_devices_list);mutex_unlock (&mdev_list_lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_dev_ops);return 0 ; }
@@ -1388,6 +1391,14 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; +static const struct vfio_mdev_device_ops vfio_dev_ops = { + .open = mtty_open, + .release = mtty_close, + .read = mtty_read, + .write = mtty_write, + .ioctl = mtty_ioctl, +}; +static const struct mdev_parent_ops mdev_fops = { .owner =THIS_MODULE , .dev_attr_groups = mtty_dev_groups,
@@ -1395,11 +1406,6 @@ static const struct mdev_parent_ops mdev_fops = { .supported_type_groups = mdev_type_groups, .create = mtty_create, .remove = mtty_remove, - .open = mtty_open, - .release = mtty_close, - .read = mtty_read, - .write = mtty_write, - .ioctl = mtty_ioctl, };static void mtty_device_release (struct device *dev)
Signature · 1 line
2.19.1
Re: [PATCH V4 3/6] mdev: introduce device specific ops
Quoted 30 lines · On Thu, 17 Oct 2019 18:48:33 +0800 Jason Wang <[email protected]> wrote:
Currently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644 include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 156
Quoted 10 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-5@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.) -The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create()
s/in create()/in the create()/
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 157
Quoted 1 line
Documentation/driver-api/vfio-mediated-device.rst +1
-0+callback. E.g for vfio-mdev device it needs to be done through:
"Each class provides a helper function to do so; e.g. for vfio-mdev devices, the function to be called is:"
?
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 162
Quoted 5 lines
Documentation/driver-api/vfio-mediated-device.rst +5
-0+ + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device
"(set by this helper function to MDEV_CLASS_ID_VFIO)" ?
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 164
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-0+with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by
"(specified in *vfio_ops by the caller)" ?
Quoted 10 lines
Documentation/driver-api/vfio-mediated-device.rst +6
-0+the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback
Documentation/driver-api/vfio-mediated-device.rst register itself with the mdev core driver:: · line 173
Quoted 7 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-4@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); -It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); -
I'm wondering if this patch set should start out with introducing helper functions already (i.e. don't introduce mdev_set_class(), but start out with mdev_set_class_vfio() which will gain the *vfio_ops argument in this patch.)
Quoted 3 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-0However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver::
(...)
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 50
Quoted 13 lines
drivers/vfio/mdev/mdev_core.c +2
-2@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */
/*
* Specify the mdev device to be a VFIO mdev device, and set the
* VFIO devices ops for it. This must be called from the create()
* callback for VFIO mdev devices.
*/
?
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +4
-3-void mdev_set_class (struct mdev_device *mdev,u16 id) +void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class);
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 67
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +7
-0+EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) +{ +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);struct device *mdev_dev (struct mdev_device *mdev) {
(...)
The code change looks good to me; I'm just wondering if we should introduce mdev_set_class() at all (see above).
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH V4 3/6] mdev: introduce device specific ops
Quoted 79 lines · On Thu, 17 Oct 2019 17:07:55 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 30 lines · On Thu, 17 Oct 2019 18:48:33 +0800 Jason Wang <[email protected]> wrote:
Currently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644 include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 156
Quoted 10 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-5@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.) -The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create()s/in create()/in the create()/
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 157
Quoted 1 line
Documentation/driver-api/vfio-mediated-device.rst +1
-0+callback. E.g for vfio-mdev device it needs to be done through:"Each class provides a helper function to do so; e.g. for vfio-mdev devices, the function to be called is:"
?
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 162
Quoted 5 lines
Documentation/driver-api/vfio-mediated-device.rst +5
-0+ + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device"(set by this helper function to
MDEV_CLASS_ID_VFIO)" ?Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 164
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-0+with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by"(specified in
*vfio_opsby the caller)" ?Quoted 13 lines
Documentation/driver-api/vfio-mediated-device.rst +6
-0+the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops);
Quoted 9 lines
Documentation/driver-api/vfio-mediated-device.rst register itself with the mdev core driver:: · line 173
Quoted 4 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-4-It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); -I'm wondering if this patch set should start out with introducing helper functions already (i.e. don't introduce
mdev_set_class(), but start out withmdev_set_class_vfio()which will gain the*vfio_opsargument in this patch.)
Yes, it would be cleaner, but is it really worth the churn? Correct me if I'm wrong, but I think we get to the same point after this patch and aside from the function name itself, the difference is really just that the class_id is briefly exposed to the parent driver, right? Thanks,
Alex
Quoted 46 lines
Quoted 3 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-0However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver::(...)
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 50
Quoted 13 lines
drivers/vfio/mdev/mdev_core.c +2
-2@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ /*
* Specify the mdev device to be a VFIO mdev device, and set the
* VFIO devices ops for it. This must be called from thecreate()
* callback for VFIO mdev devices.
*/?
Quoted 18 lines
drivers/vfio/mdev/mdev_core.c +11
-3-void mdev_set_class (struct mdev_device *mdev,u16 id) +void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class); +EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) +{ +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);
Quoted 7 lines
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 67
Quoted 2 lines
drivers/vfio/mdev/mdev_core.c +0
-0struct device *mdev_dev (struct mdev_device *mdev) {(...)
The code change looks good to me; I'm just wondering if we should introduce
mdev_set_class()at all (see above).
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH V4 3/6] mdev: introduce device specific ops
Quoted 92 lines · On Thu, 17 Oct 2019 11:53:10 -0600 Alex Williamson…
Quoted 79 lines · On Thu, 17 Oct 2019 17:07:55 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 30 lines · On Thu, 17 Oct 2019 18:48:33 +0800 Jason Wang <[email protected]> wrote:
Currently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644 include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 156
Quoted 10 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-5@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.) -The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create()s/in create()/in the create()/
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 157
Quoted 1 line
Documentation/driver-api/vfio-mediated-device.rst +1
-0+callback. E.g for vfio-mdev device it needs to be done through:"Each class provides a helper function to do so; e.g. for vfio-mdev devices, the function to be called is:"
?
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 162
Quoted 5 lines
Documentation/driver-api/vfio-mediated-device.rst +5
-0+ + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device"(set by this helper function to
MDEV_CLASS_ID_VFIO)" ?Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 164
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-0+with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by"(specified in
*vfio_opsby the caller)" ?Quoted 13 lines
Documentation/driver-api/vfio-mediated-device.rst +6
-0+the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops);Quoted 9 lines
Documentation/driver-api/vfio-mediated-device.rst register itself with the mdev core driver:: · line 173
Quoted 4 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-4-It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); -I'm wondering if this patch set should start out with introducing helper functions already (i.e. don't introduce
mdev_set_class(), but start out withmdev_set_class_vfio()which will gain the*vfio_opsargument in this patch.)
Quoted 4 lines
Yes, it would be cleaner, but is it really worth the churn? Correct me if I'm wrong, but I think we get to the same point after this patch and aside from the function name itself, the difference is really just that the
class_idis briefly exposed to the parent driver, right? Thanks,
Yes, it does not really matter much. If there's no other reason to rework things, I'd just keep this as it is now.
Re: [PATCH V4 3/6] mdev: introduce device specific ops
In reply to Cornelia HuckQuoted 79 lines · On Thu, 17 Oct 2019 17:07:55 +0200 Cornelia Huck <[email protected]> wrote:
Quoted 30 lines · On Thu, 17 Oct 2019 18:48:33 +0800 Jason Wang <[email protected]> wrote:
Currently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644 include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 156
Quoted 10 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-5@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.) -The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create()s/in create()/in the create()/
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 157
Quoted 1 line
Documentation/driver-api/vfio-mediated-device.rst +1
-0+callback. E.g for vfio-mdev device it needs to be done through:"Each class provides a helper function to do so; e.g. for vfio-mdev devices, the function to be called is:"
?
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 162
Quoted 5 lines
Documentation/driver-api/vfio-mediated-device.rst +5
-0+ + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device"(set by this helper function to
MDEV_CLASS_ID_VFIO)" ?Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 164
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-0+with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by"(specified in
*vfio_opsby the caller)" ?Quoted 13 lines
Documentation/driver-api/vfio-mediated-device.rst +6
-0+the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops);
Quoted 9 lines
Documentation/driver-api/vfio-mediated-device.rst register itself with the mdev core driver:: · line 173
Quoted 4 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-4-It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); -I'm wondering if this patch set should start out with introducing helper functions already (i.e. don't introduce
mdev_set_class(), but start out withmdev_set_class_vfio()which will gain the*vfio_opsargument in this patch.)
Yes, it would be cleaner, but is it really worth the churn? Correct me if I'm wrong, but I think we get to the same point after this patch and aside from the function name itself, the difference is really just that the class_id is briefly exposed to the parent driver, right? Thanks,
Alex
Quoted 53 lines
Quoted 3 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-0However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver::(...)
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 50
Quoted 13 lines
drivers/vfio/mdev/mdev_core.c +2
-2@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ /*
* Specify the mdev device to be a VFIO mdev device, and set the
* VFIO devices ops for it. This must be called from thecreate()
* callback for VFIO mdev devices.
*/?
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +4
-3-void mdev_set_class (struct mdev_device *mdev,u16 id) +void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class);drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 67
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +7
-0+EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) +{ +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);struct device *mdev_dev (struct mdev_device *mdev) {(...)
The code change looks good to me; I'm just wondering if we should introduce
mdev_set_class()at all (see above).
Re: [PATCH V4 3/6] mdev: introduce device specific ops
In reply to Cornelia HuckQuoted 36 lines · Cornelia Huck
Quoted 33 lines · On Thu, 17 Oct 2019 18:48:33 +0800 Jason Wang <[email protected]> wrote:
Currently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-)create mode 100644
include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.)
Quoted 8 lines
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 156
Quoted 7 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-5-The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create()s/in create()/in the create()/
Will fix.
Quoted 6 lines
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 157
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +1
-0+callback. E.g for vfio-mdev device it needs to be done through:"Each class provides a helper function to do so; e.g. for vfio-mdev devices, the function to be called is:"
?
This looks better.
Quoted 7 lines
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 162
Quoted 6 lines
Documentation/driver-api/vfio-mediated-device.rst +5
-0+ + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device"(set by this helper function to
MDEV_CLASS_ID_VFIO)" ?
Yes.
Quoted 3 lines
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 164
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-0+with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by"(specified in
*vfio_opsby the caller)" ?
Yes.
Quoted 13 lines
Quoted 13 lines
Documentation/driver-api/vfio-mediated-device.rst +6
-0+the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops);
Quoted 8 lines
Documentation/driver-api/vfio-mediated-device.rst register itself with the mdev core driver:: · line 173
Quoted 4 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-4-It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); -I'm wondering if this patch set should start out with introducing helper functions already (i.e. don't introduce
mdev_set_class(), but start out withmdev_set_class_vfio()which will gain the*vfio_opsargument in this patch.)
I think it doesn't harm to keep it as is since in patch 1 we introduce class_id and bus match method based on that without device ops there. But if you stick I can change.
Thanks
Quoted 51 lines
Quoted 4 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-0However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver::(...)
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 50
Quoted 13 lines
drivers/vfio/mdev/mdev_core.c +2
-2@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ /*
* Specify the mdev device to be a VFIO mdev device, and set the
* VFIO devices ops for it. This must be called from thecreate()
* callback for VFIO mdev devices.
*/?
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +4
-3-void mdev_set_class (struct mdev_device *mdev,u16 id) +void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class);drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 67
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +7
-0+EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) +{ +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);struct device *mdev_dev (struct mdev_device *mdev) {(...)
The code change looks good to me; I'm just wondering if we should introduce
mdev_set_class()at all (see above).
Re: [PATCH V4 3/6] mdev: introduce device specific ops
In reply to Cornelia HuckQuoted 36 lines · Cornelia Huck
Quoted 33 lines · On Thu, 17 Oct 2019 18:48:33 +0800 Jason Wang <[email protected]> wrote:
Currently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-)create mode 100644
include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.)
Quoted 8 lines
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 156
Quoted 7 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-5-The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create()s/in create()/in the create()/
Will fix.
Quoted 6 lines
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 157
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +1
-0+callback. E.g for vfio-mdev device it needs to be done through:"Each class provides a helper function to do so; e.g. for vfio-mdev devices, the function to be called is:"
?
This looks better.
Quoted 7 lines
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 162
Quoted 6 lines
Documentation/driver-api/vfio-mediated-device.rst +5
-0+ + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device"(set by this helper function to
MDEV_CLASS_ID_VFIO)" ?
Yes.
Quoted 3 lines
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 164
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-0+with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by"(specified in
*vfio_opsby the caller)" ?
Yes.
Quoted 13 lines
Quoted 13 lines
Documentation/driver-api/vfio-mediated-device.rst +6
-0+the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops);
Quoted 8 lines
Documentation/driver-api/vfio-mediated-device.rst register itself with the mdev core driver:: · line 173
Quoted 4 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-4-It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); -I'm wondering if this patch set should start out with introducing helper functions already (i.e. don't introduce
mdev_set_class(), but start out withmdev_set_class_vfio()which will gain the*vfio_opsargument in this patch.)
I think it doesn't harm to keep it as is since in patch 1 we introduce class_id and bus match method based on that without device ops there. But if you stick I can change.
Thanks
Quoted 45 lines
Quoted 4 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-0However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver::(...)
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 50
Quoted 13 lines
drivers/vfio/mdev/mdev_core.c +2
-2@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ /*
* Specify the mdev device to be a VFIO mdev device, and set the
* VFIO devices ops for it. This must be called from thecreate()
* callback for VFIO mdev devices.
*/?
Quoted 18 lines
drivers/vfio/mdev/mdev_core.c +11
-3-void mdev_set_class (struct mdev_device *mdev,u16 id) +void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class); +EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) +{ +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);
Quoted 6 lines
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 67
Quoted 2 lines
drivers/vfio/mdev/mdev_core.c +0
-0struct device *mdev_dev (struct mdev_device *mdev) {(...)
The code change looks good to me; I'm just wondering if we should introduce
mdev_set_class()at all (see above).
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 3/6] mdev: introduce device specific ops
In reply to Jason WangQuoted 30 lines · On Thu, 17 Oct 2019 18:48:33 +0800 Jason Wang <[email protected]> wrote:
Currently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644 include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 156
Quoted 10 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-5@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.) -The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create()
s/in create()/in the create()/
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 157
Quoted 1 line
Documentation/driver-api/vfio-mediated-device.rst +1
-0+callback. E.g for vfio-mdev device it needs to be done through:
"Each class provides a helper function to do so; e.g. for vfio-mdev devices, the function to be called is:"
?
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 162
Quoted 5 lines
Documentation/driver-api/vfio-mediated-device.rst +5
-0+ + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device
"(set by this helper function to MDEV_CLASS_ID_VFIO)" ?
Documentation/driver-api/vfio-mediated-device.rst callbacks per mdev parent device, per mdev type, or any other categorization. · line 164
Quoted 2 lines
Documentation/driver-api/vfio-mediated-device.rst +2
-0+with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by
"(specified in *vfio_ops by the caller)" ?
Quoted 10 lines
Documentation/driver-api/vfio-mediated-device.rst +6
-0+the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback
Documentation/driver-api/vfio-mediated-device.rst register itself with the mdev core driver:: · line 173
Quoted 7 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-4@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); -It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); -
I'm wondering if this patch set should start out with introducing helper functions already (i.e. don't introduce mdev_set_class(), but start out with mdev_set_class_vfio() which will gain the *vfio_ops argument in this patch.)
Quoted 3 lines
Documentation/driver-api/vfio-mediated-device.rst +0
-0However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver::
(...)
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 50
Quoted 13 lines
drivers/vfio/mdev/mdev_core.c +2
-2@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */
/*
* Specify the mdev device to be a VFIO mdev device, and set the
* VFIO devices ops for it. This must be called from the create()
* callback for VFIO mdev devices.
*/
?
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +4
-3-void mdev_set_class (struct mdev_device *mdev,u16 id) +void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class);
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 67
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +7
-0+EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) +{ +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);struct device *mdev_dev (struct mdev_device *mdev) {
(...)
The code change looks good to me; I'm just wondering if we should introduce mdev_set_class() at all (see above).
RE: [PATCH V4 3/6] mdev: introduce device specific ops
In reply to Jason WangQuoted 287 lines
-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Thursday, October 17, 2019 5:49 AM
To: [email protected]; [email protected]; linux- [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ido Shamay <[email protected]>; [email protected]; [email protected]; Parav Pandit <[email protected]>; [email protected]; [email protected]; [email protected]; Jason Wang <[email protected]>
Subject: [PATCH V4 3/6] mdev: introduce device specific opsCurrently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644
include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type,or any other categorization.
Vendor drivers are expected to be fully asynchronous in this respect or
provide their own internal resource protection.)Documentation/driver-api/vfio-mediated-device.rst +16
-9-The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device must +set up the class id and the device specific callbacks in create() +callback. E.g for vfio-mdev device it needs to be done through: + + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device with +an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by +the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); -It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); - However, the mdev_parent_ops structure is not required in the function callthat a driver should use to unregister itself with the mdev core driver::
MAINTAINERS +1
-0@@ -17127,6 +17127,7 @@ S: Maintained F: Documentation/driver-api/vfio-mediated-device.rst F: drivers/vfio/mdev/ F: include/linux/mdev.h +F: include/linux/vfio_mdev.h F: samples/vfio-mdev/ VFIO PLATFORM DRIVERdrivers/gpu/drm/i915/gvt/kvmgt.c +4
-1@@ -42,6 +42,7 @@#include <linux/kvm_host.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/debugfs.h> #include <linux/nospec.h> @@ -643,6 +644,8 @@ static void kvmgt_put_vfio_device(void *vgpu)vfio_device_put (((struct intel_vgpu *)vgpu)->vdev.vfio_device); } +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops; +static int intel_vgpu_create (struct kobject *kobj,struct mdev_device *mdev) {struct intel_vgpu *vgpu =NULL ;@@ -678,7 +681,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) dev_name(mdev_dev(mdev))); ret =0 ; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &intel_vfio_vgpu_dev_ops); out:return ret;}
drivers/gpu/drm/i915/gvt/kvmgt.c +7
-6@@ -1599,20 +1602,21 @@ static const struct attribute_group *intel_vgpu_groups[] = { NULL, }; -static struct mdev_parent_ops intel_vgpu_ops = { - .mdev_attr_groups = intel_vgpu_groups, - .create = intel_vgpu_create, - .remove = intel_vgpu_remove, - +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops = { .open = intel_vgpu_open, .release = intel_vgpu_release, - .read = intel_vgpu_read, .write = intel_vgpu_write, .mmap = intel_vgpu_mmap, .ioctl = intel_vgpu_ioctl, }; +static struct mdev_parent_ops intel_vgpu_ops = { + .mdev_attr_groups = intel_vgpu_groups, + .create = intel_vgpu_create, + .remove = intel_vgpu_remove, +}; +static int kvmgt_host_init (struct device *dev,void *gvt,const void *ops) {struct attribute **kvm_type_attrs;(quoted diff) +0
-0
b/drivers/s390/cio/vfio_ccw_ops.cindexcf2c013ae32f..6e606cdb1aa9100644drivers/s390/cio/vfio_ccw_ops.c +3
-0@@ -12,6 +12,7 @@#include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/nospec.h> #include <linux/slab.h> @@ -110,6 +111,8 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ccw_mdev_create (struct kobject *kobj,struct mdev_device *mdev) {drivers/s390/cio/vfio_ccw_ops.c +2
-6struct vfio_ccw_private *private =@@ -129,7 +132,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) private->sch->schid.ssid, private->sch->schid.sch_no); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -575,11 +578,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, } } -static const struct mdev_parent_ops vfio_ccw_mdev_ops = { - .owner =THIS_MODULE , - .supported_type_groups = mdev_type_groups, - .create = vfio_ccw_mdev_create, - .remove = vfio_ccw_mdev_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = vfio_ccw_mdev_open, .release = vfio_ccw_mdev_release,drivers/s390/cio/vfio_ccw_ops.c +7
-1.read = vfio_ccw_mdev_read,@@ -587,6 +586,13 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = { .ioctl = vfio_ccw_mdev_ioctl, }; +static const struct mdev_parent_ops vfio_ccw_mdev_ops = { + .owner =THIS_MODULE , + .supported_type_groups = mdev_type_groups, + .create = vfio_ccw_mdev_create, + .remove = vfio_ccw_mdev_remove, +}; +int vfio_ccw_mdev_reg (struct subchannel *sch) { return mdev_register_device(&sch->dev, &vfio_ccw_mdev_ops); diff - -git a/drivers/s390/crypto/vfio_ap_ops.c
b/drivers/s390/crypto/vfio_ap_ops.c
index07c31070afeb..195c8f4c6f10100644drivers/s390/crypto/vfio_ap_ops.c +10
-4@@ -16,6 +16,7 @@#include <linux/bitops.h> #include <linux/kvm_host.h> #include <linux/module.h> +#include <linux/vfio_mdev.h> #include <asm/kvm.h> #include <asm/zcrypt.h> @@ -321,6 +322,8 @@ static void vfio_ap_matrix_init(struct ap_config_info *info, matrix->adm_max = info->apxa ? info->Nd :15 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ap_mdev_create (struct kobject *kobj,struct mdev_device *mdev) {struct ap_matrix_mdev *matrix_mdev;@@ -343,7 +346,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev) list_add(&matrix_mdev->node, &matrix_dev->mdev_list);mutex_unlock (&matrix_dev->lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -1281,15 +1284,18 @@ static ssize_t vfio_ap_mdev_ioctl(structmdev_device *mdev, return ret; } +static const struct vfio_mdev_device_ops vfio_mdev_ops = { + .open = vfio_ap_mdev_open, + .release = vfio_ap_mdev_release, + .ioctl = vfio_ap_mdev_ioctl, +}; +static const struct mdev_parent_ops vfio_ap_matrix_ops = { .owner =THIS_MODULE , .supported_type_groups = vfio_ap_mdev_type_groups, .mdev_attr_groups = vfio_ap_mdev_attr_groups, .create = vfio_ap_mdev_create, .remove = vfio_ap_mdev_remove, - .open = vfio_ap_mdev_open, - .release = vfio_ap_mdev_release, - .ioctl = vfio_ap_mdev_ioctl, };int
vfio_ap_mdev_register(void)drivers/vfio/mdev/mdev_core.c +0
-0
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, · line 50
Quoted 8 lines
drivers/vfio/mdev/mdev_core.c +2
-3@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) } EXPORT_SYMBOL(mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ -void mdev_set_class (struct mdev_device *mdev,u16 id)
I think you should keep the mdev_set_class API and let mdev_set_vfio_ops call it. Even though its two line function. The reason to avoid a code churn in short time with mlx5_core patch which will only call mdev_set_class(), as it doesn't have any ops yet.
Quoted 22 lines
drivers/vfio/mdev/mdev_core.c +10
-2+void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class); +EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) { +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops); struct device *mdev_dev(struct mdev_device *mdev) { diff --git
a/drivers/vfio/mdev/mdev_private.hb/drivers/vfio/mdev/mdev_private.hindexc65f436c1869..b666805f0b1f100644
drivers/vfio/mdev/mdev_private.h struct mdev_device { · line 37
Quoted 4 lines
drivers/vfio/mdev/mdev_private.h +1
-0@@ -34,6 +34,7 @@ struct mdev_device {struct device *iommu_device;bool active;u16 class_id; +const void *device_ops;
Instead of void *, this should be union vfio_ops and virtio_ops.
Quoted 184 lines
drivers/vfio/mdev/mdev_private.h +0
-0};#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev)drivers/vfio/mdev/vfio_mdev.c +19
-18@@ -14,6 +14,7 @@#include <linux/slab.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include "mdev_private.h" @@ -24,16 +25,16 @@static int vfio_mdev_open (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev);int ret; -if (unlikely (!parent->ops->open)) +if (unlikely (!ops->open))return -EINVAL ;if (!try_module_get (THIS_MODULE ))return -ENODEV ; - ret = parent->ops->open (mdev); + ret = ops->open (mdev);if (ret)module_put (THIS_MODULE );@@ -43,10 +44,10 @@ static int vfio_mdev_open(void *device_data) staticvoid vfio_mdev_release (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (likely (parent->ops->release)) - parent->ops->release (mdev); +if (likely (ops->release)) + ops->release (mdev);module_put (THIS_MODULE ); }@@ -55,47 +56,47 @@ static long vfio_mdev_unlocked_ioctl(void *device_data, unsigned int cmd, unsigned long arg) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->ioctl)) +if (unlikely (!ops->ioctl))return -EINVAL ; -return parent->ops->ioctl (mdev, cmd, arg); +return ops->ioctl (mdev, cmd, arg); }static ssize_t vfio_mdev_read (void *device_data,char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->read)) +if (unlikely (!ops->read))return -EINVAL ; -return parent->ops->read (mdev, buf, count, ppos); +return ops->read (mdev, buf, count, ppos); }static ssize_t vfio_mdev_write (void *device_data,const char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->write)) +if (unlikely (!ops->write))return -EINVAL ; -return parent->ops->write (mdev, buf, count, ppos); +return ops->write (mdev, buf, count, ppos); }static int vfio_mdev_mmap (void *device_data,struct vm_area_struct *vma) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->mmap)) +if (unlikely (!ops->mmap))return -EINVAL ; -return parent->ops->mmap (mdev, vma); +return ops->mmap (mdev, vma); } static const struct vfio_device_ops vfio_mdev_dev_ops = { diff --git
a/include/linux/mdev.hb/include/linux/mdev.hindex78b69d09eb54..3d29e09e20c9100644include/linux/mdev.h +6
-1@@ -10,7 +10,13 @@#ifndef MDEV_H #define MDEV_H +#include <linux/types.h> +#include <linux/device.h> +#include <linux/mdev.h> +#include <uapi/linux/uuid.h> +struct mdev_device ; +struct vfio_mdev_device_ops ;/* * Called by the parent device driver to set the device which represents @@ -48,30 +54,7 @@ struct device *mdev_get_iommu_device(struct device *dev);
* @mdev:mdev_devicedevice structure which is being
* destroyed
* Returns integer: success (0) or error (< 0)
- * @open: Open mediated device.
- * @mdev: mediated device.
- * Returns integer: success (0) or error (< 0)
- * @release: release mediated device
- * @mdev: mediated device.
- * @read: Read emulation callback
- * @mdev: mediated device structure
- * @buf: read buffer
- * @count: number of bytes to read
- * @ppos: address.
- * Retuns number on bytes read on success or error.
- * @write: Write emulation callback
- * @mdev: mediated device structure
- * @buf: write buffer
- * @count: number of bytes to be written
- * @ppos: address.
- * Retuns number on bytes written on success or error.
- * @ioctl: IOCTL callback
- * @mdev: mediated device structure
- * @cmd: ioctl command
- * @arg: arguments to ioctl
- * @mmap: mmap callback
- * @mdev: mediated device structure
- * @vma: vma structure
+ *
* Parent device that support mediated device should be registered with
mdev
* module withmdev_parent_opsstructure.
**/include/linux/mdev.h +0
-9@@ -83,15 +66,6 @@ struct mdev_parent_ops {int (*create)(struct kobject *kobj,struct mdev_device *mdev);int (*remove)(struct mdev_device *mdev); -int (*open)(struct mdev_device *mdev); -void (*release)(struct mdev_device *mdev); -ssize_t (*read)(struct mdev_device *mdev,char __user *buf, -size_t count,loff_t *ppos); -ssize_t (*write)(struct mdev_device *mdev,const char __user *buf, -size_t count,loff_t *ppos); -long (*ioctl)(struct mdev_device *mdev,unsigned int cmd, -unsigned long arg); -int (*mmap)(struct mdev_device *mdev,struct vm_area_struct *vma); };/* interface for exporting mdev supported type attributes */ @@ -133,8
+107,11 @@ structmdev_driver{
Quoted 3 lines
void *mdev_get_drvdata(struct
mdev_device*mdev); voidmdev_set_drvdata(struct mdev_device *mdev, void *data); +
Unrelated line change for this patch. Please remove.
Quoted 7 lines
const
guid_t*mdev_uuid(structmdev_device*mdev); -voidmdev_set_class(struct mdev_device *mdev, u16 id);include/linux/mdev.h +2
-0+void mdev_set_vfio_ops (struct mdev_device *mdev, + const struct vfio_mdev_device_ops *vfio_ops); constvoid
+*mdev_get_dev_ops(structmdev_device*mdev);
Since you have the set_vfio_ops, its better to have get_vfio_ops() and similarly get_virtio_ops.
include/linux/vfio_mdev.h
Quoted 6 lines
extern struct
bus_typemdev_bus_type;include/linux/vfio_mdev.h new file renamed from include/linux/vfio_mdev.h +0
-0mode 100644 index 000000000000..3907c5371c2b
include/linux/vfio_mdev.h new file +0
-0
This file name is confusing.vfio_mdev_ops.h is more accurate name of what it intends to achieve. If you see this file expanding scope beyond ops, this file name looks fine.
Quoted 209 lines
include/linux/vfio_mdev.h new file +49
-0@@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* VFIO Mediated device definition +*/ + +#ifndef VFIO_MDEV_H +#define VFIO_MDEV_H + +#include <linux/mdev.h> + +/** + * struct vfio_mdev_device_ops - Structure to be registered for each + * mdev device to register the device to vfio-mdev module. + * + * @open: Open mediated device. + * @mdev: mediated device. + * Returns integer: success (0) or error (< 0) + * @release: release mediated device + * @mdev: mediated device. + * @read: Read emulation callback + * @mdev: mediated device structure + * @buf: read buffer + * @count: number of bytes to read + * @ppos: address. + * Retuns number on bytes read on success or error. + * @write: Write emulation callback + * @mdev: mediated device structure + * @buf: write buffer + * @count: number of bytes to be written + * @ppos: address. + * Retuns number on bytes written on success or error. + * @ioctl: IOCTL callback + * @mdev: mediated device structure + * @cmd: ioctl command + * @arg: arguments to ioctl + * @mmap: mmap callback + * @mdev: mediated device structure + * @vma: vma structure + */ +struct vfio_mdev_device_ops { + int (*open)(struct mdev_device *mdev); + void (*release)(struct mdev_device *mdev); + ssize_t (*read)(struct mdev_device *mdev, char __user *buf, + size_t count, loff_t *ppos); + ssize_t (*write)(struct mdev_device *mdev, const char __user *buf, + size_t count, loff_t *ppos); + long (*ioctl)(struct mdev_device *mdev, unsigned int cmd, + unsigned long arg); + int (*mmap)(struct mdev_device *mdev, struct vm_area_struct*vma);
include/linux/vfio_mdev.h new file +3
-0+}; + +#endif samples/vfio-mdev/mbochs.c +3
-0@@ -30,6 +30,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/dma-buf.h> #include <linux/highmem.h> @@ -516,6 +517,8 @@ static int mbochs_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mbochs_create (struct kobject *kobj,struct mdev_device *mdev) { const struct mbochs_type *type = mbochs_find_type(kobj); @@ -561,7 +564,7 @@ static int
mbochs_create(struct kobject *kobj, struct mdev_device *mdev)samples/vfio-mdev/mbochs.c +2
-7mbochs_reset (mdev); mbochs_used_mbytes += type->mbytes; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; err_mem:@@ -1419,12 +1422,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mbochs_create, - .remove = mbochs_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mbochs_open, .release = mbochs_close,samples/vfio-mdev/mbochs.c +8
-0.read = mbochs_read,@@ -1433,6 +1431,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mbochs_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mbochs_create, + .remove = mbochs_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE ,};
samples/vfio-mdev/mdpy.c index renamed from samples/vfio-mdev/mdpy.c +0
-0
665614574d50..f21c795c40e4100644samples/vfio-mdev/mdpy.c +4
-0@@ -26,6 +26,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <drm/drm_fourcc.h> #include "mdpy-defs.h" @@ -226,6 +227,8 @@ static int mdpy_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mdpy_create (struct kobject *kobj,struct mdev_device *mdev) { const struct mdpy_type *type = mdpy_find_type(kobj); @@ -269,7 +272,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device*mdev)
samples/vfio-mdev/mdpy.c +2
-7mdpy_reset (mdev); mdpy_count++; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -726,12 +729,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mdpy_create, - .remove = mdpy_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mdpy_open, .release = mdpy_close,samples/vfio-mdev/mdpy.c +8
-0.read = mdpy_read,@@ -740,6 +738,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mdpy_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mdpy_create, + .remove = mdpy_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE , };samples/vfio-mdev/mtty.c index renamed from samples/vfio-mdev/mtty.c +0
-0
90da12ff7fd9..b829f33b98f5100644samples/vfio-mdev/mtty.c +4
-1@@ -27,6 +27,7 @@#include <linux/ctype.h> #include <linux/file.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/serial.h> #include <uapi/linux/serial_reg.h> @@ -708,6 +709,8 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count, return ret; } +static const struct vfio_mdev_device_ops vfio_dev_ops; +static int mtty_create (struct kobject *kobj,struct mdev_device *mdev) {struct mdev_state *mdev_state;@@ -755,7 +758,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev) list_add(&mdev_state->next, &mdev_devices_list);mutex_unlock (&mdev_list_lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_dev_ops);return 0 ; }@@ -1388,6 +1391,14 @@ static struct attribute_group *mdev_type_groups[] = { NULL,
samples/vfio-mdev/mtty.c static struct attribute_group · line 1402
Quoted 10 lines
samples/vfio-mdev/mtty.c +8
-0}; +static const struct vfio_mdev_device_ops vfio_dev_ops = { + .open = mtty_open, + .release = mtty_close, + .read = mtty_read, + .write = mtty_write, + .ioctl = mtty_ioctl, +}; +
Since hunk shows that vfio_dev_ops added new here, it is better to drop the extra white space mixed with tab alignment. Just have single white space like below.
.open = mtty_open,
.release = mtty_close,
.read = mtty_read,
.write = mtty_write,
.ioctl = mtty_ioctl
Quoted 18 lines
samples/vfio-mdev/mtty.c +0
-0static const struct mdev_parent_ops mdev_fops = { .owner =THIS_MODULE ,samples/vfio-mdev/mtty.c +0
-5.dev_attr_groups = mtty_dev_groups,@@ -1395,11 +1406,6 @@ static const struct mdev_parent_ops mdev_fops = { .supported_type_groups = mdev_type_groups, .create = mtty_create, .remove = mtty_remove, - .open = mtty_open, - .release = mtty_close, - .read = mtty_read, - .write = mtty_write, - .ioctl = mtty_ioctl, };static void
mtty_device_release(struct device *dev)
--
2.19.1
Re: [PATCH V4 3/6] mdev: introduce device specific ops
Quoted 288 lines · Parav Pandit
Quoted 288 lines
-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Thursday, October 17, 2019 5:49 AM
To: [email protected]; [email protected]; linux- [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ido Shamay <[email protected]>; [email protected]; [email protected]; Parav Pandit <[email protected]>; [email protected]; [email protected]; [email protected]; Jason Wang <[email protected]>
Subject: [PATCH V4 3/6] mdev: introduce device specific opsCurrently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644
include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type,or any other categorization.
Vendor drivers are expected to be fully asynchronous in this respect or
provide their own internal resource protection.)Documentation/driver-api/vfio-mediated-device.rst +16
-9-The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device must +set up the class id and the device specific callbacks in create() +callback. E.g for vfio-mdev device it needs to be done through: + + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device with +an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by +the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); -It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); - However, the mdev_parent_ops structure is not required in the function callthat a driver should use to unregister itself with the mdev core driver::
MAINTAINERS +1
-0@@ -17127,6 +17127,7 @@ S: Maintained F: Documentation/driver-api/vfio-mediated-device.rst F: drivers/vfio/mdev/ F: include/linux/mdev.h +F: include/linux/vfio_mdev.h F: samples/vfio-mdev/ VFIO PLATFORM DRIVERdrivers/gpu/drm/i915/gvt/kvmgt.c +4
-1@@ -42,6 +42,7 @@#include <linux/kvm_host.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/debugfs.h> #include <linux/nospec.h> @@ -643,6 +644,8 @@ static void kvmgt_put_vfio_device(void *vgpu)vfio_device_put (((struct intel_vgpu *)vgpu)->vdev.vfio_device); } +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops; +static int intel_vgpu_create (struct kobject *kobj,struct mdev_device *mdev) {struct intel_vgpu *vgpu =NULL ;@@ -678,7 +681,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) dev_name(mdev_dev(mdev))); ret =0 ; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &intel_vfio_vgpu_dev_ops); out:return ret;}drivers/gpu/drm/i915/gvt/kvmgt.c +7
-6@@ -1599,20 +1602,21 @@ static const struct attribute_group *intel_vgpu_groups[] = { NULL, }; -static struct mdev_parent_ops intel_vgpu_ops = { - .mdev_attr_groups = intel_vgpu_groups, - .create = intel_vgpu_create, - .remove = intel_vgpu_remove, - +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops = { .open = intel_vgpu_open, .release = intel_vgpu_release, - .read = intel_vgpu_read, .write = intel_vgpu_write, .mmap = intel_vgpu_mmap, .ioctl = intel_vgpu_ioctl, }; +static struct mdev_parent_ops intel_vgpu_ops = { + .mdev_attr_groups = intel_vgpu_groups, + .create = intel_vgpu_create, + .remove = intel_vgpu_remove, +}; +static int kvmgt_host_init (struct device *dev,void *gvt,const void *ops) {struct attribute **kvm_type_attrs;(quoted diff) +0
-0
b/drivers/s390/cio/vfio_ccw_ops.cindexcf2c013ae32f..6e606cdb1aa9100644drivers/s390/cio/vfio_ccw_ops.c +3
-0@@ -12,6 +12,7 @@#include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/nospec.h> #include <linux/slab.h> @@ -110,6 +111,8 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ccw_mdev_create (struct kobject *kobj,struct mdev_device *mdev) {struct
vfio_ccw_private*private =drivers/s390/cio/vfio_ccw_ops.c +2
-6@@ -129,7 +132,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) private->sch->schid.ssid, private->sch->schid.sch_no); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -575,11 +578,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, } } -static const struct mdev_parent_ops vfio_ccw_mdev_ops = { - .owner =THIS_MODULE , - .supported_type_groups = mdev_type_groups, - .create = vfio_ccw_mdev_create, - .remove = vfio_ccw_mdev_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = vfio_ccw_mdev_open, .release = vfio_ccw_mdev_release,.read =
vfio_ccw_mdev_read,drivers/s390/cio/vfio_ccw_ops.c +7
-1@@ -587,6 +586,13 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = { .ioctl = vfio_ccw_mdev_ioctl, }; +static const struct mdev_parent_ops vfio_ccw_mdev_ops = { + .owner =THIS_MODULE , + .supported_type_groups = mdev_type_groups, + .create = vfio_ccw_mdev_create, + .remove = vfio_ccw_mdev_remove, +}; +int vfio_ccw_mdev_reg (struct subchannel *sch) { return mdev_register_device(&sch->dev, &vfio_ccw_mdev_ops); diff - -git a/drivers/s390/crypto/vfio_ap_ops.c
b/drivers/s390/crypto/vfio_ap_ops.c
index07c31070afeb..195c8f4c6f10100644drivers/s390/crypto/vfio_ap_ops.c +10
-4@@ -16,6 +16,7 @@#include <linux/bitops.h> #include <linux/kvm_host.h> #include <linux/module.h> +#include <linux/vfio_mdev.h> #include <asm/kvm.h> #include <asm/zcrypt.h> @@ -321,6 +322,8 @@ static void vfio_ap_matrix_init(struct ap_config_info *info, matrix->adm_max = info->apxa ? info->Nd :15 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ap_mdev_create (struct kobject *kobj,struct mdev_device *mdev) {struct ap_matrix_mdev *matrix_mdev;@@ -343,7 +346,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev) list_add(&matrix_mdev->node, &matrix_dev->mdev_list);mutex_unlock (&matrix_dev->lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -1281,15 +1284,18 @@ static ssize_t vfio_ap_mdev_ioctl(structmdev_device *mdev, return ret; } +static const struct vfio_mdev_device_ops vfio_mdev_ops = { + .open = vfio_ap_mdev_open, + .release = vfio_ap_mdev_release, + .ioctl = vfio_ap_mdev_ioctl, +}; +static const struct mdev_parent_ops vfio_ap_matrix_ops = { .owner =THIS_MODULE , .supported_type_groups = vfio_ap_mdev_type_groups, .mdev_attr_groups = vfio_ap_mdev_attr_groups, .create = vfio_ap_mdev_create, .remove = vfio_ap_mdev_remove, - .open = vfio_ap_mdev_open, - .release = vfio_ap_mdev_release, - .ioctl = vfio_ap_mdev_ioctl, };int
vfio_ap_mdev_register(void)drivers/vfio/mdev/mdev_core.c +0
-0@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) } EXPORT_SYMBOL(mdev_set_drvdata);
Quoted 8 lines
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 51
Quoted 6 lines
drivers/vfio/mdev/mdev_core.c +2
-3-/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ -void mdev_set_class (struct mdev_device *mdev,u16 id)I think you should keep the
mdev_set_classAPI and letmdev_set_vfio_opscall it. Even though its two line function. The reason to avoid a code churn in short time withmlx5_corepatch which will only callmdev_set_class(), as it doesn't have any ops yet.
That sounds good, will do.
Quoted 16 lines
Quoted 16 lines
drivers/vfio/mdev/mdev_core.c +10
-2+void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class); +EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) { +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);
Quoted 11 lines
drivers/vfio/mdev/mdev_private.h struct mdev_device { · line 37
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +0
-0struct device *mdev_dev(struct mdev_device *mdev) { diff --git
a/drivers/vfio/mdev/mdev_private.hb/drivers/vfio/mdev/mdev_private.hindexc65f436c1869..b666805f0b1f100644drivers/vfio/mdev/mdev_private.h +1
-0@@ -34,6 +34,7 @@ struct mdev_device {struct device *iommu_device;bool active;u16 class_id; +const void *device_ops;Instead of void *, this should be union
vfio_opsandvirtio_ops.
Ok.
Quoted 181 lines
Quoted 181 lines
drivers/vfio/mdev/mdev_private.h +0
-0};#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev)drivers/vfio/mdev/vfio_mdev.c +19
-18@@ -14,6 +14,7 @@#include <linux/slab.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include "mdev_private.h" @@ -24,16 +25,16 @@static int vfio_mdev_open (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev);int ret; -if (unlikely (!parent->ops->open)) +if (unlikely (!ops->open))return -EINVAL ;if (!try_module_get (THIS_MODULE ))return -ENODEV ; - ret = parent->ops->open (mdev); + ret = ops->open (mdev);if (ret)module_put (THIS_MODULE );@@ -43,10 +44,10 @@ static int vfio_mdev_open(void *device_data) staticvoid vfio_mdev_release (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (likely (parent->ops->release)) - parent->ops->release (mdev); +if (likely (ops->release)) + ops->release (mdev);module_put (THIS_MODULE ); }@@ -55,47 +56,47 @@ static long vfio_mdev_unlocked_ioctl(void *device_data, unsigned int cmd, unsigned long arg) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->ioctl)) +if (unlikely (!ops->ioctl))return -EINVAL ; -return parent->ops->ioctl (mdev, cmd, arg); +return ops->ioctl (mdev, cmd, arg); }static ssize_t vfio_mdev_read (void *device_data,char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->read)) +if (unlikely (!ops->read))return -EINVAL ; -return parent->ops->read (mdev, buf, count, ppos); +return ops->read (mdev, buf, count, ppos); }static ssize_t vfio_mdev_write (void *device_data,const char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->write)) +if (unlikely (!ops->write))return -EINVAL ; -return parent->ops->write (mdev, buf, count, ppos); +return ops->write (mdev, buf, count, ppos); }static int vfio_mdev_mmap (void *device_data,struct vm_area_struct *vma) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->mmap)) +if (unlikely (!ops->mmap))return -EINVAL ; -return parent->ops->mmap (mdev, vma); +return ops->mmap (mdev, vma); } static const struct vfio_device_ops vfio_mdev_dev_ops = { diff --git
a/include/linux/mdev.hb/include/linux/mdev.hindex78b69d09eb54..3d29e09e20c9100644include/linux/mdev.h +6
-1@@ -10,7 +10,13 @@#ifndef MDEV_H #define MDEV_H +#include <linux/types.h> +#include <linux/device.h> +#include <linux/mdev.h> +#include <uapi/linux/uuid.h> +struct mdev_device ; +struct vfio_mdev_device_ops ;/* * Called by the parent device driver to set the device which represents @@ -48,30 +54,7 @@ struct device *mdev_get_iommu_device(struct device *dev);
* @mdev:mdev_devicedevice structure which is being
* destroyed
* Returns integer: success (0) or error (< 0)
- * @open: Open mediated device.
- * @mdev: mediated device.
- * Returns integer: success (0) or error (< 0)
- * @release: release mediated device
- * @mdev: mediated device.
- * @read: Read emulation callback
- * @mdev: mediated device structure
- * @buf: read buffer
- * @count: number of bytes to read
- * @ppos: address.
- * Retuns number on bytes read on success or error.
- * @write: Write emulation callback
- * @mdev: mediated device structure
- * @buf: write buffer
- * @count: number of bytes to be written
- * @ppos: address.
- * Retuns number on bytes written on success or error.
- * @ioctl: IOCTL callback
- * @mdev: mediated device structure
- * @cmd: ioctl command
- * @arg: arguments to ioctl
- * @mmap: mmap callback
- * @mdev: mediated device structure
- * @vma: vma structure
+ *
* Parent device that support mediated device should be registered with
mdev
* module withmdev_parent_opsstructure.
**/include/linux/mdev.h +0
-9@@ -83,15 +66,6 @@ struct mdev_parent_ops {int (*create)(struct kobject *kobj,struct mdev_device *mdev);int (*remove)(struct mdev_device *mdev); -int (*open)(struct mdev_device *mdev); -void (*release)(struct mdev_device *mdev); -ssize_t (*read)(struct mdev_device *mdev,char __user *buf, -size_t count,loff_t *ppos); -ssize_t (*write)(struct mdev_device *mdev,const char __user *buf, -size_t count,loff_t *ppos); -long (*ioctl)(struct mdev_device *mdev,unsigned int cmd, -unsigned long arg); -int (*mmap)(struct mdev_device *mdev,struct vm_area_struct *vma); };
Quoted 7 lines
Quoted 6 lines
/* interface for exporting mdev supported type attributes */ @@ -133,8
+107,11 @@ structmdev_driver{void *mdev_get_drvdata(struct
mdev_device*mdev); voidmdev_set_drvdata(struct mdev_device *mdev, void *data); +Unrelated line change for this patch. Please remove.
Sure.
Quoted 9 lines
Quoted 8 lines
const
guid_t*mdev_uuid(structmdev_device*mdev); -voidmdev_set_class(struct mdev_device *mdev, u16 id);include/linux/mdev.h +2
-0+void mdev_set_vfio_ops (struct mdev_device *mdev, + const struct vfio_mdev_device_ops *vfio_ops); constvoid
+*mdev_get_dev_ops(structmdev_device*mdev);Since you have the
set_vfio_ops, its better to haveget_vfio_ops()and similarlyget_virtio_ops.
Ok.
Quoted 233 lines
include/linux/vfio_mdev.h
Quoted 7 lines
extern struct
bus_typemdev_bus_type;include/linux/vfio_mdev.h new file renamed from include/linux/vfio_mdev.h +0
-0mode 100644 index 000000000000..3907c5371c2b
include/linux/vfio_mdev.h new file +0
-0This file name is confusing.
vfio_mdev_ops.his more accurate name of what it intends to achieve. If you see this file expanding scope beyond ops, this file name looks fine.Quoted 209 lines
include/linux/vfio_mdev.h new file +49
-0@@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* VFIO Mediated device definition +*/ + +#ifndef VFIO_MDEV_H +#define VFIO_MDEV_H + +#include <linux/mdev.h> + +/** + * struct vfio_mdev_device_ops - Structure to be registered for each + * mdev device to register the device to vfio-mdev module. + * + * @open: Open mediated device. + * @mdev: mediated device. + * Returns integer: success (0) or error (< 0) + * @release: release mediated device + * @mdev: mediated device. + * @read: Read emulation callback + * @mdev: mediated device structure + * @buf: read buffer + * @count: number of bytes to read + * @ppos: address. + * Retuns number on bytes read on success or error. + * @write: Write emulation callback + * @mdev: mediated device structure + * @buf: write buffer + * @count: number of bytes to be written + * @ppos: address. + * Retuns number on bytes written on success or error. + * @ioctl: IOCTL callback + * @mdev: mediated device structure + * @cmd: ioctl command + * @arg: arguments to ioctl + * @mmap: mmap callback + * @mdev: mediated device structure + * @vma: vma structure + */ +struct vfio_mdev_device_ops { + int (*open)(struct mdev_device *mdev); + void (*release)(struct mdev_device *mdev); + ssize_t (*read)(struct mdev_device *mdev, char __user *buf, + size_t count, loff_t *ppos); + ssize_t (*write)(struct mdev_device *mdev, const char __user *buf, + size_t count, loff_t *ppos); + long (*ioctl)(struct mdev_device *mdev, unsigned int cmd, + unsigned long arg); + int (*mmap)(struct mdev_device *mdev, struct vm_area_struct*vma);
include/linux/vfio_mdev.h new file +3
-0+}; + +#endif samples/vfio-mdev/mbochs.c +3
-0@@ -30,6 +30,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/dma-buf.h> #include <linux/highmem.h> @@ -516,6 +517,8 @@ static int mbochs_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mbochs_create (struct kobject *kobj,struct mdev_device *mdev) { const struct mbochs_type *type = mbochs_find_type(kobj); @@ -561,7 +564,7 @@ static int
mbochs_create(struct kobject *kobj, struct mdev_device *mdev)
mbochs_reset(mdev);mbochs_used_mbytes += type->mbytes;samples/vfio-mdev/mbochs.c +2
-7-mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; err_mem:@@ -1419,12 +1422,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mbochs_create, - .remove = mbochs_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mbochs_open, .release = mbochs_close,.read =
mbochs_read,samples/vfio-mdev/mbochs.c +8
-0@@ -1433,6 +1431,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mbochs_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mbochs_create, + .remove = mbochs_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE ,};samples/vfio-mdev/mdpy.c index renamed from samples/vfio-mdev/mdpy.c +0
-0
665614574d50..f21c795c40e4100644samples/vfio-mdev/mdpy.c +4
-0@@ -26,6 +26,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <drm/drm_fourcc.h> #include "mdpy-defs.h" @@ -226,6 +227,8 @@ static int mdpy_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mdpy_create (struct kobject *kobj,struct mdev_device *mdev) { const struct mdpy_type *type = mdpy_find_type(kobj); @@ -269,7 +272,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device*mdev)
mdpy_reset(mdev);mdpy_count++;
samples/vfio-mdev/mdpy.c +2
-7-mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -726,12 +729,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mdpy_create, - .remove = mdpy_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mdpy_open, .release = mdpy_close,.read =
mdpy_read,samples/vfio-mdev/mdpy.c +8
-0@@ -740,6 +738,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mdpy_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mdpy_create, + .remove = mdpy_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE , };samples/vfio-mdev/mtty.c index renamed from samples/vfio-mdev/mtty.c +0
-0
90da12ff7fd9..b829f33b98f5100644samples/vfio-mdev/mtty.c +4
-1@@ -27,6 +27,7 @@#include <linux/ctype.h> #include <linux/file.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/serial.h> #include <uapi/linux/serial_reg.h> @@ -708,6 +709,8 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count, return ret; } +static const struct vfio_mdev_device_ops vfio_dev_ops; +static int mtty_create (struct kobject *kobj,struct mdev_device *mdev) {struct mdev_state *mdev_state;@@ -755,7 +758,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev) list_add(&mdev_state->next, &mdev_devices_list);mutex_unlock (&mdev_list_lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_dev_ops);return 0 ; }@@ -1388,6 +1391,14 @@ static struct attribute_group *mdev_type_groups[] = { NULL,samples/vfio-mdev/mtty.c static struct attribute_group · line 1402
Quoted 10 lines
samples/vfio-mdev/mtty.c +8
-0}; +static const struct vfio_mdev_device_ops vfio_dev_ops = { + .open = mtty_open, + .release = mtty_close, + .read = mtty_read, + .write = mtty_write, + .ioctl = mtty_ioctl, +}; +Since hunk shows that
vfio_dev_opsadded new here, it is better to drop the extra white space mixed with tab alignment. Just have single white space like below.
Quoted 5 lines
.open =
mtty_open,
.release =mtty_close,
.read =mtty_read,
.write =mtty_write,
.ioctl =mtty_ioctl
Will do.
Thanks
Quoted 19 lines
Quoted 19 lines
samples/vfio-mdev/mtty.c +0
-0static const struct mdev_parent_ops mdev_fops = { .owner =THIS_MODULE ,.dev_attr_groups =
mtty_dev_groups,samples/vfio-mdev/mtty.c +0
-5@@ -1395,11 +1406,6 @@ static const struct mdev_parent_ops mdev_fops = { .supported_type_groups = mdev_type_groups, .create = mtty_create, .remove = mtty_remove, - .open = mtty_open, - .release = mtty_close, - .read = mtty_read, - .write = mtty_write, - .ioctl = mtty_ioctl, };static void
mtty_device_release(struct device *dev)
--
2.19.1
Re: [PATCH V4 3/6] mdev: introduce device specific ops
In reply to Parav PanditQuoted 288 lines · Parav Pandit
Quoted 288 lines
-----Original Message-----
From: Jason Wang <[email protected]>
Sent: Thursday, October 17, 2019 5:49 AM
To: [email protected]; [email protected]; linux- [email protected]; [email protected]; intel- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Ido Shamay <[email protected]>; [email protected]; [email protected]; Parav Pandit <[email protected]>; [email protected]; [email protected]; [email protected]; Jason Wang <[email protected]>
Subject: [PATCH V4 3/6] mdev: introduce device specific opsCurrently, except for the create and remove, the rest of
mdev_parent_opsis designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks insidemdev_devicestructure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.Signed-off-by Jason Wang <[email protected]>--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644
include/linux/vfio_mdev.hDocumentation/driver-api/vfio-mediated-device.rst +0
-0@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type,or any other categorization.
Vendor drivers are expected to be fully asynchronous in this respect or
provide their own internal resource protection.)Documentation/driver-api/vfio-mediated-device.rst +16
-9-The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device must +set up the class id and the device specific callbacks in create() +callback. E.g for vfio-mdev device it needs to be done through: + + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device with +an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by +the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); -It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); - However, the mdev_parent_ops structure is not required in the function callthat a driver should use to unregister itself with the mdev core driver::
MAINTAINERS +1
-0@@ -17127,6 +17127,7 @@ S: Maintained F: Documentation/driver-api/vfio-mediated-device.rst F: drivers/vfio/mdev/ F: include/linux/mdev.h +F: include/linux/vfio_mdev.h F: samples/vfio-mdev/ VFIO PLATFORM DRIVERdrivers/gpu/drm/i915/gvt/kvmgt.c +4
-1@@ -42,6 +42,7 @@#include <linux/kvm_host.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/debugfs.h> #include <linux/nospec.h> @@ -643,6 +644,8 @@ static void kvmgt_put_vfio_device(void *vgpu)vfio_device_put (((struct intel_vgpu *)vgpu)->vdev.vfio_device); } +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops; +static int intel_vgpu_create (struct kobject *kobj,struct mdev_device *mdev) {struct intel_vgpu *vgpu =NULL ;@@ -678,7 +681,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) dev_name(mdev_dev(mdev))); ret =0 ; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &intel_vfio_vgpu_dev_ops); out:return ret;}drivers/gpu/drm/i915/gvt/kvmgt.c +7
-6@@ -1599,20 +1602,21 @@ static const struct attribute_group *intel_vgpu_groups[] = { NULL, }; -static struct mdev_parent_ops intel_vgpu_ops = { - .mdev_attr_groups = intel_vgpu_groups, - .create = intel_vgpu_create, - .remove = intel_vgpu_remove, - +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops = { .open = intel_vgpu_open, .release = intel_vgpu_release, - .read = intel_vgpu_read, .write = intel_vgpu_write, .mmap = intel_vgpu_mmap, .ioctl = intel_vgpu_ioctl, }; +static struct mdev_parent_ops intel_vgpu_ops = { + .mdev_attr_groups = intel_vgpu_groups, + .create = intel_vgpu_create, + .remove = intel_vgpu_remove, +}; +static int kvmgt_host_init (struct device *dev,void *gvt,const void *ops) {struct attribute **kvm_type_attrs;(quoted diff) +0
-0
b/drivers/s390/cio/vfio_ccw_ops.cindexcf2c013ae32f..6e606cdb1aa9100644drivers/s390/cio/vfio_ccw_ops.c +3
-0@@ -12,6 +12,7 @@#include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/nospec.h> #include <linux/slab.h> @@ -110,6 +111,8 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ccw_mdev_create (struct kobject *kobj,struct mdev_device *mdev) {struct
vfio_ccw_private*private =drivers/s390/cio/vfio_ccw_ops.c +2
-6@@ -129,7 +132,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) private->sch->schid.ssid, private->sch->schid.sch_no); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -575,11 +578,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, } } -static const struct mdev_parent_ops vfio_ccw_mdev_ops = { - .owner =THIS_MODULE , - .supported_type_groups = mdev_type_groups, - .create = vfio_ccw_mdev_create, - .remove = vfio_ccw_mdev_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = vfio_ccw_mdev_open, .release = vfio_ccw_mdev_release,.read =
vfio_ccw_mdev_read,drivers/s390/cio/vfio_ccw_ops.c +7
-1@@ -587,6 +586,13 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = { .ioctl = vfio_ccw_mdev_ioctl, }; +static const struct mdev_parent_ops vfio_ccw_mdev_ops = { + .owner =THIS_MODULE , + .supported_type_groups = mdev_type_groups, + .create = vfio_ccw_mdev_create, + .remove = vfio_ccw_mdev_remove, +}; +int vfio_ccw_mdev_reg (struct subchannel *sch) { return mdev_register_device(&sch->dev, &vfio_ccw_mdev_ops); diff - -git a/drivers/s390/crypto/vfio_ap_ops.c
b/drivers/s390/crypto/vfio_ap_ops.c
index07c31070afeb..195c8f4c6f10100644drivers/s390/crypto/vfio_ap_ops.c +10
-4@@ -16,6 +16,7 @@#include <linux/bitops.h> #include <linux/kvm_host.h> #include <linux/module.h> +#include <linux/vfio_mdev.h> #include <asm/kvm.h> #include <asm/zcrypt.h> @@ -321,6 +322,8 @@ static void vfio_ap_matrix_init(struct ap_config_info *info, matrix->adm_max = info->apxa ? info->Nd :15 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ap_mdev_create (struct kobject *kobj,struct mdev_device *mdev) {struct ap_matrix_mdev *matrix_mdev;@@ -343,7 +346,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev) list_add(&matrix_mdev->node, &matrix_dev->mdev_list);mutex_unlock (&matrix_dev->lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -1281,15 +1284,18 @@ static ssize_t vfio_ap_mdev_ioctl(structmdev_device *mdev, return ret; } +static const struct vfio_mdev_device_ops vfio_mdev_ops = { + .open = vfio_ap_mdev_open, + .release = vfio_ap_mdev_release, + .ioctl = vfio_ap_mdev_ioctl, +}; +static const struct mdev_parent_ops vfio_ap_matrix_ops = { .owner =THIS_MODULE , .supported_type_groups = vfio_ap_mdev_type_groups, .mdev_attr_groups = vfio_ap_mdev_attr_groups, .create = vfio_ap_mdev_create, .remove = vfio_ap_mdev_remove, - .open = vfio_ap_mdev_open, - .release = vfio_ap_mdev_release, - .ioctl = vfio_ap_mdev_ioctl, };int
vfio_ap_mdev_register(void)drivers/vfio/mdev/mdev_core.c +0
-0@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) } EXPORT_SYMBOL(mdev_set_drvdata);
Quoted 8 lines
drivers/vfio/mdev/mdev_core.c void mdev_set_drvdata(struct mdev_device *mdev, void *data) · line 51
Quoted 6 lines
drivers/vfio/mdev/mdev_core.c +2
-3-/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ -void mdev_set_class (struct mdev_device *mdev,u16 id)I think you should keep the
mdev_set_classAPI and letmdev_set_vfio_opscall it. Even though its two line function. The reason to avoid a code churn in short time withmlx5_corepatch which will only callmdev_set_class(), as it doesn't have any ops yet.
That sounds good, will do.
Quoted 16 lines
Quoted 16 lines
drivers/vfio/mdev/mdev_core.c +10
-2+void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class); +EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) { +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);
Quoted 11 lines
drivers/vfio/mdev/mdev_private.h struct mdev_device { · line 37
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +0
-0struct device *mdev_dev(struct mdev_device *mdev) { diff --git
a/drivers/vfio/mdev/mdev_private.hb/drivers/vfio/mdev/mdev_private.hindexc65f436c1869..b666805f0b1f100644drivers/vfio/mdev/mdev_private.h +1
-0@@ -34,6 +34,7 @@ struct mdev_device {struct device *iommu_device;bool active;u16 class_id; +const void *device_ops;Instead of void *, this should be union
vfio_opsandvirtio_ops.
Ok.
Quoted 181 lines
Quoted 181 lines
drivers/vfio/mdev/mdev_private.h +0
-0};#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev)drivers/vfio/mdev/vfio_mdev.c +19
-18@@ -14,6 +14,7 @@#include <linux/slab.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include "mdev_private.h" @@ -24,16 +25,16 @@static int vfio_mdev_open (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev);int ret; -if (unlikely (!parent->ops->open)) +if (unlikely (!ops->open))return -EINVAL ;if (!try_module_get (THIS_MODULE ))return -ENODEV ; - ret = parent->ops->open (mdev); + ret = ops->open (mdev);if (ret)module_put (THIS_MODULE );@@ -43,10 +44,10 @@ static int vfio_mdev_open(void *device_data) staticvoid vfio_mdev_release (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (likely (parent->ops->release)) - parent->ops->release (mdev); +if (likely (ops->release)) + ops->release (mdev);module_put (THIS_MODULE ); }@@ -55,47 +56,47 @@ static long vfio_mdev_unlocked_ioctl(void *device_data, unsigned int cmd, unsigned long arg) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->ioctl)) +if (unlikely (!ops->ioctl))return -EINVAL ; -return parent->ops->ioctl (mdev, cmd, arg); +return ops->ioctl (mdev, cmd, arg); }static ssize_t vfio_mdev_read (void *device_data,char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->read)) +if (unlikely (!ops->read))return -EINVAL ; -return parent->ops->read (mdev, buf, count, ppos); +return ops->read (mdev, buf, count, ppos); }static ssize_t vfio_mdev_write (void *device_data,const char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->write)) +if (unlikely (!ops->write))return -EINVAL ; -return parent->ops->write (mdev, buf, count, ppos); +return ops->write (mdev, buf, count, ppos); }static int vfio_mdev_mmap (void *device_data,struct vm_area_struct *vma) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->mmap)) +if (unlikely (!ops->mmap))return -EINVAL ; -return parent->ops->mmap (mdev, vma); +return ops->mmap (mdev, vma); } static const struct vfio_device_ops vfio_mdev_dev_ops = { diff --git
a/include/linux/mdev.hb/include/linux/mdev.hindex78b69d09eb54..3d29e09e20c9100644include/linux/mdev.h +6
-1@@ -10,7 +10,13 @@#ifndef MDEV_H #define MDEV_H +#include <linux/types.h> +#include <linux/device.h> +#include <linux/mdev.h> +#include <uapi/linux/uuid.h> +struct mdev_device ; +struct vfio_mdev_device_ops ;/* * Called by the parent device driver to set the device which represents @@ -48,30 +54,7 @@ struct device *mdev_get_iommu_device(struct device *dev);
* @mdev:mdev_devicedevice structure which is being
* destroyed
* Returns integer: success (0) or error (< 0)
- * @open: Open mediated device.
- * @mdev: mediated device.
- * Returns integer: success (0) or error (< 0)
- * @release: release mediated device
- * @mdev: mediated device.
- * @read: Read emulation callback
- * @mdev: mediated device structure
- * @buf: read buffer
- * @count: number of bytes to read
- * @ppos: address.
- * Retuns number on bytes read on success or error.
- * @write: Write emulation callback
- * @mdev: mediated device structure
- * @buf: write buffer
- * @count: number of bytes to be written
- * @ppos: address.
- * Retuns number on bytes written on success or error.
- * @ioctl: IOCTL callback
- * @mdev: mediated device structure
- * @cmd: ioctl command
- * @arg: arguments to ioctl
- * @mmap: mmap callback
- * @mdev: mediated device structure
- * @vma: vma structure
+ *
* Parent device that support mediated device should be registered with
mdev
* module withmdev_parent_opsstructure.
**/include/linux/mdev.h +0
-9@@ -83,15 +66,6 @@ struct mdev_parent_ops {int (*create)(struct kobject *kobj,struct mdev_device *mdev);int (*remove)(struct mdev_device *mdev); -int (*open)(struct mdev_device *mdev); -void (*release)(struct mdev_device *mdev); -ssize_t (*read)(struct mdev_device *mdev,char __user *buf, -size_t count,loff_t *ppos); -ssize_t (*write)(struct mdev_device *mdev,const char __user *buf, -size_t count,loff_t *ppos); -long (*ioctl)(struct mdev_device *mdev,unsigned int cmd, -unsigned long arg); -int (*mmap)(struct mdev_device *mdev,struct vm_area_struct *vma); };
Quoted 7 lines
Quoted 6 lines
/* interface for exporting mdev supported type attributes */ @@ -133,8
+107,11 @@ structmdev_driver{void *mdev_get_drvdata(struct
mdev_device*mdev); voidmdev_set_drvdata(struct mdev_device *mdev, void *data); +Unrelated line change for this patch. Please remove.
Sure.
Quoted 9 lines
Quoted 8 lines
const
guid_t*mdev_uuid(structmdev_device*mdev); -voidmdev_set_class(struct mdev_device *mdev, u16 id);include/linux/mdev.h +2
-0+void mdev_set_vfio_ops (struct mdev_device *mdev, + const struct vfio_mdev_device_ops *vfio_ops); constvoid
+*mdev_get_dev_ops(structmdev_device*mdev);Since you have the
set_vfio_ops, its better to haveget_vfio_ops()and similarlyget_virtio_ops.
Ok.
Quoted 233 lines
include/linux/vfio_mdev.h
Quoted 7 lines
extern struct
bus_typemdev_bus_type;include/linux/vfio_mdev.h new file renamed from include/linux/vfio_mdev.h +0
-0mode 100644 index 000000000000..3907c5371c2b
include/linux/vfio_mdev.h new file +0
-0This file name is confusing.
vfio_mdev_ops.his more accurate name of what it intends to achieve. If you see this file expanding scope beyond ops, this file name looks fine.Quoted 209 lines
include/linux/vfio_mdev.h new file +49
-0@@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* VFIO Mediated device definition +*/ + +#ifndef VFIO_MDEV_H +#define VFIO_MDEV_H + +#include <linux/mdev.h> + +/** + * struct vfio_mdev_device_ops - Structure to be registered for each + * mdev device to register the device to vfio-mdev module. + * + * @open: Open mediated device. + * @mdev: mediated device. + * Returns integer: success (0) or error (< 0) + * @release: release mediated device + * @mdev: mediated device. + * @read: Read emulation callback + * @mdev: mediated device structure + * @buf: read buffer + * @count: number of bytes to read + * @ppos: address. + * Retuns number on bytes read on success or error. + * @write: Write emulation callback + * @mdev: mediated device structure + * @buf: write buffer + * @count: number of bytes to be written + * @ppos: address. + * Retuns number on bytes written on success or error. + * @ioctl: IOCTL callback + * @mdev: mediated device structure + * @cmd: ioctl command + * @arg: arguments to ioctl + * @mmap: mmap callback + * @mdev: mediated device structure + * @vma: vma structure + */ +struct vfio_mdev_device_ops { + int (*open)(struct mdev_device *mdev); + void (*release)(struct mdev_device *mdev); + ssize_t (*read)(struct mdev_device *mdev, char __user *buf, + size_t count, loff_t *ppos); + ssize_t (*write)(struct mdev_device *mdev, const char __user *buf, + size_t count, loff_t *ppos); + long (*ioctl)(struct mdev_device *mdev, unsigned int cmd, + unsigned long arg); + int (*mmap)(struct mdev_device *mdev, struct vm_area_struct*vma);
include/linux/vfio_mdev.h new file +3
-0+}; + +#endif samples/vfio-mdev/mbochs.c +3
-0@@ -30,6 +30,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/dma-buf.h> #include <linux/highmem.h> @@ -516,6 +517,8 @@ static int mbochs_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mbochs_create (struct kobject *kobj,struct mdev_device *mdev) { const struct mbochs_type *type = mbochs_find_type(kobj); @@ -561,7 +564,7 @@ static int
mbochs_create(struct kobject *kobj, struct mdev_device *mdev)
mbochs_reset(mdev);mbochs_used_mbytes += type->mbytes;samples/vfio-mdev/mbochs.c +2
-7-mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; err_mem:@@ -1419,12 +1422,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mbochs_create, - .remove = mbochs_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mbochs_open, .release = mbochs_close,.read =
mbochs_read,samples/vfio-mdev/mbochs.c +8
-0@@ -1433,6 +1431,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mbochs_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mbochs_create, + .remove = mbochs_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE ,};samples/vfio-mdev/mdpy.c index renamed from samples/vfio-mdev/mdpy.c +0
-0
665614574d50..f21c795c40e4100644samples/vfio-mdev/mdpy.c +4
-0@@ -26,6 +26,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <drm/drm_fourcc.h> #include "mdpy-defs.h" @@ -226,6 +227,8 @@ static int mdpy_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mdpy_create (struct kobject *kobj,struct mdev_device *mdev) { const struct mdpy_type *type = mdpy_find_type(kobj); @@ -269,7 +272,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device*mdev)
mdpy_reset(mdev);mdpy_count++;
samples/vfio-mdev/mdpy.c +2
-7-mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }@@ -726,12 +729,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mdpy_create, - .remove = mdpy_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mdpy_open, .release = mdpy_close,.read =
mdpy_read,samples/vfio-mdev/mdpy.c +8
-0@@ -740,6 +738,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mdpy_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mdpy_create, + .remove = mdpy_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE , };samples/vfio-mdev/mtty.c index renamed from samples/vfio-mdev/mtty.c +0
-0
90da12ff7fd9..b829f33b98f5100644samples/vfio-mdev/mtty.c +4
-1@@ -27,6 +27,7 @@#include <linux/ctype.h> #include <linux/file.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/serial.h> #include <uapi/linux/serial_reg.h> @@ -708,6 +709,8 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count, return ret; } +static const struct vfio_mdev_device_ops vfio_dev_ops; +static int mtty_create (struct kobject *kobj,struct mdev_device *mdev) {struct mdev_state *mdev_state;@@ -755,7 +758,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev) list_add(&mdev_state->next, &mdev_devices_list);mutex_unlock (&mdev_list_lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_dev_ops);return 0 ; }@@ -1388,6 +1391,14 @@ static struct attribute_group *mdev_type_groups[] = { NULL,samples/vfio-mdev/mtty.c static struct attribute_group · line 1402
Quoted 10 lines
samples/vfio-mdev/mtty.c +8
-0}; +static const struct vfio_mdev_device_ops vfio_dev_ops = { + .open = mtty_open, + .release = mtty_close, + .read = mtty_read, + .write = mtty_write, + .ioctl = mtty_ioctl, +}; +Since hunk shows that
vfio_dev_opsadded new here, it is better to drop the extra white space mixed with tab alignment. Just have single white space like below.
Quoted 5 lines
.open =
mtty_open,
.release =mtty_close,
.read =mtty_read,
.write =mtty_write,
.ioctl =mtty_ioctl
Will do.
Thanks
Quoted 16 lines
Quoted 16 lines
samples/vfio-mdev/mtty.c +0
-0static const struct mdev_parent_ops mdev_fops = { .owner =THIS_MODULE ,.dev_attr_groups =
mtty_dev_groups,samples/vfio-mdev/mtty.c +0
-5@@ -1395,11 +1406,6 @@ static const struct mdev_parent_ops mdev_fops = { .supported_type_groups = mdev_type_groups, .create = mtty_create, .remove = mtty_remove, - .open = mtty_open, - .release = mtty_close, - .read = mtty_read, - .write = mtty_write, - .ioctl = mtty_ioctl, };
Quoted 3 lines
Quoted 3 lines
static void
mtty_device_release(struct device *dev)
--
2.19.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
PATCH v4 3/6 mdev: introduce device specific ops
In reply to Jason WangCurrently, except for the create and remove, the rest of mdev_parent_ops is designed for vfio-mdev driver only and may not help for kernel mdev driver. With the help of class id, this patch introduces device specific callbacks inside mdev_device structure. This allows different set of callback to be used by vfio-mdev and virtio-mdev.
--- .../driver-api/vfio-mediated-device.rst | 25 +++++---- MAINTAINERS | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- drivers/vfio/mdev/mdev_core.c | 18 +++++-- drivers/vfio/mdev/mdev_private.h | 1 + drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- include/linux/mdev.h | 45 ++++------------ include/linux/vfio_mdev.h | 52 +++++++++++++++++++ samples/vfio-mdev/mbochs.c | 20 ++++--- samples/vfio-mdev/mdpy.c | 20 ++++--- samples/vfio-mdev/mtty.c | 18 ++++--- 13 files changed, 184 insertions(+), 103 deletions(-) create mode 100644 include/linux/vfio_mdev.h
Documentation/driver-api/vfio-mediated-device.rst +16 -9
@@ -152,11 +152,22 @@ callbacks per mdev parent device, per mdev type, or any other categorization. Vendor drivers are expected to be fully asynchronous in this respect or provide their own internal resource protection.) -The callbacks in the mdev_parent_ops structure are as follows: - -* open: open callback of mediated device -* close: close callback of mediated device -* ioctl: ioctl callback of mediated device +As multiple types of mediated devices may be supported, the device +must set up the class id and the device specific callbacks in create() +callback. E.g for vfio-mdev device it needs to be done through: + + int mdev_set_vfio_ops(struct mdev_device *mdev, + const struct vfio_mdev_ops *vfio_ops); + +The class id (set to MDEV_CLASS_ID_VFIO) is used to match a device +with an mdev driver via its id table. The device specific callbacks +(specified in *ops) are obtainable via mdev_get_dev_ops() (for use by +the mdev bus driver). A vfio-mdev device (class id MDEV_CLASS_ID_VFIO) +uses the following device-specific ops: + +* open: open callback of vfio mediated device +* close: close callback of vfio mediated device +* ioctl: ioctl callback of vfio mediated device * read : read emulation callback * write: write emulation callback * mmap: mmap emulation callback
@@ -167,10 +178,6 @@ register itself with the mdev core driver:: extern int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops); -It is also required to specify the class_id in create() callback through:: - - int mdev_set_class(struct mdev_device *mdev, u16 id); - However, the mdev_parent_ops structure is not required in the function call that a driver should use to unregister itself with the mdev core driver::
MAINTAINERS +1 -0
@@ -17127,6 +17127,7 @@ S: Maintained F: Documentation/driver-api/vfio-mediated-device.rst F: drivers/vfio/mdev/ F: include/linux/mdev.h +F: include/linux/vfio_mdev.h F: samples/vfio-mdev/ VFIO PLATFORM DRIVER
drivers/gpu/drm/i915/gvt/kvmgt.c +11 -7
@@ -42,6 +42,7 @@#include <linux/kvm_host.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/debugfs.h> #include <linux/nospec.h>
@@ -643,6 +644,8 @@ static void kvmgt_put_vfio_device(void *vgpu)vfio_device_put (((struct intel_vgpu *)vgpu)->vdev.vfio_device); } +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops; +static int intel_vgpu_create (struct kobject *kobj,struct mdev_device *mdev) {struct intel_vgpu *vgpu =NULL ;
@@ -678,7 +681,7 @@ static int intel_vgpu_create(struct kobject *kobj, struct mdev_device *mdev) dev_name(mdev_dev(mdev))); ret =0 ; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &intel_vfio_vgpu_dev_ops); out:return ret; }
@@ -1599,20 +1602,21 @@ static const struct attribute_group *intel_vgpu_groups[] = { NULL, }; -static struct mdev_parent_ops intel_vgpu_ops = { - .mdev_attr_groups = intel_vgpu_groups, - .create = intel_vgpu_create, - .remove = intel_vgpu_remove, - +static const struct vfio_mdev_device_ops intel_vfio_vgpu_dev_ops = { .open = intel_vgpu_open, .release = intel_vgpu_release, - .read = intel_vgpu_read, .write = intel_vgpu_write, .mmap = intel_vgpu_mmap, .ioctl = intel_vgpu_ioctl, }; +static struct mdev_parent_ops intel_vgpu_ops = { + .mdev_attr_groups = intel_vgpu_groups, + .create = intel_vgpu_create, + .remove = intel_vgpu_remove, +}; +static int kvmgt_host_init (struct device *dev,void *gvt,const void *ops) {struct attribute **kvm_type_attrs;
drivers/s390/cio/vfio_ccw_ops.c +12 -6
@@ -12,6 +12,7 @@#include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/nospec.h> #include <linux/slab.h>
@@ -110,6 +111,8 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ccw_mdev_create (struct kobject *kobj,struct mdev_device *mdev) { struct vfio_ccw_private *private =
@@ -129,7 +132,7 @@ static int vfio_ccw_mdev_create(struct kobject *kobj, struct mdev_device *mdev) private->sch->schid.ssid, private->sch->schid.sch_no); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }
@@ -575,11 +578,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, } } -static const struct mdev_parent_ops vfio_ccw_mdev_ops = { - .owner =THIS_MODULE , - .supported_type_groups = mdev_type_groups, - .create = vfio_ccw_mdev_create, - .remove = vfio_ccw_mdev_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = vfio_ccw_mdev_open, .release = vfio_ccw_mdev_release, .read = vfio_ccw_mdev_read,
@@ -587,6 +586,13 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = { .ioctl = vfio_ccw_mdev_ioctl, }; +static const struct mdev_parent_ops vfio_ccw_mdev_ops = { + .owner =THIS_MODULE , + .supported_type_groups = mdev_type_groups, + .create = vfio_ccw_mdev_create, + .remove = vfio_ccw_mdev_remove, +}; +int vfio_ccw_mdev_reg (struct subchannel *sch) {return mdev_register_device (&sch->dev, &vfio_ccw_mdev_ops);
drivers/s390/crypto/vfio_ap_ops.c +10 -4
@@ -16,6 +16,7 @@#include <linux/bitops.h> #include <linux/kvm_host.h> #include <linux/module.h> +#include <linux/vfio_mdev.h> #include <asm/kvm.h> #include <asm/zcrypt.h>
@@ -321,6 +322,8 @@ static void vfio_ap_matrix_init(struct ap_config_info *info, matrix->adm_max = info->apxa ? info->Nd :15 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int vfio_ap_mdev_create (struct kobject *kobj,struct mdev_device *mdev) {struct ap_matrix_mdev *matrix_mdev;
@@ -343,7 +346,7 @@ static int vfio_ap_mdev_create(struct kobject *kobj, struct mdev_device *mdev)list_add (&matrix_mdev->node, &matrix_dev->mdev_list);mutex_unlock (&matrix_dev->lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }
@@ -1281,15 +1284,18 @@ static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev,return ret; } +static const struct vfio_mdev_device_ops vfio_mdev_ops = { + .open = vfio_ap_mdev_open, + .release = vfio_ap_mdev_release, + .ioctl = vfio_ap_mdev_ioctl, +}; +static const struct mdev_parent_ops vfio_ap_matrix_ops = { .owner =THIS_MODULE , .supported_type_groups = vfio_ap_mdev_type_groups, .mdev_attr_groups = vfio_ap_mdev_attr_groups, .create = vfio_ap_mdev_create, .remove = vfio_ap_mdev_remove, - .open = vfio_ap_mdev_open, - .release = vfio_ap_mdev_release, - .ioctl = vfio_ap_mdev_ioctl, };int vfio_ap_mdev_register (void )
drivers/vfio/mdev/mdev_core.c +13 -5
@@ -45,15 +45,23 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data) }EXPORT_SYMBOL (mdev_set_drvdata); -/* Specify the class for the mdev device, this must be called during -* create() callback. +/* Specify the VFIO device ops for the mdev device, this +* must be called during create() callback for VFIO mdev device. */ -void mdev_set_class (struct mdev_device *mdev,u16 id) +void mdev_set_vfio_ops (struct mdev_device *mdev, +const struct vfio_mdev_device_ops *vfio_ops) {WARN_ON (mdev->class_id); - mdev->class_id = id; + mdev->class_id =MDEV_CLASS_ID_VFIO ; + mdev->device_ops = vfio_ops; } -EXPORT_SYMBOL (mdev_set_class); +EXPORT_SYMBOL (mdev_set_vfio_ops); + +const void *mdev_get_dev_ops (struct mdev_device *mdev) +{ +return mdev->device_ops; +} +EXPORT_SYMBOL (mdev_get_dev_ops);struct device *mdev_dev (struct mdev_device *mdev) {
drivers/vfio/mdev/mdev_private.h +1 -0
@@ -34,6 +34,7 @@ struct mdev_device {struct device *iommu_device;bool active;u16 class_id; +const void *device_ops; };#define to_mdev_device (dev) container_of(dev, struct mdev_device, dev)
drivers/vfio/mdev/vfio_mdev.c +19 -18
@@ -14,6 +14,7 @@#include <linux/slab.h> #include <linux/vfio.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include "mdev_private.h"
@@ -24,16 +25,16 @@static int vfio_mdev_open (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev);int ret; -if (unlikely (!parent->ops->open)) +if (unlikely (!ops->open))return -EINVAL ;if (!try_module_get (THIS_MODULE ))return -ENODEV ; - ret = parent->ops->open (mdev); + ret = ops->open (mdev);if (ret)module_put (THIS_MODULE );
@@ -43,10 +44,10 @@ static int vfio_mdev_open(void *device_data)static void vfio_mdev_release (void *device_data) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (likely (parent->ops->release)) - parent->ops->release (mdev); +if (likely (ops->release)) + ops->release (mdev);module_put (THIS_MODULE ); }
@@ -55,47 +56,47 @@ static long vfio_mdev_unlocked_ioctl(void *device_data, unsigned int cmd, unsigned long arg) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->ioctl)) +if (unlikely (!ops->ioctl))return -EINVAL ; -return parent->ops->ioctl (mdev, cmd, arg); +return ops->ioctl (mdev, cmd, arg); }static ssize_t vfio_mdev_read (void *device_data,char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->read)) +if (unlikely (!ops->read))return -EINVAL ; -return parent->ops->read (mdev, buf, count, ppos); +return ops->read (mdev, buf, count, ppos); }static ssize_t vfio_mdev_write (void *device_data,const char __user *buf,size_t count,loff_t *ppos) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->write)) +if (unlikely (!ops->write))return -EINVAL ; -return parent->ops->write (mdev, buf, count, ppos); +return ops->write (mdev, buf, count, ppos); }static int vfio_mdev_mmap (void *device_data,struct vm_area_struct *vma) {struct mdev_device *mdev = device_data; -struct mdev_parent *parent = mdev->parent; +const struct vfio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); -if (unlikely (!parent->ops->mmap)) +if (unlikely (!ops->mmap))return -EINVAL ; -return parent->ops->mmap (mdev, vma); +return ops->mmap (mdev, vma); }static const struct vfio_device_ops vfio_mdev_dev_ops = {
include/linux/mdev.h +11 -34
71 lines not on this page · raw message
include/linux/vfio_mdev.h new file +52 -0
52 lines not on this page · raw message
samples/vfio-mdev/mbochs.c +13 -7
@@ -30,6 +30,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/dma-buf.h> #include <linux/highmem.h>
@@ -516,6 +517,8 @@ static int mbochs_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mbochs_create (struct kobject *kobj,struct mdev_device *mdev) {const struct mbochs_type *type =mbochs_find_type (kobj);
@@ -561,7 +564,7 @@ static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)mbochs_reset (mdev); mbochs_used_mbytes += type->mbytes; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; err_mem:
@@ -1419,12 +1422,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mbochs_create, - .remove = mbochs_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mbochs_open, .release = mbochs_close, .read = mbochs_read,
@@ -1433,6 +1431,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mbochs_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mbochs_create, + .remove = mbochs_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE , };
samples/vfio-mdev/mdpy.c +13 -7
@@ -26,6 +26,7 @@#include <linux/iommu.h> #include <linux/sysfs.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <drm/drm_fourcc.h> #include "mdpy-defs.h"
@@ -226,6 +227,8 @@ static int mdpy_reset(struct mdev_device *mdev)return 0 ; } +static const struct vfio_mdev_device_ops vfio_mdev_ops; +static int mdpy_create (struct kobject *kobj,struct mdev_device *mdev) {const struct mdpy_type *type =mdpy_find_type (kobj);
@@ -269,7 +272,7 @@ static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)mdpy_reset (mdev); mdpy_count++; -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_mdev_ops);return 0 ; }
@@ -726,12 +729,7 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; -static const struct mdev_parent_ops mdev_fops = { - .owner =THIS_MODULE , - .mdev_attr_groups = mdev_dev_groups, - .supported_type_groups = mdev_type_groups, - .create = mdpy_create, - .remove = mdpy_remove, +static const struct vfio_mdev_device_ops vfio_mdev_ops = { .open = mdpy_open, .release = mdpy_close, .read = mdpy_read,
@@ -740,6 +738,14 @@ static const struct mdev_parent_ops mdev_fops = { .mmap = mdpy_mmap, }; +static const struct mdev_parent_ops mdev_fops = { + .owner =THIS_MODULE , + .mdev_attr_groups = mdev_dev_groups, + .supported_type_groups = mdev_type_groups, + .create = mdpy_create, + .remove = mdpy_remove, +}; +static const struct file_operations vd_fops = { .owner =THIS_MODULE , };
samples/vfio-mdev/mtty.c +12 -6
@@ -27,6 +27,7 @@#include <linux/ctype.h> #include <linux/file.h> #include <linux/mdev.h> +#include <linux/vfio_mdev.h> #include <linux/pci.h> #include <linux/serial.h> #include <uapi/linux/serial_reg.h>
@@ -708,6 +709,8 @@ static ssize_t mdev_access(struct mdev_device *mdev, u8 *buf, size_t count,return ret; } +static const struct vfio_mdev_device_ops vfio_dev_ops; +static int mtty_create (struct kobject *kobj,struct mdev_device *mdev) {struct mdev_state *mdev_state;
@@ -755,7 +758,7 @@ static int mtty_create(struct kobject *kobj, struct mdev_device *mdev)list_add (&mdev_state->next, &mdev_devices_list);mutex_unlock (&mdev_list_lock); -mdev_set_class (mdev,MDEV_CLASS_ID_VFIO ); +mdev_set_vfio_ops (mdev, &vfio_dev_ops);return 0 ; }
@@ -1388,6 +1391,14 @@ static struct attribute_group *mdev_type_groups[] = { NULL, }; +static const struct vfio_mdev_device_ops vfio_dev_ops = { + .open = mtty_open, + .release = mtty_close, + .read = mtty_read, + .write = mtty_write, + .ioctl = mtty_ioctl, +}; +static const struct mdev_parent_ops mdev_fops = { .owner =THIS_MODULE , .dev_attr_groups = mtty_dev_groups,
@@ -1395,11 +1406,6 @@ static const struct mdev_parent_ops mdev_fops = { .supported_type_groups = mdev_type_groups, .create = mtty_create, .remove = mtty_remove, - .open = mtty_open, - .release = mtty_close, - .read = mtty_read, - .write = mtty_write, - .ioctl = mtty_ioctl, };static void mtty_device_release (struct device *dev)
Signature · 1 line
2.19.1
PATCH v4 4/6 mdev: introduce virtio device and its device ops
In reply to Jason WangThis patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 include/linux/virtio_mdev.h
drivers/vfio/mdev/mdev_core.c +12 -0
@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops); +/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/ +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id); + mdev->class_id =MDEV_CLASS_ID_VIRTIO ; + mdev->device_ops = virtio_ops; +} +EXPORT_SYMBOL (mdev_set_virtio_ops); +const void *mdev_get_dev_ops (struct mdev_device *mdev) {return mdev->device_ops;
include/linux/mdev.h +4 -0
@@ -17,6 +17,7 @@struct mdev_device ;struct vfio_mdev_device_ops ; +struct virtio_mdev_device_ops ;/* * Called by the parent device driver to set the device which represents
@@ -111,6 +112,8 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data);const guid_t *mdev_uuid (struct mdev_device *mdev);void mdev_set_vfio_ops (struct mdev_device *mdev,const struct vfio_mdev_device_ops *vfio_ops); +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops);const void *mdev_get_dev_ops (struct mdev_device *mdev);extern struct bus_type mdev_bus_type;
@@ -127,6 +130,7 @@ struct mdev_device *mdev_from_dev(struct device *dev);enum {MDEV_CLASS_ID_VFIO =1 , +MDEV_CLASS_ID_VIRTIO =2 ,/* New entries must be added here */ };
include/linux/virtio_mdev.h new file +151 -0
151 lines not on this page · raw message
Signature · 6 lines
2.19.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
This patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
Signed-off-by Jason Wang <[email protected]>--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 include/linux/virtio_mdev.hdrivers/vfio/mdev/mdev_core.c +0
-0
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 66
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +7
-0@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops); +/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/ +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id);
Nit, this one is a BUG_ON, but the vfio one is a WARN_ON. Thanks,
Alex
Quoted 194 lines
drivers/vfio/mdev/mdev_core.c +5
-0+ mdev->class_id =MDEV_CLASS_ID_VIRTIO ; + mdev->device_ops = virtio_ops; +} +EXPORT_SYMBOL (mdev_set_virtio_ops); +const void *mdev_get_dev_ops (struct mdev_device *mdev) {return mdev->device_ops;include/linux/mdev.h +4
-0@@ -17,6 +17,7 @@struct mdev_device ;struct vfio_mdev_device_ops ; +struct virtio_mdev_device_ops ;/* * Called by the parent device driver to set the device which represents @@ -111,6 +112,8 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data);const guid_t *mdev_uuid (struct mdev_device *mdev);void mdev_set_vfio_ops (struct mdev_device *mdev,const struct vfio_mdev_device_ops *vfio_ops); +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops);const void *mdev_get_dev_ops (struct mdev_device *mdev);extern struct bus_type mdev_bus_type;@@ -127,6 +130,7 @@ struct mdev_device *mdev_from_dev(struct device *dev);enum {MDEV_CLASS_ID_VFIO =1 , +MDEV_CLASS_ID_VIRTIO =2 ,/* New entries must be added here */ };include/linux/virtio_mdev.h new file +151
-0@@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Virtio mediated device driver +* +* Copyright 2019, Red Hat Corp. +* Author: Jason Wang <[email protected]> +*/ +#ifndef _LINUX_VIRTIO_MDEV_H +#define _LINUX_VIRTIO_MDEV_H + +#include <linux/interrupt.h> +#include <linux/mdev.h> +#include <uapi/linux/vhost.h> + +#define VIRTIO_MDEV_DEVICE_API_STRING "virtio-mdev" +#define VIRTIO_MDEV_F_VERSION_1 0x1 + +struct virtio_mdev_callback { +irqreturn_t (*callback)(void *data); +void *private; +}; + +/** +* struct vfio_mdev_device_ops - Structure to be registered for each +* mdev device to register the device to virtio-mdev module. +* +* @set_vq_address: Set the address of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @desc_area: address of desc area +* @driver_area: address of driver area +* @device_area: address of device area +* Returns integer: success (0) or error (< 0) +* @set_vq_num: Set the size of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @num: the size of virtqueue +* @kick_vq: Kick the virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @set_vq_cb: Set the interrupt callback function for +* a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @cb: virtio-mdev interrupt callback structure +* @set_vq_ready: Set ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @ready: ready (true) not ready(false) +* @get_vq_ready: Get ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* Returns boolean: ready (true) or not (false) +* @set_vq_state: Set the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @state: virtqueue state (last_avail_idx) +* Returns integer: success (0) or error (< 0) +* @get_vq_state: Get the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* Returns virtqueue state (last_avail_idx) +* @get_vq_align: Get the virtqueue align requirement +* for the device +* @mdev: mediated device +* Returns virtqueue algin requirement +* @get_features: Get virtio features supported by the device +* @mdev: mediated device +* Returns the virtio features support by the +* device +* @get_features: Set virtio features supported by the driver +* @mdev: mediated device +* @features: feature support by the driver +* Returns integer: success (0) or error (< 0) +* @set_config_cb: Set the config interrupt callback +* @mdev: mediated device +* @cb: virtio-mdev interrupt callback structure +* @get_vq_num_max: Get the max size of virtqueue +* @mdev: mediated device +* Returns u16: max size of virtqueue +* @get_device_id: Get virtio device id +* @mdev: mediated device +* Returns u32: virtio device id +* @get_vendor_id: Get virtio vendor id +* @mdev: mediated device +* Returns u32: virtio vendor id +* @get_status: Get the device status +* @mdev: mediated device +* Returns u8: virtio device status +* @set_status: Set the device status +* @mdev: mediated device +* @status: virtio device status +* @get_config: Read from device specific configuration space +* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to read to +* @len: the length to read from +* configration space +* @set_config: Write to device specific configuration space +* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to write from +* @len: the length to write to +* configration space +* @get_mdev_features: Get the feature of virtio mdev device +* @mdev: mediated device +* Returns the mdev features (API) support by +* the device. +* @get_generation: Get device generaton +* @mdev: mediated device +* Returns u32: device generation +*/ +struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb); +u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev); +u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev); +u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
Quoted 31 lines · Alex Williamson
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang<[email protected]> wrote:
This patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
Signed-off-by Jason Wang<[email protected]>--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+)create mode 100644
include/linux/virtio_mdev.hdrivers/vfio/mdev/mdev_core.c +0
-0drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 66
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +7
-0@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops); +/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/ +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id);Nit, this one is a
BUG_ON, but the vfio one is aWARN_ON. Thanks,
Quoted 1 line
Alex
Let me fix in next version.
Thanks
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Alex WilliamsonQuoted 31 lines · Alex Williamson
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang<[email protected]> wrote:
This patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
Signed-off-by Jason Wang<[email protected]>--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+)create mode 100644
include/linux/virtio_mdev.hdrivers/vfio/mdev/mdev_core.c +0
-0drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 66
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +7
-0@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops); +/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/ +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id);Nit, this one is a
BUG_ON, but the vfio one is aWARN_ON. Thanks,
Quoted 1 line
Alex
Let me fix in next version.
Thanks
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Jason WangQuoted 16 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
This patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
Signed-off-by Jason Wang <[email protected]>--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 include/linux/virtio_mdev.hdrivers/vfio/mdev/mdev_core.c +0
-0
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 66
Quoted 10 lines
drivers/vfio/mdev/mdev_core.c +7
-0@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops); +/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/ +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id);
Nit, this one is a BUG_ON, but the vfio one is a WARN_ON. Thanks,
Alex
Quoted 194 lines
drivers/vfio/mdev/mdev_core.c +5
-0+ mdev->class_id =MDEV_CLASS_ID_VIRTIO ; + mdev->device_ops = virtio_ops; +} +EXPORT_SYMBOL (mdev_set_virtio_ops); +const void *mdev_get_dev_ops (struct mdev_device *mdev) {return mdev->device_ops;include/linux/mdev.h +4
-0@@ -17,6 +17,7 @@struct mdev_device ;struct vfio_mdev_device_ops ; +struct virtio_mdev_device_ops ;/* * Called by the parent device driver to set the device which represents @@ -111,6 +112,8 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data);const guid_t *mdev_uuid (struct mdev_device *mdev);void mdev_set_vfio_ops (struct mdev_device *mdev,const struct vfio_mdev_device_ops *vfio_ops); +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops);const void *mdev_get_dev_ops (struct mdev_device *mdev);extern struct bus_type mdev_bus_type;@@ -127,6 +130,7 @@ struct mdev_device *mdev_from_dev(struct device *dev);enum {MDEV_CLASS_ID_VFIO =1 , +MDEV_CLASS_ID_VIRTIO =2 ,/* New entries must be added here */ };include/linux/virtio_mdev.h new file +151
-0@@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Virtio mediated device driver +* +* Copyright 2019, Red Hat Corp. +* Author: Jason Wang <[email protected]> +*/ +#ifndef _LINUX_VIRTIO_MDEV_H +#define _LINUX_VIRTIO_MDEV_H + +#include <linux/interrupt.h> +#include <linux/mdev.h> +#include <uapi/linux/vhost.h> + +#define VIRTIO_MDEV_DEVICE_API_STRING "virtio-mdev" +#define VIRTIO_MDEV_F_VERSION_1 0x1 + +struct virtio_mdev_callback { +irqreturn_t (*callback)(void *data); +void *private; +}; + +/** +* struct vfio_mdev_device_ops - Structure to be registered for each +* mdev device to register the device to virtio-mdev module. +* +* @set_vq_address: Set the address of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @desc_area: address of desc area +* @driver_area: address of driver area +* @device_area: address of device area +* Returns integer: success (0) or error (< 0) +* @set_vq_num: Set the size of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @num: the size of virtqueue +* @kick_vq: Kick the virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @set_vq_cb: Set the interrupt callback function for +* a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @cb: virtio-mdev interrupt callback structure +* @set_vq_ready: Set ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @ready: ready (true) not ready(false) +* @get_vq_ready: Get ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* Returns boolean: ready (true) or not (false) +* @set_vq_state: Set the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @state: virtqueue state (last_avail_idx) +* Returns integer: success (0) or error (< 0) +* @get_vq_state: Get the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* Returns virtqueue state (last_avail_idx) +* @get_vq_align: Get the virtqueue align requirement +* for the device +* @mdev: mediated device +* Returns virtqueue algin requirement +* @get_features: Get virtio features supported by the device +* @mdev: mediated device +* Returns the virtio features support by the +* device +* @get_features: Set virtio features supported by the driver +* @mdev: mediated device +* @features: feature support by the driver +* Returns integer: success (0) or error (< 0) +* @set_config_cb: Set the config interrupt callback +* @mdev: mediated device +* @cb: virtio-mdev interrupt callback structure +* @get_vq_num_max: Get the max size of virtqueue +* @mdev: mediated device +* Returns u16: max size of virtqueue +* @get_device_id: Get virtio device id +* @mdev: mediated device +* Returns u32: virtio device id +* @get_vendor_id: Get virtio vendor id +* @mdev: mediated device +* Returns u32: virtio vendor id +* @get_status: Get the device status +* @mdev: mediated device +* Returns u8: virtio device status +* @set_status: Set the device status +* @mdev: mediated device +* @status: virtio device status +* @get_config: Read from device specific configuration space +* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to read to +* @len: the length to read from +* configration space +* @set_config: Write to device specific configuration space +* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to write from +* @len: the length to write to +* configration space +* @get_mdev_features: Get the feature of virtio mdev device +* @mdev: mediated device +* Returns the mdev features (API) support by +* the device. +* @get_generation: Get device generaton +* @mdev: mediated device +* Returns u32: device generation +*/ +struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb); +u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev); +u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev); +u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Jason WangQuoted 16 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
This patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
Signed-off-by Jason Wang <[email protected]>--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 include/linux/virtio_mdev.hdrivers/vfio/mdev/mdev_core.c +0
-0
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 62
Quoted 6 lines
drivers/vfio/mdev/mdev_core.c +3
-0@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops); +/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/
Change this as for the vfio comment (last patch?)
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 66
Quoted 4 lines
drivers/vfio/mdev/mdev_core.c +4
-0+void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id);
s/BUG_ON/WARN_ON/
Quoted 8 lines
drivers/vfio/mdev/mdev_core.c +5
-0+ mdev->class_id =MDEV_CLASS_ID_VIRTIO ; + mdev->device_ops = virtio_ops; +} +EXPORT_SYMBOL (mdev_set_virtio_ops); +const void *mdev_get_dev_ops (struct mdev_device *mdev) {return mdev->device_ops;
(...)
Quoted 29 lines
include/linux/virtio_mdev.h new file +23
-0@@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Virtio mediated device driver +* +* Copyright 2019, Red Hat Corp. +* Author: Jason Wang <[email protected]> +*/ +#ifndef _LINUX_VIRTIO_MDEV_H +#define _LINUX_VIRTIO_MDEV_H + +#include <linux/interrupt.h> +#include <linux/mdev.h> +#include <uapi/linux/vhost.h> + +#define VIRTIO_MDEV_DEVICE_API_STRING "virtio-mdev" +#define VIRTIO_MDEV_F_VERSION_1 0x1 + +struct virtio_mdev_callback { +irqreturn_t (*callback)(void *data); +void *private; +}; + +/**
include/linux/virtio_mdev.h line 33
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* struct vfio_mdev_device_ops - Structure to be registered for each +* mdev device to register the device to virtio-mdev module. +* +* @set_vq_address: Set the address of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @desc_area: address of desc area +* @driver_area: address of driver area +* @device_area: address of device area +* Returns integer: success (0) or error (< 0)
Probably dumb question (have not read the next patches yet): Is this agnostic regarding split or packed queues?
Quoted 28 lines
include/linux/virtio_mdev.h new file +28
-0+* @set_vq_num: Set the size of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @num: the size of virtqueue +* @kick_vq: Kick the virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @set_vq_cb: Set the interrupt callback function for +* a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @cb: virtio-mdev interrupt callback structure +* @set_vq_ready: Set ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @ready: ready (true) not ready(false) +* @get_vq_ready: Get ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* Returns boolean: ready (true) or not (false) +* @set_vq_state: Set the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @state: virtqueue state (last_avail_idx) +* Returns integer: success (0) or error (< 0) +* @get_vq_state: Get the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index
include/linux/virtio_mdev.h line 71
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* Returns virtqueue state (last_avail_idx) +* @get_vq_align: Get the virtqueue align requirement +* for the device +* @mdev: mediated device +* Returns virtqueue algin requirement +* @get_features: Get virtio features supported by the device +* @mdev: mediated device +* Returns the virtio features support by the +* device +* @get_features: Set virtio features supported by the driver
s/get_features/set_features/
Quoted 5 lines
include/linux/virtio_mdev.h new file +5
-0+* @mdev: mediated device +* @features: feature support by the driver +* Returns integer: success (0) or error (< 0) +* @set_config_cb: Set the config interrupt callback +* @mdev: mediated device
include/linux/virtio_mdev.h line 86
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* @cb: virtio-mdev interrupt callback structure +* @get_vq_num_max: Get the max size of virtqueue +* @mdev: mediated device +* Returns u16: max size of virtqueue +* @get_device_id: Get virtio device id +* @mdev: mediated device +* Returns u32: virtio device id +* @get_vendor_id: Get virtio vendor id +* @mdev: mediated device +* Returns u32: virtio vendor id
How is the vendor id defined? As for normal virtio-pci devices?
Quoted 14 lines
include/linux/virtio_mdev.h new file +14
-0+* @get_status: Get the device status +* @mdev: mediated device +* Returns u8: virtio device status +* @set_status: Set the device status +* @mdev: mediated device +* @status: virtio device status +* @get_config: Read from device specific configuration space +* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to read to +* @len: the length to read from +* configration space +* @set_config: Write to device specific configuration space
include/linux/virtio_mdev.h line 110
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to write from +* @len: the length to write to +* configration space +* @get_mdev_features: Get the feature of virtio mdev device +* @mdev: mediated device +* Returns the mdev features (API) support by +* the device.
What kind of 'features' are supposed to go in there? Are these bits, like you defined for VIRTIO_MDEV_F_VERSION_1 above?
include/linux/virtio_mdev.h line 113
Quoted 3 lines
include/linux/virtio_mdev.h new file +3
-0+* @get_generation: Get device generaton +* @mdev: mediated device +* Returns u32: device generation
Is that callback mandatory?
Quoted 28 lines
include/linux/virtio_mdev.h new file +28
-0+*/ +struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb); +u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev); +u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len);
include/linux/virtio_mdev.h line 151
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev); + u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
Quoted 22 lines · Cornelia Huck
Quoted 19 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
This patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
Signed-off-by Jason Wang <[email protected]>--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+)create mode 100644
include/linux/virtio_mdev.hdrivers/vfio/mdev/mdev_core.c +0
-0@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops);
Quoted 4 lines
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 62
Quoted 3 lines
drivers/vfio/mdev/mdev_core.c +3
-0+/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/ Change this as for the vfio comment (last patch?)
Ok.
Quoted 6 lines
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 66
Quoted 5 lines
drivers/vfio/mdev/mdev_core.c +4
-0+void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id);s/BUG_ON/WARN_ON/
Yes.
Quoted 44 lines
Quoted 9 lines
drivers/vfio/mdev/mdev_core.c +5
-0+ mdev->class_id =MDEV_CLASS_ID_VIRTIO ; + mdev->device_ops = virtio_ops; +} +EXPORT_SYMBOL (mdev_set_virtio_ops); +const void *mdev_get_dev_ops (struct mdev_device *mdev) {return mdev->device_ops;(...)
Quoted 33 lines
include/linux/virtio_mdev.h new file +27
-0@@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Virtio mediated device driver +* +* Copyright 2019, Red Hat Corp. +* Author: Jason Wang <[email protected]> +*/ +#ifndef _LINUX_VIRTIO_MDEV_H +#define _LINUX_VIRTIO_MDEV_H + +#include <linux/interrupt.h> +#include <linux/mdev.h> +#include <uapi/linux/vhost.h> + +#define VIRTIO_MDEV_DEVICE_API_STRING "virtio-mdev" +#define VIRTIO_MDEV_F_VERSION_1 0x1 + +struct virtio_mdev_callback { +irqreturn_t (*callback)(void *data); +void *private; +}; + +/** +* struct vfio_mdev_device_ops - Structure to be registered for each +* mdev device to register the device to virtio-mdev module. +* +* @set_vq_address: Set the address of virtqueue
Quoted 8 lines
include/linux/virtio_mdev.h line 33
Quoted 6 lines
include/linux/virtio_mdev.h new file +6
-0+* @mdev: mediated device +* @idx: virtqueue index +* @desc_area: address of desc area +* @driver_area: address of driver area +* @device_area: address of device area +* Returns integer: success (0) or error (< 0) Probably dumb question (have not read the next patches yet): Is this agnostic regarding split or packed queues?
Yes, it is to and to be more obvious, I use the terminology from recent spec.
Quoted 39 lines
Quoted 29 lines
include/linux/virtio_mdev.h new file +28
-0+* @set_vq_num: Set the size of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @num: the size of virtqueue +* @kick_vq: Kick the virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @set_vq_cb: Set the interrupt callback function for +* a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @cb: virtio-mdev interrupt callback structure +* @set_vq_ready: Set ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @ready: ready (true) not ready(false) +* @get_vq_ready: Get ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* Returns boolean: ready (true) or not (false) +* @set_vq_state: Set the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @state: virtqueue state (last_avail_idx) +* Returns integer: success (0) or error (< 0) +* @get_vq_state: Get the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index include/linux/virtio_mdev.h line 71
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* Returns virtqueue state (last_avail_idx) +* @get_vq_align: Get the virtqueue align requirement +* for the device +* @mdev: mediated device +* Returns virtqueue algin requirement +* @get_features: Get virtio features supported by the device +* @mdev: mediated device +* Returns the virtio features support by the +* device +* @get_features: Set virtio features supported by the driver
Quoted 1 line
s/get_features/set_features/
Will fix.
Quoted 16 lines
Quoted 6 lines
include/linux/virtio_mdev.h new file +5
-0+* @mdev: mediated device +* @features: feature support by the driver +* Returns integer: success (0) or error (< 0) +* @set_config_cb: Set the config interrupt callback +* @mdev: mediated device include/linux/virtio_mdev.h line 86
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* @cb: virtio-mdev interrupt callback structure +* @get_vq_num_max: Get the max size of virtqueue +* @mdev: mediated device +* Returns u16: max size of virtqueue +* @get_device_id: Get virtio device id +* @mdev: mediated device +* Returns u32: virtio device id +* @get_vendor_id: Get virtio vendor id +* @mdev: mediated device +* Returns u32: virtio vendor id
Quoted 1 line
How is the vendor id defined? As for normal virtio-pci devices?
The vendor that provides this device. So something like this
I notice that MMIO also had this so it looks to me it's not pci specific.
Quoted 25 lines
Quoted 15 lines
include/linux/virtio_mdev.h new file +14
-0+* @get_status: Get the device status +* @mdev: mediated device +* Returns u8: virtio device status +* @set_status: Set the device status +* @mdev: mediated device +* @status: virtio device status +* @get_config: Read from device specific configuration space +* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to read to +* @len: the length to read from +* configration space +* @set_config: Write to device specific configuration space include/linux/virtio_mdev.h line 110
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to write from +* @len: the length to write to +* configration space +* @get_mdev_features: Get the feature of virtio mdev device +* @mdev: mediated device +* Returns the mdev features (API) support by +* the device.
Quoted 2 lines
What kind of 'features' are supposed to go in there? Are these bits, like you defined for
VIRTIO_MDEV_F_VERSION_1above?
It's the API or mdev features other than virtio features. It could be used by driver to determine the capability of the mdev device. Besides _F_VERSION_1, we may add dirty page tracking etc which means we need new device ops.
Quoted 5 lines
include/linux/virtio_mdev.h line 113
Quoted 4 lines
include/linux/virtio_mdev.h new file +3
-0+* @get_generation: Get device generaton +* @mdev: mediated device +* Returns u32: device generation Is that callback mandatory?
I think so, it's hard to emulate that completely in virtio-mdev transport.
Thanks
Quoted 39 lines
Quoted 39 lines
include/linux/virtio_mdev.h new file +38
-0+*/ +struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb); +u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev); +u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev); +u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
Quoted 7 lines · On Fri, 18 Oct 2019 18:55:02 +0800 Jason Wang <[email protected]> wrote:
Quoted 6 lines · Cornelia Huck
Quoted 3 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
+ * @get_vendor_id: Get virtio vendor id
+ * @mdev: mediated device
+ * Returns u32: virtio vendor id
Quoted 6 lines
Quoted 1 line
How is the vendor id defined? As for normal virtio-pci devices?
The vendor that provides this device. So something like this
I notice that MMIO also had this so it looks to me it's not pci specific.
Ok. Would be good to specify this more explicitly.
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
+ * @get_status: Get the device status
+ * @mdev: mediated device
+ * Returns u8: virtio device status
+ * @set_status: Set the device status
+ * @mdev: mediated device
+ * @status: virtio device status
+ * @get_config: Read from device specific configuration space
+ * @mdev: mediated device
+ * @offset: offset from the beginning of
+ * configuration space
+ * @buf: buffer used to read to
+ * @len: the length to read from
+ * configration space
+ * @set_config: Write to device specific configuration space
+ * @mdev: mediated device
+ * @offset: offset from the beginning of
+ * configuration space
+ * @buf: buffer used to write from
+ * @len: the length to write to
+ * configration space
+ * @get_mdev_features: Get the feature of virtio mdev device
+ * @mdev: mediated device
+ * Returns the mdev features (API) support by
+ * the device.
Quoted 8 lines
Quoted 2 lines
What kind of 'features' are supposed to go in there? Are these bits, like you defined for
VIRTIO_MDEV_F_VERSION_1above?It's the API or mdev features other than virtio features. It could be used by driver to determine the capability of the mdev device. Besides
_F_VERSION_1, we may add dirty page tracking etc which means we need new device ops.
Ok, so that's supposed to be distinct bits that can be or'ed together? Makes sense, but probably needs some more documentation somewhere.
Quoted 10 lines
Quoted 7 lines
Quoted 6 lines
+ * @get_generation: Get device generaton
+ * @mdev: mediated device
+ * Returns u32: device generationIs that callback mandatory?
I think so, it's hard to emulate that completely in virtio-mdev transport.
IIRC, the generation stuff is not mandatory in the current version of virtio, as not all transports have that concept.
Generally, are any of the callbacks optional, or are all of them mandatory? From what I understand, you plan to add new things that depend on features... would that mean non-mandatory callbacks?
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
Quoted 9 lines · Cornelia Huck
Quoted 6 lines · On Fri, 18 Oct 2019 18:55:02 +0800 Jason Wang <[email protected]> wrote:
Quoted 5 lines · Cornelia Huck
Quoted 3 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
+ * @get_vendor_id: Get virtio vendor id
+ * @mdev: mediated device
+ * Returns u32: virtio vendor id
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
How is the vendor id defined? As for normal virtio-pci devices?
The vendor that provides this device. So something like this
I notice that MMIO also had this so it looks to me it's not pci specific.
Ok. Would be good to specify this more explicitly.
Ok.
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
+ * @get_status: Get the device status
+ * @mdev: mediated device
+ * Returns u8: virtio device status
+ * @set_status: Set the device status
+ * @mdev: mediated device
+ * @status: virtio device status
+ * @get_config: Read from device specific configuration space
+ * @mdev: mediated device
+ * @offset: offset from the beginning of
+ * configuration space
+ * @buf: buffer used to read to
+ * @len: the length to read from
+ * configration space
+ * @set_config: Write to device specific configuration space
+ * @mdev: mediated device
+ * @offset: offset from the beginning of
+ * configuration space
+ * @buf: buffer used to write from
+ * @len: the length to write to
+ * configration space
+ * @get_mdev_features: Get the feature of virtio mdev device
+ * @mdev: mediated device
+ * Returns the mdev features (API) support by
+ * the device.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
What kind of 'features' are supposed to go in there? Are these bits, like you defined for
VIRTIO_MDEV_F_VERSION_1above?It's the API or mdev features other than virtio features. It could be used by driver to determine the capability of the mdev device. Besides
_F_VERSION_1, we may add dirty page tracking etc which means we need new device ops.Ok, so that's supposed to be distinct bits that can be or'ed together?
Yes.
Quoted 1 line
Makes sense, but probably needs some more documentation somewhere.
Let me add some doc above this helper.
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 6 lines
+ * @get_generation: Get device generaton
+ * @mdev: mediated device
+ * Returns u32: device generationIs that callback mandatory?
I think so, it's hard to emulate that completely in virtio-mdev transport.
IIRC, the generation stuff is not mandatory in the current version of virtio, as not all transports have that concept.
It looks to me we can have workaround as what has been done by virtio.c. Return 0 if this helper is not provided.
Quoted 4 lines
Generally, are any of the callbacks optional, or are all of them mandatory? From what I understand, you plan to add new things that depend on features... would that mean non-mandatory callbacks?
Yes, not all of them were mandatory, I will explicit explain which are mandatory and which are not.
Thanks
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Cornelia HuckQuoted 9 lines · Cornelia Huck
Quoted 6 lines · On Fri, 18 Oct 2019 18:55:02 +0800 Jason Wang <[email protected]> wrote:
Quoted 5 lines · Cornelia Huck
Quoted 3 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
+ * @get_vendor_id: Get virtio vendor id
+ * @mdev: mediated device
+ * Returns u32: virtio vendor id
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
How is the vendor id defined? As for normal virtio-pci devices?
The vendor that provides this device. So something like this
I notice that MMIO also had this so it looks to me it's not pci specific.
Ok. Would be good to specify this more explicitly.
Ok.
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
+ * @get_status: Get the device status
+ * @mdev: mediated device
+ * Returns u8: virtio device status
+ * @set_status: Set the device status
+ * @mdev: mediated device
+ * @status: virtio device status
+ * @get_config: Read from device specific configuration space
+ * @mdev: mediated device
+ * @offset: offset from the beginning of
+ * configuration space
+ * @buf: buffer used to read to
+ * @len: the length to read from
+ * configration space
+ * @set_config: Write to device specific configuration space
+ * @mdev: mediated device
+ * @offset: offset from the beginning of
+ * configuration space
+ * @buf: buffer used to write from
+ * @len: the length to write to
+ * configration space
+ * @get_mdev_features: Get the feature of virtio mdev device
+ * @mdev: mediated device
+ * Returns the mdev features (API) support by
+ * the device.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
What kind of 'features' are supposed to go in there? Are these bits, like you defined for
VIRTIO_MDEV_F_VERSION_1above?It's the API or mdev features other than virtio features. It could be used by driver to determine the capability of the mdev device. Besides
_F_VERSION_1, we may add dirty page tracking etc which means we need new device ops.Ok, so that's supposed to be distinct bits that can be or'ed together?
Yes.
Quoted 1 line
Makes sense, but probably needs some more documentation somewhere.
Let me add some doc above this helper.
Quoted 11 lines
Quoted 9 lines
Quoted 7 lines
Quoted 6 lines
+ * @get_generation: Get device generaton
+ * @mdev: mediated device
+ * Returns u32: device generationIs that callback mandatory?
I think so, it's hard to emulate that completely in virtio-mdev transport.
IIRC, the generation stuff is not mandatory in the current version of virtio, as not all transports have that concept.
It looks to me we can have workaround as what has been done by virtio.c. Return 0 if this helper is not provided.
Quoted 4 lines
Generally, are any of the callbacks optional, or are all of them mandatory? From what I understand, you plan to add new things that depend on features... would that mean non-mandatory callbacks?
Yes, not all of them were mandatory, I will explicit explain which are mandatory and which are not.
Thanks
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Jason WangQuoted 7 lines · On Fri, 18 Oct 2019 18:55:02 +0800 Jason Wang <[email protected]> wrote:
Quoted 6 lines · Cornelia Huck
Quoted 3 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
+ * @get_vendor_id: Get virtio vendor id
+ * @mdev: mediated device
+ * Returns u32: virtio vendor id
Quoted 6 lines
Quoted 1 line
How is the vendor id defined? As for normal virtio-pci devices?
The vendor that provides this device. So something like this
I notice that MMIO also had this so it looks to me it's not pci specific.
Ok. Would be good to specify this more explicitly.
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
+ * @get_status: Get the device status
+ * @mdev: mediated device
+ * Returns u8: virtio device status
+ * @set_status: Set the device status
+ * @mdev: mediated device
+ * @status: virtio device status
+ * @get_config: Read from device specific configuration space
+ * @mdev: mediated device
+ * @offset: offset from the beginning of
+ * configuration space
+ * @buf: buffer used to read to
+ * @len: the length to read from
+ * configration space
+ * @set_config: Write to device specific configuration space
+ * @mdev: mediated device
+ * @offset: offset from the beginning of
+ * configuration space
+ * @buf: buffer used to write from
+ * @len: the length to write to
+ * configration space
+ * @get_mdev_features: Get the feature of virtio mdev device
+ * @mdev: mediated device
+ * Returns the mdev features (API) support by
+ * the device.
Quoted 8 lines
Quoted 2 lines
What kind of 'features' are supposed to go in there? Are these bits, like you defined for
VIRTIO_MDEV_F_VERSION_1above?It's the API or mdev features other than virtio features. It could be used by driver to determine the capability of the mdev device. Besides
_F_VERSION_1, we may add dirty page tracking etc which means we need new device ops.
Ok, so that's supposed to be distinct bits that can be or'ed together? Makes sense, but probably needs some more documentation somewhere.
Quoted 10 lines
Quoted 7 lines
Quoted 6 lines
+ * @get_generation: Get device generaton
+ * @mdev: mediated device
+ * Returns u32: device generationIs that callback mandatory?
I think so, it's hard to emulate that completely in virtio-mdev transport.
IIRC, the generation stuff is not mandatory in the current version of virtio, as not all transports have that concept.
Generally, are any of the callbacks optional, or are all of them mandatory? From what I understand, you plan to add new things that depend on features... would that mean non-mandatory callbacks?
_______________________________________________
Virtualization mailing list [email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Cornelia HuckQuoted 22 lines · Cornelia Huck
Quoted 19 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
This patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
Signed-off-by Jason Wang <[email protected]>--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+)create mode 100644
include/linux/virtio_mdev.hdrivers/vfio/mdev/mdev_core.c +0
-0@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops);
Quoted 4 lines
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 62
Quoted 3 lines
drivers/vfio/mdev/mdev_core.c +3
-0+/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/ Change this as for the vfio comment (last patch?)
Ok.
Quoted 6 lines
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 66
Quoted 5 lines
drivers/vfio/mdev/mdev_core.c +4
-0+void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id);s/BUG_ON/WARN_ON/
Yes.
Quoted 44 lines
Quoted 9 lines
drivers/vfio/mdev/mdev_core.c +5
-0+ mdev->class_id =MDEV_CLASS_ID_VIRTIO ; + mdev->device_ops = virtio_ops; +} +EXPORT_SYMBOL (mdev_set_virtio_ops); +const void *mdev_get_dev_ops (struct mdev_device *mdev) {return mdev->device_ops;(...)
Quoted 33 lines
include/linux/virtio_mdev.h new file +27
-0@@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Virtio mediated device driver +* +* Copyright 2019, Red Hat Corp. +* Author: Jason Wang <[email protected]> +*/ +#ifndef _LINUX_VIRTIO_MDEV_H +#define _LINUX_VIRTIO_MDEV_H + +#include <linux/interrupt.h> +#include <linux/mdev.h> +#include <uapi/linux/vhost.h> + +#define VIRTIO_MDEV_DEVICE_API_STRING "virtio-mdev" +#define VIRTIO_MDEV_F_VERSION_1 0x1 + +struct virtio_mdev_callback { +irqreturn_t (*callback)(void *data); +void *private; +}; + +/** +* struct vfio_mdev_device_ops - Structure to be registered for each +* mdev device to register the device to virtio-mdev module. +* +* @set_vq_address: Set the address of virtqueue
Quoted 8 lines
include/linux/virtio_mdev.h line 33
Quoted 6 lines
include/linux/virtio_mdev.h new file +6
-0+* @mdev: mediated device +* @idx: virtqueue index +* @desc_area: address of desc area +* @driver_area: address of driver area +* @device_area: address of device area +* Returns integer: success (0) or error (< 0) Probably dumb question (have not read the next patches yet): Is this agnostic regarding split or packed queues?
Yes, it is to and to be more obvious, I use the terminology from recent spec.
Quoted 39 lines
Quoted 29 lines
include/linux/virtio_mdev.h new file +28
-0+* @set_vq_num: Set the size of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @num: the size of virtqueue +* @kick_vq: Kick the virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @set_vq_cb: Set the interrupt callback function for +* a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @cb: virtio-mdev interrupt callback structure +* @set_vq_ready: Set ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @ready: ready (true) not ready(false) +* @get_vq_ready: Get ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* Returns boolean: ready (true) or not (false) +* @set_vq_state: Set the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @state: virtqueue state (last_avail_idx) +* Returns integer: success (0) or error (< 0) +* @get_vq_state: Get the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index include/linux/virtio_mdev.h line 71
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* Returns virtqueue state (last_avail_idx) +* @get_vq_align: Get the virtqueue align requirement +* for the device +* @mdev: mediated device +* Returns virtqueue algin requirement +* @get_features: Get virtio features supported by the device +* @mdev: mediated device +* Returns the virtio features support by the +* device +* @get_features: Set virtio features supported by the driver
Quoted 1 line
s/get_features/set_features/
Will fix.
Quoted 16 lines
Quoted 6 lines
include/linux/virtio_mdev.h new file +5
-0+* @mdev: mediated device +* @features: feature support by the driver +* Returns integer: success (0) or error (< 0) +* @set_config_cb: Set the config interrupt callback +* @mdev: mediated device include/linux/virtio_mdev.h line 86
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* @cb: virtio-mdev interrupt callback structure +* @get_vq_num_max: Get the max size of virtqueue +* @mdev: mediated device +* Returns u16: max size of virtqueue +* @get_device_id: Get virtio device id +* @mdev: mediated device +* Returns u32: virtio device id +* @get_vendor_id: Get virtio vendor id +* @mdev: mediated device +* Returns u32: virtio vendor id
Quoted 1 line
How is the vendor id defined? As for normal virtio-pci devices?
The vendor that provides this device. So something like this
I notice that MMIO also had this so it looks to me it's not pci specific.
Quoted 25 lines
Quoted 15 lines
include/linux/virtio_mdev.h new file +14
-0+* @get_status: Get the device status +* @mdev: mediated device +* Returns u8: virtio device status +* @set_status: Set the device status +* @mdev: mediated device +* @status: virtio device status +* @get_config: Read from device specific configuration space +* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to read to +* @len: the length to read from +* configration space +* @set_config: Write to device specific configuration space include/linux/virtio_mdev.h line 110
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to write from +* @len: the length to write to +* configration space +* @get_mdev_features: Get the feature of virtio mdev device +* @mdev: mediated device +* Returns the mdev features (API) support by +* the device.
Quoted 2 lines
What kind of 'features' are supposed to go in there? Are these bits, like you defined for
VIRTIO_MDEV_F_VERSION_1above?
It's the API or mdev features other than virtio features. It could be used by driver to determine the capability of the mdev device. Besides _F_VERSION_1, we may add dirty page tracking etc which means we need new device ops.
Quoted 5 lines
include/linux/virtio_mdev.h line 113
Quoted 4 lines
include/linux/virtio_mdev.h new file +3
-0+* @get_generation: Get device generaton +* @mdev: mediated device +* Returns u32: device generation Is that callback mandatory?
I think so, it's hard to emulate that completely in virtio-mdev transport.
Thanks
Quoted 31 lines
Quoted 31 lines
include/linux/virtio_mdev.h new file +30
-0+*/ +struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb); +u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev); +u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len);
Quoted 8 lines
include/linux/virtio_mdev.h line 151
Quoted 8 lines
include/linux/virtio_mdev.h new file +8
-0+u64 (*get_mdev_features)(struct mdev_device *mdev); + u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Jason WangQuoted 16 lines · On Thu, 17 Oct 2019 18:48:34 +0800 Jason Wang <[email protected]> wrote:
This patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
Signed-off-by Jason Wang <[email protected]>--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 include/linux/virtio_mdev.hdrivers/vfio/mdev/mdev_core.c +0
-0
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 62
Quoted 6 lines
drivers/vfio/mdev/mdev_core.c +3
-0@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops); +/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/
Change this as for the vfio comment (last patch?)
drivers/vfio/mdev/mdev_core.c void mdev_set_vfio_ops(struct mdev_device *mdev, · line 66
Quoted 4 lines
drivers/vfio/mdev/mdev_core.c +4
-0+void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id);
s/BUG_ON/WARN_ON/
Quoted 8 lines
drivers/vfio/mdev/mdev_core.c +5
-0+ mdev->class_id =MDEV_CLASS_ID_VIRTIO ; + mdev->device_ops = virtio_ops; +} +EXPORT_SYMBOL (mdev_set_virtio_ops); +const void *mdev_get_dev_ops (struct mdev_device *mdev) {return mdev->device_ops;
(...)
Quoted 29 lines
include/linux/virtio_mdev.h new file +23
-0@@ -0,0 +1,151 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Virtio mediated device driver +* +* Copyright 2019, Red Hat Corp. +* Author: Jason Wang <[email protected]> +*/ +#ifndef _LINUX_VIRTIO_MDEV_H +#define _LINUX_VIRTIO_MDEV_H + +#include <linux/interrupt.h> +#include <linux/mdev.h> +#include <uapi/linux/vhost.h> + +#define VIRTIO_MDEV_DEVICE_API_STRING "virtio-mdev" +#define VIRTIO_MDEV_F_VERSION_1 0x1 + +struct virtio_mdev_callback { +irqreturn_t (*callback)(void *data); +void *private; +}; + +/**
include/linux/virtio_mdev.h line 33
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* struct vfio_mdev_device_ops - Structure to be registered for each +* mdev device to register the device to virtio-mdev module. +* +* @set_vq_address: Set the address of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @desc_area: address of desc area +* @driver_area: address of driver area +* @device_area: address of device area +* Returns integer: success (0) or error (< 0)
Probably dumb question (have not read the next patches yet): Is this agnostic regarding split or packed queues?
Quoted 28 lines
include/linux/virtio_mdev.h new file +28
-0+* @set_vq_num: Set the size of virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @num: the size of virtqueue +* @kick_vq: Kick the virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @set_vq_cb: Set the interrupt callback function for +* a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @cb: virtio-mdev interrupt callback structure +* @set_vq_ready: Set ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @ready: ready (true) not ready(false) +* @get_vq_ready: Get ready status for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* Returns boolean: ready (true) or not (false) +* @set_vq_state: Set the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index +* @state: virtqueue state (last_avail_idx) +* Returns integer: success (0) or error (< 0) +* @get_vq_state: Get the state for a virtqueue +* @mdev: mediated device +* @idx: virtqueue index
include/linux/virtio_mdev.h line 71
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* Returns virtqueue state (last_avail_idx) +* @get_vq_align: Get the virtqueue align requirement +* for the device +* @mdev: mediated device +* Returns virtqueue algin requirement +* @get_features: Get virtio features supported by the device +* @mdev: mediated device +* Returns the virtio features support by the +* device +* @get_features: Set virtio features supported by the driver
s/get_features/set_features/
Quoted 5 lines
include/linux/virtio_mdev.h new file +5
-0+* @mdev: mediated device +* @features: feature support by the driver +* Returns integer: success (0) or error (< 0) +* @set_config_cb: Set the config interrupt callback +* @mdev: mediated device
include/linux/virtio_mdev.h line 86
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* @cb: virtio-mdev interrupt callback structure +* @get_vq_num_max: Get the max size of virtqueue +* @mdev: mediated device +* Returns u16: max size of virtqueue +* @get_device_id: Get virtio device id +* @mdev: mediated device +* Returns u32: virtio device id +* @get_vendor_id: Get virtio vendor id +* @mdev: mediated device +* Returns u32: virtio vendor id
How is the vendor id defined? As for normal virtio-pci devices?
Quoted 14 lines
include/linux/virtio_mdev.h new file +14
-0+* @get_status: Get the device status +* @mdev: mediated device +* Returns u8: virtio device status +* @set_status: Set the device status +* @mdev: mediated device +* @status: virtio device status +* @get_config: Read from device specific configuration space +* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to read to +* @len: the length to read from +* configration space +* @set_config: Write to device specific configuration space
include/linux/virtio_mdev.h line 110
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+* @mdev: mediated device +* @offset: offset from the beginning of +* configuration space +* @buf: buffer used to write from +* @len: the length to write to +* configration space +* @get_mdev_features: Get the feature of virtio mdev device +* @mdev: mediated device +* Returns the mdev features (API) support by +* the device.
What kind of 'features' are supposed to go in there? Are these bits, like you defined for VIRTIO_MDEV_F_VERSION_1 above?
include/linux/virtio_mdev.h line 113
Quoted 3 lines
include/linux/virtio_mdev.h new file +3
-0+* @get_generation: Get device generaton +* @mdev: mediated device +* Returns u32: device generation
Is that callback mandatory?
Quoted 38 lines
include/linux/virtio_mdev.h new file +38
-0+*/ +struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb); +u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev); +u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev); +u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Jason WangQuoted 5 lines · Jason Wang
+ * @get_vq_state: Get the state for a virtqueue
+ * @mdev: mediated device
+ * @idx: virtqueue index
+ * Returns virtqueue state (last_avail_idx)
+ * @get_vq_align: Get the virtqueue align requirement
Quoted 8 lines
+ * for the device
+ * @mdev: mediated device
+ * Returns virtqueue algin requirement
+ * @get_features: Get virtio features supported by the device
+ * @mdev: mediated device
+ * Returns the virtio features support by the
+ * device
+ * @get_features: Set virtio features supported by the driver
s/get_features/set_features/
Quoted 29 lines
+ * configration space
+ * @get_mdev_features: Get the feature of virtio mdev device
+ * @mdev: mediated device
+ * Returns the mdev features (API) support by
+ * the device.
+ * @get_generation: Get device generaton
+ * @mdev: mediated device
+ * Returns u32: device generation
+ */include/linux/virtio_mdev.h new file +20
-0+struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb);
include/linux/virtio_mdev.h line 144
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev); +u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev);
Do we need a .set_mdev_features method as well?
It's not very clear what does mdev_features mean.
Does it mean the vhost backend features?
Quoted 10 lines
include/linux/virtio_mdev.h new file +7
-0+ u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif Signature · 1 line
2.19.1
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
Quoted 14 lines · Tiwei Bie
Quoted 5 lines · Jason Wang
+ * @get_vq_state: Get the state for a virtqueue
+ * @mdev: mediated device
+ * @idx: virtqueue index
+ * Returns virtqueue state (last_avail_idx)
+ * @get_vq_align: Get the virtqueue align requirementQuoted 8 lines
+ * for the device
+ * @mdev: mediated device
+ * Returns virtqueue algin requirement
+ * @get_features: Get virtio features supported by the device
+ * @mdev: mediated device
+ * Returns the virtio features support by the
+ * device
+ * @get_features: Set virtio features supported by the driver
Quoted 1 line
s/get_features/set_features/
Will fix.
Quoted 33 lines
Quoted 33 lines
+ * configration space
+ * @get_mdev_features: Get the feature of virtio mdev device
+ * @mdev: mediated device
+ * Returns the mdev features (API) support by
+ * the device.
+ * @get_generation: Get device generaton
+ * @mdev: mediated device
+ * Returns u32: device generation
+ */include/linux/virtio_mdev.h new file +23
-0+struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb); +u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev);
Quoted 8 lines
include/linux/virtio_mdev.h line 144
Quoted 7 lines
include/linux/virtio_mdev.h new file +7
-0+u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev);Do we need a .set_mdev_features method as well?
Good question. To me I think we may document that the API provides backward compatibility, so there's no need for set_mdev_features. Or is there any other chance that we need that?
Quoted 5 lines
It's not very clear what does
mdev_featuresmean.
Does it mean the vhost backend features?
Something like this, it's kind of the version of the API, except for the _F_VERSION_1, the first user should be _F_LOG_ALL. I will add more docs for this API.
Thanks
Quoted 12 lines
Quoted 12 lines
include/linux/virtio_mdev.h new file +7
-0+ u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif Signature · 1 line
2.19.1
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Tiwei BieQuoted 14 lines · Tiwei Bie
Quoted 5 lines · Jason Wang
+ * @get_vq_state: Get the state for a virtqueue
+ * @mdev: mediated device
+ * @idx: virtqueue index
+ * Returns virtqueue state (last_avail_idx)
+ * @get_vq_align: Get the virtqueue align requirementQuoted 8 lines
+ * for the device
+ * @mdev: mediated device
+ * Returns virtqueue algin requirement
+ * @get_features: Get virtio features supported by the device
+ * @mdev: mediated device
+ * Returns the virtio features support by the
+ * device
+ * @get_features: Set virtio features supported by the driver
Quoted 1 line
s/get_features/set_features/
Will fix.
Quoted 33 lines
Quoted 33 lines
+ * configration space
+ * @get_mdev_features: Get the feature of virtio mdev device
+ * @mdev: mediated device
+ * Returns the mdev features (API) support by
+ * the device.
+ * @get_generation: Get device generaton
+ * @mdev: mediated device
+ * Returns u32: device generation
+ */include/linux/virtio_mdev.h new file +23
-0+struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb); +u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev);
Quoted 8 lines
include/linux/virtio_mdev.h line 144
Quoted 7 lines
include/linux/virtio_mdev.h new file +7
-0+u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev);Do we need a .set_mdev_features method as well?
Good question. To me I think we may document that the API provides backward compatibility, so there's no need for set_mdev_features. Or is there any other chance that we need that?
Quoted 5 lines
It's not very clear what does
mdev_featuresmean.
Does it mean the vhost backend features?
Something like this, it's kind of the version of the API, except for the _F_VERSION_1, the first user should be _F_LOG_ALL. I will add more docs for this API.
Thanks
Quoted 12 lines
Quoted 12 lines
include/linux/virtio_mdev.h new file +7
-0+ u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif Signature · 1 line
2.19.1
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 4/6] mdev: introduce virtio device and its device ops
In reply to Jason WangQuoted 5 lines · Jason Wang
+ * @get_vq_state: Get the state for a virtqueue
+ * @mdev: mediated device
+ * @idx: virtqueue index
+ * Returns virtqueue state (last_avail_idx)
+ * @get_vq_align: Get the virtqueue align requirement
Quoted 8 lines
+ * for the device
+ * @mdev: mediated device
+ * Returns virtqueue algin requirement
+ * @get_features: Get virtio features supported by the device
+ * @mdev: mediated device
+ * Returns the virtio features support by the
+ * device
+ * @get_features: Set virtio features supported by the driver
s/get_features/set_features/
Quoted 29 lines
+ * configration space
+ * @get_mdev_features: Get the feature of virtio mdev device
+ * @mdev: mediated device
+ * Returns the mdev features (API) support by
+ * the device.
+ * @get_generation: Get device generaton
+ * @mdev: mediated device
+ * Returns u32: device generation
+ */include/linux/virtio_mdev.h new file +20
-0+struct virtio_mdev_device_ops { +/* Virtqueue ops */ +int (*set_vq_address)(struct mdev_device *mdev, +u16 idx,u64 desc_area,u64 driver_area, +u64 device_area); +void (*set_vq_num)(struct mdev_device *mdev,u16 idx,u32 num); +void (*kick_vq)(struct mdev_device *mdev,u16 idx); +void (*set_vq_cb)(struct mdev_device *mdev,u16 idx, +struct virtio_mdev_callback *cb); +void (*set_vq_ready)(struct mdev_device *mdev,u16 idx,bool ready); +bool (*get_vq_ready)(struct mdev_device *mdev,u16 idx); +int (*set_vq_state)(struct mdev_device *mdev,u16 idx,u64 state); +u64 (*get_vq_state)(struct mdev_device *mdev,u16 idx); + +/* Device ops */ +u16 (*get_vq_align)(struct mdev_device *mdev); +u64 (*get_features)(struct mdev_device *mdev); +int (*set_features)(struct mdev_device *mdev,u64 features); +void (*set_config_cb)(struct mdev_device *mdev, +struct virtio_mdev_callback *cb);
include/linux/virtio_mdev.h line 144
Quoted 10 lines
include/linux/virtio_mdev.h new file +10
-0+u16 (*get_vq_num_max)(struct mdev_device *mdev); +u32 (*get_device_id)(struct mdev_device *mdev); +u32 (*get_vendor_id)(struct mdev_device *mdev); +u8 (*get_status)(struct mdev_device *mdev); +void (*set_status)(struct mdev_device *mdev,u8 status); +void (*get_config)(struct mdev_device *mdev,unsigned int offset, +void *buf,unsigned int len); +void (*set_config)(struct mdev_device *mdev,unsigned int offset, +const void *buf,unsigned int len); +u64 (*get_mdev_features)(struct mdev_device *mdev);
Do we need a .set_mdev_features method as well?
It's not very clear what does mdev_features mean.
Does it mean the vhost backend features?
Quoted 10 lines
include/linux/virtio_mdev.h new file +7
-0+ u32 (*get_generation)(struct mdev_device *mdev); +}; + +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops); + +#endif Signature · 1 line
2.19.1
PATCH v4 4/6 mdev: introduce virtio device and its device ops
In reply to Jason WangThis patch implements basic support for mdev driver that supports virtio transport for kernel virtio driver.
--- drivers/vfio/mdev/mdev_core.c | 12 +++ include/linux/mdev.h | 4 + include/linux/virtio_mdev.h | 151 ++++++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 include/linux/virtio_mdev.h
drivers/vfio/mdev/mdev_core.c +12 -0
@@ -57,6 +57,18 @@ void mdev_set_vfio_ops(struct mdev_device *mdev, }EXPORT_SYMBOL (mdev_set_vfio_ops); +/* Specify the virtio device ops for the mdev device, this +* must be called during create() callback for virtio mdev device. +*/ +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops) +{ +BUG_ON (mdev->class_id); + mdev->class_id =MDEV_CLASS_ID_VIRTIO ; + mdev->device_ops = virtio_ops; +} +EXPORT_SYMBOL (mdev_set_virtio_ops); +const void *mdev_get_dev_ops (struct mdev_device *mdev) {return mdev->device_ops;
include/linux/mdev.h +4 -0
@@ -17,6 +17,7 @@struct mdev_device ;struct vfio_mdev_device_ops ; +struct virtio_mdev_device_ops ;/* * Called by the parent device driver to set the device which represents
@@ -111,6 +112,8 @@ void mdev_set_drvdata(struct mdev_device *mdev, void *data);const guid_t *mdev_uuid (struct mdev_device *mdev);void mdev_set_vfio_ops (struct mdev_device *mdev,const struct vfio_mdev_device_ops *vfio_ops); +void mdev_set_virtio_ops (struct mdev_device *mdev, +const struct virtio_mdev_device_ops *virtio_ops);const void *mdev_get_dev_ops (struct mdev_device *mdev);extern struct bus_type mdev_bus_type;
@@ -127,6 +130,7 @@ struct mdev_device *mdev_from_dev(struct device *dev);enum {MDEV_CLASS_ID_VFIO =1 , +MDEV_CLASS_ID_VIRTIO =2 ,/* New entries must be added here */ };
include/linux/virtio_mdev.h new file +151 -0
151 lines not on this page · raw message
Signature · 1 line
2.19.1
PATCH v4 5/6 virtio: introduce a mdev based transport
In reply to Jason WangThis patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of mdev_parent_ops now.
--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+) create mode 100644 drivers/virtio/virtio_mdev.c
drivers/virtio/Kconfig +7 -0
@@ -43,6 +43,13 @@ config VIRTIO_PCI_LEGACY If unsure, say Y. +config VIRTIO_MDEV_DEVICE + tristate "VIRTIO driver for Mediated devices" + depends on VFIO_MDEV && VIRTIO + default n + help + VIRTIO based driver for Mediated devices. + config VIRTIO_PMEM tristate "Support for virtio pmem driver" depends on VIRTIO
drivers/virtio/Makefile +1 -0
@@ -6,3 +6,4 @@ virtio_pci-y := virtio_pci_modern.o virtio_pci_common.o virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o +obj-$(CONFIG_VIRTIO_MDEV_DEVICE) += virtio_mdev.o
drivers/virtio/virtio_mdev.c new file +409 -0
409 lines not on this page · raw message
Signature · 1 line
2.19.1
Re: [PATCH V4 5/6] virtio: introduce a mdev based transport
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:35 +0800 Jason Wang <[email protected]> wrote:
This patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of
mdev_parent_opsnow.Signed-off-by Jason Wang <[email protected]>--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+)
(...)
Quoted 13 lines
drivers/virtio/virtio_mdev.c new file +13
-0+static int virtio_mdev_probe (struct device *dev) +{ +struct mdev_device *mdev =mdev_from_dev (dev); +const struct virtio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); +struct virtio_mdev_device *vm_dev; +int rc; + + vm_dev =devm_kzalloc (dev,sizeof (*vm_dev),GFP_KERNEL ); +if (!vm_dev) +return -ENOMEM ; + + vm_dev->vdev.dev.parent = dev; + vm_dev->vdev.dev.release = virtio_mdev_release_dev;
drivers/virtio/virtio_mdev.c line 356
Quoted 10 lines
drivers/virtio/virtio_mdev.c new file +10
-0+ vm_dev->vdev.config = &virtio_mdev_config_ops; + vm_dev->mdev = mdev; +INIT_LIST_HEAD (&vm_dev->virtqueues); +spin_lock_init (&vm_dev->lock); + + vm_dev->version = ops->get_mdev_features (mdev); +if (vm_dev->version !=VIRTIO_MDEV_F_VERSION_1 ) { +dev_err (dev,"VIRTIO_MDEV_F_VERSION_1 is mandatory\n" ); +return -ENXIO ; + }
Hm, so how is that mdev features interface supposed to work? If VIRTIO_MDEV_F_VERSION_1 is a bit, I would expect this code to test for its presence, and not for identity.
What will happen if we come up with a version 2? If this is backwards compatible, will both version 2 and version 1 be set?
Quoted 14 lines
drivers/virtio/virtio_mdev.c new file +14
-0+ + vm_dev->vdev.id.device = ops->get_device_id (mdev); +if (vm_dev->vdev.id.device ==0 ) +return -ENODEV ; + + vm_dev->vdev.id.vendor = ops->get_vendor_id (mdev); + rc =register_virtio_device (&vm_dev->vdev); +if (rc) +put_device (dev); +else +dev_set_drvdata (dev, vm_dev); + +return rc; +}
(...)
Re: [PATCH V4 5/6] virtio: introduce a mdev based transport
Quoted 39 lines · Cornelia Huck
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:35 +0800 Jason Wang <[email protected]> wrote:
This patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of
mdev_parent_opsnow.Signed-off-by Jason Wang <[email protected]>--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+)(...)
Quoted 18 lines
drivers/virtio/virtio_mdev.c new file +18
-0+static int virtio_mdev_probe (struct device *dev) +{ +struct mdev_device *mdev =mdev_from_dev (dev); +const struct virtio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); +struct virtio_mdev_device *vm_dev; +int rc; + + vm_dev =devm_kzalloc (dev,sizeof (*vm_dev),GFP_KERNEL ); +if (!vm_dev) +return -ENOMEM ; + + vm_dev->vdev.dev.parent = dev; + vm_dev->vdev.dev.release = virtio_mdev_release_dev; + vm_dev->vdev.config = &virtio_mdev_config_ops; + vm_dev->mdev = mdev; +INIT_LIST_HEAD (&vm_dev->virtqueues); +spin_lock_init (&vm_dev->lock); +
Quoted 8 lines
drivers/virtio/virtio_mdev.c line 356
Quoted 5 lines
drivers/virtio/virtio_mdev.c new file +5
-0+ vm_dev->version = ops->get_mdev_features (mdev); +if (vm_dev->version !=VIRTIO_MDEV_F_VERSION_1 ) { +dev_err (dev,"VIRTIO_MDEV_F_VERSION_1 is mandatory\n" ); +return -ENXIO ; + }Hm, so how is that mdev features interface supposed to work? If
VIRTIO_MDEV_F_VERSION_1is a bit, I would expect this code to test for its presence, and not for identity.
This should be used by driver to detect the which sets of functions and their semantics that could be provided by the device. E.g when driver support both version 2 and version 1 but device only support version 1, driver can switch to use version 1. Btw, Is there a easy way for to test its presence or do you mean doing sanity testing on existence of the mandatory ops that provided by the device?
Quoted 3 lines
What will happen if we come up with a version 2? If this is backwards compatible, will both version 2 and version 1 be set?
Yes, I think so, and version 2 should be considered as some extensions of version 1. If it's completely, it should use a new class id.
Thanks
Quoted 16 lines
Quoted 15 lines
drivers/virtio/virtio_mdev.c new file +14
-0+ + vm_dev->vdev.id.device = ops->get_device_id (mdev); +if (vm_dev->vdev.id.device ==0 ) +return -ENODEV ; + + vm_dev->vdev.id.vendor = ops->get_vendor_id (mdev); + rc =register_virtio_device (&vm_dev->vdev); +if (rc) +put_device (dev); +else +dev_set_drvdata (dev, vm_dev); + +return rc; +}(...)
Re: [PATCH V4 5/6] virtio: introduce a mdev based transport
Quoted 50 lines · On Mon, 21 Oct 2019 13:59:23 +0800 Jason Wang <[email protected]> wrote:
Quoted 39 lines · Cornelia Huck
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:35 +0800 Jason Wang <[email protected]> wrote:
This patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of
mdev_parent_opsnow.Signed-off-by Jason Wang <[email protected]>--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+)(...)
Quoted 18 lines
drivers/virtio/virtio_mdev.c new file +18
-0+static int virtio_mdev_probe (struct device *dev) +{ +struct mdev_device *mdev =mdev_from_dev (dev); +const struct virtio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); +struct virtio_mdev_device *vm_dev; +int rc; + + vm_dev =devm_kzalloc (dev,sizeof (*vm_dev),GFP_KERNEL ); +if (!vm_dev) +return -ENOMEM ; + + vm_dev->vdev.dev.parent = dev; + vm_dev->vdev.dev.release = virtio_mdev_release_dev; + vm_dev->vdev.config = &virtio_mdev_config_ops; + vm_dev->mdev = mdev; +INIT_LIST_HEAD (&vm_dev->virtqueues); +spin_lock_init (&vm_dev->lock); +Quoted 8 lines
drivers/virtio/virtio_mdev.c line 356
Quoted 5 lines
drivers/virtio/virtio_mdev.c new file +5
-0+ vm_dev->version = ops->get_mdev_features (mdev); +if (vm_dev->version !=VIRTIO_MDEV_F_VERSION_1 ) { +dev_err (dev,"VIRTIO_MDEV_F_VERSION_1 is mandatory\n" ); +return -ENXIO ; + }Hm, so how is that mdev features interface supposed to work? If
VIRTIO_MDEV_F_VERSION_1is a bit, I would expect this code to test for its presence, and not for identity.
Quoted 6 lines
This should be used by driver to detect the which sets of functions and their semantics that could be provided by the device. E.g when driver support both version 2 and version 1 but device only support version 1, driver can switch to use version 1. Btw, Is there a easy way for to test its presence or do you mean doing sanity testing on existence of the mandatory ops that provided by the device?
What I meant was something like:
features = ops->get_mdev_features(mdev);
if (features & VIRTIO_MDEV_F_VERSION_1)
vm_dev->version = 1; else //moan about missing support for version 1
Can there be class id specific extra features, or is this only for core features? If the latter, maybe also do something like
supported_features = ORED_LIST_OF_FEATURES;
if (features & ~supported_features)
//moan about extra feature bits
Quoted 9 lines
Quoted 5 lines
What will happen if we come up with a version 2? If this is backwards compatible, will both version 2 and version 1 be set?
Yes, I think so, and version 2 should be considered as some extensions of version 1. If it's completely, it should use a new class id.
Ok, that makes sense.
Re: [PATCH V4 5/6] virtio: introduce a mdev based transport
Quoted 66 lines · Cornelia Huck
Quoted 49 lines · On Mon, 21 Oct 2019 13:59:23 +0800 Jason Wang <[email protected]> wrote:
Quoted 39 lines · Cornelia Huck
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:35 +0800 Jason Wang <[email protected]> wrote:
This patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of
mdev_parent_opsnow.Signed-off-by Jason Wang <[email protected]>--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+)(...)
Quoted 18 lines
drivers/virtio/virtio_mdev.c new file +18
-0+static int virtio_mdev_probe (struct device *dev) +{ +struct mdev_device *mdev =mdev_from_dev (dev); +const struct virtio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); +struct virtio_mdev_device *vm_dev; +int rc; + + vm_dev =devm_kzalloc (dev,sizeof (*vm_dev),GFP_KERNEL ); +if (!vm_dev) +return -ENOMEM ; + + vm_dev->vdev.dev.parent = dev; + vm_dev->vdev.dev.release = virtio_mdev_release_dev; + vm_dev->vdev.config = &virtio_mdev_config_ops; + vm_dev->mdev = mdev; +INIT_LIST_HEAD (&vm_dev->virtqueues); +spin_lock_init (&vm_dev->lock); +Quoted 8 lines
drivers/virtio/virtio_mdev.c line 356
Quoted 5 lines
drivers/virtio/virtio_mdev.c new file +5
-0+ vm_dev->version = ops->get_mdev_features (mdev); +if (vm_dev->version !=VIRTIO_MDEV_F_VERSION_1 ) { +dev_err (dev,"VIRTIO_MDEV_F_VERSION_1 is mandatory\n" ); +return -ENXIO ; + }Hm, so how is that mdev features interface supposed to work? If
VIRTIO_MDEV_F_VERSION_1is a bit, I would expect this code to test for its presence, and not for identity.Quoted 6 lines
This should be used by driver to detect the which sets of functions and their semantics that could be provided by the device. E.g when driver support both version 2 and version 1 but device only support version 1, driver can switch to use version 1. Btw, Is there a easy way for to test its presence or do you mean doing sanity testing on existence of the mandatory ops that provided by the device?
What I meant was something like:
features =
ops->get_mdev_features(mdev);
if (features &VIRTIO_MDEV_F_VERSION_1)vm_dev->version = 1; else //moan about missing support for version 1
Quoted 6 lines
Can there be class id specific extra features, or is this only for core features? If the latter, maybe also do something like
supported_features=ORED_LIST_OF_FEATURES;
if (features & ~supported_features)//moan about extra feature bits
Consider driver can claim to support a list of ids, so I this it's former.
Will do as what you proposed.
Thanks
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
What will happen if we come up with a version 2? If this is backwards compatible, will both version 2 and version 1 be set?
Yes, I think so, and version 2 should be considered as some extensions of version 1. If it's completely, it should use a new class id.
Ok, that makes sense.
Re: [PATCH V4 5/6] virtio: introduce a mdev based transport
In reply to Cornelia HuckQuoted 66 lines · Cornelia Huck
Quoted 49 lines · On Mon, 21 Oct 2019 13:59:23 +0800 Jason Wang <[email protected]> wrote:
Quoted 39 lines · Cornelia Huck
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:35 +0800 Jason Wang <[email protected]> wrote:
This patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of
mdev_parent_opsnow.Signed-off-by Jason Wang <[email protected]>--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+)(...)
Quoted 18 lines
drivers/virtio/virtio_mdev.c new file +18
-0+static int virtio_mdev_probe (struct device *dev) +{ +struct mdev_device *mdev =mdev_from_dev (dev); +const struct virtio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); +struct virtio_mdev_device *vm_dev; +int rc; + + vm_dev =devm_kzalloc (dev,sizeof (*vm_dev),GFP_KERNEL ); +if (!vm_dev) +return -ENOMEM ; + + vm_dev->vdev.dev.parent = dev; + vm_dev->vdev.dev.release = virtio_mdev_release_dev; + vm_dev->vdev.config = &virtio_mdev_config_ops; + vm_dev->mdev = mdev; +INIT_LIST_HEAD (&vm_dev->virtqueues); +spin_lock_init (&vm_dev->lock); +Quoted 8 lines
drivers/virtio/virtio_mdev.c line 356
Quoted 5 lines
drivers/virtio/virtio_mdev.c new file +5
-0+ vm_dev->version = ops->get_mdev_features (mdev); +if (vm_dev->version !=VIRTIO_MDEV_F_VERSION_1 ) { +dev_err (dev,"VIRTIO_MDEV_F_VERSION_1 is mandatory\n" ); +return -ENXIO ; + }Hm, so how is that mdev features interface supposed to work? If
VIRTIO_MDEV_F_VERSION_1is a bit, I would expect this code to test for its presence, and not for identity.Quoted 6 lines
This should be used by driver to detect the which sets of functions and their semantics that could be provided by the device. E.g when driver support both version 2 and version 1 but device only support version 1, driver can switch to use version 1. Btw, Is there a easy way for to test its presence or do you mean doing sanity testing on existence of the mandatory ops that provided by the device?
What I meant was something like:
features =
ops->get_mdev_features(mdev);
if (features &VIRTIO_MDEV_F_VERSION_1)vm_dev->version = 1; else //moan about missing support for version 1
Quoted 6 lines
Can there be class id specific extra features, or is this only for core features? If the latter, maybe also do something like
supported_features=ORED_LIST_OF_FEATURES;
if (features & ~supported_features)//moan about extra feature bits
Consider driver can claim to support a list of ids, so I this it's former.
Will do as what you proposed.
Thanks
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
What will happen if we come up with a version 2? If this is backwards compatible, will both version 2 and version 1 be set?
Yes, I think so, and version 2 should be considered as some extensions of version 1. If it's completely, it should use a new class id.
Ok, that makes sense.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 5/6] virtio: introduce a mdev based transport
In reply to Jason WangQuoted 50 lines · On Mon, 21 Oct 2019 13:59:23 +0800 Jason Wang <[email protected]> wrote:
Quoted 39 lines · Cornelia Huck
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:35 +0800 Jason Wang <[email protected]> wrote:
This patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of
mdev_parent_opsnow.Signed-off-by Jason Wang <[email protected]>--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+)(...)
Quoted 18 lines
drivers/virtio/virtio_mdev.c new file +18
-0+static int virtio_mdev_probe (struct device *dev) +{ +struct mdev_device *mdev =mdev_from_dev (dev); +const struct virtio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); +struct virtio_mdev_device *vm_dev; +int rc; + + vm_dev =devm_kzalloc (dev,sizeof (*vm_dev),GFP_KERNEL ); +if (!vm_dev) +return -ENOMEM ; + + vm_dev->vdev.dev.parent = dev; + vm_dev->vdev.dev.release = virtio_mdev_release_dev; + vm_dev->vdev.config = &virtio_mdev_config_ops; + vm_dev->mdev = mdev; +INIT_LIST_HEAD (&vm_dev->virtqueues); +spin_lock_init (&vm_dev->lock); +Quoted 8 lines
drivers/virtio/virtio_mdev.c line 356
Quoted 5 lines
drivers/virtio/virtio_mdev.c new file +5
-0+ vm_dev->version = ops->get_mdev_features (mdev); +if (vm_dev->version !=VIRTIO_MDEV_F_VERSION_1 ) { +dev_err (dev,"VIRTIO_MDEV_F_VERSION_1 is mandatory\n" ); +return -ENXIO ; + }Hm, so how is that mdev features interface supposed to work? If
VIRTIO_MDEV_F_VERSION_1is a bit, I would expect this code to test for its presence, and not for identity.
Quoted 6 lines
This should be used by driver to detect the which sets of functions and their semantics that could be provided by the device. E.g when driver support both version 2 and version 1 but device only support version 1, driver can switch to use version 1. Btw, Is there a easy way for to test its presence or do you mean doing sanity testing on existence of the mandatory ops that provided by the device?
What I meant was something like:
features = ops->get_mdev_features(mdev);
if (features & VIRTIO_MDEV_F_VERSION_1)
vm_dev->version = 1; else //moan about missing support for version 1
Can there be class id specific extra features, or is this only for core features? If the latter, maybe also do something like
supported_features = ORED_LIST_OF_FEATURES;
if (features & ~supported_features)
//moan about extra feature bits
Quoted 9 lines
Quoted 5 lines
What will happen if we come up with a version 2? If this is backwards compatible, will both version 2 and version 1 be set?
Yes, I think so, and version 2 should be considered as some extensions of version 1. If it's completely, it should use a new class id.
Ok, that makes sense.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 5/6] virtio: introduce a mdev based transport
In reply to Cornelia HuckQuoted 39 lines · Cornelia Huck
Quoted 16 lines · On Thu, 17 Oct 2019 18:48:35 +0800 Jason Wang <[email protected]> wrote:
This patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of
mdev_parent_opsnow.Signed-off-by Jason Wang <[email protected]>--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+)(...)
Quoted 18 lines
drivers/virtio/virtio_mdev.c new file +18
-0+static int virtio_mdev_probe (struct device *dev) +{ +struct mdev_device *mdev =mdev_from_dev (dev); +const struct virtio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); +struct virtio_mdev_device *vm_dev; +int rc; + + vm_dev =devm_kzalloc (dev,sizeof (*vm_dev),GFP_KERNEL ); +if (!vm_dev) +return -ENOMEM ; + + vm_dev->vdev.dev.parent = dev; + vm_dev->vdev.dev.release = virtio_mdev_release_dev; + vm_dev->vdev.config = &virtio_mdev_config_ops; + vm_dev->mdev = mdev; +INIT_LIST_HEAD (&vm_dev->virtqueues); +spin_lock_init (&vm_dev->lock); +
Quoted 8 lines
drivers/virtio/virtio_mdev.c line 356
Quoted 5 lines
drivers/virtio/virtio_mdev.c new file +5
-0+ vm_dev->version = ops->get_mdev_features (mdev); +if (vm_dev->version !=VIRTIO_MDEV_F_VERSION_1 ) { +dev_err (dev,"VIRTIO_MDEV_F_VERSION_1 is mandatory\n" ); +return -ENXIO ; + }Hm, so how is that mdev features interface supposed to work? If
VIRTIO_MDEV_F_VERSION_1is a bit, I would expect this code to test for its presence, and not for identity.
This should be used by driver to detect the which sets of functions and their semantics that could be provided by the device. E.g when driver support both version 2 and version 1 but device only support version 1, driver can switch to use version 1. Btw, Is there a easy way for to test its presence or do you mean doing sanity testing on existence of the mandatory ops that provided by the device?
Quoted 3 lines
What will happen if we come up with a version 2? If this is backwards compatible, will both version 2 and version 1 be set?
Yes, I think so, and version 2 should be considered as some extensions of version 1. If it's completely, it should use a new class id.
Thanks
Quoted 16 lines
Quoted 15 lines
drivers/virtio/virtio_mdev.c new file +14
-0+ + vm_dev->vdev.id.device = ops->get_device_id (mdev); +if (vm_dev->vdev.id.device ==0 ) +return -ENODEV ; + + vm_dev->vdev.id.vendor = ops->get_vendor_id (mdev); + rc =register_virtio_device (&vm_dev->vdev); +if (rc) +put_device (dev); +else +dev_set_drvdata (dev, vm_dev); + +return rc; +}(...)
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Re: [PATCH V4 5/6] virtio: introduce a mdev based transport
In reply to Jason WangQuoted 16 lines · On Thu, 17 Oct 2019 18:48:35 +0800 Jason Wang <[email protected]> wrote:
This patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of
mdev_parent_opsnow.Signed-off-by Jason Wang <[email protected]>--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+)
(...)
Quoted 13 lines
drivers/virtio/virtio_mdev.c new file +13
-0+static int virtio_mdev_probe (struct device *dev) +{ +struct mdev_device *mdev =mdev_from_dev (dev); +const struct virtio_mdev_device_ops *ops =mdev_get_dev_ops (mdev); +struct virtio_mdev_device *vm_dev; +int rc; + + vm_dev =devm_kzalloc (dev,sizeof (*vm_dev),GFP_KERNEL ); +if (!vm_dev) +return -ENOMEM ; + + vm_dev->vdev.dev.parent = dev; + vm_dev->vdev.dev.release = virtio_mdev_release_dev;
drivers/virtio/virtio_mdev.c line 356
Quoted 10 lines
drivers/virtio/virtio_mdev.c new file +10
-0+ vm_dev->vdev.config = &virtio_mdev_config_ops; + vm_dev->mdev = mdev; +INIT_LIST_HEAD (&vm_dev->virtqueues); +spin_lock_init (&vm_dev->lock); + + vm_dev->version = ops->get_mdev_features (mdev); +if (vm_dev->version !=VIRTIO_MDEV_F_VERSION_1 ) { +dev_err (dev,"VIRTIO_MDEV_F_VERSION_1 is mandatory\n" ); +return -ENXIO ; + }
Hm, so how is that mdev features interface supposed to work? If VIRTIO_MDEV_F_VERSION_1 is a bit, I would expect this code to test for its presence, and not for identity.
What will happen if we come up with a version 2? If this is backwards compatible, will both version 2 and version 1 be set?
Quoted 14 lines
drivers/virtio/virtio_mdev.c new file +14
-0+ + vm_dev->vdev.id.device = ops->get_device_id (mdev); +if (vm_dev->vdev.id.device ==0 ) +return -ENODEV ; + + vm_dev->vdev.id.vendor = ops->get_vendor_id (mdev); + rc =register_virtio_device (&vm_dev->vdev); +if (rc) +put_device (dev); +else +dev_set_drvdata (dev, vm_dev); + +return rc; +}
(...)
PATCH v4 5/6 virtio: introduce a mdev based transport
In reply to Jason WangThis patch introduces a new mdev transport for virtio. This is used to use kernel virtio driver to drive the mediated device that is capable of populating virtqueue directly.
A new virtio-mdev driver will be registered to the mdev bus, when a new virtio-mdev device is probed, it will register the device with mdev based config ops. This means it is a software transport between mdev driver and mdev device. The transport was implemented through device specific ops which is a part of mdev_parent_ops now.
--- drivers/virtio/Kconfig | 7 + drivers/virtio/Makefile | 1 + drivers/virtio/virtio_mdev.c | 409 +++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+) create mode 100644 drivers/virtio/virtio_mdev.c
drivers/virtio/Kconfig +7 -0
@@ -43,6 +43,13 @@ config VIRTIO_PCI_LEGACY If unsure, say Y. +config VIRTIO_MDEV_DEVICE + tristate "VIRTIO driver for Mediated devices" + depends on VFIO_MDEV && VIRTIO + default n + help + VIRTIO based driver for Mediated devices. + config VIRTIO_PMEM tristate "Support for virtio pmem driver" depends on VIRTIO
drivers/virtio/Makefile +1 -0
@@ -6,3 +6,4 @@ virtio_pci-y := virtio_pci_modern.o virtio_pci_common.o virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o +obj-$(CONFIG_VIRTIO_MDEV_DEVICE) += virtio_mdev.o
drivers/virtio/virtio_mdev.c new file +409 -0
409 lines not on this page · raw message
Signature · 1 line
2.19.1
PATCH v4 6/6 docs: sample driver to demonstrate how to implement virtio-mdev framework
In reply to Jason WangThis sample driver creates mdev device that simulate virtio net device over virtio mdev transport. The device is implemented through vringh and workqueue. A device specific dma ops is to make sure HVA is used directly as the IOVA. This should be sufficient for kernel virtio driver to work.
Only 'virtio' type is supported right now. I plan to add 'vhost' type on top which requires some virtual IOMMU implemented in this sample driver.
--- MAINTAINERS | 1 + samples/Kconfig | 7 + samples/vfio-mdev/Makefile | 1 + samples/vfio-mdev/mvnet.c | 691 +++++++++++++++++++++++++++++++++++++ 4 files changed, 700 insertions(+) create mode 100644 samples/vfio-mdev/mvnet.c
MAINTAINERS +1 -0
@@ -17254,6 +17254,7 @@ F: include/linux/virtio*.h F: include/uapi/linux/virtio_*.h F: drivers/crypto/virtio/ F: mm/balloon_compaction.c +F: samples/vfio-mdev/mvnet.c VIRTIO BLOCK AND SCSI DRIVERS M: "Michael S. Tsirkin" <[email protected]>
samples/Kconfig +7 -0
@@ -131,6 +131,13 @@ config SAMPLE_VFIO_MDEV_MDPY mediated device. It is a simple framebuffer and supports the region display interface (VFIO_GFX_PLANE_TYPE_REGION). +config SAMPLE_VIRTIO_MDEV_NET + tristate "Build virtio mdev net example mediated device sample code -- loadable modules only" + depends on VIRTIO_MDEV_DEVICE && VHOST_RING && m + help + Build a networking sample device for use as a virtio + mediated device. + config SAMPLE_VFIO_MDEV_MDPY_FB tristate "Build VFIO mdpy example guest fbdev driver -- loadable module only" depends on FB && m
samples/vfio-mdev/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_SAMPLE_VFIO_MDEV_MTTY) += mtty.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY) += mdpy.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY_FB) += mdpy-fb.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MBOCHS) += mbochs.o +obj-$(CONFIG_SAMPLE_VIRTIO_MDEV_NET) += mvnet.o
samples/vfio-mdev/mvnet.c new file +691 -0
691 lines not on this page · raw message
Signature · 6 lines
2.19.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 6/6 docs: sample driver to demonstrate how to implement virtio-mdev framework
In reply to Jason WangThis sample driver creates mdev device that simulate virtio net device over virtio mdev transport. The device is implemented through vringh and workqueue. A device specific dma ops is to make sure HVA is used directly as the IOVA. This should be sufficient for kernel virtio driver to work.
Only 'virtio' type is supported right now. I plan to add 'vhost' type on top which requires some virtual IOMMU implemented in this sample driver.
--- MAINTAINERS | 1 + samples/Kconfig | 7 + samples/vfio-mdev/Makefile | 1 + samples/vfio-mdev/mvnet.c | 691 +++++++++++++++++++++++++++++++++++++ 4 files changed, 700 insertions(+) create mode 100644 samples/vfio-mdev/mvnet.c
MAINTAINERS +1 -0
@@ -17254,6 +17254,7 @@ F: include/linux/virtio*.h F: include/uapi/linux/virtio_*.h F: drivers/crypto/virtio/ F: mm/balloon_compaction.c +F: samples/vfio-mdev/mvnet.c VIRTIO BLOCK AND SCSI DRIVERS M: "Michael S. Tsirkin" <[email protected]>
samples/Kconfig +7 -0
@@ -131,6 +131,13 @@ config SAMPLE_VFIO_MDEV_MDPY mediated device. It is a simple framebuffer and supports the region display interface (VFIO_GFX_PLANE_TYPE_REGION). +config SAMPLE_VIRTIO_MDEV_NET + tristate "Build virtio mdev net example mediated device sample code -- loadable modules only" + depends on VIRTIO_MDEV_DEVICE && VHOST_RING && m + help + Build a networking sample device for use as a virtio + mediated device. + config SAMPLE_VFIO_MDEV_MDPY_FB tristate "Build VFIO mdpy example guest fbdev driver -- loadable module only" depends on FB && m
samples/vfio-mdev/Makefile +1 -0
@@ -3,3 +3,4 @@ obj-$(CONFIG_SAMPLE_VFIO_MDEV_MTTY) += mtty.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY) += mdpy.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY_FB) += mdpy-fb.o obj-$(CONFIG_SAMPLE_VFIO_MDEV_MBOCHS) += mbochs.o +obj-$(CONFIG_SAMPLE_VIRTIO_MDEV_NET) += mvnet.o
samples/vfio-mdev/mvnet.c new file +691 -0
691 lines not on this page · raw message
Signature · 1 line
2.19.1
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for mdev based hardware virtio offloading support (rev5)
In reply to Jason Wang== Series Details ==
== Series Details ==
Series: mdev based hardware virtio offloading support (rev5)
URL : https://patchwork.freedesktop.org/series/66989/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 2d2711d83299 mdev: class id support 335f12f84dd7 modpost: add support for mdev class id 1c27243b07bd mdev: introduce device specific ops -:468: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #468: new file mode 100644
total: 0 errors, 1 warnings, 0 checks, 590 lines checked0cf5dbea3c83 mdev: introduce virtio device and its device ops
-:25: WARNING:AVOID_BUG: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON() #25: FILE: drivers/vfio/mdev/mdev_core.c:66:
+ BUG_ON(mdev->class_id);
-:51: ERROR:CODE_INDENT: code indent should use tabs where possible #51: FILE: include/linux/mdev.h:116:
+ const struct virtio_mdev_device_ops *virtio_ops);$
-:51: WARNING:LEADING_SPACE: please, no spaces at the start of a line #51: FILE: include/linux/mdev.h:116:
+ const struct virtio_mdev_device_ops *virtio_ops);$
-:64: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #64:
new file mode 100644
-:155: WARNING:SPACE_BEFORE_TAB: please, no space before tabs #155: FILE: include/linux/virtio_mdev.h:87:
+ * @get_status: ^I^IGet the device status$
-:158: WARNING:SPACE_BEFORE_TAB: please, no space before tabs #158: FILE: include/linux/virtio_mdev.h:90:
+ * @set_status: ^I^ISet the device status$
-:161: WARNING:SPACE_BEFORE_TAB: please, no space before tabs #161: FILE: include/linux/virtio_mdev.h:93:
+ * @get_config: ^I^IRead from device specific configuration space$
-:168: WARNING:SPACE_BEFORE_TAB: please, no space before tabs #168: FILE: include/linux/virtio_mdev.h:100:
+ * @set_config: ^I^IWrite to device specific configuration space$
total: 1 errors, 7 warnings, 0 checks, 191 lines checked7566405601ce virtio: introduce a mdev based transport
-:26: WARNING:CONFIG_DESCRIPTION: please write a paragraph that describes the config symbol fully #26: FILE: drivers/virtio/Kconfig:46:
+config VIRTIO_MDEV_DEVICE
-:46: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #46:
new file mode 100644
-:106: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' #106: FILE: drivers/virtio/virtio_mdev.c:56:
+static void virtio_mdev_get(struct virtio_device *vdev, unsigned offset,
-:107: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' #107: FILE: drivers/virtio/virtio_mdev.c:57:
+ void *buf, unsigned len)
-:115: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' #115: FILE: drivers/virtio/virtio_mdev.c:65:
+static void virtio_mdev_set(struct virtio_device *vdev, unsigned offset,
-:116: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' #116: FILE: drivers/virtio/virtio_mdev.c:66:
+ const void *buf, unsigned len)
-:183: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' #183: FILE: drivers/virtio/virtio_mdev.c:133:
+virtio_mdev_setup_vq(struct virtio_device *vdev, unsigned index,
-:262: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #262: FILE: drivers/virtio/virtio_mdev.c:212:
+
+}
-:294: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' #294: FILE: drivers/virtio/virtio_mdev.c:244:
+static int virtio_mdev_find_vqs(struct virtio_device *vdev, unsigned nvqs,
total: 0 errors, 8 warnings, 1 checks, 426 lines checked5dd612418610 docs: sample driver to demonstrate how to implement virtio-mdev framework -:39: WARNING:CONFIG_DESCRIPTION: please write a paragraph that describes the config symbol fully #39: FILE: samples/Kconfig:134:
+config SAMPLE_VIRTIO_MDEV_NET
-:59: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #59:
new file mode 100644
-:147: CHECK:UNCOMMENTED_DEFINITION: spinlock_t definition without comment #147: FILE: samples/vfio-mdev/mvnet.c:84:
+ spinlock_t lock;
-:180: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #180: FILE: samples/vfio-mdev/mvnet.c:117:
+ vringh_init_kern(&vq->vring, mvnet_features, MVNET_QUEUE_MAX,
+ false, 0, 0, 0);
-:285: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!addr" #285: FILE: samples/vfio-mdev/mvnet.c:222:
+ if (addr == NULL)
-:288: CHECK:SPACING: No space is necessary after a cast #288: FILE: samples/vfio-mdev/mvnet.c:225:
+ *dma_addr = (dma_addr_t) addr;
-:318: CHECK:ALLOC_SIZEOF_STRUCT: Prefer kzalloc(sizeof(*mvnet)...) over kzalloc(sizeof(struct mvnet_state)...) #318: FILE: samples/vfio-mdev/mvnet.c:255:
+ mvnet = kzalloc(sizeof(struct mvnet_state), GFP_KERNEL);
-:319: CHECK:COMPARISON_TO_NULL: Comparison to NULL could be written "!mvnet" #319: FILE: samples/vfio-mdev/mvnet.c:256:
+ if (mvnet == NULL)
-:375: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #375: FILE: samples/vfio-mdev/mvnet.c:312:
+sample_mvnet_dev_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
total: 0 errors, 2 warnings, 7 checks, 715 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for mdev based hardware virtio offloading support (rev5)
In reply to Jason Wang== Series Details ==
== Series Details ==
Series: mdev based hardware virtio offloading support (rev5)
URL : https://patchwork.freedesktop.org/series/66989/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_7122 -> Patchwork_14857
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/index.html
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_14857:
### IGT changes ###
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* igt@i915_selftest@live_execlists:
- {fi-kbl-soraka}: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/fi-kbl-soraka/igt@i915_selftest@live_execlists.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/fi-kbl-soraka/igt@i915_selftest@live_execlists.html
- {fi-icl-dsi}: [PASS][3] -> [DMESG-FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/fi-icl-dsi/igt@i915_selftest@live_execlists.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/fi-icl-dsi/igt@i915_selftest@live_execlists.html
- {fi-icl-u4}: [PASS][5] -> [DMESG-FAIL][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/fi-icl-u4/igt@i915_selftest@live_execlists.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/fi-icl-u4/igt@i915_selftest@live_execlists.html
Known issues
------------
Here are the changes found in Patchwork_14857 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [PASS][7] -> [DMESG-WARN][8] ([fdo#102614])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/fi-hsw-peppy/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/fi-hsw-peppy/igt@[email protected]
#### Possible fixes ####
* igt@gem_ctx_switch@rcs0:
- {fi-icl-guc}: [INCOMPLETE][9] ([fdo#107713]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/fi-icl-guc/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/fi-icl-guc/igt@[email protected]
* igt@i915_selftest@live_execlists:
- fi-cfl-8109u: [DMESG-FAIL][11] -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/fi-cfl-8109u/igt@i915_selftest@live_execlists.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/fi-cfl-8109u/igt@i915_selftest@live_execlists.html
#### Warnings ####
* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [FAIL][13] ([fdo#111407]) -> [FAIL][14] ([fdo#111045] / [fdo#111096])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/fi-kbl-7500u/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/fi-kbl-7500u/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
[fdo#111096]: https://bugs.freedesktop.org/show_bug.cgi?id=111096
[fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
Participating hosts (53 -> 43)
------------------------------
Missing (10): fi-ilk-m540 fi-tgl-u2 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-skl-6260u fi-icl-u3 fi-icl-y fi-byt-clapper fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_7122 -> Patchwork_14857
CI-20190529: 20190529
CI_DRM_7122: c2f6bdc09f8f046cd38e3c39c92e14e6033dbd44 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5232: bb5735423eaf6fdbf6b2f94ef0b8520e74eab993 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_14857: 5dd612418610a446ab5fa70114a8dbc4be483e2b @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
5dd612418610 docs: sample driver to demonstrate how to implement virtio-mdev framework 7566405601ce virtio: introduce a mdev based transport0cf5dbea3c83 mdev: introduce virtio device and its device ops 1c27243b07bd mdev: introduce device specific ops335f12f84dd7 modpost: add support for mdev class id2d2711d83299 mdev: class id support
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: failure for mdev based hardware virtio offloading support (rev5)
In reply to Jason Wang== Series Details ==
== Series Details ==
Series: mdev based hardware virtio offloading support (rev5)
URL : https://patchwork.freedesktop.org/series/66989/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_7122_full -> Patchwork_14857_full
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_14857_full absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_14857_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_14857_full:
### IGT changes ###
#### Possible regressions ####
* igt@gem_persistent_relocs@forked-thrashing:
- shard-snb: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-snb5/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-snb7/igt@[email protected]
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.
* {igt@kms_cursor_crc@pipe-d-cursor-256x256-sliding}:
- {shard-tglb}: NOTRUN -> [FAIL][3] +4 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-tglb1/igt@[email protected]
* {igt@kms_cursor_crc@pipe-d-cursor-512x170-offscreen}:
- {shard-tglb}: NOTRUN -> [SKIP][4]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-tglb1/igt@[email protected]
* {igt@perf_pmu@semaphore-busy-bcs0}:
- shard-skl: [PASS][5] -> [DMESG-WARN][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-skl4/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-skl2/igt@[email protected]
Known issues
------------
Here are the changes found in Patchwork_14857_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_reuse@single:
- shard-iclb: [PASS][7] -> [INCOMPLETE][8] ([fdo#107713] / [fdo#109100])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb7/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb7/igt@[email protected]
* igt@gem_exec_schedule@preempt-queue-bsd:
- shard-iclb: [PASS][9] -> [SKIP][10] ([fdo#111325]) +6 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb5/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb2/igt@[email protected]
* igt@gem_exec_schedule@preempt-queue-chain-bsd2:
- shard-iclb: [PASS][11] -> [SKIP][12] ([fdo#109276]) +9 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb1/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb5/igt@[email protected]
* igt@gem_userptr_blits@map-fixed-invalidate-overlap-busy:
- shard-hsw: [PASS][13] -> [DMESG-WARN][14] ([fdo#111870])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-hsw4/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-hsw5/igt@[email protected]
* igt@gem_userptr_blits@sync-unmap-after-close:
- shard-snb: [PASS][15] -> [DMESG-WARN][16] ([fdo#111870])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-snb1/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-snb2/igt@[email protected]
* igt@i915_selftest@live_hangcheck:
- shard-hsw: [PASS][17] -> [DMESG-FAIL][18] ([fdo#111991])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-hsw5/igt@i915_selftest@live_hangcheck.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-hsw7/igt@i915_selftest@live_hangcheck.html
* igt@i915_suspend@fence-restore-tiled2untiled:
- shard-snb: [PASS][19] -> [DMESG-WARN][20] ([fdo#102365])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-snb6/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-snb4/igt@[email protected]
* igt@kms_cursor_crc@pipe-b-cursor-256x85-sliding:
- shard-skl: [PASS][21] -> [FAIL][22] ([fdo#103232])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-skl2/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-skl8/igt@[email protected]
* igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions:
- shard-skl: [PASS][23] -> [FAIL][24] ([fdo#102670])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-skl10/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-skl7/igt@[email protected]
* igt@kms_flip@flip-vs-suspend:
- shard-skl: [PASS][25] -> [INCOMPLETE][26] ([fdo#109507])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-skl9/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-skl10/igt@[email protected]
* igt@kms_flip@plain-flip-fb-recreate:
- shard-skl: [PASS][27] -> [FAIL][28] ([fdo#100368])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-skl2/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-skl4/igt@[email protected]
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-wc:
- shard-iclb: [PASS][29] -> [INCOMPLETE][30] ([fdo#107713])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb2/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-wc.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb1/igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-wc.html
* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-draw-render:
- shard-iclb: [PASS][31] -> [FAIL][32] ([fdo#103167]) +2 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb5/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-draw-render.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb6/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-draw-render.html
* igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min:
- shard-skl: [PASS][33] -> [FAIL][34] ([fdo#108145])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-skl2/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-skl8/igt@[email protected]
* igt@kms_psr@psr2_sprite_plane_move:
- shard-iclb: [PASS][35] -> [SKIP][36] ([fdo#109441]) +1 similar issue
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb2/igt@kms_psr@psr2_sprite_plane_move.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb3/igt@kms_psr@psr2_sprite_plane_move.html
* igt@kms_vblank@pipe-a-ts-continuation-suspend:
- shard-apl: [PASS][37] -> [DMESG-WARN][38] ([fdo#108566]) +3 similar issues
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-apl3/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-apl1/igt@[email protected]
* igt@kms_vblank@pipe-c-query-forked-hang:
- shard-apl: [PASS][39] -> [INCOMPLETE][40] ([fdo#103927])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-apl8/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-apl8/igt@[email protected]
#### Possible fixes ####
* igt@gem_exec_schedule@preempt-other-chain-bsd:
- shard-iclb: [SKIP][41] ([fdo#111325]) -> [PASS][42] +6 similar issues
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb1/igt@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb8/igt@[email protected]
* igt@gem_exec_schedule@preempt-queue-bsd1:
- shard-iclb: [SKIP][43] ([fdo#109276]) -> [PASS][44] +18 similar issues
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb3/igt@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb1/igt@[email protected]
* igt@gem_userptr_blits@map-fixed-invalidate-busy-gup:
- shard-apl: [INCOMPLETE][45] ([fdo#103927]) -> [PASS][46] +3 similar issues
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-apl3/igt@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-apl2/igt@[email protected]
* igt@gem_userptr_blits@sync-unmap:
- shard-snb: [DMESG-WARN][47] ([fdo#111870]) -> [PASS][48]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-snb1/igt@[email protected]
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-snb4/igt@[email protected]
* igt@gem_userptr_blits@sync-unmap-after-close:
- shard-hsw: [DMESG-WARN][49] ([fdo#111870]) -> [PASS][50] +1 similar issue
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-hsw7/igt@[email protected]
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-hsw8/igt@[email protected]
* igt@i915_selftest@live_execlists:
- shard-skl: [DMESG-FAIL][51] -> [PASS][52]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-skl9/igt@i915_selftest@live_execlists.html
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-skl4/igt@i915_selftest@live_execlists.html
* igt@i915_suspend@sysfs-reader:
- shard-apl: [DMESG-WARN][53] ([fdo#108566]) -> [PASS][54] +2 similar issues
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-apl2/igt@[email protected]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-apl2/igt@[email protected]
* igt@kms_atomic@crtc_invalid_params:
- shard-snb: [SKIP][55] ([fdo#109271]) -> [PASS][56]
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-snb7/igt@kms_atomic@crtc_invalid_params.html
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-snb5/igt@kms_atomic@crtc_invalid_params.html
* igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
- shard-hsw: [FAIL][57] ([fdo#105767]) -> [PASS][58]
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-hsw6/igt@[email protected]
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-hsw6/igt@[email protected]
* igt@kms_flip@flip-vs-expired-vblank:
- shard-apl: [FAIL][59] ([fdo#105363]) -> [PASS][60]
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-apl6/igt@[email protected]
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-apl6/igt@[email protected]
* igt@kms_flip@flip-vs-suspend-interruptible:
- shard-hsw: [INCOMPLETE][61] ([fdo#103540]) -> [PASS][62]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-hsw5/igt@[email protected]
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-hsw6/igt@[email protected]
* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-cur-indfb-move:
- shard-iclb: [FAIL][63] ([fdo#103167]) -> [PASS][64] +2 similar issues
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb1/igt@[email protected]
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb5/igt@[email protected]
* igt@kms_psr@psr2_cursor_render:
- shard-iclb: [SKIP][65] ([fdo#109441]) -> [PASS][66] +4 similar issues
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb6/igt@kms_psr@psr2_cursor_render.html
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb2/igt@kms_psr@psr2_cursor_render.html
#### Warnings ####
* igt@gem_ctx_isolation@vcs1-nonpriv:
- shard-iclb: [SKIP][67] ([fdo#109276]) -> [FAIL][68] ([fdo#111329])
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb7/igt@[email protected]
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb2/igt@[email protected]
* igt@gem_mocs_settings@mocs-isolation-bsd2:
- shard-iclb: [FAIL][69] ([fdo#111330]) -> [SKIP][70] ([fdo#109276])
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb1/igt@[email protected]
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb6/igt@[email protected]
* igt@gem_mocs_settings@mocs-reset-bsd2:
- shard-iclb: [SKIP][71] ([fdo#109276]) -> [FAIL][72] ([fdo#111330]) +2 similar issues
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7122/shard-iclb5/igt@[email protected]
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/shard-iclb4/igt@[email protected]
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#100368]: https://bugs.freedesktop.org/show_bug.cgi?id=100368
[fdo#102365]: https://bugs.freedesktop.org/show_bug.cgi?id=102365
[fdo#102670]: https://bugs.freedesktop.org/show_bug.cgi?id=102670
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
[fdo#105767]: https://bugs.freedesktop.org/show_bug.cgi?id=105767
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[fdo#109507]: https://bugs.freedesktop.org/show_bug.cgi?id=109507
[fdo#110548]: https://bugs.freedesktop.org/show_bug.cgi?id=110548
[fdo#111325]: https://bugs.freedesktop.org/show_bug.cgi?id=111325
[fdo#111329]: https://bugs.freedesktop.org/show_bug.cgi?id=111329
[fdo#111330]: https://bugs.freedesktop.org/show_bug.cgi?id=111330
[fdo#111703]: https://bugs.freedesktop.org/show_bug.cgi?id=111703
[fdo#111832]: https://bugs.freedesktop.org/show_bug.cgi?id=111832
[fdo#111850]: https://bugs.freedesktop.org/show_bug.cgi?id=111850
[fdo#111870]: https://bugs.freedesktop.org/show_bug.cgi?id=111870
[fdo#111991]: https://bugs.freedesktop.org/show_bug.cgi?id=111991
Participating hosts (11 -> 11)
------------------------------
No changes in participating hosts
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_7122 -> Patchwork_14857
CI-20190529: 20190529
CI_DRM_7122: c2f6bdc09f8f046cd38e3c39c92e14e6033dbd44 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5232: bb5735423eaf6fdbf6b2f94ef0b8520e74eab993 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_14857: 5dd612418610a446ab5fa70114a8dbc4be483e2b @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14857/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx