dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0212-spice-make-number-of-surfaces-runtime-configurable.patch

Hans de Goede c8dfc6
From 72e437d9b775cb92f93c3acd0109239f1bb3e6e2 Mon Sep 17 00:00:00 2001
Hans de Goede c8dfc6
From: Gerd Hoffmann <kraxel@redhat.com>
Hans de Goede c8dfc6
Date: Tue, 4 Sep 2012 11:39:41 +0200
Hans de Goede c8dfc6
Subject: [PATCH 212/215] spice: make number of surfaces runtime-configurable.
Hans de Goede c8dfc6
Hans de Goede c8dfc6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Hans de Goede c8dfc6
---
Hans de Goede c8dfc6
 hw/qxl.c           | 31 +++++++++++++++++--------------
Hans de Goede c8dfc6
 hw/qxl.h           |  3 +--
Hans de Goede c8dfc6
 ui/spice-display.c |  5 ++++-
Hans de Goede c8dfc6
 ui/spice-display.h |  3 +--
Hans de Goede c8dfc6
 4 files changed, 23 insertions(+), 19 deletions(-)
Hans de Goede c8dfc6
Hans de Goede c8dfc6
diff --git a/hw/qxl.c b/hw/qxl.c
Hans de Goede c8dfc6
index adf17fd..8725f67 100644
Hans de Goede c8dfc6
--- a/hw/qxl.c
Hans de Goede c8dfc6
+++ b/hw/qxl.c
Hans de Goede c8dfc6
@@ -236,7 +236,8 @@ static void qxl_spice_destroy_surfaces_complete(PCIQXLDevice *qxl)
Hans de Goede c8dfc6
 {
Hans de Goede c8dfc6
     trace_qxl_spice_destroy_surfaces_complete(qxl->id);
Hans de Goede c8dfc6
     qemu_mutex_lock(&qxl->track_lock);
Hans de Goede c8dfc6
-    memset(&qxl->guest_surfaces.cmds, 0, sizeof(qxl->guest_surfaces.cmds));
Hans de Goede c8dfc6
+    memset(qxl->guest_surfaces.cmds, 0,
Hans de Goede c8dfc6
+           sizeof(qxl->guest_surfaces.cmds) * qxl->ssd.num_surfaces);
Hans de Goede c8dfc6
     qxl->guest_surfaces.count = 0;
Hans de Goede c8dfc6
     qemu_mutex_unlock(&qxl->track_lock);
Hans de Goede c8dfc6
 }
Hans de Goede c8dfc6
@@ -345,7 +346,7 @@ static void init_qxl_rom(PCIQXLDevice *d)
Hans de Goede c8dfc6
     rom->slot_id_bits  = MEMSLOT_SLOT_BITS;
Hans de Goede c8dfc6
     rom->slots_start   = 1;
Hans de Goede c8dfc6
     rom->slots_end     = NUM_MEMSLOTS - 1;
Hans de Goede c8dfc6
-    rom->n_surfaces    = cpu_to_le32(NUM_SURFACES);
Hans de Goede c8dfc6
+    rom->n_surfaces    = cpu_to_le32(d->ssd.num_surfaces);
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
     for (i = 0, n = 0; i < ARRAY_SIZE(qxl_modes); i++) {
Hans de Goede c8dfc6
         fb = qxl_modes[i].y_res * qxl_modes[i].stride;
Hans de Goede c8dfc6
@@ -449,9 +450,9 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)
Hans de Goede c8dfc6
         }
Hans de Goede c8dfc6
         uint32_t id = le32_to_cpu(cmd->surface_id);
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
-        if (id >= NUM_SURFACES) {
Hans de Goede c8dfc6
+        if (id >= qxl->ssd.num_surfaces) {
Hans de Goede c8dfc6
             qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE id %d >= %d", id,
Hans de Goede c8dfc6
-                              NUM_SURFACES);
Hans de Goede c8dfc6
+                              qxl->ssd.num_surfaces);
Hans de Goede c8dfc6
             return 1;
Hans de Goede c8dfc6
         }
Hans de Goede c8dfc6
         qemu_mutex_lock(&qxl->track_lock);
Hans de Goede c8dfc6
@@ -527,7 +528,7 @@ static void interface_get_init_info(QXLInstance *sin, QXLDevInitInfo *info)
Hans de Goede c8dfc6
     info->num_memslots_groups = NUM_MEMSLOTS_GROUPS;
Hans de Goede c8dfc6
     info->internal_groupslot_id = 0;
Hans de Goede c8dfc6
     info->qxl_ram_size = le32_to_cpu(qxl->shadow_rom.num_pages) << TARGET_PAGE_BITS;
Hans de Goede c8dfc6
-    info->n_surfaces = NUM_SURFACES;
Hans de Goede c8dfc6
+    info->n_surfaces = qxl->ssd.num_surfaces;
Hans de Goede c8dfc6
 }
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
 static const char *qxl_mode_to_string(int mode)
Hans de Goede c8dfc6
@@ -1436,7 +1437,7 @@ async_common:
Hans de Goede c8dfc6
         QXLCookie *cookie = NULL;
Hans de Goede c8dfc6
         QXLRect update = d->ram->update_area;
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
-        if (d->ram->update_surface > NUM_SURFACES) {
Hans de Goede c8dfc6
+        if (d->ram->update_surface > d->ssd.num_surfaces) {
Hans de Goede c8dfc6
             qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
Hans de Goede c8dfc6
                               d->ram->update_surface);
Hans de Goede c8dfc6
             return;
Hans de Goede c8dfc6
@@ -1529,7 +1530,7 @@ async_common:
Hans de Goede c8dfc6
         }
Hans de Goede c8dfc6
         break;
Hans de Goede c8dfc6
     case QXL_IO_DESTROY_SURFACE_WAIT:
Hans de Goede c8dfc6
-        if (val >= NUM_SURFACES) {
Hans de Goede c8dfc6
+        if (val >= d->ssd.num_surfaces) {
Hans de Goede c8dfc6
             qxl_set_guest_bug(d, "QXL_IO_DESTROY_SURFACE (async=%d):"
Hans de Goede c8dfc6
                              "%" PRIu64 " >= NUM_SURFACES", async, val);
Hans de Goede c8dfc6
             goto cancel_async;
Hans de Goede c8dfc6
@@ -1707,7 +1708,7 @@ static void qxl_dirty_surfaces(PCIQXLDevice *qxl)
Hans de Goede c8dfc6
     vram_start =  (intptr_t)memory_region_get_ram_ptr(&qxl->vram_bar);
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
     /* dirty the off-screen surfaces */
Hans de Goede c8dfc6
-    for (i = 0; i < NUM_SURFACES; i++) {
Hans de Goede c8dfc6
+    for (i = 0; i < qxl->ssd.num_surfaces; i++) {
Hans de Goede c8dfc6
         QXLSurfaceCmd *cmd;
Hans de Goede c8dfc6
         intptr_t surface_offset;
Hans de Goede c8dfc6
         int surface_size;
Hans de Goede c8dfc6
@@ -1835,7 +1836,6 @@ static int qxl_init_common(PCIQXLDevice *qxl)
Hans de Goede c8dfc6
     qxl->mode = QXL_MODE_UNDEFINED;
Hans de Goede c8dfc6
     qxl->generation = 1;
Hans de Goede c8dfc6
     qxl->num_memslots = NUM_MEMSLOTS;
Hans de Goede c8dfc6
-    qxl->num_surfaces = NUM_SURFACES;
Hans de Goede c8dfc6
     qemu_mutex_init(&qxl->track_lock);
Hans de Goede c8dfc6
     qemu_mutex_init(&qxl->async_lock);
Hans de Goede c8dfc6
     qxl->current_async = QXL_UNDEFINED_IO;
Hans de Goede c8dfc6
@@ -1877,6 +1877,7 @@ static int qxl_init_common(PCIQXLDevice *qxl)
Hans de Goede c8dfc6
     init_qxl_rom(qxl);
Hans de Goede c8dfc6
     init_qxl_ram(qxl);
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
+    qxl->guest_surfaces.cmds = g_new0(QXLPHYSICAL, qxl->ssd.num_surfaces);
Hans de Goede c8dfc6
     memory_region_init_ram(&qxl->vram_bar, "qxl.vram", qxl->vram_size);
Hans de Goede c8dfc6
     vmstate_register_ram(&qxl->vram_bar, &qxl->pci.qdev);
Hans de Goede c8dfc6
     memory_region_init_alias(&qxl->vram32_bar, "qxl.vram32", &qxl->vram_bar,
Hans de Goede c8dfc6
@@ -2042,8 +2043,8 @@ static int qxl_post_load(void *opaque, int version)
Hans de Goede c8dfc6
         qxl_create_guest_primary(d, 1, QXL_SYNC);
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
         /* replay surface-create and cursor-set commands */
Hans de Goede c8dfc6
-        cmds = g_malloc0(sizeof(QXLCommandExt) * (NUM_SURFACES + 1));
Hans de Goede c8dfc6
-        for (in = 0, out = 0; in < NUM_SURFACES; in++) {
Hans de Goede c8dfc6
+        cmds = g_malloc0(sizeof(QXLCommandExt) * (d->ssd.num_surfaces + 1));
Hans de Goede c8dfc6
+        for (in = 0, out = 0; in < d->ssd.num_surfaces; in++) {
Hans de Goede c8dfc6
             if (d->guest_surfaces.cmds[in] == 0) {
Hans de Goede c8dfc6
                 continue;
Hans de Goede c8dfc6
             }
Hans de Goede c8dfc6
@@ -2143,9 +2144,10 @@ static VMStateDescription qxl_vmstate = {
Hans de Goede c8dfc6
                              qxl_memslot, struct guest_slots),
Hans de Goede c8dfc6
         VMSTATE_STRUCT(guest_primary.surface, PCIQXLDevice, 0,
Hans de Goede c8dfc6
                        qxl_surface, QXLSurfaceCreate),
Hans de Goede c8dfc6
-        VMSTATE_INT32_EQUAL(num_surfaces, PCIQXLDevice),
Hans de Goede c8dfc6
-        VMSTATE_ARRAY(guest_surfaces.cmds, PCIQXLDevice, NUM_SURFACES, 0,
Hans de Goede c8dfc6
-                      vmstate_info_uint64, uint64_t),
Hans de Goede c8dfc6
+        VMSTATE_INT32_EQUAL(ssd.num_surfaces, PCIQXLDevice),
Hans de Goede c8dfc6
+        VMSTATE_VARRAY_INT32(guest_surfaces.cmds, PCIQXLDevice,
Hans de Goede c8dfc6
+                             ssd.num_surfaces, 0,
Hans de Goede c8dfc6
+                             vmstate_info_uint64, uint64_t),
Hans de Goede c8dfc6
         VMSTATE_UINT64(guest_cursor, PCIQXLDevice),
Hans de Goede c8dfc6
         VMSTATE_END_OF_LIST()
Hans de Goede c8dfc6
     },
Hans de Goede c8dfc6
@@ -2173,6 +2175,7 @@ static Property qxl_properties[] = {
Hans de Goede c8dfc6
         DEFINE_PROP_UINT32("vram_size_mb", PCIQXLDevice, vram32_size_mb, -1),
Hans de Goede c8dfc6
         DEFINE_PROP_UINT32("vram64_size_mb", PCIQXLDevice, vram_size_mb, -1),
Hans de Goede c8dfc6
         DEFINE_PROP_UINT32("vgamem_mb", PCIQXLDevice, vgamem_size_mb, 16),
Hans de Goede c8dfc6
+        DEFINE_PROP_INT32("surfaces", PCIQXLDevice, ssd.num_surfaces, 1024),
Hans de Goede c8dfc6
         DEFINE_PROP_END_OF_LIST(),
Hans de Goede c8dfc6
 };
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
diff --git a/hw/qxl.h b/hw/qxl.h
Hans de Goede c8dfc6
index 9cfedb7..5553824 100644
Hans de Goede c8dfc6
--- a/hw/qxl.h
Hans de Goede c8dfc6
+++ b/hw/qxl.h
Hans de Goede c8dfc6
@@ -40,7 +40,6 @@ typedef struct PCIQXLDevice {
Hans de Goede c8dfc6
     uint32_t           revision;
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
     int32_t            num_memslots;
Hans de Goede c8dfc6
-    int32_t            num_surfaces;
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
     uint32_t           current_async;
Hans de Goede c8dfc6
     QemuMutex          async_lock;
Hans de Goede c8dfc6
@@ -65,7 +64,7 @@ typedef struct PCIQXLDevice {
Hans de Goede c8dfc6
     } guest_primary;
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
     struct surfaces {
Hans de Goede c8dfc6
-        QXLPHYSICAL    cmds[NUM_SURFACES];
Hans de Goede c8dfc6
+        QXLPHYSICAL    *cmds;
Hans de Goede c8dfc6
         uint32_t       count;
Hans de Goede c8dfc6
         uint32_t       max;
Hans de Goede c8dfc6
     } guest_surfaces;
Hans de Goede c8dfc6
diff --git a/ui/spice-display.c b/ui/spice-display.c
Hans de Goede c8dfc6
index 1c31418..99bc665 100644
Hans de Goede c8dfc6
--- a/ui/spice-display.c
Hans de Goede c8dfc6
+++ b/ui/spice-display.c
Hans de Goede c8dfc6
@@ -317,6 +317,9 @@ void qemu_spice_display_init_common(SimpleSpiceDisplay *ssd, DisplayState *ds)
Hans de Goede c8dfc6
     qemu_mutex_init(&ssd->lock);
Hans de Goede c8dfc6
     ssd->mouse_x = -1;
Hans de Goede c8dfc6
     ssd->mouse_y = -1;
Hans de Goede c8dfc6
+    if (ssd->num_surfaces == 0) {
Hans de Goede c8dfc6
+        ssd->num_surfaces = 1024;
Hans de Goede c8dfc6
+    }
Hans de Goede c8dfc6
     ssd->bufsize = (16 * 1024 * 1024);
Hans de Goede c8dfc6
     ssd->buf = g_malloc(ssd->bufsize);
Hans de Goede c8dfc6
 }
Hans de Goede c8dfc6
@@ -427,7 +430,7 @@ static void interface_get_init_info(QXLInstance *sin, QXLDevInitInfo *info)
Hans de Goede c8dfc6
     info->num_memslots_groups = NUM_MEMSLOTS_GROUPS;
Hans de Goede c8dfc6
     info->internal_groupslot_id = 0;
Hans de Goede c8dfc6
     info->qxl_ram_size = ssd->bufsize;
Hans de Goede c8dfc6
-    info->n_surfaces = NUM_SURFACES;
Hans de Goede c8dfc6
+    info->n_surfaces = ssd->num_surfaces;
Hans de Goede c8dfc6
 }
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
 static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)
Hans de Goede c8dfc6
diff --git a/ui/spice-display.h b/ui/spice-display.h
Hans de Goede c8dfc6
index bcff114..512ab78 100644
Hans de Goede c8dfc6
--- a/ui/spice-display.h
Hans de Goede c8dfc6
+++ b/ui/spice-display.h
Hans de Goede c8dfc6
@@ -32,8 +32,6 @@
Hans de Goede c8dfc6
 #define MEMSLOT_GROUP_GUEST 1
Hans de Goede c8dfc6
 #define NUM_MEMSLOTS_GROUPS 2
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
-#define NUM_SURFACES 1024
Hans de Goede c8dfc6
-
Hans de Goede c8dfc6
 /*
Hans de Goede c8dfc6
  * Internal enum to differenciate between options for
Hans de Goede c8dfc6
  * io calls that have a sync (old) version and an _async (new)
Hans de Goede c8dfc6
@@ -80,6 +78,7 @@ struct SimpleSpiceDisplay {
Hans de Goede c8dfc6
     QXLInstance qxl;
Hans de Goede c8dfc6
     uint32_t unique;
Hans de Goede c8dfc6
     QemuPfConv *conv;
Hans de Goede c8dfc6
+    int32_t num_surfaces;
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
     QXLRect dirty;
Hans de Goede c8dfc6
     int notify;
Hans de Goede c8dfc6
-- 
Hans de Goede c8dfc6
1.7.12
Hans de Goede c8dfc6