vfio: Use a refcount_t instead of a kref in the vfio_group
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 15 Oct 2021 11:40:53 +0000 (08:40 -0300)
committerAlex Williamson <alex.williamson@redhat.com>
Fri, 15 Oct 2021 19:58:20 +0000 (13:58 -0600)
commit2b678aa2f0990a25e15cdef66256a131566ecd2e
tree96c10c15697f3d0e3f9db7ed695e12193024fb30
parent325a31c920309d2225311573a05c2f4dd402b2ed
vfio: Use a refcount_t instead of a kref in the vfio_group

The next patch adds a struct device to the struct vfio_group, and it is
confusing/bad practice to have two krefs in the same struct. This kref is
controlling the period when the vfio_group is registered in sysfs, and
visible in the internal lookup. Switch it to a refcount_t instead.

The refcount_dec_and_mutex_lock() is still required because we need
atomicity of the list searches and sysfs presence.

Reviewed-by: Liu Yi L <yi.l.liu@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/4-v3-2fdfe4ca2cc6+18c-vfio_group_cdev_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio.c