aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhenzhong Duan <zhenzhong.duan@intel.com>2025-04-23 15:28:20 +0800
committerCédric Le Goater <clg@redhat.com>2025-04-25 09:01:37 +0200
commit436114cc4390ff46535229e67e43056196a971c1 (patch)
tree2bd1730877111322ea1cceeec883a68a25ef64c3
parent85ae745edd2815c504a3198410a545e50f583e6a (diff)
downloadqemu-436114cc4390ff46535229e67e43056196a971c1.zip
qemu-436114cc4390ff46535229e67e43056196a971c1.tar.gz
qemu-436114cc4390ff46535229e67e43056196a971c1.tar.bz2
vfio/iommufd: Make a separate call to get IOMMU capabilities
Currently we depend on .realize() calling iommufd_backend_get_device_info() to get IOMMU capabilities and check for dirty page tracking support. By make a extra separate call, this dependency is removed. This happens only during device attach, it's not a hot path. Suggested-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Joao Martins <joao.m.martins@oracle.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Link: https://lore.kernel.org/qemu-devel/20250423072824.3647952-2-zhenzhong.duan@intel.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
-rw-r--r--hw/vfio/iommufd.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 48db105..2253778 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -287,7 +287,8 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,
{
ERRP_GUARD();
IOMMUFDBackend *iommufd = vbasedev->iommufd;
- uint32_t flags = 0;
+ uint32_t type, flags = 0;
+ uint64_t hw_caps;
VFIOIOASHwpt *hwpt;
uint32_t hwpt_id;
int ret;
@@ -324,7 +325,12 @@ static bool iommufd_cdev_autodomains_get(VFIODevice *vbasedev,
* vfio_migration_realize() may decide to use VF dirty tracking
* instead.
*/
- if (vbasedev->hiod->caps.hw_caps & IOMMU_HW_CAP_DIRTY_TRACKING) {
+ if (!iommufd_backend_get_device_info(vbasedev->iommufd, vbasedev->devid,
+ &type, NULL, 0, &hw_caps, errp)) {
+ return false;
+ }
+
+ if (hw_caps & IOMMU_HW_CAP_DIRTY_TRACKING) {
flags = IOMMU_HWPT_ALLOC_DIRTY_TRACKING;
}