On Tue, Aug 16, 2022 at 09:21:05AM +0800, Yi Liu wrote: > Hi Jason, > > On 2022/8/16 00:50, Jason Gunthorpe wrote: > > This counts the number of devices attached to a vfio_group, ie the number > > of items in the group->device_list. > > yes. This dev_counter is added to ensure only singleton vfio group supports > pin page. Although I don't think it is a good approach as it only counts the > registered devices. Ah, I missed explaining this, lets try again: vfio: Remove vfio_group dev_counter This counts the number of devices attached to a vfio_group, ie the number of items in the group->device_list. It has two purposes - To ensure the vfio_device is opened - To assert the group is singleton because the dirty tracking code in the type1 iommu has limitations However, vfio_pin_pages() already calls vfio_assert_device_open() so the first is taken care of, and all callers of vfio_pin_pages() use now use vfio_register_emulated_iommu_dev() which guarentees single groups by constrution. So delete dev_counter and leave a note that vfio_pin_pages() can only be used with vfio_register_emulated_iommu_dev(). Jason