From patchwork Fri Apr 21 09:16:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 9692267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BC6126037F for ; Fri, 21 Apr 2017 09:20:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A53C4285F1 for ; Fri, 21 Apr 2017 09:20:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 994412861A; Fri, 21 Apr 2017 09:20:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4B135285F1 for ; Fri, 21 Apr 2017 09:20:14 +0000 (UTC) Received: from localhost ([::1]:58103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Ujd-0003gQ-8G for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Apr 2017 05:20:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgF-0001wX-PC for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1UgD-0001Fl-Ee for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2753) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgD-0001Ec-64 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 341D67D0E9 for ; Fri, 21 Apr 2017 09:16:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 341D67D0E9 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 341D67D0E9 Received: from nilsson.home.kraxel.org (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5C6F60F8B; Fri, 21 Apr 2017 09:16:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id E9EE4814D9; Fri, 21 Apr 2017 11:16:34 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:32 +0200 Message-Id: <20170421091632.30900-10-kraxel@redhat.com> In-Reply-To: <20170421091632.30900-1-kraxel@redhat.com> References: <20170421091632.30900-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 21 Apr 2017 09:16:40 +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 9/9] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Gerd Hoffmann --- hw/display/sm501.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index 040a0b93f2..1987a537c0 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1259,6 +1259,7 @@ static inline int get_depth_index(DisplaySurface *surface) static void sm501_draw_crt(SM501State * s) { DisplaySurface *surface = qemu_console_surface(s->con); + DirtyBitmapSnapshot *snap; int y; int width = (s->dc_crt_h_total & 0x00000FFF) + 1; int height = (s->dc_crt_v_total & 0x00000FFF) + 1; @@ -1274,8 +1275,6 @@ static void sm501_draw_crt(SM501State * s) draw_hwc_line_func * draw_hwc_line = NULL; int full_update = 0; int y_start = -1; - ram_addr_t page_min = ~0l; - ram_addr_t page_max = 0l; ram_addr_t offset = 0; /* choose draw_line function */ @@ -1326,15 +1325,15 @@ static void sm501_draw_crt(SM501State * s) /* draw each line according to conditions */ memory_region_sync_dirty_bitmap(&s->local_mem_region); + snap = memory_region_snapshot_and_clear_dirty(&s->local_mem_region, + offset, width * height * src_bpp, DIRTY_MEMORY_VGA); for (y = 0; y < height; y++) { int update_hwc = draw_hwc_line ? within_hwc_y_range(s, y, 1) : 0; int update = full_update || update_hwc; - ram_addr_t page0 = offset; - ram_addr_t page1 = offset + width * src_bpp - 1; /* check dirty flags for each line */ - update = memory_region_get_dirty(&s->local_mem_region, page0, - page1 - page0, DIRTY_MEMORY_VGA); + update = memory_region_snapshot_get_dirty(&s->local_mem_region, snap, + offset, width * src_bpp); /* draw line and change status */ if (update) { @@ -1351,10 +1350,6 @@ static void sm501_draw_crt(SM501State * s) if (y_start < 0) y_start = y; - if (page0 < page_min) - page_min = page0; - if (page1 > page_max) - page_max = page1; } else { if (y_start >= 0) { /* flush to display */ @@ -1366,17 +1361,11 @@ static void sm501_draw_crt(SM501State * s) src += width * src_bpp; offset += width * src_bpp; } + g_free(snap); /* complete flush to display */ if (y_start >= 0) dpy_gfx_update(s->con, 0, y_start, width, y - y_start); - - /* clear dirty flags */ - if (page_min != ~0l) { - memory_region_reset_dirty(&s->local_mem_region, - page_min, page_max + TARGET_PAGE_SIZE, - DIRTY_MEMORY_VGA); - } } static void sm501_update_display(void *opaque)