From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlenL-0006YD-Np for qemu-devel@nongnu.org; Tue, 04 Nov 2014 09:09:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XlenF-0002Sq-JR for qemu-devel@nongnu.org; Tue, 04 Nov 2014 09:09:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XlenF-0002Sk-Br for qemu-devel@nongnu.org; Tue, 04 Nov 2014 09:09:09 -0500 From: Gerd Hoffmann Date: Tue, 4 Nov 2014 15:08:57 +0100 Message-Id: <1415110138-24577-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 1/2] spice: use bottom half instead of refresh timer for cursor updates List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Anthony Liguori Calling directly doesn't work due to the qxl-render code running in spice server thread context. Meanwhile bottom half scheduling is thread-safe though, so we can use that to kick a cursor update in main i/o thread context. Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Gerd Hoffmann --- hw/display/qxl-render.c | 2 ++ hw/display/qxl.c | 5 +---- include/ui/spice-display.h | 3 ++- ui/spice-display.c | 12 ++++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c index e812ddd..a542087 100644 --- a/hw/display/qxl-render.c +++ b/hw/display/qxl-render.c @@ -283,12 +283,14 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommand= Ext *ext) qxl->ssd.mouse_x =3D cmd->u.set.position.x; qxl->ssd.mouse_y =3D cmd->u.set.position.y; qemu_mutex_unlock(&qxl->ssd.lock); + qemu_bh_schedule(qxl->ssd.cursor_bh); break; case QXL_CURSOR_MOVE: qemu_mutex_lock(&qxl->ssd.lock); qxl->ssd.mouse_x =3D cmd->u.position.x; qxl->ssd.mouse_y =3D cmd->u.position.y; qemu_mutex_unlock(&qxl->ssd.lock); + qemu_bh_schedule(qxl->ssd.cursor_bh); break; } return 0; diff --git a/hw/display/qxl.c b/hw/display/qxl.c index b540dd6..5151bac 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1861,10 +1861,6 @@ static void display_refresh(DisplayChangeListener = *dcl) =20 if (qxl->mode =3D=3D QXL_MODE_VGA) { qemu_spice_display_refresh(&qxl->ssd); - } else { - qemu_mutex_lock(&qxl->ssd.lock); - qemu_spice_cursor_refresh_unlocked(&qxl->ssd); - qemu_mutex_unlock(&qxl->ssd.lock); } } =20 @@ -2025,6 +2021,7 @@ static int qxl_init_common(PCIQXLDevice *qxl) qxl_reset_state(qxl); =20 qxl->update_area_bh =3D qemu_bh_new(qxl_render_update_area_bh, qxl); + qxl->ssd.cursor_bh =3D qemu_bh_new(qemu_spice_cursor_refresh_bh, &qx= l->ssd); =20 return 0; } diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index 4252ab8..53883a1 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -102,6 +102,7 @@ struct SimpleSpiceDisplay { /* cursor (with qxl): qxl local renderer -> displaychangelistener */ QEMUCursor *cursor; int mouse_x, mouse_y; + QEMUBH *cursor_bh; }; =20 struct SimpleSpiceUpdate { @@ -134,7 +135,7 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ss= d, void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, DisplaySurface *surface); void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd); -void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd); +void qemu_spice_cursor_refresh_bh(void *opaque); =20 void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *mems= lot, qxl_async_io async); diff --git a/ui/spice-display.c b/ui/spice-display.c index def7b52..5d03340 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -438,7 +438,7 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ss= d, ssd->notify++; } =20 -void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd) +static void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd) { if (ssd->cursor) { assert(ssd->dcl.con); @@ -454,6 +454,15 @@ void qemu_spice_cursor_refresh_unlocked(SimpleSpiceD= isplay *ssd) } } =20 +void qemu_spice_cursor_refresh_bh(void *opaque) +{ + SimpleSpiceDisplay *ssd =3D opaque; + + qemu_mutex_lock(&ssd->lock); + qemu_spice_cursor_refresh_unlocked(ssd); + qemu_mutex_unlock(&ssd->lock); +} + void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd) { dprint(3, "%s/%d:\n", __func__, ssd->qxl.id); @@ -464,7 +473,6 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *s= sd) qemu_spice_create_update(ssd); ssd->notify++; } - qemu_spice_cursor_refresh_unlocked(ssd); qemu_mutex_unlock(&ssd->lock); =20 if (ssd->notify) { --=20 1.8.3.1