On 2022/11/28 16:08, Tian, Kevin wrote:
From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
Sent: Thursday, November 24, 2022 8:27 PM
This avoids referencing device->group in __vfio_register_dev()
this is not true. There is still reference to device->group when adding
the device to the group->device_list.
this remark will become true if you put it after patch04.
oh yes. :-)
+static int vfio_device_set_group(struct vfio_device *device,
+ enum vfio_group_type type)
{
- int ret;
+ struct vfio_group *group;
+
+ if (type == VFIO_IOMMU)
+ group = vfio_group_find_or_alloc(device->dev);
+ else
+ group = vfio_noiommu_group_alloc(device->dev, type);
Do we need a WARN_ON(type == VFIO_NO_IOMMU)?
do you mean a heads-up to user? if so, there is already a warn in
vfio_group_find_or_alloc() and vfio_group_ioctl_get_device_fd()
@@ -638,6 +651,7 @@ void vfio_unregister_group_dev(struct vfio_device
*device)
/* Balances device_add in register path */
device_del(&device->device);
+ /* Balances vfio_device_set_group in register path */
"vfio_device_set_group()"
got it.
vfio_device_remove_group(device);
}
EXPORT_SYMBOL_GPL(vfio_unregister_group_dev);
--
2.34.1
--
Regards,
Yi Liu