On Mon, 10 Apr 2023 15:18:27 +0000 "Liu, Yi L" <yi.l.liu@xxxxxxxxx> wrote: > > From: Alex Williamson <alex.williamson@xxxxxxxxxx> > > Sent: Monday, April 10, 2023 10:41 PM > > > > On Mon, 10 Apr 2023 08:48:54 +0000 > > "Liu, Yi L" <yi.l.liu@xxxxxxxxx> wrote: > > > > > > From: Alex Williamson <alex.williamson@xxxxxxxxxx> > > > > Sent: Sunday, April 9, 2023 9:30 PM > > > [...] > > > > > yeah, needs to move the iommu group creation back to vfio_main.c. This > > > > > would be a prerequisite for [1] > > > > > > > > > > [1] https://lore.kernel.org/kvm/20230401151833.124749-25-yi.l.liu@xxxxxxxxx/ > > > > > > > > > > I'll also try out your suggestion to add a capability like below and link > > > > > it in the vfio_device_info cap chain. > > > > > > > > > > #define VFIO_DEVICE_INFO_CAP_PCI_BDF 5 > > > > > > > > > > struct vfio_device_info_cap_pci_bdf { > > > > > struct vfio_info_cap_header header; > > > > > __u32 group_id; > > > > > __u16 segment; > > > > > __u8 bus; > > > > > __u8 devfn; /* Use PCI_SLOT/PCI_FUNC */ > > > > > }; > > > > > > > > > > > > > Group-id and bdf should be separate capabilities, all device should > > > > report a group-id capability and only PCI devices a bdf capability. > > > > > > ok. Since this is to support the device fd passing usage, so we need to > > > let all the vfio device drivers report group-id capability. is it? So may > > > have a below helper in vfio_main.c. How about the sample drivers? > > > seems not necessary for them. right? > > > > The more common we can make it, the better, but if it ends up that the > > individual drivers need to initialize the capability then it would > > probably be limited to those driver with a need to expose the group. > > looks to be such a case. vfio_device_info is assembled by the individual > drivers. If want to report group_id capability as a common behavior, needs > to change all of them. Had a quick draft for it as below commit: > > https://github.com/yiliu1765/iommufd/commit/ff4b8bee90761961041126305183a9a7e0f0542d > > https://github.com/yiliu1765/iommufd/commits/report_group_id > > > Sample drivers for the purpose of illustrating the interface and of > > course anything based on vfio-pci-core which exposes hot-reset. Thanks > > do you see any sample drivers need to report group_id cap? IMHO, seems > no. As in the quoted text, part of the purpose of the sample drivers is to act both as a proof-of-concept and illustration of the API, therefore gratuitous exposure of such capabilities should be encouraged. They would also provide a proof point of an mdev device, ie. emulated IOMMU device, exposing the capability. Thanks, Alex