From nobody Fri May 3 06:09:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494328844934835.9869008433031; Tue, 9 May 2017 04:20:44 -0700 (PDT) Received: from localhost ([::1]:36493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d83C3-0004X9-Ea for importer@patchew.org; Tue, 09 May 2017 07:20:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d83B7-00047X-9r for qemu-devel@nongnu.org; Tue, 09 May 2017 07:19:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d83B2-0004rk-8v for qemu-devel@nongnu.org; Tue, 09 May 2017 07:19:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42070) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d83B1-0004rd-Vh for qemu-devel@nongnu.org; Tue, 09 May 2017 07:19:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B18F180F97 for ; Tue, 9 May 2017 11:19:34 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-142.ams2.redhat.com [10.36.116.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63B1583DD3; Tue, 9 May 2017 11:19:32 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 52260807E0; Tue, 9 May 2017 13:19:30 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B18F180F97 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B18F180F97 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 9 May 2017 13:19:28 +0200 Message-Id: <20170509111928.30935-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 09 May 2017 11:19:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] sm501: make display updates thread safe X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Gerd Hoffmann --- hw/display/sm501.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 2094adbc9c..9d254ef2e1 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1414,6 +1414,7 @@ static void sm501_update_display(void *opaque) { SM501State *s =3D (SM501State *)opaque; DisplaySurface *surface =3D qemu_console_surface(s->con); + DirtyBitmapSnapshot *snap; int y, c_x =3D 0, c_y =3D 0; int crt =3D (s->dc_crt_control & SM501_DC_CRT_CONTROL_SEL) ? 1 : 0; int width =3D get_width(s, crt); @@ -1425,9 +1426,7 @@ static void sm501_update_display(void *opaque) draw_hwc_line_func *draw_hwc_line =3D NULL; int full_update =3D 0; int y_start =3D -1; - ram_addr_t page_min =3D ~0l; - ram_addr_t page_max =3D 0l; - ram_addr_t offset; + ram_addr_t offset =3D 0; uint32_t *palette; uint8_t hwc_palette[3 * 3]; uint8_t *hwc_src =3D NULL; @@ -1479,17 +1478,17 @@ static void sm501_update_display(void *opaque) =20 /* draw each line according to conditions */ memory_region_sync_dirty_bitmap(&s->local_mem_region); + snap =3D memory_region_snapshot_and_clear_dirty(&s->local_mem_region, + offset, width * height * src_bpp, DIRTY_MEMORY_VGA); for (y =3D 0, offset =3D 0; y < height; y++, offset +=3D width * src_b= pp) { int update, update_hwc; - ram_addr_t page0 =3D offset; - ram_addr_t page1 =3D offset + width * src_bpp - 1; =20 /* check if hardware cursor is enabled and we're within its range = */ update_hwc =3D draw_hwc_line && c_y <=3D y && y < c_y + SM501_HWC_= HEIGHT; update =3D full_update || update_hwc; /* check dirty flags for each line */ - update |=3D memory_region_get_dirty(&s->local_mem_region, page0, - page1 - page0, DIRTY_MEMORY_VGA); + update |=3D memory_region_snapshot_get_dirty(&s->local_mem_region,= snap, + offset, width * src_bpp= ); =20 /* draw line and change status */ if (update) { @@ -1507,12 +1506,6 @@ static void sm501_update_display(void *opaque) if (y_start < 0) { y_start =3D y; } - if (page0 < page_min) { - page_min =3D page0; - } - if (page1 > page_max) { - page_max =3D page1; - } } else { if (y_start >=3D 0) { /* flush to display */ @@ -1521,18 +1514,12 @@ static void sm501_update_display(void *opaque) } } } + g_free(snap); =20 /* complete flush to display */ if (y_start >=3D 0) { dpy_gfx_update(s->con, 0, y_start, width, y - y_start); } - - /* clear dirty flags */ - if (page_min !=3D ~0l) { - memory_region_reset_dirty(&s->local_mem_region, - page_min, page_max + TARGET_PAGE_SIZE, - DIRTY_MEMORY_VGA); - } } =20 static const GraphicHwOps sm501_ops =3D { --=20 2.9.3