48 lines
1.5 KiB
Diff
48 lines
1.5 KiB
Diff
|
|
From bf4c408cd5d3daadbfd11136655e5bcb40dcbba0 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Date: Sat, 11 Jan 2025 10:52:39 +0800
|
||
|
|
Subject: [PATCH] vfio/common: return early if space isn't empty
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
This is a trivial optimization. If there is active container in space,
|
||
|
|
vfio_reset_handler will never be unregistered. So revert the check of
|
||
|
|
space->containers and return early.
|
||
|
|
|
||
|
|
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Reviewed-by: Cédric Le Goater <clg@redhat.com>
|
||
|
|
Reviewed-by: Eric Auger <eric.auger@redhat.com>
|
||
|
|
Tested-by: Eric Auger <eric.auger@redhat.com>
|
||
|
|
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
|
||
|
|
Signed-off-by: Cédric Le Goater <clg@redhat.com>
|
||
|
|
Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>
|
||
|
|
---
|
||
|
|
hw/vfio/common.c | 9 ++++++---
|
||
|
|
1 file changed, 6 insertions(+), 3 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||
|
|
index 679fee4321..f6c2029aec 100644
|
||
|
|
--- a/hw/vfio/common.c
|
||
|
|
+++ b/hw/vfio/common.c
|
||
|
|
@@ -1608,10 +1608,13 @@ VFIOAddressSpace *vfio_get_address_space(AddressSpace *as)
|
||
|
|
|
||
|
|
void vfio_put_address_space(VFIOAddressSpace *space)
|
||
|
|
{
|
||
|
|
- if (QLIST_EMPTY(&space->containers)) {
|
||
|
|
- QLIST_REMOVE(space, list);
|
||
|
|
- g_free(space);
|
||
|
|
+ if (!QLIST_EMPTY(&space->containers)) {
|
||
|
|
+ return;
|
||
|
|
}
|
||
|
|
+
|
||
|
|
+ QLIST_REMOVE(space, list);
|
||
|
|
+ g_free(space);
|
||
|
|
+
|
||
|
|
if (QLIST_EMPTY(&vfio_address_spaces)) {
|
||
|
|
qemu_unregister_reset(vfio_reset_handler, NULL);
|
||
|
|
}
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|