diff mbox series

[2/2] virtio-gpu: clear command queue on reset

Message ID 20190314061119.6218-3-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series virtio-gpu: more reset fixes. | expand

Commit Message

Gerd Hoffmann March 14, 2019, 6:11 a.m. UTC
It was never correct to not clear them.  Due to commit "3912e66a3feb
virtio-vga: fix reset." this became more obvious though.  The virtio
rings get properly reset now, and trying to process the stale commands
will trigger an assert in the virtio core.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-gpu.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Marc-André Lureau March 14, 2019, 11:01 a.m. UTC | #1
Hi

On Thu, Mar 14, 2019 at 7:17 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> It was never correct to not clear them.  Due to commit "3912e66a3feb
> virtio-vga: fix reset." this became more obvious though.  The virtio
> rings get properly reset now, and trying to process the stale commands
> will trigger an assert in the virtio core.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

what about the fences and related data?

> ---
>  hw/display/virtio-gpu.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index fbd8d908ad32..cdab327658d2 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -1356,6 +1356,7 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
>  {
>      VirtIOGPU *g = VIRTIO_GPU(vdev);
>      struct virtio_gpu_simple_resource *res, *tmp;
> +    struct virtio_gpu_ctrl_command *cmd;
>      int i;
>
>      g->enable = 0;
> @@ -1372,6 +1373,12 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
>          g->scanout[i].ds = NULL;
>      }
>
> +    while (!QTAILQ_EMPTY(&g->cmdq)) {
> +        cmd = QTAILQ_FIRST(&g->cmdq);
> +        QTAILQ_REMOVE(&g->cmdq, cmd, next);
> +        g_free(cmd);
> +    }
> +
>  #ifdef CONFIG_VIRGL
>      if (g->use_virgl_renderer) {
>          if (g->renderer_blocked) {
> --
> 2.18.1
>
>
Gerd Hoffmann March 14, 2019, 11:54 a.m. UTC | #2
On Thu, Mar 14, 2019 at 12:01:27PM +0100, Marc-André Lureau wrote:
> Hi
> 
> On Thu, Mar 14, 2019 at 7:17 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
> >
> > It was never correct to not clear them.  Due to commit "3912e66a3feb
> > virtio-vga: fix reset." this became more obvious though.  The virtio
> > rings get properly reset now, and trying to process the stale commands
> > will trigger an assert in the virtio core.
> >
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> 
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> what about the fences and related data?

Good point.  v2 sent.

cheers,
  Gerd
diff mbox series

Patch

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index fbd8d908ad32..cdab327658d2 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1356,6 +1356,7 @@  static void virtio_gpu_reset(VirtIODevice *vdev)
 {
     VirtIOGPU *g = VIRTIO_GPU(vdev);
     struct virtio_gpu_simple_resource *res, *tmp;
+    struct virtio_gpu_ctrl_command *cmd;
     int i;
 
     g->enable = 0;
@@ -1372,6 +1373,12 @@  static void virtio_gpu_reset(VirtIODevice *vdev)
         g->scanout[i].ds = NULL;
     }
 
+    while (!QTAILQ_EMPTY(&g->cmdq)) {
+        cmd = QTAILQ_FIRST(&g->cmdq);
+        QTAILQ_REMOVE(&g->cmdq, cmd, next);
+        g_free(cmd);
+    }
+
 #ifdef CONFIG_VIRGL
     if (g->use_virgl_renderer) {
         if (g->renderer_blocked) {