From patchwork Tue Mar 15 20:17:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 87075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AB793B6FA7 for ; Wed, 16 Mar 2011 07:22:59 +1100 (EST) Received: from localhost ([127.0.0.1]:34115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzalY-0003ys-8w for incoming@patchwork.ozlabs.org; Tue, 15 Mar 2011 16:22:52 -0400 Received: from [140.186.70.92] (port=48023 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzagV-0001K2-Q8 for qemu-devel@nongnu.org; Tue, 15 Mar 2011 16:17:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzagU-0001yX-Fa for qemu-devel@nongnu.org; Tue, 15 Mar 2011 16:17:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52638) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzagU-0001y0-2Q for qemu-devel@nongnu.org; Tue, 15 Mar 2011 16:17:38 -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 p2FKHbYv008320 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 15 Mar 2011 16:17:37 -0400 Received: from playa.tlv.redhat.com (dhcp-3-110.tlv.redhat.com [10.35.3.110]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2FKHVh0011443 for ; Tue, 15 Mar 2011 16:17:36 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Tue, 15 Mar 2011 22:17:08 +0200 Message-Id: <1300220228-27423-5-git-send-email-alevy@redhat.com> In-Reply-To: <1300220228-27423-1-git-send-email-alevy@redhat.com> References: <1300220228-27423-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/4] hw/qxl-render: drop cursor locks, add TODO's. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; } }