[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/47] vfio/spapr: Move prereg_listener into spapr container
From: |
Cédric Le Goater |
Subject: |
[PULL 18/47] vfio/spapr: Move prereg_listener into spapr container |
Date: |
Tue, 19 Dec 2023 19:56:14 +0100 |
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
No functional changes intended.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
include/hw/vfio/vfio-common.h | 1 -
hw/vfio/spapr.c | 24 ++++++++++++++++--------
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index
055f6793635e8c0faa2bbd910737bf8db4e45c88..ed6148c058be03f6c1898ff680072f23dbe51ba2
100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -78,7 +78,6 @@ struct VFIOGroup;
typedef struct VFIOContainer {
VFIOContainerBase bcontainer;
int fd; /* /dev/vfio/vfio, empowered by the attached groups */
- MemoryListener prereg_listener;
unsigned iommu_type;
QLIST_HEAD(, VFIOHostDMAWindow) hostwin_list;
QLIST_HEAD(, VFIOGroup) group_list;
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
index
5be1911aadccc3b3300b84b614a212aff39d57e0..68c3dd6c75678dcfa901b8e7bc241a56047c0fbe
100644
--- a/hw/vfio/spapr.c
+++ b/hw/vfio/spapr.c
@@ -26,6 +26,7 @@
typedef struct VFIOSpaprContainer {
VFIOContainer container;
+ MemoryListener prereg_listener;
} VFIOSpaprContainer;
static bool vfio_prereg_listener_skipped_section(MemoryRegionSection *section)
@@ -48,8 +49,9 @@ static void *vfio_prereg_gpa_to_vaddr(MemoryRegionSection
*section, hwaddr gpa)
static void vfio_prereg_listener_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
- VFIOContainer *container = container_of(listener, VFIOContainer,
- prereg_listener);
+ VFIOSpaprContainer *scontainer = container_of(listener, VFIOSpaprContainer,
+ prereg_listener);
+ VFIOContainer *container = &scontainer->container;
VFIOContainerBase *bcontainer = &container->bcontainer;
const hwaddr gpa = section->offset_within_address_space;
hwaddr end;
@@ -107,8 +109,9 @@ static void vfio_prereg_listener_region_add(MemoryListener
*listener,
static void vfio_prereg_listener_region_del(MemoryListener *listener,
MemoryRegionSection *section)
{
- VFIOContainer *container = container_of(listener, VFIOContainer,
- prereg_listener);
+ VFIOSpaprContainer *scontainer = container_of(listener, VFIOSpaprContainer,
+ prereg_listener);
+ VFIOContainer *container = &scontainer->container;
const hwaddr gpa = section->offset_within_address_space;
hwaddr end;
int ret;
@@ -445,6 +448,8 @@ static void setup_spapr_ops(VFIOContainerBase *bcontainer)
int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
{
VFIOContainerBase *bcontainer = &container->bcontainer;
+ VFIOSpaprContainer *scontainer = container_of(container,
VFIOSpaprContainer,
+ container);
struct vfio_iommu_spapr_tce_info info;
bool v2 = container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU;
int ret, fd = container->fd;
@@ -463,9 +468,9 @@ int vfio_spapr_container_init(VFIOContainer *container,
Error **errp)
return -errno;
}
} else {
- container->prereg_listener = vfio_prereg_listener;
+ scontainer->prereg_listener = vfio_prereg_listener;
- memory_listener_register(&container->prereg_listener,
+ memory_listener_register(&scontainer->prereg_listener,
&address_space_memory);
if (bcontainer->error) {
ret = -1;
@@ -513,7 +518,7 @@ int vfio_spapr_container_init(VFIOContainer *container,
Error **errp)
listener_unregister_exit:
if (v2) {
- memory_listener_unregister(&container->prereg_listener);
+ memory_listener_unregister(&scontainer->prereg_listener);
}
return ret;
}
@@ -523,7 +528,10 @@ void vfio_spapr_container_deinit(VFIOContainer *container)
VFIOHostDMAWindow *hostwin, *next;
if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {
- memory_listener_unregister(&container->prereg_listener);
+ VFIOSpaprContainer *scontainer = container_of(container,
+ VFIOSpaprContainer,
+ container);
+ memory_listener_unregister(&scontainer->prereg_listener);
}
QLIST_FOREACH_SAFE(hostwin, &container->hostwin_list, hostwin_next,
next) {
--
2.43.0
- [PULL 07/47] vfio/container: Switch to IOMMU BE set_dirty_page_tracking/query_dirty_bitmap API, (continued)
- [PULL 07/47] vfio/container: Switch to IOMMU BE set_dirty_page_tracking/query_dirty_bitmap API, Cédric Le Goater, 2023/12/19
- [PULL 08/47] vfio/container: Move per container device list in base container, Cédric Le Goater, 2023/12/19
- [PULL 09/47] vfio/container: Convert functions to base container, Cédric Le Goater, 2023/12/19
- [PULL 10/47] vfio/container: Move pgsizes and dma_max_mappings to base container, Cédric Le Goater, 2023/12/19
- [PULL 11/47] vfio/container: Move vrdl_list to base container, Cédric Le Goater, 2023/12/19
- [PULL 12/47] vfio/container: Move listener to base container, Cédric Le Goater, 2023/12/19
- [PULL 13/47] vfio/container: Move dirty_pgsizes and max_dirty_bitmap_size to base container, Cédric Le Goater, 2023/12/19
- [PULL 14/47] vfio/container: Move iova_ranges to base container, Cédric Le Goater, 2023/12/19
- [PULL 16/47] vfio/spapr: Introduce spapr backend and target interface, Cédric Le Goater, 2023/12/19
- [PULL 17/47] vfio/spapr: switch to spapr IOMMU BE add/del_section_window, Cédric Le Goater, 2023/12/19
- [PULL 18/47] vfio/spapr: Move prereg_listener into spapr container,
Cédric Le Goater <=
- [PULL 15/47] vfio/container: Implement attach/detach_device, Cédric Le Goater, 2023/12/19
- [PULL 19/47] vfio/spapr: Move hostwin_list into spapr container, Cédric Le Goater, 2023/12/19
- [PULL 21/47] util/char_dev: Add open_cdev(), Cédric Le Goater, 2023/12/19
- [PULL 20/47] backends/iommufd: Introduce the iommufd object, Cédric Le Goater, 2023/12/19
- RE: [PULL 20/47] backends/iommufd: Introduce the iommufd object, Duan, Zhenzhong, 2023/12/21