>-----Original Message----- >From: Cédric Le Goater <c...@redhat.com> >Subject: Re: [PATCH 1/5] vfio/iommufd: Save host iommu capabilities in >VFIODevice.caps > >On 4/11/25 12:17, Zhenzhong Duan wrote: >> The saved caps copy can be used to check dirty tracking capability. >> >> The capabilities is gotten through IOMMUFD interface, so define a >> new structure HostIOMMUDeviceIOMMUFDCaps which contains vendor >> caps raw data in "include/system/iommufd.h". >> >> This is a prepare work for moving .realize() after .attach_device(). >> >> Suggested-by: Cédric Le Goater <c...@redhat.com> >> Suggested-by: Eric Auger <eric.au...@redhat.com> >> Suggested-by: Nicolin Chen <nicol...@nvidia.com> >> Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com> >> --- >> include/hw/vfio/vfio-device.h | 1 + >> include/system/iommufd.h | 22 ++++++++++++++++++++++ >> hw/vfio/iommufd.c | 10 +++++++++- >> 3 files changed, 32 insertions(+), 1 deletion(-) >> >> diff --git a/include/hw/vfio/vfio-device.h b/include/hw/vfio/vfio-device.h >> index 66797b4c92..09a7af891a 100644 >> --- a/include/hw/vfio/vfio-device.h >> +++ b/include/hw/vfio/vfio-device.h >> @@ -77,6 +77,7 @@ typedef struct VFIODevice { >> bool dirty_tracking; /* Protected by BQL */ >> bool iommu_dirty_tracking; >> HostIOMMUDevice *hiod; >> + HostIOMMUDeviceIOMMUFDCaps caps; > >IMO, these capabilities belong to HostIOMMUDevice and not VFIODevice.
This was trying to address suggestions in [1], caps is generated by IOMMUFD backend and is only used by hiod_iommufd_get_cap(), hiod_legacy_vfio_get_cap() never check it. By putting it in VFIODevice, I can save vendor caps in a union and raw data format, hiod_iommufd_get_cap() recognizes the raw data format and can check it for a cap support. If keep caps in HostIOMMUDevice, I can think of a change like below to address Eric and Nicolin's suggestion: https://github.com/yiliu1765/qemu/commit/e05f91b2a724cefa8356969cb43284f7c3ec11d1 https://github.com/yiliu1765/qemu/commit/e05f91b2a724cefa8356969cb43284f7c3ec11d1 Does the change make sense for you? [1] https://lists.gnu.org/archive/html/qemu-devel/2025-03/msg01552.html > >I would simply call iommufd_backend_get_device_info() twice where needed : >iommufd_cdev_autodomains_get() and hiod_iommufd_vfio_realize() OK, will do, that's simpler than current change. Thanks Zhenzhong