diff options
author | Jason Gunthorpe <[email protected]> | 2021-03-30 09:53:05 -0600 |
---|---|---|
committer | Alex Williamson <[email protected]> | 2021-04-06 11:55:10 -0600 |
commit | 0bfc6a4ea63c2adac71a824397ef48f28dbc5e47 (patch) | |
tree | 2bc5ba0a34d54f7dece5067b4fa435588507d3e2 /scripts/gdb/linux/timerlist.py | |
parent | 5e42c999445bd0ae86e35affeb3e7c473d74a893 (diff) |
vfio: Split creation of a vfio_device into init and register ops
This makes the struct vfio_device part of the public interface so it
can be used with container_of and so forth, as is typical for a Linux
subystem.
This is the first step to bring some type-safety to the vfio interface by
allowing the replacement of 'void *' and 'struct device *' inputs with a
simple and clear 'struct vfio_device *'
For now the self-allocating vfio_add_group_dev() interface is kept so each
user can be updated as a separate patch.
The expected usage pattern is
driver core probe() function:
my_device = kzalloc(sizeof(*mydevice));
vfio_init_group_dev(&my_device->vdev, dev, ops, mydevice);
/* other driver specific prep */
vfio_register_group_dev(&my_device->vdev);
dev_set_drvdata(dev, my_device);
driver core remove() function:
my_device = dev_get_drvdata(dev);
vfio_unregister_group_dev(&my_device->vdev);
/* other driver specific tear down */
kfree(my_device);
Allowing the driver to be able to use the drvdata and vfio_device to go
to/from its own data.
The pattern also makes it clear that vfio_register_group_dev() must be
last in the sequence, as once it is called the core code can immediately
start calling ops. The init/register gap is provided to allow for the
driver to do setup before ops can be called and thus avoid races.
Reviewed-by: Christoph Hellwig <[email protected]>
Reviewed-by: Liu Yi L <[email protected]>
Reviewed-by: Cornelia Huck <[email protected]>
Reviewed-by: Max Gurtovoy <[email protected]>
Reviewed-by: Kevin Tian <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Alex Williamson <[email protected]>
Diffstat (limited to 'scripts/gdb/linux/timerlist.py')
0 files changed, 0 insertions, 0 deletions