From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=42623 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pzmtg-0007eN-Hz for qemu-devel@nongnu.org; Wed, 16 Mar 2011 05:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pzmtc-0004mB-UK for qemu-devel@nongnu.org; Wed, 16 Mar 2011 05:20:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65224) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pzmtc-0004lz-HV for qemu-devel@nongnu.org; Wed, 16 Mar 2011 05:20:00 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2G9JxqP010720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Mar 2011 05:19:59 -0400 Message-ID: <4D80813D.2010504@redhat.com> Date: Wed, 16 Mar 2011 10:22:05 +0100 From: Hans de Goede MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 4/4] hw/qxl-render: drop cursor locks, add TODO's. References: <1300220228-27423-1-git-send-email-alevy@redhat.com> <1300220228-27423-5-git-send-email-alevy@redhat.com> In-Reply-To: <1300220228-27423-5-git-send-email-alevy@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alon Levy Cc: qemu-devel@nongnu.org Hi, As discussed on irc I think we need to look into this and see if we can fix it properly while at it. IOW to be continued... Regards, Hans On 03/15/2011 09:17 PM, Alon Levy wrote: > Dropping the locks prevents a deadlock when running with -sdl or -vnc > in addition to -spice. > > When server calls get_cursor_command, and we have an active ds > cursor related callback in non vga mode, we need to lock to prevent > the iothread (via sdl/vnc gui_update timer) from touching the ds as well. > > Currently (-sdl/-vnc) + -spice seems to work, due to dropping the locking in > qxl-render.c:qxl_render_cursor, but this is just waiting to break because of > touching the cursor from two threads without any locking. > --- > hw/qxl-render.c | 13 +++++++++---- > 1 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/hw/qxl-render.c b/hw/qxl-render.c > index 58965e0..1065388 100644 > --- a/hw/qxl-render.c > +++ b/hw/qxl-render.c > @@ -209,18 +209,23 @@ void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext) > if (c == NULL) { > c = cursor_builtin_left_ptr(); > } > - qemu_mutex_lock_iothread(); > + /* TODO: move this operation to iothread via pipe > + * we can't use the global lock here without dropping it > + * in gui_update (vl.c), or we get a dead lock (gui_update > + * calls dispatcher, waiting on pipe read, and spice server calls > + * this function, waiting on the lock that iothread is holding). > + * But when used with sdl this calls sdl.c:sdl_mouse_define, which > + * afaict must be locked or called from iothread. Moving to iothread > + * seems easiest from correctness pov. */ > qxl->ssd.ds->cursor_define(c); > qxl->ssd.ds->mouse_set(x, y, 1); > - qemu_mutex_unlock_iothread(); > cursor_put(c); > break; > case QXL_CURSOR_MOVE: > x = cmd->u.position.x; > y = cmd->u.position.y; > - qemu_mutex_lock_iothread(); > + /* TODO: move this operation to iothread via pipe. See comment above */ > qxl->ssd.ds->mouse_set(x, y, 1); > - qemu_mutex_unlock_iothread(); > break; > } > }