mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-21 17:11:57 -06:00
vfio: add vfio_device_unprepare()
Add a helper that's the inverse of vfio_device_prepare(). Reviewed-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: John Levon <john.levon@nutanix.com> Link: https://lore.kernel.org/qemu-devel/20250507152020.1254632-3-john.levon@nutanix.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
parent
a901682f53
commit
d60fb709cf
4 changed files with 13 additions and 6 deletions
|
@ -927,10 +927,10 @@ static void vfio_legacy_detach_device(VFIODevice *vbasedev)
|
||||||
{
|
{
|
||||||
VFIOGroup *group = vbasedev->group;
|
VFIOGroup *group = vbasedev->group;
|
||||||
|
|
||||||
QLIST_REMOVE(vbasedev, global_next);
|
|
||||||
QLIST_REMOVE(vbasedev, container_next);
|
|
||||||
vbasedev->bcontainer = NULL;
|
|
||||||
trace_vfio_device_detach(vbasedev->name, group->groupid);
|
trace_vfio_device_detach(vbasedev->name, group->groupid);
|
||||||
|
|
||||||
|
vfio_device_unprepare(vbasedev);
|
||||||
|
|
||||||
object_unref(vbasedev->hiod);
|
object_unref(vbasedev->hiod);
|
||||||
vfio_device_put(vbasedev);
|
vfio_device_put(vbasedev);
|
||||||
vfio_group_put(group);
|
vfio_group_put(group);
|
||||||
|
|
|
@ -412,3 +412,10 @@ void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainerBase *bcontainer,
|
||||||
|
|
||||||
QLIST_INSERT_HEAD(&vfio_device_list, vbasedev, global_next);
|
QLIST_INSERT_HEAD(&vfio_device_list, vbasedev, global_next);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void vfio_device_unprepare(VFIODevice *vbasedev)
|
||||||
|
{
|
||||||
|
QLIST_REMOVE(vbasedev, container_next);
|
||||||
|
QLIST_REMOVE(vbasedev, global_next);
|
||||||
|
vbasedev->bcontainer = NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -615,9 +615,7 @@ static void iommufd_cdev_detach(VFIODevice *vbasedev)
|
||||||
VFIOIOMMUFDContainer *container = container_of(bcontainer,
|
VFIOIOMMUFDContainer *container = container_of(bcontainer,
|
||||||
VFIOIOMMUFDContainer,
|
VFIOIOMMUFDContainer,
|
||||||
bcontainer);
|
bcontainer);
|
||||||
QLIST_REMOVE(vbasedev, global_next);
|
vfio_device_unprepare(vbasedev);
|
||||||
QLIST_REMOVE(vbasedev, container_next);
|
|
||||||
vbasedev->bcontainer = NULL;
|
|
||||||
|
|
||||||
if (!vbasedev->ram_block_discard_allowed) {
|
if (!vbasedev->ram_block_discard_allowed) {
|
||||||
iommufd_cdev_ram_block_discard_disable(false);
|
iommufd_cdev_ram_block_discard_disable(false);
|
||||||
|
|
|
@ -137,6 +137,8 @@ extern VFIODeviceList vfio_device_list;
|
||||||
void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainerBase *bcontainer,
|
void vfio_device_prepare(VFIODevice *vbasedev, VFIOContainerBase *bcontainer,
|
||||||
struct vfio_device_info *info);
|
struct vfio_device_info *info);
|
||||||
|
|
||||||
|
void vfio_device_unprepare(VFIODevice *vbasedev);
|
||||||
|
|
||||||
int vfio_device_get_region_info(VFIODevice *vbasedev, int index,
|
int vfio_device_get_region_info(VFIODevice *vbasedev, int index,
|
||||||
struct vfio_region_info **info);
|
struct vfio_region_info **info);
|
||||||
int vfio_device_get_region_info_type(VFIODevice *vbasedev, uint32_t type,
|
int vfio_device_get_region_info_type(VFIODevice *vbasedev, uint32_t type,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue