RE: [PATCH v5 09/19] vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET

Liu, Yi L
2023-03-07T02:36:22Z

> From: Tian, Kevin <kevin.tian@intel.com>
> Sent: Tuesday, March 7, 2023 10:31 AM
>
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Monday, March 6, 2023 9:17 PM
> >
> > On Fri, Mar 03, 2023 at 09:55:42AM -0700, Alex Williamson wrote:
> >
> > > I can't think of a reason DPDK couldn't use hot-reset. If we want to
> > > make it a policy, it should be enforced by code, but creating that
> > > policy based on a difficulty in supporting that mode with iommufd isn't
> > > great.
> >
> > On the other hand adding code to allow device FDs in the hot reset
> > path that is never used and never tested isn't great either..
> >
> > hot-reset does work for DPDK, it just doesn't work in the case where
> > DPDK would have many VFIO devices open and they have overlapping
> > device sets. Which, again, is something it doesn't do.
> >
> > IMHO we should leave it out of the kernel and wait for a no-iommu user
> > to come forward that wants hot-reset of many devices. Then we can add
> > and test the device FD part. Most likely such a thing will never come
> > at this point.
> >
>
> I think we don't need to have this tradeoff if following Yi's last proposal
> which requires every opened device in the set to be covered by the
> device fd array. with dev_set->lock held in the reset/open path this is
> a safe measure and fully contained in vfio-pci w/o need of further
> checking noiommu or iommufd.
>
> In the end same reset uAPI except the fd array can be device fd now. 😊
>
> btw Yi, since this also affects the group path (though positive) it's clearer
> to first add open_count check in existing group path in a separate patch
> and then add the device fd support.

Yes. I've made them in the below branch. I plan to send v6 out with the
iommufd_access created in bind (not in the below branch yet).

https://github.com/yiliu1765/iommufd/tree/vfio_device_cdev_v6

vfio/pci: Accept device fd for VFIO_DEVICE_PCI_HOT_RESET
(https://github.com/yiliu1765/iommufd/commit/dcefb8ca5d13388ab9b9862992fd77cffcbadc30)
vfio/pci: Only need to check opened devices in the dev_set for hot reset
(https://github.com/yiliu1765/iommufd/commit/f7257f2db958d9d961a6e45ab0e301ee0397a243)

Regards,
Yi Liu