]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
vfio: Export vfio device get and put registration helpers
authorVivek Kasireddy <vivek.kasireddy@intel.com>
Thu, 20 Nov 2025 09:28:26 +0000 (11:28 +0200)
committerAlex Williamson <alex@shazbot.org>
Thu, 20 Nov 2025 19:02:32 +0000 (12:02 -0700)
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>
drivers/vfio/vfio_main.c
include/linux/vfio.h

index 38c8e9350a60ecae779a879f9db5daf05773ad8d..9aa4a5d081e8f00c757ca47bf1cb167cd0925e78 100644 (file)
@@ -172,11 +172,13 @@ void vfio_device_put_registration(struct vfio_device *device)
        if (refcount_dec_and_test(&device->refcount))
                complete(&device->comp);
 }
+EXPORT_SYMBOL_GPL(vfio_device_put_registration);
 
 bool vfio_device_try_get_registration(struct vfio_device *device)
 {
        return refcount_inc_not_zero(&device->refcount);
 }
+EXPORT_SYMBOL_GPL(vfio_device_try_get_registration);
 
 /*
  * VFIO driver API
index eb563f538dee519c8930d55bfc5f84bdc99bf44f..217ba4ef17522215a29523d775e47a62b3f684a3 100644 (file)
@@ -297,6 +297,8 @@ static inline void vfio_put_device(struct vfio_device *device)
 int vfio_register_group_dev(struct vfio_device *device);
 int vfio_register_emulated_iommu_dev(struct vfio_device *device);
 void vfio_unregister_group_dev(struct vfio_device *device);
+bool vfio_device_try_get_registration(struct vfio_device *device);
+void vfio_device_put_registration(struct vfio_device *device);
 
 int vfio_assign_device_set(struct vfio_device *device, void *set_id);
 unsigned int vfio_device_set_open_count(struct vfio_device_set *dev_set);