> 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? int vfio_pci_info_add_group_cap(struct device *dev, struct vfio_info_cap *caps) { struct vfio_pci_device_info_cap_group cap = { .header.id = VFIO_DEVICE_INFO_CAP_GROUP_ID, .header.version = 1, }; struct iommu_group *iommu_group; iommu_group = iommu_group_get(&pdev->dev); if (!iommu_group) { kfree(caps->buf); return -EPERM; } cap.group_id = iommu_group_id(iommu_group); iommu_group_put(iommu_group); return vfio_info_add_capability(caps, &cap.header, sizeof(cap)); } Regards, Yi Liu