From nobody Mon Apr 29 18:51:37 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 149444966625062.015093312360364; Wed, 10 May 2017 13:54:26 -0700 (PDT) Received: from localhost ([::1]:44769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8Ycp-0000a2-Tz for importer@patchew.org; Wed, 10 May 2017 16:54:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8Ybc-0008S1-Fn for qemu-devel@nongnu.org; Wed, 10 May 2017 16:53:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8YbY-00085a-KW for qemu-devel@nongnu.org; Wed, 10 May 2017 16:53:08 -0400 Received: from chuckie.co.uk ([82.165.15.123]:57056 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8YbY-00081B-D7 for qemu-devel@nongnu.org; Wed, 10 May 2017 16:53:04 -0400 Received: from host109-151-159-236.range109-151.btcentralplus.com ([109.151.159.236] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1d8YbP-0003Hi-HX; Wed, 10 May 2017 21:52:56 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, kraxel@redhat.com Date: Wed, 10 May 2017 21:52:30 +0100 Message-Id: <1494449551-20227-2-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1494449551-20227-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1494449551-20227-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.151.159.236 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 1/2] cg3: 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: , 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: Mark Cave-Ayland --- hw/display/cg3.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/hw/display/cg3.c b/hw/display/cg3.c index 7ef8a96..1de15a1 100644 --- a/hw/display/cg3.c +++ b/hw/display/cg3.c @@ -94,7 +94,8 @@ static void cg3_update_display(void *opaque) uint32_t dval; int x, y, y_start; unsigned int width, height; - ram_addr_t page, page_min, page_max; + ram_addr_t page; + DirtyBitmapSnapshot *snap =3D NULL; =20 if (surface_bits_per_pixel(surface) !=3D 32) { return; @@ -103,29 +104,32 @@ static void cg3_update_display(void *opaque) height =3D s->height; =20 y_start =3D -1; - page_min =3D -1; - page_max =3D 0; - page =3D 0; pix =3D memory_region_get_ram_ptr(&s->vram_mem); data =3D (uint32_t *)surface_data(surface); =20 - memory_region_sync_dirty_bitmap(&s->vram_mem); + if (!s->full_update) { + memory_region_sync_dirty_bitmap(&s->vram_mem); + snap =3D memory_region_snapshot_and_clear_dirty(&s->vram_mem, 0x0, + memory_region_size(&s->vram_= mem), + DIRTY_MEMORY_VGA); + } + for (y =3D 0; y < height; y++) { - int update =3D s->full_update; + int update; =20 page =3D (ram_addr_t)y * width; - update |=3D memory_region_get_dirty(&s->vram_mem, page, width, - DIRTY_MEMORY_VGA); + + if (s->full_update) { + update =3D 1; + } else { + update =3D memory_region_snapshot_get_dirty(&s->vram_mem, snap= , page, + width); + } + if (update) { if (y_start < 0) { y_start =3D y; } - if (page < page_min) { - page_min =3D page; - } - if (page > page_max) { - page_max =3D page; - } =20 for (x =3D 0; x < width; x++) { dval =3D *pix++; @@ -134,7 +138,7 @@ static void cg3_update_display(void *opaque) } } else { if (y_start >=3D 0) { - dpy_gfx_update(s->con, 0, y_start, s->width, y - y_start); + dpy_gfx_update(s->con, 0, y_start, width, y - y_start); y_start =3D -1; } pix +=3D width; @@ -143,17 +147,14 @@ static void cg3_update_display(void *opaque) } s->full_update =3D 0; if (y_start >=3D 0) { - dpy_gfx_update(s->con, 0, y_start, s->width, y - y_start); - } - if (page_max >=3D page_min) { - memory_region_reset_dirty(&s->vram_mem, - page_min, page_max - page_min, DIRTY_MEMORY_= VGA); + dpy_gfx_update(s->con, 0, y_start, width, y - y_start); } /* vsync interrupt? */ if (s->regs[0] & CG3_CR_ENABLE_INTS) { s->regs[1] |=3D CG3_SR_PENDING_INT; qemu_irq_raise(s->irq); } + g_free(snap); } =20 static void cg3_invalidate_display(void *opaque) --=20 1.7.10.4 From nobody Mon Apr 29 18:51:37 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 1494449755264988.9608023850597; Wed, 10 May 2017 13:55:55 -0700 (PDT) Received: from localhost ([::1]:44777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8YeG-0001Wz-5T for importer@patchew.org; Wed, 10 May 2017 16:55:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d8Ybd-0008S6-GL for qemu-devel@nongnu.org; Wed, 10 May 2017 16:53:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d8Ybc-000871-Ca for qemu-devel@nongnu.org; Wed, 10 May 2017 16:53:09 -0400 Received: from chuckie.co.uk ([82.165.15.123]:57063 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d8Ybc-00084t-4z for qemu-devel@nongnu.org; Wed, 10 May 2017 16:53:08 -0400 Received: from host109-151-159-236.range109-151.btcentralplus.com ([109.151.159.236] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1d8YbQ-0003Hi-L0; Wed, 10 May 2017 21:52:57 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, kraxel@redhat.com Date: Wed, 10 May 2017 21:52:31 +0100 Message-Id: <1494449551-20227-3-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1494449551-20227-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1494449551-20227-1-git-send-email-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 109.151.159.236 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 2/2] tcx: 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: , 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: Mark Cave-Ayland --- hw/display/tcx.c | 68 +++++++++++++++++++-------------------------------= ---- 1 file changed, 24 insertions(+), 44 deletions(-) diff --git a/hw/display/tcx.c b/hw/display/tcx.c index 0e66dcd..6593c1d 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -104,36 +104,23 @@ static void tcx_set_dirty(TCXState *s, ram_addr_t add= r, int len) } } =20 -static int tcx_check_dirty(TCXState *s, ram_addr_t addr, int len) +static int tcx_check_dirty(TCXState *s, DirtyBitmapSnapshot *snap, + ram_addr_t addr, int len) { int ret; =20 - ret =3D memory_region_get_dirty(&s->vram_mem, addr, len, DIRTY_MEMORY_= VGA); + ret =3D memory_region_snapshot_get_dirty(&s->vram_mem, snap, addr, len= ); =20 if (s->depth =3D=3D 24) { - ret |=3D memory_region_get_dirty(&s->vram_mem, - s->vram24_offset + addr * 4, len * = 4, - DIRTY_MEMORY_VGA); - ret |=3D memory_region_get_dirty(&s->vram_mem, - s->cplane_offset + addr * 4, len * = 4, - DIRTY_MEMORY_VGA); + ret |=3D memory_region_snapshot_get_dirty(&s->vram_mem, snap, + s->vram24_offset + addr * 4, len * = 4); + ret |=3D memory_region_snapshot_get_dirty(&s->vram_mem, snap, + s->cplane_offset + addr * 4, len * = 4); } =20 return ret; } =20 -static void tcx_reset_dirty(TCXState *s, ram_addr_t addr, int len) -{ - memory_region_reset_dirty(&s->vram_mem, addr, len, DIRTY_MEMORY_VGA); - - if (s->depth =3D=3D 24) { - memory_region_reset_dirty(&s->vram_mem, s->vram24_offset + addr * = 4, - len * 4, DIRTY_MEMORY_VGA); - memory_region_reset_dirty(&s->vram_mem, s->cplane_offset + addr * = 4, - len * 4, DIRTY_MEMORY_VGA); - } -} - static void update_palette_entries(TCXState *s, int start, int end) { DisplaySurface *surface =3D qemu_console_surface(s->con); @@ -233,7 +220,8 @@ static void tcx_update_display(void *opaque) { TCXState *ts =3D opaque; DisplaySurface *surface =3D qemu_console_surface(ts->con); - ram_addr_t page, page_min, page_max; + ram_addr_t page; + DirtyBitmapSnapshot *snap =3D NULL; int y, y_start, dd, ds; uint8_t *d, *s; =20 @@ -243,22 +231,20 @@ static void tcx_update_display(void *opaque) =20 page =3D 0; y_start =3D -1; - page_min =3D -1; - page_max =3D 0; d =3D surface_data(surface); s =3D ts->vram; dd =3D surface_stride(surface); ds =3D 1024; =20 memory_region_sync_dirty_bitmap(&ts->vram_mem); + snap =3D memory_region_snapshot_and_clear_dirty(&ts->vram_mem, 0x0, + memory_region_size(&ts->vram_= mem), + DIRTY_MEMORY_VGA); + for (y =3D 0; y < ts->height; y++, page +=3D ds) { - if (tcx_check_dirty(ts, page, ds)) { + if (tcx_check_dirty(ts, snap, page, ds)) { if (y_start < 0) y_start =3D y; - if (page < page_min) - page_min =3D page; - if (page > page_max) - page_max =3D page; =20 tcx_draw_line32(ts, d, s, ts->width); if (y >=3D ts->cursy && y < ts->cursy + 32 && ts->cursx < ts->= width) { @@ -280,17 +266,15 @@ static void tcx_update_display(void *opaque) dpy_gfx_update(ts->con, 0, y_start, ts->width, y - y_start); } - /* reset modified pages */ - if (page_max >=3D page_min) { - tcx_reset_dirty(ts, page_min, page_max - page_min); - } + g_free(snap); } =20 static void tcx24_update_display(void *opaque) { TCXState *ts =3D opaque; DisplaySurface *surface =3D qemu_console_surface(ts->con); - ram_addr_t page, page_min, page_max; + ram_addr_t page; + DirtyBitmapSnapshot *snap =3D NULL; int y, y_start, dd, ds; uint8_t *d, *s; uint32_t *cptr, *s24; @@ -301,8 +285,6 @@ static void tcx24_update_display(void *opaque) =20 page =3D 0; y_start =3D -1; - page_min =3D -1; - page_max =3D 0; d =3D surface_data(surface); s =3D ts->vram; s24 =3D ts->vram24; @@ -311,14 +293,15 @@ static void tcx24_update_display(void *opaque) ds =3D 1024; =20 memory_region_sync_dirty_bitmap(&ts->vram_mem); + snap =3D memory_region_snapshot_and_clear_dirty(&ts->vram_mem, 0x0, + memory_region_size(&ts->vram_= mem), + DIRTY_MEMORY_VGA); + for (y =3D 0; y < ts->height; y++, page +=3D ds) { - if (tcx_check_dirty(ts, page, ds)) { + if (tcx_check_dirty(ts, snap, page, ds)) { if (y_start < 0) y_start =3D y; - if (page < page_min) - page_min =3D page; - if (page > page_max) - page_max =3D page; + tcx24_draw_line32(ts, d, s, ts->width, cptr, s24); if (y >=3D ts->cursy && y < ts->cursy+32 && ts->cursx < ts->wi= dth) { tcx_draw_cursor32(ts, d, y, ts->width); @@ -341,10 +324,7 @@ static void tcx24_update_display(void *opaque) dpy_gfx_update(ts->con, 0, y_start, ts->width, y - y_start); } - /* reset modified pages */ - if (page_max >=3D page_min) { - tcx_reset_dirty(ts, page_min, page_max - page_min); - } + g_free(snap); } =20 static void tcx_invalidate_display(void *opaque) --=20 1.7.10.4