vfio: allow external user to get vfio group from device
authorYan Zhao <yan.y.zhao@intel.com>
Tue, 24 Mar 2020 15:27:56 +0000 (09:27 -0600)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 24 Mar 2020 15:27:56 +0000 (09:27 -0600)
commitc0560f51cf77472f4ed113539b0a02ca6cda7961
treef738f84f02f8dbc0c43d1a4312e8f5f38a228b9a
parent16fbf79b0f83bc752cee8589279f1ebfe57b3b6e
vfio: allow external user to get vfio group from device

external user calls vfio_group_get_external_user_from_dev() with a device
pointer to get the VFIO group associated with this device.
The VFIO group is checked to be vialbe and have IOMMU set. Then
container user counter is increased and VFIO group reference is hold
to prevent the VFIO group from disposal before external user exits.

when the external user finishes using of the VFIO group, it calls
vfio_group_put_external_user() to dereference the VFIO group and the
container user counter.

Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio.c
include/linux/vfio.h