vfio: Remove vfio_free_device
With the "mess" sorted out, we should be able to inline the
vfio_free_device call introduced by commit cb9ff3f3b8
("vfio: Add helpers for unifying vfio_device life cycle")
and remove them from driver release callbacks.
Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com> # vfio-ap part
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Link: https://lore.kernel.org/r/20221104142007.1314999-8-farman@linux.ibm.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
parent
d1104f9327
commit
913447d06f
|
@ -1461,7 +1461,6 @@ static void intel_vgpu_release_dev(struct vfio_device *vfio_dev)
|
||||||
struct intel_vgpu *vgpu = vfio_dev_to_vgpu(vfio_dev);
|
struct intel_vgpu *vgpu = vfio_dev_to_vgpu(vfio_dev);
|
||||||
|
|
||||||
intel_gvt_destroy_vgpu(vgpu);
|
intel_gvt_destroy_vgpu(vgpu);
|
||||||
vfio_free_device(vfio_dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct vfio_device_ops intel_vgpu_dev_ops = {
|
static const struct vfio_device_ops intel_vgpu_dev_ops = {
|
||||||
|
|
|
@ -143,8 +143,6 @@ static void vfio_ccw_mdev_release_dev(struct vfio_device *vdev)
|
||||||
kmem_cache_free(vfio_ccw_io_region, private->io_region);
|
kmem_cache_free(vfio_ccw_io_region, private->io_region);
|
||||||
kfree(private->cp.guest_cp);
|
kfree(private->cp.guest_cp);
|
||||||
mutex_destroy(&private->io_mutex);
|
mutex_destroy(&private->io_mutex);
|
||||||
|
|
||||||
vfio_free_device(vdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_ccw_mdev_remove(struct mdev_device *mdev)
|
static void vfio_ccw_mdev_remove(struct mdev_device *mdev)
|
||||||
|
|
|
@ -765,11 +765,6 @@ static void vfio_ap_mdev_unlink_fr_queues(struct ap_matrix_mdev *matrix_mdev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_ap_mdev_release_dev(struct vfio_device *vdev)
|
|
||||||
{
|
|
||||||
vfio_free_device(vdev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vfio_ap_mdev_remove(struct mdev_device *mdev)
|
static void vfio_ap_mdev_remove(struct mdev_device *mdev)
|
||||||
{
|
{
|
||||||
struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(&mdev->dev);
|
struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(&mdev->dev);
|
||||||
|
@ -1784,7 +1779,6 @@ static const struct attribute_group vfio_queue_attr_group = {
|
||||||
|
|
||||||
static const struct vfio_device_ops vfio_ap_matrix_dev_ops = {
|
static const struct vfio_device_ops vfio_ap_matrix_dev_ops = {
|
||||||
.init = vfio_ap_mdev_init_dev,
|
.init = vfio_ap_mdev_init_dev,
|
||||||
.release = vfio_ap_mdev_release_dev,
|
|
||||||
.open_device = vfio_ap_mdev_open_device,
|
.open_device = vfio_ap_mdev_open_device,
|
||||||
.close_device = vfio_ap_mdev_close_device,
|
.close_device = vfio_ap_mdev_close_device,
|
||||||
.ioctl = vfio_ap_mdev_ioctl,
|
.ioctl = vfio_ap_mdev_ioctl,
|
||||||
|
|
|
@ -568,7 +568,6 @@ static void vfio_fsl_mc_release_dev(struct vfio_device *core_vdev)
|
||||||
|
|
||||||
vfio_fsl_uninit_device(vdev);
|
vfio_fsl_uninit_device(vdev);
|
||||||
mutex_destroy(&vdev->igate);
|
mutex_destroy(&vdev->igate);
|
||||||
vfio_free_device(core_vdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_fsl_mc_remove(struct fsl_mc_device *mc_dev)
|
static int vfio_fsl_mc_remove(struct fsl_mc_device *mc_dev)
|
||||||
|
|
|
@ -2109,7 +2109,6 @@ void vfio_pci_core_release_dev(struct vfio_device *core_vdev)
|
||||||
mutex_destroy(&vdev->vma_lock);
|
mutex_destroy(&vdev->vma_lock);
|
||||||
kfree(vdev->region);
|
kfree(vdev->region);
|
||||||
kfree(vdev->pm_save);
|
kfree(vdev->pm_save);
|
||||||
vfio_free_device(core_vdev);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(vfio_pci_core_release_dev);
|
EXPORT_SYMBOL_GPL(vfio_pci_core_release_dev);
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,6 @@ static void vfio_amba_release_dev(struct vfio_device *core_vdev)
|
||||||
|
|
||||||
vfio_platform_release_common(vdev);
|
vfio_platform_release_common(vdev);
|
||||||
kfree(vdev->name);
|
kfree(vdev->name);
|
||||||
vfio_free_device(core_vdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vfio_amba_remove(struct amba_device *adev)
|
static void vfio_amba_remove(struct amba_device *adev)
|
||||||
|
|
|
@ -83,7 +83,6 @@ static void vfio_platform_release_dev(struct vfio_device *core_vdev)
|
||||||
container_of(core_vdev, struct vfio_platform_device, vdev);
|
container_of(core_vdev, struct vfio_platform_device, vdev);
|
||||||
|
|
||||||
vfio_platform_release_common(vdev);
|
vfio_platform_release_common(vdev);
|
||||||
vfio_free_device(core_vdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_platform_remove(struct platform_device *pdev)
|
static int vfio_platform_remove(struct platform_device *pdev)
|
||||||
|
|
|
@ -339,13 +339,10 @@ static void vfio_device_release(struct device *dev)
|
||||||
vfio_release_device_set(device);
|
vfio_release_device_set(device);
|
||||||
ida_free(&vfio.device_ida, device->index);
|
ida_free(&vfio.device_ida, device->index);
|
||||||
|
|
||||||
/*
|
if (device->ops->release)
|
||||||
* kvfree() cannot be done here due to a life cycle mess in
|
device->ops->release(device);
|
||||||
* vfio-ccw. Before the ccw part is fixed all drivers are
|
|
||||||
* required to support @release and call vfio_free_device()
|
kvfree(device);
|
||||||
* from there.
|
|
||||||
*/
|
|
||||||
device->ops->release(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vfio_init_device(struct vfio_device *device, struct device *dev,
|
static int vfio_init_device(struct vfio_device *device, struct device *dev,
|
||||||
|
@ -424,17 +421,6 @@ out_uninit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* The helper called by driver @release callback to free the device
|
|
||||||
* structure. Drivers which don't have private data to clean can
|
|
||||||
* simply use this helper as its @release.
|
|
||||||
*/
|
|
||||||
void vfio_free_device(struct vfio_device *device)
|
|
||||||
{
|
|
||||||
kvfree(device);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL_GPL(vfio_free_device);
|
|
||||||
|
|
||||||
static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev,
|
static struct vfio_group *vfio_noiommu_group_alloc(struct device *dev,
|
||||||
enum vfio_group_type type)
|
enum vfio_group_type type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -176,7 +176,6 @@ struct vfio_device *_vfio_alloc_device(size_t size, struct device *dev,
|
||||||
dev, ops), \
|
dev, ops), \
|
||||||
struct dev_struct, member)
|
struct dev_struct, member)
|
||||||
|
|
||||||
void vfio_free_device(struct vfio_device *device);
|
|
||||||
static inline void vfio_put_device(struct vfio_device *device)
|
static inline void vfio_put_device(struct vfio_device *device)
|
||||||
{
|
{
|
||||||
put_device(&device->device);
|
put_device(&device->device);
|
||||||
|
|
|
@ -594,7 +594,6 @@ static void mbochs_release_dev(struct vfio_device *vdev)
|
||||||
atomic_add(mdev_state->type->mbytes, &mbochs_avail_mbytes);
|
atomic_add(mdev_state->type->mbytes, &mbochs_avail_mbytes);
|
||||||
kfree(mdev_state->pages);
|
kfree(mdev_state->pages);
|
||||||
kfree(mdev_state->vconfig);
|
kfree(mdev_state->vconfig);
|
||||||
vfio_free_device(vdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mbochs_remove(struct mdev_device *mdev)
|
static void mbochs_remove(struct mdev_device *mdev)
|
||||||
|
|
|
@ -283,7 +283,6 @@ static void mdpy_release_dev(struct vfio_device *vdev)
|
||||||
|
|
||||||
vfree(mdev_state->memblk);
|
vfree(mdev_state->memblk);
|
||||||
kfree(mdev_state->vconfig);
|
kfree(mdev_state->vconfig);
|
||||||
vfio_free_device(vdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mdpy_remove(struct mdev_device *mdev)
|
static void mdpy_remove(struct mdev_device *mdev)
|
||||||
|
|
|
@ -784,7 +784,6 @@ static void mtty_release_dev(struct vfio_device *vdev)
|
||||||
|
|
||||||
atomic_add(mdev_state->nr_ports, &mdev_avail_ports);
|
atomic_add(mdev_state->nr_ports, &mdev_avail_ports);
|
||||||
kfree(mdev_state->vconfig);
|
kfree(mdev_state->vconfig);
|
||||||
vfio_free_device(vdev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mtty_remove(struct mdev_device *mdev)
|
static void mtty_remove(struct mdev_device *mdev)
|
||||||
|
|
Loading…
Reference in New Issue