mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-05-01 15:15:19 -04:00
vfio: Move vfio_iommu_group_get() to vfio_register_group_dev()
We don't need to hold a reference to the group in the driver as well as obtain a reference to the same group as the first thing vfio_register_group_dev() does. Since the drivers never use the group move this all into the core code. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Link: https://lore.kernel.org/r/20210924155705.4258-2-hch@lst.de Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
committed by
Alex Williamson
parent
5816b3e657
commit
38a68934aa
@@ -642,7 +642,6 @@ static int vfio_platform_of_probe(struct vfio_platform_device *vdev,
|
||||
int vfio_platform_probe_common(struct vfio_platform_device *vdev,
|
||||
struct device *dev)
|
||||
{
|
||||
struct iommu_group *group;
|
||||
int ret;
|
||||
|
||||
vfio_init_group_dev(&vdev->vdev, dev, &vfio_platform_ops);
|
||||
@@ -663,24 +662,15 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
|
||||
goto out_uninit;
|
||||
}
|
||||
|
||||
group = vfio_iommu_group_get(dev);
|
||||
if (!group) {
|
||||
dev_err(dev, "No IOMMU group for device %s\n", vdev->name);
|
||||
ret = -EINVAL;
|
||||
goto put_reset;
|
||||
}
|
||||
|
||||
ret = vfio_register_group_dev(&vdev->vdev);
|
||||
if (ret)
|
||||
goto put_iommu;
|
||||
goto put_reset;
|
||||
|
||||
mutex_init(&vdev->igate);
|
||||
|
||||
pm_runtime_enable(dev);
|
||||
return 0;
|
||||
|
||||
put_iommu:
|
||||
vfio_iommu_group_put(group, dev);
|
||||
put_reset:
|
||||
vfio_platform_put_reset(vdev);
|
||||
out_uninit:
|
||||
@@ -696,7 +686,6 @@ void vfio_platform_remove_common(struct vfio_platform_device *vdev)
|
||||
pm_runtime_disable(vdev->device);
|
||||
vfio_platform_put_reset(vdev);
|
||||
vfio_uninit_group_dev(&vdev->vdev);
|
||||
vfio_iommu_group_put(vdev->vdev.dev->iommu_group, vdev->vdev.dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vfio_platform_remove_common);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user