]> git.baikalelectronics.ru Git - kernel.git/commit
vfio: Remove calls to vfio_group_add_container_user()
authorJason Gunthorpe <jgg@nvidia.com>
Wed, 11 May 2022 19:13:00 +0000 (13:13 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Wed, 11 May 2022 19:13:00 +0000 (13:13 -0600)
commiteadd86f835c63769febbd056dfcb70dafef0d4b3
tree40a4e2e36aaf2a4e15e5130bae1703124dad0243
parent231657b345046552b35670b45b892cfce2610e12
vfio: Remove calls to vfio_group_add_container_user()

When the open_device() op is called the container_users is incremented and
held incremented until close_device(). Thus, so long as drivers call
functions within their open_device()/close_device() region they do not
need to worry about the container_users.

These functions can all only be called between open_device() and
close_device():

  vfio_pin_pages()
  vfio_unpin_pages()
  vfio_dma_rw()
  vfio_register_notifier()
  vfio_unregister_notifier()

Eliminate the calls to vfio_group_add_container_user() and add
vfio_assert_device_open() to detect driver mis-use. This causes the
close_device() op to check device->open_count so always leave it elevated
while calling the op.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/7-v4-8045e76bf00b+13d-vfio_mdev_no_group_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio.c