From patchwork Wed Jun 29 11:57:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 102590 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DA7F1B6F5C for ; Wed, 29 Jun 2011 22:49:43 +1000 (EST) Received: from localhost ([::1]:38227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbuD5-0000Ez-3K for incoming@patchwork.ozlabs.org; Wed, 29 Jun 2011 08:49:39 -0400 Received: from eggs.gnu.org ([140.186.70.92]:53962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbtOh-0004Mh-8O for qemu-devel@nongnu.org; Wed, 29 Jun 2011 07:57:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QbtOf-00070a-BC for qemu-devel@nongnu.org; Wed, 29 Jun 2011 07:57:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QbtOe-00070J-QP for qemu-devel@nongnu.org; Wed, 29 Jun 2011 07:57:33 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5TBvVrr014113 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 29 Jun 2011 07:57:31 -0400 Received: from bow.redhat.com (vpn-11-114.rdu.redhat.com [10.11.11.114]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5TBvOFM002457; Wed, 29 Jun 2011 07:57:30 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Wed, 29 Jun 2011 13:57:09 +0200 Message-Id: <1309348641-20061-4-git-send-email-alevy@redhat.com> In-Reply-To: <1309348641-20061-1-git-send-email-alevy@redhat.com> References: <1309348641-20061-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: yhalperi@redhat.com, kraxel@redhat.com Subject: [Qemu-devel] [PATCHv3] qxl: use track_lock instead of wlock for guest_surfaces X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org --- hw/qxl.c | 7 +++++-- hw/qxl.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/qxl.c b/hw/qxl.c index 3f84b0c..49d7b10 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -150,10 +150,12 @@ void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id, void qxl_spice_destroy_surface_wait(PCIQXLDevice *qxl, uint32_t id) { qemu_mutex_lock(&qxl->ssd.wlock); + qemu_mutex_lock(&qxl->track_lock); PANIC_ON(id >= NUM_SURFACES); qxl->ssd.worker->destroy_surface_wait(qxl->ssd.worker, id); qxl->guest_surfaces.cmds[id] = 0; qxl->guest_surfaces.count--; + qemu_mutex_unlock(&qxl->track_lock); qemu_mutex_unlock(&qxl->ssd.wlock); } @@ -348,7 +350,7 @@ static void qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext) QXLSurfaceCmd *cmd = qxl_phys2virt(qxl, ext->cmd.data, ext->group_id); uint32_t id = le32_to_cpu(cmd->surface_id); PANIC_ON(id >= NUM_SURFACES); - qemu_mutex_lock(&qxl->ssd.wlock); + qemu_mutex_lock(&qxl->track_lock); if (cmd->type == QXL_SURFACE_CMD_CREATE) { qxl->guest_surfaces.cmds[id] = ext->cmd.data; qxl->guest_surfaces.count++; @@ -359,7 +361,7 @@ static void qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext) qxl->guest_surfaces.cmds[id] = 0; qxl->guest_surfaces.count--; } - qemu_mutex_unlock(&qxl->ssd.wlock); + qemu_mutex_unlock(&qxl->track_lock); break; } case QXL_CMD_CURSOR: @@ -1432,6 +1434,7 @@ static int qxl_init_common(PCIQXLDevice *qxl) qxl->generation = 1; qxl->num_memslots = NUM_MEMSLOTS; qxl->num_surfaces = NUM_SURFACES; + qemu_mutex_init(&qxl->track_lock); switch (qxl->revision) { case 1: /* spice 0.4 -- qxl-1 */ diff --git a/hw/qxl.h b/hw/qxl.h index f005943..7df594e 100644 --- a/hw/qxl.h +++ b/hw/qxl.h @@ -58,6 +58,8 @@ typedef struct PCIQXLDevice { } guest_surfaces; QXLPHYSICAL guest_cursor; + QemuMutex track_lock; + /* thread signaling */ pthread_t main; int pipe[2];