mirror of https://github.com/xemu-project/xemu.git
vfio/spapr: Move prereg_listener into spapr container
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>
This commit is contained in:
parent
233309e8e4
commit
6ad359ec29
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
typedef struct VFIOSpaprContainer {
|
typedef struct VFIOSpaprContainer {
|
||||||
VFIOContainer container;
|
VFIOContainer container;
|
||||||
|
MemoryListener prereg_listener;
|
||||||
} VFIOSpaprContainer;
|
} VFIOSpaprContainer;
|
||||||
|
|
||||||
static bool vfio_prereg_listener_skipped_section(MemoryRegionSection *section)
|
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,
|
static void vfio_prereg_listener_region_add(MemoryListener *listener,
|
||||||
MemoryRegionSection *section)
|
MemoryRegionSection *section)
|
||||||
{
|
{
|
||||||
VFIOContainer *container = container_of(listener, VFIOContainer,
|
VFIOSpaprContainer *scontainer = container_of(listener, VFIOSpaprContainer,
|
||||||
prereg_listener);
|
prereg_listener);
|
||||||
|
VFIOContainer *container = &scontainer->container;
|
||||||
VFIOContainerBase *bcontainer = &container->bcontainer;
|
VFIOContainerBase *bcontainer = &container->bcontainer;
|
||||||
const hwaddr gpa = section->offset_within_address_space;
|
const hwaddr gpa = section->offset_within_address_space;
|
||||||
hwaddr end;
|
hwaddr end;
|
||||||
|
@ -107,8 +109,9 @@ static void vfio_prereg_listener_region_add(MemoryListener *listener,
|
||||||
static void vfio_prereg_listener_region_del(MemoryListener *listener,
|
static void vfio_prereg_listener_region_del(MemoryListener *listener,
|
||||||
MemoryRegionSection *section)
|
MemoryRegionSection *section)
|
||||||
{
|
{
|
||||||
VFIOContainer *container = container_of(listener, VFIOContainer,
|
VFIOSpaprContainer *scontainer = container_of(listener, VFIOSpaprContainer,
|
||||||
prereg_listener);
|
prereg_listener);
|
||||||
|
VFIOContainer *container = &scontainer->container;
|
||||||
const hwaddr gpa = section->offset_within_address_space;
|
const hwaddr gpa = section->offset_within_address_space;
|
||||||
hwaddr end;
|
hwaddr end;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -445,6 +448,8 @@ static void setup_spapr_ops(VFIOContainerBase *bcontainer)
|
||||||
int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
|
int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
|
||||||
{
|
{
|
||||||
VFIOContainerBase *bcontainer = &container->bcontainer;
|
VFIOContainerBase *bcontainer = &container->bcontainer;
|
||||||
|
VFIOSpaprContainer *scontainer = container_of(container, VFIOSpaprContainer,
|
||||||
|
container);
|
||||||
struct vfio_iommu_spapr_tce_info info;
|
struct vfio_iommu_spapr_tce_info info;
|
||||||
bool v2 = container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU;
|
bool v2 = container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU;
|
||||||
int ret, fd = container->fd;
|
int ret, fd = container->fd;
|
||||||
|
@ -463,9 +468,9 @@ int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
&address_space_memory);
|
||||||
if (bcontainer->error) {
|
if (bcontainer->error) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -513,7 +518,7 @@ int vfio_spapr_container_init(VFIOContainer *container, Error **errp)
|
||||||
|
|
||||||
listener_unregister_exit:
|
listener_unregister_exit:
|
||||||
if (v2) {
|
if (v2) {
|
||||||
memory_listener_unregister(&container->prereg_listener);
|
memory_listener_unregister(&scontainer->prereg_listener);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -523,7 +528,10 @@ void vfio_spapr_container_deinit(VFIOContainer *container)
|
||||||
VFIOHostDMAWindow *hostwin, *next;
|
VFIOHostDMAWindow *hostwin, *next;
|
||||||
|
|
||||||
if (container->iommu_type == VFIO_SPAPR_TCE_v2_IOMMU) {
|
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,
|
QLIST_FOREACH_SAFE(hostwin, &container->hostwin_list, hostwin_next,
|
||||||
next) {
|
next) {
|
||||||
|
|
|
@ -78,7 +78,6 @@ struct VFIOGroup;
|
||||||
typedef struct VFIOContainer {
|
typedef struct VFIOContainer {
|
||||||
VFIOContainerBase bcontainer;
|
VFIOContainerBase bcontainer;
|
||||||
int fd; /* /dev/vfio/vfio, empowered by the attached groups */
|
int fd; /* /dev/vfio/vfio, empowered by the attached groups */
|
||||||
MemoryListener prereg_listener;
|
|
||||||
unsigned iommu_type;
|
unsigned iommu_type;
|
||||||
QLIST_HEAD(, VFIOHostDMAWindow) hostwin_list;
|
QLIST_HEAD(, VFIOHostDMAWindow) hostwin_list;
|
||||||
QLIST_HEAD(, VFIOGroup) group_list;
|
QLIST_HEAD(, VFIOGroup) group_list;
|
||||||
|
|
Loading…
Reference in New Issue