[Spice-devel,15/19] prefix io with qxl_io, add several

Submitted by Alon Levy on May 31, 2012, 10:24 a.m.

Details

Message ID 1338459893-1980-16-git-send-email-alevy@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Alon Levy May 31, 2012, 10:24 a.m.
---
 src/qxl.h         |    9 +++++---
 src/qxl_driver.c  |   65 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 src/qxl_surface.c |    2 +-
 3 files changed, 67 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/qxl.h b/src/qxl.h
index 56e03a3..819c98d 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -433,9 +433,12 @@  inline void qxl_mem_unverifiable(struct qxl_mem *mem) {}
  * I/O port commands
  */
 void qxl_update_area(qxl_screen_t *qxl);
-void qxl_memslot_add(qxl_screen_t *qxl, uint8_t id);
-void qxl_create_primary(qxl_screen_t *qxl);
-void qxl_notify_oom(qxl_screen_t *qxl);
+void qxl_io_memslot_add(qxl_screen_t *qxl, uint8_t id);
+void qxl_io_create_primary(qxl_screen_t *qxl);
+void qxl_io_notify_oom(qxl_screen_t *qxl);
+void qxl_io_flush_surfaces(qxl_screen_t *qxl);
+void qxl_io_destroy_all_surfaces (qxl_screen_t *qxl);
+void qxl_io_flush_release (qxl_screen_t *qxl);
 
 #ifdef XSPICE
 /* device to spice-server, now xspice to spice-server */
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index d78ea23..852cae2 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -153,7 +153,7 @@  void qxl_update_area(qxl_screen_t *qxl)
 #endif
 }
 
-void qxl_memslot_add(qxl_screen_t *qxl, uint8_t id)
+void qxl_io_memslot_add(qxl_screen_t *qxl, uint8_t id)
 {
 #ifndef XSPICE
     if (qxl->pci->revision >= 3) {
@@ -167,7 +167,7 @@  void qxl_memslot_add(qxl_screen_t *qxl, uint8_t id)
 #endif
 }
 
-void qxl_create_primary(qxl_screen_t *qxl)
+void qxl_io_create_primary(qxl_screen_t *qxl)
 {
 #ifndef XSPICE
     if (qxl->pci->revision >= 3) {
@@ -182,11 +182,21 @@  void qxl_create_primary(qxl_screen_t *qxl)
     qxl->device_primary = QXL_DEVICE_PRIMARY_CREATED;
 }
 
-void qxl_notify_oom(qxl_screen_t *qxl)
+void qxl_io_notify_oom(qxl_screen_t *qxl)
 {
     ioport_write(qxl, QXL_IO_NOTIFY_OOM, 0);
 }
 
+void qxl_io_flush_surfaces(qxl_screen_t *qxl)
+{
+#ifndef XSPICE
+    ioport_write(qxl, QXL_IO_FLUSH_SURFACES_ASYNC, 0);
+    qxl_wait_for_io_command(qxl);
+#else
+    ioport_write(qxl, QXL_IO_FLUSH_SURFACES_ASYNC, 0);
+#endif
+}
+
 int
 qxl_garbage_collect (qxl_screen_t *qxl)
 {
@@ -275,7 +285,7 @@  qxl_usleep (int useconds)
 int
 qxl_handle_oom (qxl_screen_t *qxl)
 {
-    qxl_notify_oom(qxl);
+    qxl_io_notify_oom(qxl);
 
 #if 0
     ErrorF (".");
@@ -533,7 +543,7 @@  setup_slot(qxl_screen_t *qxl, uint8_t slot_index_offset,
     ram_header->mem_slot.mem_start = slot->start_phys_addr;
     ram_header->mem_slot.mem_end = slot->end_phys_addr;
 
-    qxl_memslot_add(qxl, slot_index);
+    qxl_io_memslot_add(qxl, slot_index);
 
     slot->generation = qxl->rom->slot_generation;
     
@@ -586,6 +596,51 @@  qxl_mark_mem_unverifiable(qxl_screen_t *qxl)
     qxl_mem_unverifiable(qxl->surf_mem);
 }
 
+void
+qxl_io_destroy_all_surfaces (qxl_screen_t *qxl)
+{
+#ifndef XSPICE
+    if (qxl->pci->revision >= 3) {
+        ioport_write(qxl, QXL_IO_DESTROY_ALL_SURFACES_ASYNC, 0);
+        qxl_wait_for_io_command(qxl);
+    } else {
+        ioport_write(qxl, QXL_IO_DESTROY_ALL_SURFACES, 0);
+    }
+#else
+    ErrorF("Xspice: error: UNIMPLEMENTED qxl_io_destroy_all_surfaces\n");
+#endif
+    qxl->device_primary = QXL_DEVICE_PRIMARY_NONE;
+}
+
+void
+qxl_io_flush_release (qxl_screen_t *qxl)
+{
+    int do_reset;
+#ifndef XSPICE
+    /* can't send QXL_IO_FLUSH_RELEASE when not in native mode,
+     * see qxl.c:ioport_write */
+    do_reset = qxl->pci->revision < QXL_REVISION_STABLE_V10 &&
+               qxl->device_primary == QXL_DEVICE_PRIMARY_CREATED;
+#else
+    do_reset = 1;
+#endif
+    if (do_reset) {
+        ErrorF("%s: revision too old for QXL_IO_FLUSH_RELEASE\n", __FUNCTION__);
+        qxl_mark_mem_unverifiable(qxl);
+        if (qxl->device_primary == QXL_DEVICE_PRIMARY_CREATED) {
+            ioport_write(qxl, QXL_IO_RESET, 0);
+        }
+    } else {
+        /* Free release ring contents */
+        qxl_garbage_collect(qxl);
+        /* Get the last free list onto the release ring */
+        ioport_write(qxl, QXL_IO_FLUSH_RELEASE, 0);
+        ErrorF("%s after FLUSH_RELEASE\n", __FUNCTION__);
+        /* And release that. mspace allocators should be clean after. */
+        qxl_garbage_collect(qxl);
+    }
+}
+
 static Bool
 qxl_close_screen(int scrnIndex, ScreenPtr pScreen)
 {
diff --git a/src/qxl_surface.c b/src/qxl_surface.c
index 6414351..fd62576 100644
--- a/src/qxl_surface.c
+++ b/src/qxl_surface.c
@@ -335,7 +335,7 @@  qxl_surface_cache_create_primary (surface_cache_t	*cache,
     create->type = QXL_SURF_TYPE_PRIMARY;
     create->mem = physical_address (cache->qxl, cache->qxl->ram, cache->qxl->main_mem_slot);
 
-    qxl_create_primary(qxl);
+    qxl_io_create_primary(qxl);
 
     dev_addr = (uint8_t *)qxl->ram + mode->stride * (mode->y_res - 1);