diff options
author | Jason Gunthorpe <jgg@nvidia.com> | 2021-03-30 09:53:05 -0600 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2021-04-06 11:55:10 -0600 |
commit | 5e42c999445bd0ae86e35affeb3e7c473d74a893 (patch) | |
tree | 239df5eef4b6a5d5028c913121ccca1e6b5e2d17 /Documentation/driver-api | |
parent | e572bfb2b6a83b05acd30c03010e661b1967960f (diff) |
vfio: Simplify the lifetime logic for vfio_device
The vfio_device is using a 'sleep until all refs go to zero' pattern for
its lifetime, but it is indirectly coded by repeatedly scanning the group
list waiting for the device to be removed on its own.
Switch this around to be a direct representation, use a refcount to count
the number of places that are blocking destruction and sleep directly on a
completion until that counter goes to zero. kfree the device after other
accesses have been excluded in vfio_del_group_dev(). This is a fairly
common Linux idiom.
Due to this we can now remove kref_put_mutex(), which is very rarely used
in the kernel. Here it is being used to prevent a zero ref device from
being seen in the group list. Instead allow the zero ref device to
continue to exist in the device_list and use refcount_inc_not_zero() to
exclude it once refs go to zero.
This patch is organized so the next patch will be able to alter the API to
allow drivers to provide the kfree.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Message-Id: <2-v3-225de1400dfc+4e074-vfio1_jgg@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'Documentation/driver-api')
0 files changed, 0 insertions, 0 deletions