diff options
author | Jason Gunthorpe <jgg@nvidia.com> | 2022-09-29 17:59:25 +0300 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2022-10-04 21:06:58 +0300 |
commit | c82e81ab2569559ad873b3061217c2f37560682b (patch) | |
tree | 3cdb8747c5bbe641a1f0811aaa403dbc7364ff28 /drivers/vfio/container.c | |
parent | 912b74d26c7df2da1e261f3dac8942c8cbb76a49 (diff) | |
download | linux-c82e81ab2569559ad873b3061217c2f37560682b.tar.xz |
vfio: Change vfio_group->group_rwsem to a mutex
These days not much is using the read side:
- device first open
- ioctl_get_status
- device FD release
- check enforced_coherent
None of this is performance, so just make it into a normal mutex.
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/2-v1-917e3647f123+b1a-vfio_group_users_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'drivers/vfio/container.c')
-rw-r--r-- | drivers/vfio/container.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/vfio/container.c b/drivers/vfio/container.c index db7c071ee3de..d74164abbf40 100644 --- a/drivers/vfio/container.c +++ b/drivers/vfio/container.c @@ -430,7 +430,7 @@ int vfio_container_attach_group(struct vfio_container *container, struct vfio_iommu_driver *driver; int ret = 0; - lockdep_assert_held_write(&group->group_rwsem); + lockdep_assert_held(&group->group_lock); if (group->type == VFIO_NO_IOMMU && !capable(CAP_SYS_RAWIO)) return -EPERM; @@ -481,7 +481,7 @@ void vfio_group_detach_container(struct vfio_group *group) struct vfio_container *container = group->container; struct vfio_iommu_driver *driver; - lockdep_assert_held_write(&group->group_rwsem); + lockdep_assert_held(&group->group_lock); WARN_ON(group->container_users != 1); down_write(&container->group_lock); @@ -515,7 +515,7 @@ int vfio_device_assign_container(struct vfio_device *device) { struct vfio_group *group = device->group; - lockdep_assert_held_write(&group->group_rwsem); + lockdep_assert_held(&group->group_lock); if (!group->container || !group->container->iommu_driver || WARN_ON(!group->container_users)) @@ -531,11 +531,11 @@ int vfio_device_assign_container(struct vfio_device *device) void vfio_device_unassign_container(struct vfio_device *device) { - down_write(&device->group->group_rwsem); + mutex_lock(&device->group->group_lock); WARN_ON(device->group->container_users <= 1); device->group->container_users--; fput(device->group->opened_file); - up_write(&device->group->group_rwsem); + mutex_unlock(&device->group->group_lock); } /* |