Blame 0215-spice-switch-to-queue-for-vga-mode-updates.patch

93b7e3
From 20b7c4b95c7f0c93000a68779e9cb9e63cff68da Mon Sep 17 00:00:00 2001
93b7e3
From: Gerd Hoffmann <kraxel@redhat.com>
93b7e3
Date: Wed, 5 Sep 2012 08:25:08 +0200
93b7e3
Subject: [PATCH 215/293] spice: switch to queue for vga mode updates
93b7e3
93b7e3
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
93b7e3
---
93b7e3
 hw/qxl.c           |  6 +++---
93b7e3
 ui/spice-display.c | 25 ++++++++++++++-----------
93b7e3
 ui/spice-display.h |  3 ++-
93b7e3
 3 files changed, 19 insertions(+), 15 deletions(-)
93b7e3
93b7e3
diff --git a/hw/qxl.c b/hw/qxl.c
93b7e3
index b726c19..833cd77 100644
93b7e3
--- a/hw/qxl.c
93b7e3
+++ b/hw/qxl.c
93b7e3
@@ -597,9 +597,9 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
93b7e3
     case QXL_MODE_VGA:
93b7e3
         ret = false;
93b7e3
         qemu_mutex_lock(&qxl->ssd.lock);
93b7e3
-        if (qxl->ssd.update != NULL) {
93b7e3
-            update = qxl->ssd.update;
93b7e3
-            qxl->ssd.update = NULL;
93b7e3
+        update = QTAILQ_FIRST(&qxl->ssd.updates);
93b7e3
+        if (update != NULL) {
93b7e3
+            QTAILQ_REMOVE(&qxl->ssd.updates, update, next);
93b7e3
             *ext = update->ext;
93b7e3
             ret = true;
93b7e3
         }
93b7e3
diff --git a/ui/spice-display.c b/ui/spice-display.c
93b7e3
index 99bc665..59c5fd7 100644
93b7e3
--- a/ui/spice-display.c
93b7e3
+++ b/ui/spice-display.c
93b7e3
@@ -164,7 +164,7 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd)
93b7e3
 #endif
93b7e3
 }
93b7e3
 
93b7e3
-static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
93b7e3
+static void qemu_spice_create_update(SimpleSpiceDisplay *ssd)
93b7e3
 {
93b7e3
     SimpleSpiceUpdate *update;
93b7e3
     QXLDrawable *drawable;
93b7e3
@@ -175,7 +175,7 @@ static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
93b7e3
     struct timespec time_space;
93b7e3
 
93b7e3
     if (qemu_spice_rect_is_empty(&ssd->dirty)) {
93b7e3
-        return NULL;
93b7e3
+        return;
93b7e3
     };
93b7e3
 
93b7e3
     trace_qemu_spice_create_update(
93b7e3
@@ -239,7 +239,7 @@ static SimpleSpiceUpdate *qemu_spice_create_update(SimpleSpiceDisplay *ssd)
93b7e3
     cmd->data = (uintptr_t)drawable;
93b7e3
 
93b7e3
     memset(&ssd->dirty, 0, sizeof(ssd->dirty));
93b7e3
-    return update;
93b7e3
+    QTAILQ_INSERT_TAIL(&ssd->updates, update, next);
93b7e3
 }
93b7e3
 
93b7e3
 /*
93b7e3
@@ -315,6 +315,7 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
93b7e3
 {
93b7e3
     ssd->ds = ds;
93b7e3
     qemu_mutex_init(&ssd->lock);
93b7e3
+    QTAILQ_INIT(&ssd->updates);
93b7e3
     ssd->mouse_x = -1;
93b7e3
     ssd->mouse_y = -1;
93b7e3
     if (ssd->num_surfaces == 0) {
93b7e3
@@ -345,6 +346,8 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ssd,
93b7e3
 
93b7e3
 void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
93b7e3
 {
93b7e3
+    SimpleSpiceUpdate *update;
93b7e3
+
93b7e3
     dprint(1, "%s:\n", __FUNCTION__);
93b7e3
 
93b7e3
     memset(&ssd->dirty, 0, sizeof(ssd->dirty));
93b7e3
@@ -352,9 +355,9 @@ void qemu_spice_display_resize(SimpleSpiceDisplay *ssd)
93b7e3
     ssd->conv = NULL;
93b7e3
 
93b7e3
     qemu_mutex_lock(&ssd->lock);
93b7e3
-    if (ssd->update != NULL) {
93b7e3
-        qemu_spice_destroy_update(ssd, ssd->update);
93b7e3
-        ssd->update = NULL;
93b7e3
+    while ((update = QTAILQ_FIRST(&ssd->updates)) != NULL) {
93b7e3
+        QTAILQ_REMOVE(&ssd->updates, update, next);
93b7e3
+        qemu_spice_destroy_update(ssd, update);
93b7e3
     }
93b7e3
     qemu_mutex_unlock(&ssd->lock);
93b7e3
     qemu_spice_destroy_host_primary(ssd);
93b7e3
@@ -384,8 +387,8 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
93b7e3
     vga_hw_update();
93b7e3
 
93b7e3
     qemu_mutex_lock(&ssd->lock);
93b7e3
-    if (ssd->update == NULL) {
93b7e3
-        ssd->update = qemu_spice_create_update(ssd);
93b7e3
+    if (QTAILQ_EMPTY(&ssd->updates)) {
93b7e3
+        qemu_spice_create_update(ssd);
93b7e3
         ssd->notify++;
93b7e3
     }
93b7e3
     qemu_spice_cursor_refresh_unlocked(ssd);
93b7e3
@@ -442,9 +445,9 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
93b7e3
     dprint(3, "%s:\n", __FUNCTION__);
93b7e3
 
93b7e3
     qemu_mutex_lock(&ssd->lock);
93b7e3
-    if (ssd->update != NULL) {
93b7e3
-        update = ssd->update;
93b7e3
-        ssd->update = NULL;
93b7e3
+    update = QTAILQ_FIRST(&ssd->updates);
93b7e3
+    if (update != NULL) {
93b7e3
+        QTAILQ_REMOVE(&ssd->updates, update, next);
93b7e3
         *ext = update->ext;
93b7e3
         ret = true;
93b7e3
     }
93b7e3
diff --git a/ui/spice-display.h b/ui/spice-display.h
93b7e3
index 512ab78..3fcb6fe 100644
93b7e3
--- a/ui/spice-display.h
93b7e3
+++ b/ui/spice-display.h
93b7e3
@@ -92,7 +92,7 @@ struct SimpleSpiceDisplay {
93b7e3
      * to them must be protected by the lock.
93b7e3
      */
93b7e3
     QemuMutex lock;
93b7e3
-    SimpleSpiceUpdate *update;
93b7e3
+    QTAILQ_HEAD(, SimpleSpiceUpdate) updates;
93b7e3
     QEMUCursor *cursor;
93b7e3
     int mouse_x, mouse_y;
93b7e3
 };
93b7e3
@@ -102,6 +102,7 @@ struct SimpleSpiceUpdate {
93b7e3
     QXLImage image;
93b7e3
     QXLCommandExt ext;
93b7e3
     uint8_t *bitmap;
93b7e3
+    QTAILQ_ENTRY(SimpleSpiceUpdate) next;
93b7e3
 };
93b7e3
 
93b7e3
 int qemu_spice_rect_is_empty(const QXLRect* r);
93b7e3
-- 
93b7e3
1.7.12
93b7e3