[Spice-devel] [PATCH] qxl: add support for QXL_IO_RESET_RAM_DRAW_DATA

Yonit Halperin yhalperi at redhat.com
Mon Jul 12 02:16:28 PDT 2010


---
 hw/qxl.c |   54 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 12 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index ab1587a..2501b39 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -179,22 +179,29 @@ static void init_qxl_rom(PCIQXLDevice *d)
     d->modes      = modes;
 }
 
+static inline void qxl_init_ram_rings(PCIQXLDevice *d)
+{
+    uint64_t *item;
+    d->num_free_res = 0;
+    d->last_release = NULL;
+    SPICE_RING_INIT(&d->ram->cmd_ring);
+    SPICE_RING_INIT(&d->ram->cursor_ring);
+    SPICE_RING_INIT(&d->ram->release_ring);
+    SPICE_RING_PROD_ITEM(&d->ram->release_ring, item);
+    *item = 0;
+    qxl_ring_set_dirty(d);
+}
+
 static void init_qxl_ram(PCIQXLDevice *d)
 {
     uint8_t *buf;
-    uint64_t *item;
 
     buf = d->vga.vram_ptr;
     d->ram = (QXLRam *)(buf + le32_to_cpu(d->shadow_rom.ram_header_offset));
     d->ram->magic       = cpu_to_le32(QXL_RAM_MAGIC);
     d->ram->int_pending = cpu_to_le32(0);
     d->ram->int_mask    = cpu_to_le32(0);
-    SPICE_RING_INIT(&d->ram->cmd_ring);
-    SPICE_RING_INIT(&d->ram->cursor_ring);
-    SPICE_RING_INIT(&d->ram->release_ring);
-    SPICE_RING_PROD_ITEM(&d->ram->release_ring, item);
-    *item = 0;
-    qxl_ring_set_dirty(d);
+    qxl_init_ram_rings(d);
 }
 
 static void qxl_set_dirty(ram_addr_t addr, ram_addr_t end)
@@ -590,8 +597,6 @@ static void qxl_reset_state(PCIQXLDevice *d)
     *rom = d->shadow_rom;
     qxl_rom_set_dirty(d);
     init_qxl_ram(d);
-    d->num_free_res = 0;
-    d->last_release = NULL;
     memset(&d->ssd.dirty, 0, sizeof(d->ssd.dirty));
 }
 
@@ -607,14 +612,20 @@ static void qxl_soft_reset(PCIQXLDevice *d)
     }
 }
 
+
+static inline void qxl_reset_worker_ram_draw_data(PCIQXLDevice *d)
+{
+    d->ssd.worker->reset_cursor(d->ssd.worker);
+    d->ssd.worker->reset_image_cache(d->ssd.worker);
+    qxl_reset_surfaces(d);
+}
+
 static void qxl_hard_reset(PCIQXLDevice *d, int loadvm)
 {
     dprintf(d, 1, "%s: start%s\n", __FUNCTION__,
             loadvm ? " (loadvm)" : "");
 
-    d->ssd.worker->reset_cursor(d->ssd.worker);
-    d->ssd.worker->reset_image_cache(d->ssd.worker);
-    qxl_reset_surfaces(d);
+    qxl_reset_worker_ram_draw_data(d);
     qxl_reset_memslots(d);
 
     /* pre loadvm reset must not touch QXLRam.  This lives in
@@ -850,6 +861,20 @@ static void qxl_set_mode(PCIQXLDevice *d, int modenr)
     qxl_rom_set_dirty(d);
 }
 
+static void qxl_reset_ram_draw_data(PCIQXLDevice *d)
+{
+    dprintf(d, 1, "%s\n", __FUNCTION__);
+    if (d->mode == QXL_MODE_VGA) {
+        return;
+    }
+
+    qxl_reset_worker_ram_draw_data(d);
+
+    assert(SPICE_RING_IS_EMPTY(&d->ram->cmd_ring));
+    assert(SPICE_RING_IS_EMPTY(&d->ram->cursor_ring));
+    qxl_init_ram_rings(d);
+}
+
 static void ioport_write(void *opaque, uint32_t addr, uint32_t val)
 {
     PCIQXLDevice *d = opaque;
@@ -861,6 +886,7 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)
     case QXL_IO_MEMSLOT_ADD:
     case QXL_IO_MEMSLOT_DEL:
     case QXL_IO_CREATE_PRIMARY:
+    case QXL_IO_RESET_RAM_DRAW_DATA:
         break;
     default:
         if (d->mode == QXL_MODE_NATIVE || d->mode == QXL_MODE_COMPAT)
@@ -933,6 +959,10 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)
     case QXL_IO_DESTROY_ALL_SURFACES:
         d->ssd.worker->destroy_surfaces(d->ssd.worker);
         break;
+    case QXL_IO_RESET_RAM_DRAW_DATA:
+        dprintf(d, 1, "QXL_IO_RESET_RAM_DRAW_DATA\n");
+        qxl_reset_ram_draw_data(d);
+        break;
     default:
         fprintf(stderr, "%s: ioport=0x%x, abort()\n", __FUNCTION__, io_port);
         abort();
-- 
1.6.6.1



More information about the Spice-devel mailing list