代码拉取完成,页面将自动刷新
From feed555b60bc36d3e704431148e302dae48b77a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= <clg@redhat.com>
Date: Tue, 19 Dec 2023 07:58:16 +0100
Subject: [PATCH] vfio/spapr: Extend VFIOIOMMUOps with a release handler
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This allows to abstract a bit more the sPAPR IOMMU support in the
legacy IOMMU backend.
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Tested-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/container.c | 8 ++++++--
hw/vfio/spapr.c | 19 +++++++++++++++++++
include/hw/vfio/vfio-container-base.h | 1 +
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index e245d5a082..4c62f088b1 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -764,7 +764,9 @@ listener_release_exit:
}
if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU ||
container->iommu_type == VFIO_SPAPR_TCE_IOMMU) {
- vfio_spapr_container_deinit(container);
+ if (bcontainer->ops->release) {
+ bcontainer->ops->release(bcontainer);
+ }
}
enable_discards_exit:
@@ -803,7 +805,9 @@ static void vfio_disconnect_container(VFIOGroup *group)
}
if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU ||
container->iommu_type == VFIO_SPAPR_TCE_IOMMU) {
- vfio_spapr_container_deinit(container);
+ if (bcontainer->ops->release) {
+ bcontainer->ops->release(bcontainer);
+ }
}
}
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index 3694dfb874..697f80d11d 100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -440,6 +440,24 @@ vfio_spapr_container_del_section_window(VFIOContainerBase *bcontainer,
}
}
+static void vfio_spapr_container_release(VFIOContainerBase *bcontainer)
+{
+ VFIOContainer *container = container_of(bcontainer, VFIOContainer,
+ bcontainer);
+ VFIOSpaprContainer *scontainer = container_of(container, VFIOSpaprContainer,
+ container);
+ VFIOHostDMAWindow *hostwin, *next;
+
+ if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {
+ memory_listener_unregister(&scontainer->prereg_listener);
+ }
+ QLIST_FOREACH_SAFE(hostwin, &scontainer->hostwin_list, hostwin_next,
+ next) {
+ QLIST_REMOVE(hostwin, hostwin_next);
+ g_free(hostwin);
+ }
+}
+
static VFIOIOMMUOps vfio_iommu_spapr_ops;
static void setup_spapr_ops(VFIOContainerBase *bcontainer)
@@ -447,6 +465,7 @@ static void setup_spapr_ops(VFIOContainerBase *bcontainer)
vfio_iommu_spapr_ops = *bcontainer->ops;
vfio_iommu_spapr_ops.add_window = vfio_spapr_container_add_section_window;
vfio_iommu_spapr_ops.del_window = vfio_spapr_container_del_section_window;
+ vfio_iommu_spapr_ops.release = vfio_spapr_container_release;
bcontainer->ops = &vfio_iommu_spapr_ops;
}
diff --git a/include/hw/vfio/vfio-container-base.h b/include/hw/vfio/vfio-container-base.h
index c12ce4dfcb..b2813b0c11 100644
--- a/include/hw/vfio/vfio-container-base.h
+++ b/include/hw/vfio/vfio-container-base.h
@@ -135,5 +135,6 @@ struct VFIOIOMMUClass {
Error **errp);
void (*del_window)(VFIOContainerBase *bcontainer,
MemoryRegionSection *section);
+ void (*release)(VFIOContainerBase *bcontainer);
};
#endif /* HW_VFIO_VFIO_CONTAINER_BASE_H */
--
2.41.0.windows.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。