vfio: Move device_del() before waiting for the last vfio_device registration refcount
authorYi Liu <yi.l.liu@intel.com>
Tue, 18 Jul 2023 13:55:42 +0000 (06:55 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 25 Jul 2023 16:19:26 +0000 (10:19 -0600)
commit38c24544e10a541d92be9d4ec2dfc8a94f4d87ba
treeb3d7fdec2db9d4f09c700dbab034bbaf66c8ff53
parent291872a533a2cdea8df1ae157987cd7ab3939421
vfio: Move device_del() before waiting for the last vfio_device registration refcount

device_del() destroys the vfio-dev/vfioX under the sysfs for vfio_device.
There is no reason to keep it while the device is going to be unregistered.

This movement is also a preparation for adding vfio_device cdev. Kernel
should remove the cdev node of the vfio_device to avoid new registration
refcount increment while the device is going to be unregistered.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Tested-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Tested-by: Yanting Jiang <yanting.jiang@intel.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20230718135551.6592-18-yi.l.liu@intel.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_main.c