WSL2-Linux-Kernel/drivers/vfio
Jason Gunthorpe 9cef73918e vfio: Use cdev_device_add() instead of device_create()
Modernize how vfio is creating the group char dev and sysfs presence.

These days drivers with state should use cdev_device_add() and
cdev_device_del() to manage the cdev and sysfs lifetime.

This API requires the driver to put the struct device and struct cdev
inside its state struct (vfio_group), and then use the usual
device_initialize()/cdev_device_add()/cdev_device_del() sequence.

Split the code to make this possible:

 - vfio_group_alloc()/vfio_group_release() are pair'd functions to
   alloc/free the vfio_group. release is done under the struct device
   kref.

 - vfio_create_group()/vfio_group_put() are pairs that manage the
   sysfs/cdev lifetime. Once the uses count is zero the vfio group's
   userspace presence is destroyed.

 - The IDR is replaced with an IDA. container_of(inode->i_cdev)
   is used to get back to the vfio_group during fops open. The IDA
   assigns unique minor numbers.

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/5-v3-2fdfe4ca2cc6+18c-vfio_group_cdev_jgg@nvidia.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2021-10-15 13:58:20 -06:00
..
fsl-mc Merge branch 'v5.16/vfio/diana-fsl-reset-v2' into v5.16/vfio/next 2021-10-11 15:50:49 -06:00
mdev vfio: simplify iommu group allocation for mediated devices 2021-09-30 12:46:44 -06:00
pci Merge branch 'v5.16/vfio/colin_xu_igd_opregion_2.0_v8' into v5.16/vfio/next 2021-10-12 10:26:41 -06:00
platform vfio: Move vfio_iommu_group_get() to vfio_register_group_dev() 2021-09-30 12:46:43 -06:00
Kconfig vfio: Use kconfig if XX/endif blocks instead of repeating 'depends on' 2021-08-26 10:36:51 -06:00
Makefile
vfio.c vfio: Use cdev_device_add() instead of device_create() 2021-10-15 13:58:20 -06:00
vfio.h vfio: clean up the check for mediated device in vfio_iommu_type1 2021-09-30 12:46:44 -06:00
vfio_iommu_spapr_tce.c vfio/spapr_tce: reject mediated devices 2021-09-30 12:46:44 -06:00
vfio_iommu_type1.c vfio/iommu_type1: remove IS_IOMMU_CAP_DOMAIN_IN_CONTAINER 2021-09-30 12:46:45 -06:00
vfio_spapr_eeh.c
virqfd.c