Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vfio: Export vfio device get and put registration helpers

These helpers are useful for managing additional references taken
on the device from other associated VFIO modules.

Original-patch-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Tested-by: Alex Mastro <amastro@fb.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Ankit Agrawal <ankita@nvidia.com>
Link: https://lore.kernel.org/r/20251120-dmabuf-vfio-v9-7-d7f71607f371@nvidia.com
Signed-off-by: Alex Williamson <alex@shazbot.org>

authored by

Vivek Kasireddy and committed by
Alex Williamson
64a5dedc 3aa31a8b

+4
+2
drivers/vfio/vfio_main.c
··· 172 172 if (refcount_dec_and_test(&device->refcount)) 173 173 complete(&device->comp); 174 174 } 175 + EXPORT_SYMBOL_GPL(vfio_device_put_registration); 175 176 176 177 bool vfio_device_try_get_registration(struct vfio_device *device) 177 178 { 178 179 return refcount_inc_not_zero(&device->refcount); 179 180 } 181 + EXPORT_SYMBOL_GPL(vfio_device_try_get_registration); 180 182 181 183 /* 182 184 * VFIO driver API
+2
include/linux/vfio.h
··· 297 297 int vfio_register_group_dev(struct vfio_device *device); 298 298 int vfio_register_emulated_iommu_dev(struct vfio_device *device); 299 299 void vfio_unregister_group_dev(struct vfio_device *device); 300 + bool vfio_device_try_get_registration(struct vfio_device *device); 301 + void vfio_device_put_registration(struct vfio_device *device); 300 302 301 303 int vfio_assign_device_set(struct vfio_device *device, void *set_id); 302 304 unsigned int vfio_device_set_open_count(struct vfio_device_set *dev_set);