vfio: Rename vfio_device_put() and vfio_device_try_get()
ANBZ: #10925
commit 4a725b8de4
upstream.
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: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Link:
https://lore.kernel.org/r/20220921104401.38898-15-kevin.tian@intel.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Qinyun Tan <qinyuntan@linux.alibaba.com>
Reviewed-by: Guanghui Feng <guanghuifeng@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/5474
This commit is contained in:
parent
2eb10dcc63
commit
e19c0b65fe
|
@ -686,7 +686,7 @@ static void kvmgt_put_vfio_device(void *vgpu)
|
|||
if (WARN_ON(!vdev->vfio_device))
|
||||
return;
|
||||
|
||||
vfio_device_put(vdev->vfio_device);
|
||||
vfio_device_put_registration(vdev->vfio_device);
|
||||
}
|
||||
|
||||
static int intel_vgpu_create(struct mdev_device *mdev)
|
||||
|
|
|
@ -2205,7 +2205,7 @@ static ssize_t vstatus_show(struct device *dev, struct device_attribute *attr, c
|
|||
|
||||
open_count = vdev->open_count;
|
||||
|
||||
vfio_device_put(vdev);
|
||||
vfio_device_put_registration(vdev);
|
||||
|
||||
return sprintf(buf, "%u\n", open_count);
|
||||
}
|
||||
|
@ -2350,7 +2350,7 @@ pci_ers_result_t vfio_pci_core_aer_err_detected(struct pci_dev *pdev,
|
|||
|
||||
mutex_unlock(&vdev->igate);
|
||||
|
||||
vfio_device_put(device);
|
||||
vfio_device_put_registration(device);
|
||||
|
||||
return PCI_ERS_RESULT_CAN_RECOVER;
|
||||
}
|
||||
|
@ -2399,7 +2399,7 @@ out_del:
|
|||
out_unlock:
|
||||
mutex_unlock(&vfio_pci_sriov_pfs_mutex);
|
||||
out_put:
|
||||
vfio_device_put(device);
|
||||
vfio_device_put_registration(device);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vfio_pci_core_sriov_configure);
|
||||
|
|
|
@ -598,14 +598,14 @@ static struct vfio_group *vfio_group_get_from_dev(struct device *dev)
|
|||
* Device objects - create, release, get, put, search
|
||||
*/
|
||||
/* Device reference always implies a group reference */
|
||||
void vfio_device_put(struct vfio_device *device)
|
||||
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);
|
||||
EXPORT_SYMBOL_GPL(vfio_device_put_registration);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -617,7 +617,8 @@ static struct vfio_device *vfio_group_get_device(struct vfio_group *group,
|
|||
|
||||
mutex_lock(&group->device_lock);
|
||||
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);
|
||||
return device;
|
||||
}
|
||||
|
@ -694,7 +695,7 @@ static int vfio_dev_viable(struct device *dev, void *data)
|
|||
|
||||
device = vfio_group_get_device(group, dev);
|
||||
if (device) {
|
||||
vfio_device_put(device);
|
||||
vfio_device_put_registration(device);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -711,7 +712,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
|
|||
/* Do we already know about it? We shouldn't */
|
||||
device = vfio_group_get_device(group, dev);
|
||||
if (WARN_ON_ONCE(device)) {
|
||||
vfio_device_put(device);
|
||||
vfio_device_put_registration(device);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -958,7 +959,7 @@ int vfio_register_group_dev(struct vfio_device *device)
|
|||
if (existing_device) {
|
||||
dev_WARN(device->dev, "Device already exists on group %d\n",
|
||||
iommu_group_id(iommu_group));
|
||||
vfio_device_put(existing_device);
|
||||
vfio_device_put_registration(existing_device);
|
||||
vfio_group_put(group);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
@ -1020,7 +1021,7 @@ static struct vfio_device *vfio_device_get_from_name(struct vfio_group *group,
|
|||
ret = !strcmp(dev_name(it->dev), buf);
|
||||
}
|
||||
|
||||
if (ret && vfio_device_try_get(it)) {
|
||||
if (ret && vfio_device_try_get_registration(it)) {
|
||||
device = it;
|
||||
break;
|
||||
}
|
||||
|
@ -1059,7 +1060,7 @@ void vfio_unregister_group_dev(struct vfio_device *device)
|
|||
}
|
||||
WARN_ON(!unbound);
|
||||
|
||||
vfio_device_put(device);
|
||||
vfio_device_put_registration(device);
|
||||
rc = try_wait_for_completion(&device->comp);
|
||||
while (rc <= 0) {
|
||||
if (device->ops->request)
|
||||
|
@ -1601,7 +1602,7 @@ err_undo_count:
|
|||
mutex_unlock(&device->dev_set->lock);
|
||||
module_put(device->dev->driver->owner);
|
||||
err_device_put:
|
||||
vfio_device_put(device);
|
||||
vfio_device_put_registration(device);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1748,7 +1749,7 @@ static int vfio_device_fops_release(struct inode *inode, struct file *filep)
|
|||
|
||||
vfio_group_try_dissolve_container(device->group);
|
||||
|
||||
vfio_device_put(device);
|
||||
vfio_device_put_registration(device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ void vfio_uninit_group_dev(struct vfio_device *device);
|
|||
int vfio_register_group_dev(struct vfio_device *device);
|
||||
void vfio_unregister_group_dev(struct vfio_device *device);
|
||||
extern struct vfio_device *vfio_device_get_from_dev(struct device *dev);
|
||||
extern void vfio_device_put(struct vfio_device *device);
|
||||
extern void vfio_device_put_registration(struct vfio_device *device);
|
||||
|
||||
int vfio_assign_device_set(struct vfio_device *device, void *set_id);
|
||||
|
||||
|
|
Loading…
Reference in New Issue