[PATCH] virtio-gpu: Call Virgl only in the main thread

Akihiko Odaki posted 1 patch 2 years, 10 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210617113520.25973-1-akihiko.odaki@gmail.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>
hw/display/virtio-gpu-gl.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
[PATCH] virtio-gpu: Call Virgl only in the main thread
Posted by Akihiko Odaki 2 years, 10 months ago
Virgl relies on callbacks provided by the OpenGL display, and such a
display may rely on eglMakeCurrent. eglMakeCurrent will fail if the
given context is current to some other thread. The easiest way to avoid
such a failure is to call the OpenGL display in a single thread. As all
operations except virtio_gpu_virgl_reset happens in the main thread,
this change makes virtio_gpu_virgl_reset happen only in the main thread.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
 hw/display/virtio-gpu-gl.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index d971b480806..57d6537120f 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -90,17 +90,12 @@ static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 
 static void virtio_gpu_gl_reset(VirtIODevice *vdev)
 {
-    VirtIOGPU *g = VIRTIO_GPU(vdev);
     VirtIOGPUGL *gl = VIRTIO_GPU_GL(vdev);
 
     virtio_gpu_reset(vdev);
 
     if (gl->renderer_inited) {
-        if (g->parent_obj.renderer_blocked) {
-            gl->renderer_reset = true;
-        } else {
-            virtio_gpu_virgl_reset(g);
-        }
+        gl->renderer_reset = true;
     }
 }
 
-- 
2.30.1 (Apple Git-130)


Re: [PATCH] virtio-gpu: Call Virgl only in the main thread
Posted by Gerd Hoffmann 2 years, 10 months ago
On Thu, Jun 17, 2021 at 08:35:20PM +0900, Akihiko Odaki wrote:
> Virgl relies on callbacks provided by the OpenGL display, and such a
> display may rely on eglMakeCurrent. eglMakeCurrent will fail if the
> given context is current to some other thread. The easiest way to avoid
> such a failure is to call the OpenGL display in a single thread. As all
> operations except virtio_gpu_virgl_reset happens in the main thread,
> this change makes virtio_gpu_virgl_reset happen only in the main thread.
> 
> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>

Added to vga patch queue.

thanks,
  Gerd