[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 11/14] virtio-gpu: refactor async blob unmapping
From: |
Alex Bennée |
Subject: |
[PATCH v2 11/14] virtio-gpu: refactor async blob unmapping |
Date: |
Tue, 6 May 2025 13:57:12 +0100 |
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Change the 3 part async cleanup of a blob memory mapping to check if the
unmapping has finished already after deleting the subregion; this
condition allows us to skip suspending the command and responding to the
guest right away.
Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20250410122643.1747913-4-manos.pitsidianakis@linaro.org>
Cc: qemu-stable@nongnu.org
---
hw/display/virtio-gpu-virgl.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c
index 8fbe4e70cc..32a32879f7 100644
--- a/hw/display/virtio-gpu-virgl.c
+++ b/hw/display/virtio-gpu-virgl.c
@@ -155,7 +155,32 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g,
* asynchronously by virtio_gpu_virgl_hostmem_region_free().
* 3. Finish the unmapping with final virgl_renderer_resource_unmap().
*/
+
+ /* 1. Check if we should start unmapping now */
+ if (!vmr->finish_unmapping) {
+ /* begin async unmapping. render will be unblocked once MR is freed */
+ b->renderer_blocked++;
+
+ memory_region_set_enabled(mr, false);
+ memory_region_del_subregion(&b->hostmem, mr);
+ object_unparent(OBJECT(mr));
+ /*
+ * The unmapping might have already finished at this point if no one
+ * else held a reference to the MR; if yes, we can skip suspending the
+ * command and unmap the resource right away.
+ */
+ *cmd_suspended = !vmr->finish_unmapping;
+ }
+
+ /*
+ * 2. if virtio_gpu_virgl_hostmem_region_free hasn't been executed yet, we
+ * have marked the command to be re-processed later by setting
+ * cmd_suspended to true. The freeing callback will be called from RCU
+ * context later.
+ */
+
if (vmr->finish_unmapping) {
+ /* 3. MemoryRegion has been freed, so finish unmapping */
res->mr = NULL;
g_free(vmr);
@@ -166,16 +191,6 @@ virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g,
__func__, strerror(-ret));
return ret;
}
- } else {
- *cmd_suspended = true;
-
- /* render will be unblocked once MR is freed */
- b->renderer_blocked++;
-
- /* memory region owns self res->mr object and frees it by itself */
- memory_region_set_enabled(mr, false);
- memory_region_del_subregion(&b->hostmem, mr);
- object_unparent(OBJECT(mr));
}
return 0;
--
2.39.5
- [PATCH v2 05/14] contrib/plugins: add a scaling factor to the ips arg, (continued)
- [PATCH v2 05/14] contrib/plugins: add a scaling factor to the ips arg, Alex Bennée, 2025/05/06
- [PATCH v2 10/14] virtio-gpu: fix hang under TCG when unmapping blob, Alex Bennée, 2025/05/06
- [PATCH v2 07/14] MAINTAINERS: add myself to virtio-gpu for Odd Fixes, Alex Bennée, 2025/05/06
- [PATCH v2 09/14] hw/display: re-arrange memory region tracking, Alex Bennée, 2025/05/06
- [PATCH v2 12/14] ui/gtk-gl-area: Remove extra draw call in refresh, Alex Bennée, 2025/05/06
[PATCH v2 11/14] virtio-gpu: refactor async blob unmapping,
Alex Bennée <=
[PATCH v2 13/14] docs: Create a uniquelabel Sphinx extension, Alex Bennée, 2025/05/06
[PATCH v2 14/14] docs: Use uniquelabel in qemu-block-drivers.rst.inc, Alex Bennée, 2025/05/06