Skip to content

Commit dc15f82

Browse files
jgunthorpeawilliam
authored andcommitted
vfio: Delete container_q
Now that the iommu core takes care of isolation there is no race between driver attach and container unset. Once iommu_group_release_dma_owner() returns the device can immediately be re-used. Remove this mechanism. Signed-off-by: Jason Gunthorpe <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent c5e8c39 commit dc15f82

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

drivers/vfio/vfio.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ struct vfio_group {
7474
struct list_head vfio_next;
7575
struct list_head container_next;
7676
atomic_t opened;
77-
wait_queue_head_t container_q;
7877
enum vfio_group_type type;
7978
unsigned int dev_counter;
8079
struct kvm *kvm;
@@ -363,7 +362,6 @@ static struct vfio_group *vfio_group_alloc(struct iommu_group *iommu_group,
363362
refcount_set(&group->users, 1);
364363
INIT_LIST_HEAD(&group->device_list);
365364
mutex_init(&group->device_lock);
366-
init_waitqueue_head(&group->container_q);
367365
group->iommu_group = iommu_group;
368366
/* put in vfio_group_release() */
369367
iommu_group_ref_get(iommu_group);
@@ -684,23 +682,6 @@ void vfio_unregister_group_dev(struct vfio_device *device)
684682
group->dev_counter--;
685683
mutex_unlock(&group->device_lock);
686684

687-
/*
688-
* In order to support multiple devices per group, devices can be
689-
* plucked from the group while other devices in the group are still
690-
* in use. The container persists with this group and those remaining
691-
* devices still attached. If the user creates an isolation violation
692-
* by binding this device to another driver while the group is still in
693-
* use, that's their fault. However, in the case of removing the last,
694-
* or potentially the only, device in the group there can be no other
695-
* in-use devices in the group. The user has done their due diligence
696-
* and we should lay no claims to those devices. In order to do that,
697-
* we need to make sure the group is detached from the container.
698-
* Without this stall, we're potentially racing with a user process
699-
* that may attempt to immediately bind this device to another driver.
700-
*/
701-
if (list_empty(&group->device_list))
702-
wait_event(group->container_q, !group->container);
703-
704685
if (group->type == VFIO_NO_IOMMU || group->type == VFIO_EMULATED_IOMMU)
705686
iommu_group_remove_device(device->dev);
706687

@@ -945,7 +926,6 @@ static void __vfio_group_unset_container(struct vfio_group *group)
945926
iommu_group_release_dma_owner(group->iommu_group);
946927

947928
group->container = NULL;
948-
wake_up(&group->container_q);
949929
list_del(&group->container_next);
950930

951931
/* Detaching the last group deprivileges a container, remove iommu */

0 commit comments

Comments
 (0)