Commit 429a781c authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Alex Williamson

vfio: Rename __vfio_group_unset_container()

To vfio_group_detach_container(). This function is really a container
function.

Fold the WARN_ON() into it as a precondition assertion.

A following patch will move the vfio_container functions to their own .c
file.
Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/2-v3-297af71838d2+b9-vfio_container_split_jgg@nvidia.comSigned-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent e3bb4de0
...@@ -1036,12 +1036,13 @@ static const struct file_operations vfio_fops = { ...@@ -1036,12 +1036,13 @@ static const struct file_operations vfio_fops = {
/* /*
* VFIO Group fd, /dev/vfio/$GROUP * VFIO Group fd, /dev/vfio/$GROUP
*/ */
static void __vfio_group_unset_container(struct vfio_group *group) static void vfio_group_detach_container(struct vfio_group *group)
{ {
struct vfio_container *container = group->container; struct vfio_container *container = group->container;
struct vfio_iommu_driver *driver; struct vfio_iommu_driver *driver;
lockdep_assert_held_write(&group->group_rwsem); lockdep_assert_held_write(&group->group_rwsem);
WARN_ON(group->container_users != 1);
down_write(&container->group_lock); down_write(&container->group_lock);
...@@ -1089,7 +1090,7 @@ static int vfio_group_ioctl_unset_container(struct vfio_group *group) ...@@ -1089,7 +1090,7 @@ static int vfio_group_ioctl_unset_container(struct vfio_group *group)
ret = -EBUSY; ret = -EBUSY;
goto out_unlock; goto out_unlock;
} }
__vfio_group_unset_container(group); vfio_group_detach_container(group);
out_unlock: out_unlock:
up_write(&group->group_rwsem); up_write(&group->group_rwsem);
...@@ -1441,10 +1442,8 @@ static int vfio_group_fops_release(struct inode *inode, struct file *filep) ...@@ -1441,10 +1442,8 @@ static int vfio_group_fops_release(struct inode *inode, struct file *filep)
* is only called when there are no open devices. * is only called when there are no open devices.
*/ */
WARN_ON(group->notifier.head); WARN_ON(group->notifier.head);
if (group->container) { if (group->container)
WARN_ON(group->container_users != 1); vfio_group_detach_container(group);
__vfio_group_unset_container(group);
}
group->opened_file = NULL; group->opened_file = NULL;
up_write(&group->group_rwsem); up_write(&group->group_rwsem);
......
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