From: Zhenzhong Duan <zhenzhong.duan@intel.com>
To: qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, clg@redhat.com,
eric.auger@redhat.com, nicolinc@nvidia.com,
joao.m.martins@oracle.com, yi.l.liu@intel.com,
chao.p.peng@intel.com, Zhenzhong Duan <zhenzhong.duan@intel.com>
Subject: [PATCH v2 1/5] vfio/iommufd: Make a separate call to get IOMMU capabilities
Date: Wed, 23 Apr 2025 15:28:20 +0800 [thread overview]
Message-ID: <20250423072824.3647952-2-zhenzhong.duan@intel.com> (raw)
In-Reply-To: <20250423072824.3647952-1-zhenzhong.duan@intel.com>
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>
---
hw/vfio/iommufd.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 48db105422..2253778b3a 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;
}
--
2.34.1
next prev parent reply other threads:[~2025-04-23 7:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 7:28 [PATCH v2 0/5] vfio: Move realize after attach_dev Zhenzhong Duan
2025-04-23 7:28 ` Zhenzhong Duan [this message]
2025-04-23 8:31 ` [PATCH v2 1/5] vfio/iommufd: Make a separate call to get IOMMU capabilities Joao Martins
2025-04-23 7:28 ` [PATCH v2 2/5] vfio/iommufd: Move realize() after attachment Zhenzhong Duan
2025-04-23 9:39 ` Joao Martins
2025-04-23 7:28 ` [PATCH v2 3/5] vfio/container: " Zhenzhong Duan
2025-04-23 7:28 ` [PATCH v2 4/5] vfio: Cleanup host IOMMU device creation Zhenzhong Duan
2025-04-23 7:28 ` [PATCH v2 5/5] vfio: Remove hiod_typename property Zhenzhong Duan
2025-04-23 13:21 ` [PATCH v2 0/5] vfio: Move realize after attach_dev Cédric Le Goater
2025-04-23 13:35 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250423072824.3647952-2-zhenzhong.duan@intel.com \
--to=zhenzhong.duan@intel.com \
--cc=alex.williamson@redhat.com \
--cc=chao.p.peng@intel.com \
--cc=clg@redhat.com \
--cc=eric.auger@redhat.com \
--cc=joao.m.martins@oracle.com \
--cc=nicolinc@nvidia.com \
--cc=qemu-devel@nongnu.org \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).