|
Hans de Goede |
56753f |
From bbe362cd6a386d98a94ac791f1263671bd79b754 Mon Sep 17 00:00:00 2001
|
|
Hans de Goede |
56753f |
From: Alon Levy <alevy@redhat.com>
|
|
Hans de Goede |
56753f |
Date: Fri, 24 Feb 2012 23:19:30 +0200
|
|
Hans de Goede |
56753f |
Subject: [PATCH 417/434] qxl: introduce QXLCookie
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
Will be used in the next patch.
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
Signed-off-by: Alon Levy <alevy@redhat.com>
|
|
Hans de Goede |
56753f |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
Hans de Goede |
56753f |
---
|
|
Hans de Goede |
56753f |
hw/qxl-render.c | 2 +-
|
|
Hans de Goede |
56753f |
hw/qxl.c | 61 ++++++++++++++++++++++++++++++++++++++++------------
|
|
Hans de Goede |
56753f |
hw/qxl.h | 2 +-
|
|
Hans de Goede |
56753f |
ui/spice-display.c | 22 ++++++++++++++++---
|
|
Hans de Goede |
56753f |
ui/spice-display.h | 14 ++++++++++++
|
|
Hans de Goede |
56753f |
5 files changed, 82 insertions(+), 19 deletions(-)
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
diff --git a/hw/qxl-render.c b/hw/qxl-render.c
|
|
Hans de Goede |
56753f |
index 5811d74..4c22166 100644
|
|
Hans de Goede |
56753f |
--- a/hw/qxl-render.c
|
|
Hans de Goede |
56753f |
+++ b/hw/qxl-render.c
|
|
Hans de Goede |
56753f |
@@ -127,7 +127,7 @@ void qxl_render_update(PCIQXLDevice *qxl)
|
|
Hans de Goede |
56753f |
if (runstate_is_running() && qxl->guest_primary.commands) {
|
|
Hans de Goede |
56753f |
qxl->guest_primary.commands = 0;
|
|
Hans de Goede |
56753f |
qxl_spice_update_area(qxl, 0, &update,
|
|
Hans de Goede |
56753f |
- dirty, ARRAY_SIZE(dirty), 1, QXL_SYNC);
|
|
Hans de Goede |
56753f |
+ dirty, ARRAY_SIZE(dirty), 1, QXL_SYNC, NULL);
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
if (redraw) {
|
|
Hans de Goede |
56753f |
memset(dirty, 0, sizeof(dirty));
|
|
Hans de Goede |
56753f |
diff --git a/hw/qxl.c b/hw/qxl.c
|
|
Hans de Goede |
56753f |
index 0be9859..e6e65d9 100644
|
|
Hans de Goede |
56753f |
--- a/hw/qxl.c
|
|
Hans de Goede |
56753f |
+++ b/hw/qxl.c
|
|
Hans de Goede |
56753f |
@@ -141,14 +141,15 @@ void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
|
|
Hans de Goede |
56753f |
struct QXLRect *area, struct QXLRect *dirty_rects,
|
|
Hans de Goede |
56753f |
uint32_t num_dirty_rects,
|
|
Hans de Goede |
56753f |
uint32_t clear_dirty_region,
|
|
Hans de Goede |
56753f |
- qxl_async_io async)
|
|
Hans de Goede |
56753f |
+ qxl_async_io async, struct QXLCookie *cookie)
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
if (async == QXL_SYNC) {
|
|
Hans de Goede |
56753f |
qxl->ssd.worker->update_area(qxl->ssd.worker, surface_id, area,
|
|
Hans de Goede |
56753f |
dirty_rects, num_dirty_rects, clear_dirty_region);
|
|
Hans de Goede |
56753f |
} else {
|
|
Hans de Goede |
56753f |
+ assert(cookie != NULL);
|
|
Hans de Goede |
56753f |
spice_qxl_update_area_async(&qxl->ssd.qxl, surface_id, area,
|
|
Hans de Goede |
56753f |
- clear_dirty_region, 0);
|
|
Hans de Goede |
56753f |
+ clear_dirty_region, (uint64_t)cookie);
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
@@ -164,9 +165,13 @@ static void qxl_spice_destroy_surface_wait_complete(PCIQXLDevice *qxl,
|
|
Hans de Goede |
56753f |
static void qxl_spice_destroy_surface_wait(PCIQXLDevice *qxl, uint32_t id,
|
|
Hans de Goede |
56753f |
qxl_async_io async)
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
+ QXLCookie *cookie;
|
|
Hans de Goede |
56753f |
+
|
|
Hans de Goede |
56753f |
if (async) {
|
|
Hans de Goede |
56753f |
- spice_qxl_destroy_surface_async(&qxl->ssd.qxl, id,
|
|
Hans de Goede |
56753f |
- (uint64_t)id);
|
|
Hans de Goede |
56753f |
+ cookie = qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
Hans de Goede |
56753f |
+ QXL_IO_DESTROY_SURFACE_ASYNC);
|
|
Hans de Goede |
56753f |
+ cookie->u.surface_id = id;
|
|
Hans de Goede |
56753f |
+ spice_qxl_destroy_surface_async(&qxl->ssd.qxl, id, (uint64_t)cookie);
|
|
Hans de Goede |
56753f |
} else {
|
|
Hans de Goede |
56753f |
qxl->ssd.worker->destroy_surface_wait(qxl->ssd.worker, id);
|
|
Hans de Goede |
56753f |
qxl_spice_destroy_surface_wait_complete(qxl, id);
|
|
Hans de Goede |
56753f |
@@ -175,7 +180,9 @@ static void qxl_spice_destroy_surface_wait(PCIQXLDevice *qxl, uint32_t id,
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
static void qxl_spice_flush_surfaces_async(PCIQXLDevice *qxl)
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
- spice_qxl_flush_surfaces_async(&qxl->ssd.qxl, 0);
|
|
Hans de Goede |
56753f |
+ spice_qxl_flush_surfaces_async(&qxl->ssd.qxl,
|
|
Hans de Goede |
56753f |
+ (uint64_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
Hans de Goede |
56753f |
+ QXL_IO_FLUSH_SURFACES_ASYNC));
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
|
|
Hans de Goede |
56753f |
@@ -205,7 +212,9 @@ static void qxl_spice_destroy_surfaces_complete(PCIQXLDevice *qxl)
|
|
Hans de Goede |
56753f |
static void qxl_spice_destroy_surfaces(PCIQXLDevice *qxl, qxl_async_io async)
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
if (async) {
|
|
Hans de Goede |
56753f |
- spice_qxl_destroy_surfaces_async(&qxl->ssd.qxl, 0);
|
|
Hans de Goede |
56753f |
+ spice_qxl_destroy_surfaces_async(&qxl->ssd.qxl,
|
|
Hans de Goede |
56753f |
+ (uint64_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
Hans de Goede |
56753f |
+ QXL_IO_DESTROY_ALL_SURFACES_ASYNC));
|
|
Hans de Goede |
56753f |
} else {
|
|
Hans de Goede |
56753f |
qxl->ssd.worker->destroy_surfaces(qxl->ssd.worker);
|
|
Hans de Goede |
56753f |
qxl_spice_destroy_surfaces_complete(qxl);
|
|
Hans de Goede |
56753f |
@@ -721,9 +730,8 @@ static int interface_flush_resources(QXLInstance *sin)
|
|
Hans de Goede |
56753f |
static void qxl_create_guest_primary_complete(PCIQXLDevice *d);
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
/* called from spice server thread context only */
|
|
Hans de Goede |
56753f |
-static void interface_async_complete(QXLInstance *sin, uint64_t cookie)
|
|
Hans de Goede |
56753f |
+static void interface_async_complete_io(PCIQXLDevice *qxl, QXLCookie *cookie)
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
- PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
Hans de Goede |
56753f |
uint32_t current_async;
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
qemu_mutex_lock(&qxl->async_lock);
|
|
Hans de Goede |
56753f |
@@ -731,8 +739,16 @@ static void interface_async_complete(QXLInstance *sin, uint64_t cookie)
|
|
Hans de Goede |
56753f |
qxl->current_async = QXL_UNDEFINED_IO;
|
|
Hans de Goede |
56753f |
qemu_mutex_unlock(&qxl->async_lock);
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
- dprint(qxl, 2, "async_complete: %d (%" PRId64 ") done\n",
|
|
Hans de Goede |
56753f |
- current_async, cookie);
|
|
Hans de Goede |
56753f |
+ dprint(qxl, 2, "async_complete: %d (%p) done\n", current_async, cookie);
|
|
Hans de Goede |
56753f |
+ if (!cookie) {
|
|
Hans de Goede |
56753f |
+ fprintf(stderr, "qxl: %s: error, cookie is NULL\n", __func__);
|
|
Hans de Goede |
56753f |
+ return;
|
|
Hans de Goede |
56753f |
+ }
|
|
Hans de Goede |
56753f |
+ if (cookie && current_async != cookie->io) {
|
|
Hans de Goede |
56753f |
+ fprintf(stderr,
|
|
Hans de Goede |
56753f |
+ "qxl: %s: error: current_async = %d != %ld = cookie->io\n",
|
|
Hans de Goede |
56753f |
+ __func__, current_async, cookie->io);
|
|
Hans de Goede |
56753f |
+ }
|
|
Hans de Goede |
56753f |
switch (current_async) {
|
|
Hans de Goede |
56753f |
case QXL_IO_CREATE_PRIMARY_ASYNC:
|
|
Hans de Goede |
56753f |
qxl_create_guest_primary_complete(qxl);
|
|
Hans de Goede |
56753f |
@@ -741,12 +757,29 @@ static void interface_async_complete(QXLInstance *sin, uint64_t cookie)
|
|
Hans de Goede |
56753f |
qxl_spice_destroy_surfaces_complete(qxl);
|
|
Hans de Goede |
56753f |
break;
|
|
Hans de Goede |
56753f |
case QXL_IO_DESTROY_SURFACE_ASYNC:
|
|
Hans de Goede |
56753f |
- qxl_spice_destroy_surface_wait_complete(qxl, (uint32_t)cookie);
|
|
Hans de Goede |
56753f |
+ qxl_spice_destroy_surface_wait_complete(qxl, cookie->u.surface_id);
|
|
Hans de Goede |
56753f |
break;
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
qxl_send_events(qxl, QXL_INTERRUPT_IO_CMD);
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
+/* called from spice server thread context only */
|
|
Hans de Goede |
56753f |
+static void interface_async_complete(QXLInstance *sin, uint64_t cookie_token)
|
|
Hans de Goede |
56753f |
+{
|
|
Hans de Goede |
56753f |
+ PCIQXLDevice *qxl = container_of(sin, PCIQXLDevice, ssd.qxl);
|
|
Hans de Goede |
56753f |
+ QXLCookie *cookie = (QXLCookie *)cookie_token;
|
|
Hans de Goede |
56753f |
+
|
|
Hans de Goede |
56753f |
+ switch (cookie->type) {
|
|
Hans de Goede |
56753f |
+ case QXL_COOKIE_TYPE_IO:
|
|
Hans de Goede |
56753f |
+ interface_async_complete_io(qxl, cookie);
|
|
Hans de Goede |
56753f |
+ break;
|
|
Hans de Goede |
56753f |
+ default:
|
|
Hans de Goede |
56753f |
+ fprintf(stderr, "qxl: %s: unexpected cookie type %d\n",
|
|
Hans de Goede |
56753f |
+ __func__, cookie->type);
|
|
Hans de Goede |
56753f |
+ }
|
|
Hans de Goede |
56753f |
+ g_free(cookie);
|
|
Hans de Goede |
56753f |
+}
|
|
Hans de Goede |
56753f |
+
|
|
Hans de Goede |
56753f |
static const QXLInterface qxl_interface = {
|
|
Hans de Goede |
56753f |
.base.type = SPICE_INTERFACE_QXL,
|
|
Hans de Goede |
56753f |
.base.description = "qxl gpu",
|
|
Hans de Goede |
56753f |
@@ -1057,9 +1090,7 @@ static int qxl_destroy_primary(PCIQXLDevice *d, qxl_async_io async)
|
|
Hans de Goede |
56753f |
if (d->mode == QXL_MODE_UNDEFINED) {
|
|
Hans de Goede |
56753f |
return 0;
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
-
|
|
Hans de Goede |
56753f |
dprint(d, 1, "%s\n", __FUNCTION__);
|
|
Hans de Goede |
56753f |
-
|
|
Hans de Goede |
56753f |
d->mode = QXL_MODE_UNDEFINED;
|
|
Hans de Goede |
56753f |
qemu_spice_destroy_primary_surface(&d->ssd, 0, async);
|
|
Hans de Goede |
56753f |
qxl_spice_reset_cursor(d);
|
|
Hans de Goede |
56753f |
@@ -1187,7 +1218,9 @@ async_common:
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
QXLRect update = d->ram->update_area;
|
|
Hans de Goede |
56753f |
qxl_spice_update_area(d, d->ram->update_surface,
|
|
Hans de Goede |
56753f |
- &update, NULL, 0, 0, async);
|
|
Hans de Goede |
56753f |
+ &update, NULL, 0, 0, async,
|
|
Hans de Goede |
56753f |
+ qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
Hans de Goede |
56753f |
+ QXL_IO_UPDATE_AREA_ASYNC));
|
|
Hans de Goede |
56753f |
break;
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
case QXL_IO_NOTIFY_CMD:
|
|
Hans de Goede |
56753f |
diff --git a/hw/qxl.h b/hw/qxl.h
|
|
Hans de Goede |
56753f |
index 53a3ace..1443925 100644
|
|
Hans de Goede |
56753f |
--- a/hw/qxl.h
|
|
Hans de Goede |
56753f |
+++ b/hw/qxl.h
|
|
Hans de Goede |
56753f |
@@ -118,7 +118,7 @@ void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
|
|
Hans de Goede |
56753f |
struct QXLRect *area, struct QXLRect *dirty_rects,
|
|
Hans de Goede |
56753f |
uint32_t num_dirty_rects,
|
|
Hans de Goede |
56753f |
uint32_t clear_dirty_region,
|
|
Hans de Goede |
56753f |
- qxl_async_io async);
|
|
Hans de Goede |
56753f |
+ qxl_async_io async, QXLCookie *cookie);
|
|
Hans de Goede |
56753f |
void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
|
|
Hans de Goede |
56753f |
uint32_t count);
|
|
Hans de Goede |
56753f |
void qxl_spice_oom(PCIQXLDevice *qxl);
|
|
Hans de Goede |
56753f |
diff --git a/ui/spice-display.c b/ui/spice-display.c
|
|
Hans de Goede |
56753f |
index ad76bae..ab266ae 100644
|
|
Hans de Goede |
56753f |
--- a/ui/spice-display.c
|
|
Hans de Goede |
56753f |
+++ b/ui/spice-display.c
|
|
Hans de Goede |
56753f |
@@ -60,11 +60,23 @@ void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r)
|
|
Hans de Goede |
56753f |
dest->right = MAX(dest->right, r->right);
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
+QXLCookie *qxl_cookie_new(int type, uint64_t io)
|
|
Hans de Goede |
56753f |
+{
|
|
Hans de Goede |
56753f |
+ QXLCookie *cookie;
|
|
Hans de Goede |
56753f |
+
|
|
Hans de Goede |
56753f |
+ cookie = g_malloc0(sizeof(*cookie));
|
|
Hans de Goede |
56753f |
+ cookie->type = type;
|
|
Hans de Goede |
56753f |
+ cookie->io = io;
|
|
Hans de Goede |
56753f |
+ return cookie;
|
|
Hans de Goede |
56753f |
+}
|
|
Hans de Goede |
56753f |
+
|
|
Hans de Goede |
56753f |
void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot,
|
|
Hans de Goede |
56753f |
qxl_async_io async)
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
if (async != QXL_SYNC) {
|
|
Hans de Goede |
56753f |
- spice_qxl_add_memslot_async(&ssd->qxl, memslot, 0);
|
|
Hans de Goede |
56753f |
+ spice_qxl_add_memslot_async(&ssd->qxl, memslot,
|
|
Hans de Goede |
56753f |
+ (uint64_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
Hans de Goede |
56753f |
+ QXL_IO_MEMSLOT_ADD_ASYNC));
|
|
Hans de Goede |
56753f |
} else {
|
|
Hans de Goede |
56753f |
ssd->worker->add_memslot(ssd->worker, memslot);
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
@@ -80,7 +92,9 @@ void qemu_spice_create_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id,
|
|
Hans de Goede |
56753f |
qxl_async_io async)
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
if (async != QXL_SYNC) {
|
|
Hans de Goede |
56753f |
- spice_qxl_create_primary_surface_async(&ssd->qxl, id, surface, 0);
|
|
Hans de Goede |
56753f |
+ spice_qxl_create_primary_surface_async(&ssd->qxl, id, surface,
|
|
Hans de Goede |
56753f |
+ (uint64_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
Hans de Goede |
56753f |
+ QXL_IO_CREATE_PRIMARY_ASYNC));
|
|
Hans de Goede |
56753f |
} else {
|
|
Hans de Goede |
56753f |
ssd->worker->create_primary_surface(ssd->worker, id, surface);
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
@@ -91,7 +105,9 @@ void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd,
|
|
Hans de Goede |
56753f |
uint32_t id, qxl_async_io async)
|
|
Hans de Goede |
56753f |
{
|
|
Hans de Goede |
56753f |
if (async != QXL_SYNC) {
|
|
Hans de Goede |
56753f |
- spice_qxl_destroy_primary_surface_async(&ssd->qxl, id, 0);
|
|
Hans de Goede |
56753f |
+ spice_qxl_destroy_primary_surface_async(&ssd->qxl, id,
|
|
Hans de Goede |
56753f |
+ (uint64_t)qxl_cookie_new(QXL_COOKIE_TYPE_IO,
|
|
Hans de Goede |
56753f |
+ QXL_IO_DESTROY_PRIMARY_ASYNC));
|
|
Hans de Goede |
56753f |
} else {
|
|
Hans de Goede |
56753f |
ssd->worker->destroy_primary_surface(ssd->worker, id);
|
|
Hans de Goede |
56753f |
}
|
|
Hans de Goede |
56753f |
diff --git a/ui/spice-display.h b/ui/spice-display.h
|
|
Hans de Goede |
56753f |
index a23bfc8..8a010cb 100644
|
|
Hans de Goede |
56753f |
--- a/ui/spice-display.h
|
|
Hans de Goede |
56753f |
+++ b/ui/spice-display.h
|
|
Hans de Goede |
56753f |
@@ -48,6 +48,20 @@ typedef enum qxl_async_io {
|
|
Hans de Goede |
56753f |
QXL_ASYNC,
|
|
Hans de Goede |
56753f |
} qxl_async_io;
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
+enum {
|
|
Hans de Goede |
56753f |
+ QXL_COOKIE_TYPE_IO,
|
|
Hans de Goede |
56753f |
+};
|
|
Hans de Goede |
56753f |
+
|
|
Hans de Goede |
56753f |
+typedef struct QXLCookie {
|
|
Hans de Goede |
56753f |
+ int type;
|
|
Hans de Goede |
56753f |
+ uint64_t io;
|
|
Hans de Goede |
56753f |
+ union {
|
|
Hans de Goede |
56753f |
+ uint32_t surface_id;
|
|
Hans de Goede |
56753f |
+ } u;
|
|
Hans de Goede |
56753f |
+} QXLCookie;
|
|
Hans de Goede |
56753f |
+
|
|
Hans de Goede |
56753f |
+QXLCookie *qxl_cookie_new(int type, uint64_t io);
|
|
Hans de Goede |
56753f |
+
|
|
Hans de Goede |
56753f |
typedef struct SimpleSpiceDisplay SimpleSpiceDisplay;
|
|
Hans de Goede |
56753f |
typedef struct SimpleSpiceUpdate SimpleSpiceUpdate;
|
|
Hans de Goede |
56753f |
|
|
Hans de Goede |
56753f |
--
|
|
Hans de Goede |
56753f |
1.7.10
|
|
Hans de Goede |
56753f |
|