summaryrefslogtreecommitdiffstats
path: root/crypto/crypto_engine.c
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2021-03-30 17:53:05 +0200
committerAlex Williamson <alex.williamson@redhat.com>2021-04-06 19:55:10 +0200
commit5e42c999445bd0ae86e35affeb3e7c473d74a893 (patch)
tree239df5eef4b6a5d5028c913121ccca1e6b5e2d17 /crypto/crypto_engine.c
parentvfio: Remove extra put/gets around vfio_device->group (diff)
downloadlinux-5e42c999445bd0ae86e35affeb3e7c473d74a893.tar.xz
linux-5e42c999445bd0ae86e35affeb3e7c473d74a893.zip
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 'crypto/crypto_engine.c')
0 files changed, 0 insertions, 0 deletions