From 9bebbb5b7d0e6da5219d1da5884d3cdf5ca0326f Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Mon, 21 Mar 2011 11:06:36 -0300 Subject: [PATCH 01/16] Revert "spice/qxl: locking fix for qemu-kvm" RH-Author: Alon Levy Message-id: <1300705600-19285-2-git-send-email-alevy@redhat.com> Patchwork-id: 20323 O-Subject: [PATCH RHEL6.1 v2 1/5] Revert "spice/qxl: locking fix for qemu-kvm" Bugzilla: 678208 RH-Acked-by: Uri Lublin RH-Acked-by: Gleb Natapov RH-Acked-by: Hans de Goede This reverts commit 15ba0114aa3ddedbeb2519cb0a8755a05f0a1d38. BZ: 681220 upstream: original isn't there. We would like to solve this without locking/unlocking the qemu-iothread-lock. Instead, operations that touch devices, are to be done in the iothread (main thread). This (currently) only affects VGA mode. --- hw/qxl.c | 37 ++++++++----------------------------- ui/spice-display.c | 12 ++++++------ ui/spice-display.h | 6 ------ 3 files changed, 14 insertions(+), 41 deletions(-) Signed-off-by: Luiz Capitulino --- hw/qxl.c | 37 ++++++++----------------------------- ui/spice-display.c | 12 ++++++------ ui/spice-display.h | 6 ------ 3 files changed, 14 insertions(+), 41 deletions(-) diff --git a/hw/qxl.c b/hw/qxl.c index 58d6222..61fd1fc 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -125,27 +125,6 @@ static void qxl_reset_memslots(PCIQXLDevice *d); static void qxl_reset_surfaces(PCIQXLDevice *d); static void qxl_ring_set_dirty(PCIQXLDevice *qxl); -/* qemu-kvm locking ... */ -void qxl_unlock_iothread(SimpleSpiceDisplay *ssd) -{ - if (cpu_single_env) { - assert(ssd->env == NULL); - ssd->env = cpu_single_env; - cpu_single_env = NULL; - } - qemu_mutex_unlock_iothread(); -} - -void qxl_lock_iothread(SimpleSpiceDisplay *ssd) -{ - qemu_mutex_lock_iothread(); - if (ssd->env) { - assert(cpu_single_env == NULL); - cpu_single_env = ssd->env; - ssd->env = NULL; - } -} - static inline uint32_t msb_mask(uint32_t val) { uint32_t mask; @@ -683,10 +662,10 @@ static void qxl_hard_reset(PCIQXLDevice *d, int loadvm) dprint(d, 1, "%s: start%s\n", __FUNCTION__, loadvm ? " (loadvm)" : ""); - qxl_unlock_iothread(&d->ssd); + qemu_mutex_unlock_iothread(); d->ssd.worker->reset_cursor(d->ssd.worker); d->ssd.worker->reset_image_cache(d->ssd.worker); - qxl_lock_iothread(&d->ssd); + qemu_mutex_lock_iothread(); qxl_reset_surfaces(d); qxl_reset_memslots(d); @@ -816,9 +795,9 @@ static void qxl_reset_surfaces(PCIQXLDevice *d) { dprint(d, 1, "%s:\n", __FUNCTION__); d->mode = QXL_MODE_UNDEFINED; - qxl_unlock_iothread(&d->ssd); + qemu_mutex_unlock_iothread(); d->ssd.worker->destroy_surfaces(d->ssd.worker); - qxl_lock_iothread(&d->ssd); + qemu_mutex_lock_iothread(); memset(&d->guest_surfaces.cmds, 0, sizeof(d->guest_surfaces.cmds)); } @@ -887,9 +866,9 @@ static void qxl_destroy_primary(PCIQXLDevice *d) dprint(d, 1, "%s\n", __FUNCTION__); d->mode = QXL_MODE_UNDEFINED; - qxl_unlock_iothread(&d->ssd); + qemu_mutex_unlock_iothread(); d->ssd.worker->destroy_primary_surface(d->ssd.worker, 0); - qxl_lock_iothread(&d->ssd); + qemu_mutex_lock_iothread(); } static void qxl_set_mode(PCIQXLDevice *d, int modenr, int loadvm) @@ -959,10 +938,10 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val) case QXL_IO_UPDATE_AREA: { QXLRect update = d->ram->update_area; - qxl_unlock_iothread(&d->ssd); + qemu_mutex_unlock_iothread(); d->ssd.worker->update_area(d->ssd.worker, d->ram->update_surface, &update, NULL, 0, 0); - qxl_lock_iothread(&d->ssd); + qemu_mutex_lock_iothread(); break; } case QXL_IO_NOTIFY_CMD: diff --git a/ui/spice-display.c b/ui/spice-display.c index 3f978e5..99d9fd6 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -187,18 +187,18 @@ void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd) surface.mem = (intptr_t)ssd->buf; surface.group_id = MEMSLOT_GROUP_HOST; - qxl_unlock_iothread(ssd); + qemu_mutex_unlock_iothread(); ssd->worker->create_primary_surface(ssd->worker, 0, &surface); - qxl_lock_iothread(ssd); + qemu_mutex_lock_iothread(); } void qemu_spice_destroy_host_primary(SimpleSpiceDisplay *ssd) { dprint(1, "%s:\n", __FUNCTION__); - qxl_unlock_iothread(ssd); + qemu_mutex_unlock_iothread(); ssd->worker->destroy_primary_surface(ssd->worker, 0); - qxl_lock_iothread(ssd); + qemu_mutex_lock_iothread(); } void qemu_spice_vm_change_state_handler(void *opaque, int running, int reason) @@ -208,9 +208,9 @@ void qemu_spice_vm_change_state_handler(void *opaque, int running, int reason) if (running) { ssd->worker->start(ssd->worker); } else { - qxl_unlock_iothread(ssd); + qemu_mutex_unlock_iothread(); ssd->worker->stop(ssd->worker); - qxl_lock_iothread(ssd); + qemu_mutex_lock_iothread(); } ssd->running = running; } diff --git a/ui/spice-display.h b/ui/spice-display.h index df74828..aef0464 100644 --- a/ui/spice-display.h +++ b/ui/spice-display.h @@ -43,9 +43,6 @@ typedef struct SimpleSpiceDisplay { QXLRect dirty; int notify; int running; - - /* qemu-kvm locking ... */ - void *env; } SimpleSpiceDisplay; typedef struct SimpleSpiceUpdate { @@ -55,9 +52,6 @@ typedef struct SimpleSpiceUpdate { uint8_t *bitmap; } SimpleSpiceUpdate; -void qxl_unlock_iothread(SimpleSpiceDisplay *ssd); -void qxl_lock_iothread(SimpleSpiceDisplay *ssd); - int qemu_spice_rect_is_empty(const QXLRect* r); void qemu_spice_rect_union(QXLRect *dest, const QXLRect *r); -- 1.7.4.1.230.gae447