Commit 4a725b8d authored by Kevin Tian's avatar Kevin Tian Committed by Alex Williamson

vfio: Rename vfio_device_put() and vfio_device_try_get()

With the addition of vfio_put_device() now the names become confusing.

vfio_put_device() is clear from object life cycle p.o.v given kref.

vfio_device_put()/vfio_device_try_get() are helpers for tracking
users on a registered device.

Now rename them:

 - vfio_device_put() -> vfio_device_put_registration()
 - vfio_device_try_get() -> vfio_device_try_get_registration()
Signed-off-by: default avatarKevin Tian <kevin.tian@intel.com>
Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
Link: https://lore.kernel.org/r/20220921104401.38898-15-kevin.tian@intel.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent ebb72b76
...@@ -453,13 +453,13 @@ static void vfio_group_get(struct vfio_group *group) ...@@ -453,13 +453,13 @@ static void vfio_group_get(struct vfio_group *group)
* Device objects - create, release, get, put, search * Device objects - create, release, get, put, search
*/ */
/* Device reference always implies a group reference */ /* Device reference always implies a group reference */
static void vfio_device_put(struct vfio_device *device) static void vfio_device_put_registration(struct vfio_device *device)
{ {
if (refcount_dec_and_test(&device->refcount)) if (refcount_dec_and_test(&device->refcount))
complete(&device->comp); complete(&device->comp);
} }
static bool vfio_device_try_get(struct vfio_device *device) static bool vfio_device_try_get_registration(struct vfio_device *device)
{ {
return refcount_inc_not_zero(&device->refcount); return refcount_inc_not_zero(&device->refcount);
} }
...@@ -471,7 +471,8 @@ static struct vfio_device *vfio_group_get_device(struct vfio_group *group, ...@@ -471,7 +471,8 @@ static struct vfio_device *vfio_group_get_device(struct vfio_group *group,
mutex_lock(&group->device_lock); mutex_lock(&group->device_lock);
list_for_each_entry(device, &group->device_list, group_next) { list_for_each_entry(device, &group->device_list, group_next) {
if (device->dev == dev && vfio_device_try_get(device)) { if (device->dev == dev &&
vfio_device_try_get_registration(device)) {
mutex_unlock(&group->device_lock); mutex_unlock(&group->device_lock);
return device; return device;
} }
...@@ -673,7 +674,7 @@ static int __vfio_register_dev(struct vfio_device *device, ...@@ -673,7 +674,7 @@ static int __vfio_register_dev(struct vfio_device *device,
if (existing_device) { if (existing_device) {
dev_WARN(device->dev, "Device already exists on group %d\n", dev_WARN(device->dev, "Device already exists on group %d\n",
iommu_group_id(group->iommu_group)); iommu_group_id(group->iommu_group));
vfio_device_put(existing_device); vfio_device_put_registration(existing_device);
if (group->type == VFIO_NO_IOMMU || if (group->type == VFIO_NO_IOMMU ||
group->type == VFIO_EMULATED_IOMMU) group->type == VFIO_EMULATED_IOMMU)
iommu_group_remove_device(device->dev); iommu_group_remove_device(device->dev);
...@@ -731,7 +732,7 @@ static struct vfio_device *vfio_device_get_from_name(struct vfio_group *group, ...@@ -731,7 +732,7 @@ static struct vfio_device *vfio_device_get_from_name(struct vfio_group *group,
ret = !strcmp(dev_name(it->dev), buf); ret = !strcmp(dev_name(it->dev), buf);
} }
if (ret && vfio_device_try_get(it)) { if (ret && vfio_device_try_get_registration(it)) {
device = it; device = it;
break; break;
} }
...@@ -751,7 +752,7 @@ void vfio_unregister_group_dev(struct vfio_device *device) ...@@ -751,7 +752,7 @@ void vfio_unregister_group_dev(struct vfio_device *device)
bool interrupted = false; bool interrupted = false;
long rc; long rc;
vfio_device_put(device); vfio_device_put_registration(device);
rc = try_wait_for_completion(&device->comp); rc = try_wait_for_completion(&device->comp);
while (rc <= 0) { while (rc <= 0) {
if (device->ops->request) if (device->ops->request)
...@@ -1311,7 +1312,7 @@ static int vfio_group_ioctl_get_device_fd(struct vfio_group *group, ...@@ -1311,7 +1312,7 @@ static int vfio_group_ioctl_get_device_fd(struct vfio_group *group,
err_put_fdno: err_put_fdno:
put_unused_fd(fdno); put_unused_fd(fdno);
err_put_device: err_put_device:
vfio_device_put(device); vfio_device_put_registration(device);
return ret; return ret;
} }
...@@ -1493,7 +1494,7 @@ static int vfio_device_fops_release(struct inode *inode, struct file *filep) ...@@ -1493,7 +1494,7 @@ static int vfio_device_fops_release(struct inode *inode, struct file *filep)
vfio_device_unassign_container(device); vfio_device_unassign_container(device);
vfio_device_put(device); vfio_device_put_registration(device);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment