55 lines
1.9 KiB
Diff
55 lines
1.9 KiB
Diff
|
|
From b727a28ce2cf062473ca011dd69697e0b7826a25 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Date: Mon, 5 Aug 2024 09:29:00 +0800
|
||
|
|
Subject: [PATCH] vfio/iommufd: Implement HostIOMMUDeviceClass::realize_late()
|
||
|
|
handler
|
||
|
|
|
||
|
|
There are three iommufd related elements iommufd handle, devid and
|
||
|
|
ioas_id. ioas_id is ready only after VFIO device attachment. Device
|
||
|
|
id and iommufd handle are ready before attachment, but they are all
|
||
|
|
iommufd related elements, initialize them together with ioas_id.
|
||
|
|
|
||
|
|
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
---
|
||
|
|
hw/vfio/iommufd.c | 17 +++++++++++++++++
|
||
|
|
1 file changed, 17 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
|
||
|
|
index 3d4f902ae5..47a8823146 100644
|
||
|
|
--- a/hw/vfio/iommufd.c
|
||
|
|
+++ b/hw/vfio/iommufd.c
|
||
|
|
@@ -827,6 +827,22 @@ static void vfio_iommu_iommufd_class_init(ObjectClass *klass, void *data)
|
||
|
|
vioc->query_dirty_bitmap = iommufd_query_dirty_bitmap;
|
||
|
|
};
|
||
|
|
|
||
|
|
+static bool hiod_iommufd_vfio_realize_late(HostIOMMUDevice *hiod, void *opaque,
|
||
|
|
+ Error **errp)
|
||
|
|
+{
|
||
|
|
+ VFIODevice *vdev = opaque;
|
||
|
|
+ VFIOIOMMUFDContainer *container = container_of(vdev->bcontainer,
|
||
|
|
+ VFIOIOMMUFDContainer,
|
||
|
|
+ bcontainer);
|
||
|
|
+ HostIOMMUDeviceIOMMUFD *idev = HOST_IOMMU_DEVICE_IOMMUFD(hiod);
|
||
|
|
+
|
||
|
|
+ idev->iommufd = vdev->iommufd;
|
||
|
|
+ idev->devid = vdev->devid;
|
||
|
|
+ idev->ioas_id = container->ioas_id;
|
||
|
|
+
|
||
|
|
+ return true;
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
|
||
|
|
Error **errp)
|
||
|
|
{
|
||
|
|
@@ -858,6 +874,7 @@ static void hiod_iommufd_vfio_class_init(ObjectClass *oc, void *data)
|
||
|
|
HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc);
|
||
|
|
|
||
|
|
hiodc->realize = hiod_iommufd_vfio_realize;
|
||
|
|
+ hiodc->realize_late = hiod_iommufd_vfio_realize_late;
|
||
|
|
};
|
||
|
|
|
||
|
|
static const TypeInfo types[] = {
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|