[PATCH 1/4] vfio: Add vfio_device_get()
Wei Lin Guay
wguay at fb.com
Mon Dec 16 09:54:15 UTC 2024
From: Jason Gunthorpe <jgg at nvidia.com>
Summary:
To increment a reference the caller already holds. Export
vfio_device_put() to pair with it.
Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>
Signed-off-by: Wei Lin Guay <wguay at meta.com>
Reviewed-by: Dag Moxnes <dagmoxnes at meta.com>
Reviewed-by: Keith Busch <kbusch at kernel.org>
Reviewed-by: Nic Viljoen <nviljoen at meta.com>
---
drivers/vfio/vfio_main.c | 1 +
include/linux/vfio.h | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/drivers/vfio/vfio_main.c b/drivers/vfio/vfio_main.c
index a5a62d9d963f..7e318e15abd5 100644
--- a/drivers/vfio/vfio_main.c
+++ b/drivers/vfio/vfio_main.c
@@ -171,6 +171,7 @@ 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)
{
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 000a6cab2d31..d7c790be4bbc 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -279,6 +279,12 @@ 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);
+void vfio_device_put_registration(struct vfio_device *device);
+
+static inline void vfio_device_get(struct vfio_device *device)
+{
+ refcount_inc(&device->refcount);
+}
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);
--
2.43.5
More information about the dri-devel
mailing list