diff mbox series

[v2,17/20] virtio-gpu: avoid re-entering cmdq processing

Message ID 20210204105232.834642-18-marcandre.lureau@redhat.com (mailing list archive)
State New, archived
Headers show
Series Various vhost-user-gpu & UI fixes | expand

Commit Message

Marc-André Lureau Feb. 4, 2021, 10:52 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

The next patch will notify the GL context got flush, which will resume
the queue processing. However, if this happens within the caller
context, it will end up with a stack overflow flush/update loop.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/virtio/virtio-gpu.h | 1 +
 hw/display/virtio-gpu.c        | 5 +++++
 2 files changed, 6 insertions(+)

Comments

Alexander Bulekov Feb. 5, 2021, 8:09 a.m. UTC | #1
On 210204 1452, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> The next patch will notify the GL context got flush, which will resume
> the queue processing. However, if this happens within the caller
> context, it will end up with a stack overflow flush/update loop.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

I know this was pulled already, but FWIW I think this is
Buglink: https://bugs.launchpad.net/qemu/+bug/1888606

> ---
>  include/hw/virtio/virtio-gpu.h | 1 +
>  hw/display/virtio-gpu.c        | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
> index 4f3dbf79f9..0043268e90 100644
> --- a/include/hw/virtio/virtio-gpu.h
> +++ b/include/hw/virtio/virtio-gpu.h
> @@ -148,6 +148,7 @@ struct VirtIOGPU {
>  
>      uint64_t hostmem;
>  
> +    bool processing_cmdq;
>      bool renderer_inited;
>      bool renderer_reset;
>      QEMUTimer *fence_poll;
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 0e833a462b..7eb4265a6d 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -814,6 +814,10 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g)
>  {
>      struct virtio_gpu_ctrl_command *cmd;
>  
> +    if (g->processing_cmdq) {
> +        return;
> +    }
> +    g->processing_cmdq = true;
>      while (!QTAILQ_EMPTY(&g->cmdq)) {
>          cmd = QTAILQ_FIRST(&g->cmdq);
>  
> @@ -843,6 +847,7 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g)
>              g_free(cmd);
>          }
>      }
> +    g->processing_cmdq = false;
>  }
>  
>  static void virtio_gpu_gl_unblock(VirtIOGPUBase *b)
> -- 
> 2.29.0
> 
>
diff mbox series

Patch

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 4f3dbf79f9..0043268e90 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -148,6 +148,7 @@  struct VirtIOGPU {
 
     uint64_t hostmem;
 
+    bool processing_cmdq;
     bool renderer_inited;
     bool renderer_reset;
     QEMUTimer *fence_poll;
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 0e833a462b..7eb4265a6d 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -814,6 +814,10 @@  void virtio_gpu_process_cmdq(VirtIOGPU *g)
 {
     struct virtio_gpu_ctrl_command *cmd;
 
+    if (g->processing_cmdq) {
+        return;
+    }
+    g->processing_cmdq = true;
     while (!QTAILQ_EMPTY(&g->cmdq)) {
         cmd = QTAILQ_FIRST(&g->cmdq);
 
@@ -843,6 +847,7 @@  void virtio_gpu_process_cmdq(VirtIOGPU *g)
             g_free(cmd);
         }
     }
+    g->processing_cmdq = false;
 }
 
 static void virtio_gpu_gl_unblock(VirtIOGPUBase *b)