From nobody Sat Apr 27 14:57:45 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 1492766788282973.8898064840117; Fri, 21 Apr 2017 02:26:28 -0700 (PDT) Received: from localhost ([::1]:58146 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Upf-0000aM-04 for importer@patchew.org; Fri, 21 Apr 2017 05:26:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgF-0001wb-Qg for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1UgD-0001F1-5P for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34372) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgC-0001Dk-Vx for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:41 -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 5AC56CDF96 for ; Fri, 21 Apr 2017 09:16:38 +0000 (UTC) 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 1FFA077FFE; Fri, 21 Apr 2017 09:16:36 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id B00DE81080; Fri, 21 Apr 2017 11:16:33 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5AC56CDF96 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5AC56CDF96 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:24 +0200 Message-Id: <20170421091632.30900-2-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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 21 Apr 2017 09:16:38 +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 1/9] bitmap: add bitmap_copy_and_clear_atomic 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 --- include/qemu/bitmap.h | 2 ++ util/bitmap.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/qemu/bitmap.h b/include/qemu/bitmap.h index 63ea2d0b1e..c318da12d7 100644 --- a/include/qemu/bitmap.h +++ b/include/qemu/bitmap.h @@ -220,6 +220,8 @@ void bitmap_set(unsigned long *map, long i, long len); void bitmap_set_atomic(unsigned long *map, long i, long len); void bitmap_clear(unsigned long *map, long start, long nr); bool bitmap_test_and_clear_atomic(unsigned long *map, long start, long nr); +void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src, + long nr); unsigned long bitmap_find_next_zero_area(unsigned long *map, unsigned long size, unsigned long start, diff --git a/util/bitmap.c b/util/bitmap.c index c1a84ca5e3..efced9a7d8 100644 --- a/util/bitmap.c +++ b/util/bitmap.c @@ -287,6 +287,17 @@ bool bitmap_test_and_clear_atomic(unsigned long *map, = long start, long nr) return dirty !=3D 0; } =20 +void bitmap_copy_and_clear_atomic(unsigned long *dst, unsigned long *src, + long nr) +{ + while (nr > 0) { + *dst =3D atomic_xchg(src, 0); + dst++; + src++; + nr -=3D BITS_PER_LONG; + } +} + #define ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) =20 /** --=20 2.9.3 From nobody Sat Apr 27 14:57:45 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 1492766309839459.77376234221947; Fri, 21 Apr 2017 02:18:29 -0700 (PDT) Received: from localhost ([::1]:58101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Uhu-0002xa-VA for importer@patchew.org; Fri, 21 Apr 2017 05:18:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgF-0001wd-R0 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-0001FS-93 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgC-0001ED-W3 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDC2013D17; Fri, 21 Apr 2017 09:16:38 +0000 (UTC) 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 07DBC5C8BB; Fri, 21 Apr 2017 09:16:36 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id F326B810D2; Fri, 21 Apr 2017 11:16:33 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CDC2013D17 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CDC2013D17 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:25 +0200 Message-Id: <20170421091632.30900-3-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 21 Apr 2017 09:16:39 +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 2/9] memory: add support getting and using a dirty bitmap copy. 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: Paolo Bonzini , Richard Henderson , Gerd Hoffmann , Peter Crosthwaite 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" This patch adds support for getting and using a local copy of the dirty bitmap. memory_region_snapshot_and_clear_dirty() will create a snapshot of the dirty bitmap for the specified range, clear the dirty bitmap and return the copy. The returned bitmap can be a bit larger than requested, the range is expanded so the code can copy unsigned longs from the bitmap and avoid atomic bit update operations. memory_region_snapshot_get_dirty() will return the dirty status of pages, pretty much like memory_region_get_dirty(), but using the copy returned by memory_region_copy_and_clear_dirty(). Signed-off-by: Gerd Hoffmann --- include/exec/memory.h | 47 +++++++++++++++++++++++++++++++ include/exec/ram_addr.h | 7 +++++ include/qemu/typedefs.h | 1 + exec.c | 75 +++++++++++++++++++++++++++++++++++++++++++++= ++++ memory.c | 17 +++++++++++ 5 files changed, 147 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index f20b191793..1e15e79d00 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -871,6 +871,53 @@ void memory_region_set_dirty(MemoryRegion *mr, hwaddr = addr, */ bool memory_region_test_and_clear_dirty(MemoryRegion *mr, hwaddr addr, hwaddr size, unsigned client); + +/** + * memory_region_snapshot_and_clear_dirty: Get a snapshot of the dirty + * bitmap and clear it. + * + * Creates a snapshot of the dirty bitmap, clears the dirty bitmap and + * returns the snapshot. The snapshot can then be used to query dirty + * status, using memory_region_snapshot_get_dirty. Unlike + * memory_region_test_and_clear_dirty this allows to query the same + * page multiple times, which is especially useful for display updates + * where the scanlines often are not page aligned. + * + * The dirty bitmap region which gets copyed into the snapshot (and + * cleared afterwards) can be larger than requested. The boundaries + * are rounded up/down so complete bitmap longs (covering 64 pages on + * 64bit hosts) can be copied over into the bitmap snapshot. Which + * isn't a problem for display updates as the extra pages are outside + * the visible area, and in case the visible area changes a full + * display redraw is due anyway. Should other use cases for this + * function emerge we might have to revisit this implementation + * detail. + * + * Use g_free to release DirtyBitmapSnapshot. + * + * @mr: the memory region being queried. + * @addr: the address (relative to the start of the region) being queried. + * @size: the size of the range being queried. + * @client: the user of the logging information; typically %DIRTY_MEMORY_V= GA. + */ +DirtyBitmapSnapshot *memory_region_snapshot_and_clear_dirty(MemoryRegion *= mr, + hwaddr addr, + hwaddr size, + unsigned clien= t); + +/** + * memory_region_snapshot_get_dirty: Check whether a range of bytes is dir= ty + * in the specified dirty bitmap snapsho= t. + * + * @mr: the memory region being queried. + * @snap: the dirty bitmap snapshot + * @addr: the address (relative to the start of the region) being queried. + * @size: the size of the range being queried. + */ +bool memory_region_snapshot_get_dirty(MemoryRegion *mr, + DirtyBitmapSnapshot *snap, + hwaddr addr, hwaddr size); + /** * memory_region_sync_dirty_bitmap: Synchronize a region's dirty bitmap wi= th * any external TLBs (e.g. kvm) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index b05dc84ab9..2b63d7f59e 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -343,6 +343,13 @@ bool cpu_physical_memory_test_and_clear_dirty(ram_addr= _t start, ram_addr_t length, unsigned client); =20 +DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty + (ram_addr_t start, ram_addr_t length, unsigned client); + +bool cpu_physical_memory_snapshot_get_dirty(DirtyBitmapSnapshot *snap, + ram_addr_t start, + ram_addr_t length); + static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start, ram_addr_t length) { diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index e95f28cfec..f08d327aec 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -23,6 +23,7 @@ typedef struct CPUAddressSpace CPUAddressSpace; typedef struct CPUState CPUState; typedef struct DeviceListener DeviceListener; typedef struct DeviceState DeviceState; +typedef struct DirtyBitmapSnapshot DirtyBitmapSnapshot; typedef struct DisplayChangeListener DisplayChangeListener; typedef struct DisplayState DisplayState; typedef struct DisplaySurface DisplaySurface; diff --git a/exec.c b/exec.c index c97ef4a8da..a8894d5ba2 100644 --- a/exec.c +++ b/exec.c @@ -223,6 +223,12 @@ struct CPUAddressSpace { MemoryListener tcg_as_listener; }; =20 +struct DirtyBitmapSnapshot { + ram_addr_t start; + ram_addr_t end; + unsigned long dirty[]; +}; + #endif =20 #if !defined(CONFIG_USER_ONLY) @@ -1061,6 +1067,75 @@ bool cpu_physical_memory_test_and_clear_dirty(ram_ad= dr_t start, return dirty; } =20 +DirtyBitmapSnapshot *cpu_physical_memory_snapshot_and_clear_dirty + (ram_addr_t start, ram_addr_t length, unsigned client) +{ + DirtyMemoryBlocks *blocks; + unsigned long align =3D 1UL << (TARGET_PAGE_BITS + BITS_PER_LEVEL); + ram_addr_t first =3D QEMU_ALIGN_DOWN(start, align); + ram_addr_t last =3D QEMU_ALIGN_UP(start + length, align); + DirtyBitmapSnapshot *snap; + unsigned long page, end, dest; + + snap =3D g_malloc0(sizeof(*snap) + + ((last - first) >> (TARGET_PAGE_BITS + 3))); + snap->start =3D first; + snap->end =3D last; + + page =3D first >> TARGET_PAGE_BITS; + end =3D last >> TARGET_PAGE_BITS; + dest =3D 0; + + rcu_read_lock(); + + blocks =3D atomic_rcu_read(&ram_list.dirty_memory[client]); + + while (page < end) { + unsigned long idx =3D page / DIRTY_MEMORY_BLOCK_SIZE; + unsigned long offset =3D page % DIRTY_MEMORY_BLOCK_SIZE; + unsigned long num =3D MIN(end - page, DIRTY_MEMORY_BLOCK_SIZE - of= fset); + + assert(QEMU_IS_ALIGNED(offset, (1 << BITS_PER_LEVEL))); + assert(QEMU_IS_ALIGNED(num, (1 << BITS_PER_LEVEL))); + offset >>=3D BITS_PER_LEVEL; + + bitmap_copy_and_clear_atomic(snap->dirty + dest, + blocks->blocks[idx] + offset, + num); + page +=3D num; + dest +=3D num >> BITS_PER_LEVEL; + } + + rcu_read_unlock(); + + if (tcg_enabled()) { + tlb_reset_dirty_range_all(start, length); + } + + return snap; +} + +bool cpu_physical_memory_snapshot_get_dirty(DirtyBitmapSnapshot *snap, + ram_addr_t start, + ram_addr_t length) +{ + unsigned long page, end; + + assert(start >=3D snap->start); + assert(start + length <=3D snap->end); + + end =3D TARGET_PAGE_ALIGN(start + length - snap->start) >> TARGET_PAGE= _BITS; + page =3D (start - snap->start) >> TARGET_PAGE_BITS; + + while (page < end) { + if (test_bit(page, snap->dirty)) { + return true; + } + page++; + } + return false; +} + /* Called from RCU critical section */ hwaddr memory_region_section_get_iotlb(CPUState *cpu, MemoryRegionSection *section, diff --git a/memory.c b/memory.c index 4c95aaf39c..8a0648551f 100644 --- a/memory.c +++ b/memory.c @@ -1716,6 +1716,23 @@ bool memory_region_test_and_clear_dirty(MemoryRegion= *mr, hwaddr addr, memory_region_get_ram_addr(mr) + addr, size, client); } =20 +DirtyBitmapSnapshot *memory_region_snapshot_and_clear_dirty(MemoryRegion *= mr, + hwaddr addr, + hwaddr size, + unsigned clien= t) +{ + assert(mr->ram_block); + return cpu_physical_memory_snapshot_and_clear_dirty( + memory_region_get_ram_addr(mr) + addr, size, client); +} + +bool memory_region_snapshot_get_dirty(MemoryRegion *mr, DirtyBitmapSnapsho= t *snap, + hwaddr addr, hwaddr size) +{ + assert(mr->ram_block); + return cpu_physical_memory_snapshot_get_dirty(snap, + memory_region_get_ram_addr(mr) + addr, size); +} =20 void memory_region_sync_dirty_bitmap(MemoryRegion *mr) { --=20 2.9.3 From nobody Sat Apr 27 14:57:45 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 1492766441299139.6856818006397; Fri, 21 Apr 2017 02:20:41 -0700 (PDT) Received: from localhost ([::1]:58111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Uk3-0004Zv-UU for importer@patchew.org; Fri, 21 Apr 2017 05:20:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgF-0001we-Qq 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 1d1UgC-0001EV-EP for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34378) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgC-0001Dp-7J for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81B74CDF98 for ; Fri, 21 Apr 2017 09:16:38 +0000 (UTC) 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 2031181429; Fri, 21 Apr 2017 09:16:36 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 22214814C2; Fri, 21 Apr 2017 11:16:34 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 81B74CDF98 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 81B74CDF98 From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:26 +0200 Message-Id: <20170421091632.30900-4-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 21 Apr 2017 09:16:38 +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 3/9] vga: add vga_scanline_invalidated helper 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" Add vga_scanline_invalidated helper to check whenever a scanline was invalidated. Add a sanity check to fix OOB read access for display heights larger than 2048. Only cirrus uses this, for hardware cursor rendering, so having this work properly for the first 2048 scanlines only shouldn't be a problem as the cirrus can't handle large resolutions anyway. Also changing the invalidated_y_table size would break live migration. Signed-off-by: Gerd Hoffmann --- hw/display/vga.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index 69c3e1d674..3991b88aac 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1434,6 +1434,14 @@ void vga_invalidate_scanlines(VGACommonState *s, int= y1, int y2) } } =20 +static bool vga_scanline_invalidated(VGACommonState *s, int y) +{ + if (y >=3D VGA_MAX_HEIGHT) { + return false; + } + return s->invalidated_y_table[y >> 5] & (1 << (y & 0x1f)); +} + void vga_sync_dirty_bitmap(VGACommonState *s) { memory_region_sync_dirty_bitmap(&s->vram); @@ -1638,8 +1646,8 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) page1 =3D addr + bwidth - 1; update |=3D memory_region_get_dirty(&s->vram, page0, page1 - page0, DIRTY_MEMORY_VGA); - /* explicit invalidation for the hardware cursor */ - update |=3D (s->invalidated_y_table[y >> 5] >> (y & 0x1f)) & 1; + /* explicit invalidation for the hardware cursor (cirrus only) */ + update |=3D vga_scanline_invalidated(s, y); if (update) { if (y_start < 0) y_start =3D y; @@ -1686,7 +1694,7 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) page_max - page_min, DIRTY_MEMORY_VGA); } - memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4); + memset(s->invalidated_y_table, 0, sizeof(s->invalidated_y_table)); } =20 static void vga_draw_blank(VGACommonState *s, int full_update) --=20 2.9.3 From nobody Sat Apr 27 14:57:45 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 1492766441688497.59899490393207; Fri, 21 Apr 2017 02:20:41 -0700 (PDT) Received: from localhost ([::1]:58113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Uk4-0004aA-7T for importer@patchew.org; Fri, 21 Apr 2017 05:20:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgF-0001wf-RI 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 1d1UgC-0001Eg-Jc for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41634) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgC-0001EG-AL for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:40 -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 E1D66335EAF for ; Fri, 21 Apr 2017 09:16:38 +0000 (UTC) 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 470A660F8B; Fri, 21 Apr 2017 09:16:36 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 3C989814C5; Fri, 21 Apr 2017 11:16:34 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E1D66335EAF Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E1D66335EAF From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:27 +0200 Message-Id: <20170421091632.30900-5-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.29]); Fri, 21 Apr 2017 09:16:39 +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 4/9] vga: 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" The vga code clears the dirty bits *after* reading the framebuffer memory. So if the guest framebuffer updates hits the race window between vga reading the framebuffer and vga clearing the dirty bits vga will miss that update Fix it by using the new memory_region_copy_and_clear_dirty() memory_region_copy_get_dirty() functions. That way we clear the dirty bitmap before reading the framebuffer. Any guest display updates happening in parallel will be properly tracked in the dirty bitmap then and the next display refresh will pick them up. Problem triggers with mttcg only. Before mttcg was merged tcg never ran in parallel to vga emulation. Using kvm will hide the problem too, due to qemu operating on a userspace copy of the kernel's dirty bitmap. Signed-off-by: Gerd Hoffmann --- hw/display/vga.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/hw/display/vga.c b/hw/display/vga.c index 3991b88aac..b2516c8d21 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1465,7 +1465,8 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) DisplaySurface *surface =3D qemu_console_surface(s->con); int y1, y, update, linesize, y_start, double_scan, mask, depth; int width, height, shift_control, line_offset, bwidth, bits; - ram_addr_t page0, page1, page_min, page_max; + ram_addr_t page0, page1; + DirtyBitmapSnapshot *snap =3D NULL; int disp_width, multi_scan, multi_run; uint8_t *d; uint32_t v, addr1, addr; @@ -1480,9 +1481,6 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) =20 full_update |=3D update_basic_params(s); =20 - if (!full_update) - vga_sync_dirty_bitmap(s); - s->get_resolution(s, &width, &height); disp_width =3D width; =20 @@ -1625,11 +1623,17 @@ static void vga_draw_graphic(VGACommonState *s, int= full_update) addr1 =3D (s->start_addr * 4); bwidth =3D (width * bits + 7) / 8; y_start =3D -1; - page_min =3D -1; - page_max =3D 0; d =3D surface_data(surface); linesize =3D surface_stride(surface); y1 =3D 0; + + if (!full_update) { + vga_sync_dirty_bitmap(s); + snap =3D memory_region_snapshot_and_clear_dirty(&s->vram, addr1, + bwidth * height, + DIRTY_MEMORY_VGA); + } + for(y =3D 0; y < height; y++) { addr =3D addr1; if (!(s->cr[VGA_CRTC_MODE] & 1)) { @@ -1644,17 +1648,17 @@ static void vga_draw_graphic(VGACommonState *s, int= full_update) update =3D full_update; page0 =3D addr; page1 =3D addr + bwidth - 1; - update |=3D memory_region_get_dirty(&s->vram, page0, page1 - page0, - DIRTY_MEMORY_VGA); + if (full_update) { + update =3D 1; + } else { + update =3D memory_region_snapshot_get_dirty(&s->vram, snap, + page0, page1 - page0= ); + } /* explicit invalidation for the hardware cursor (cirrus only) */ update |=3D vga_scanline_invalidated(s, y); if (update) { if (y_start < 0) y_start =3D y; - if (page0 < page_min) - page_min =3D page0; - if (page1 > page_max) - page_max =3D page1; if (!(is_buffer_shared(surface))) { vga_draw_line(s, d, s->vram_ptr + addr, width); if (s->cursor_draw_line) @@ -1687,13 +1691,7 @@ static void vga_draw_graphic(VGACommonState *s, int = full_update) dpy_gfx_update(s->con, 0, y_start, disp_width, y - y_start); } - /* reset modified pages */ - if (page_max >=3D page_min) { - memory_region_reset_dirty(&s->vram, - page_min, - page_max - page_min, - DIRTY_MEMORY_VGA); - } + g_free(snap); memset(s->invalidated_y_table, 0, sizeof(s->invalidated_y_table)); } =20 --=20 2.9.3 From nobody Sat Apr 27 14:57:45 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 1492766550050515.1104337232994; Fri, 21 Apr 2017 02:22:30 -0700 (PDT) Received: from localhost ([::1]:58119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Ulo-0005tB-IV for importer@patchew.org; Fri, 21 Apr 2017 05:22:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgF-0001wW-Oi for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1UgD-0001Eu-1e for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53384) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgC-0001EK-SZ for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0E737575A for ; Fri, 21 Apr 2017 09:16:39 +0000 (UTC) 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 886887EF4E; Fri, 21 Apr 2017 09:16:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 5D061814D8; Fri, 21 Apr 2017 11:16:34 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E0E737575A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E0E737575A From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:28 +0200 Message-Id: <20170421091632.30900-6-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); 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 5/9] framebuffer: 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/framebuffer.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/display/framebuffer.c b/hw/display/framebuffer.c index 25aa46c8c7..d7310d25f2 100644 --- a/hw/display/framebuffer.c +++ b/hw/display/framebuffer.c @@ -67,7 +67,7 @@ void framebuffer_update_display( int *first_row, /* Input and output. */ int *last_row /* Output only */) { - hwaddr src_len; + DirtyBitmapSnapshot *snap; uint8_t *dest; uint8_t *src; int first, last =3D 0; @@ -78,7 +78,6 @@ void framebuffer_update_display( =20 i =3D *first_row; *first_row =3D -1; - src_len =3D (hwaddr)src_width * rows; =20 mem =3D mem_section->mr; if (!mem) { @@ -102,9 +101,10 @@ void framebuffer_update_display( src +=3D i * src_width; dest +=3D i * dest_row_pitch; =20 + snap =3D memory_region_snapshot_and_clear_dirty(mem, addr, src_width *= rows, + DIRTY_MEMORY_VGA); for (; i < rows; i++) { - dirty =3D memory_region_get_dirty(mem, addr, src_width, - DIRTY_MEMORY_VGA); + dirty =3D memory_region_snapshot_get_dirty(mem, snap, addr, src_wi= dth); if (dirty || invalidate) { fn(opaque, dest, src, cols, dest_col_pitch); if (first =3D=3D -1) @@ -115,11 +115,10 @@ void framebuffer_update_display( src +=3D src_width; dest +=3D dest_row_pitch; } + g_free(snap); if (first < 0) { return; } - memory_region_reset_dirty(mem, mem_section->offset_within_region, src_= len, - DIRTY_MEMORY_VGA); *first_row =3D first; *last_row =3D last; } --=20 2.9.3 From nobody Sat Apr 27 14:57:45 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 1492766550306371.80047759194986; Fri, 21 Apr 2017 02:22:30 -0700 (PDT) Received: from localhost ([::1]:58121 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Ulo-0005tI-Uq for importer@patchew.org; Fri, 21 Apr 2017 05:22:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgI-0001yA-KI for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1UgH-0001Ir-AS for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37516) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgC-0001EI-RG; Fri, 21 Apr 2017 05:16:40 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D2A928DA2E; Fri, 21 Apr 2017 09:16:39 +0000 (UTC) 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 866AF5C8BB; Fri, 21 Apr 2017 09:16:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 8318580D46; Fri, 21 Apr 2017 11:16:34 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D2A928DA2E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D2A928DA2E From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:29 +0200 Message-Id: <20170421091632.30900-7-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); 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 6/9] exynos: 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: Igor Mitsyanko , "open list:Exynos" , 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/exynos4210_fimd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c index e5be713406..fd0b2bec65 100644 --- a/hw/display/exynos4210_fimd.c +++ b/hw/display/exynos4210_fimd.c @@ -1263,6 +1263,7 @@ static void exynos4210_fimd_update(void *opaque) Exynos4210fimdState *s =3D (Exynos4210fimdState *)opaque; DisplaySurface *surface; Exynos4210fimdWindow *w; + DirtyBitmapSnapshot *snap; int i, line; hwaddr fb_line_addr, inc_size; int scrn_height; @@ -1291,10 +1292,12 @@ static void exynos4210_fimd_update(void *opaque) memory_region_sync_dirty_bitmap(w->mem_section.mr); host_fb_addr =3D w->host_fb_addr; fb_line_addr =3D w->mem_section.offset_within_region; + snap =3D memory_region_snapshot_and_clear_dirty(w->mem_section= .mr, + fb_line_addr, inc_size * scrn_height, DIRTY_MEMORY_VGA= ); =20 for (line =3D 0; line < scrn_height; line++) { - is_dirty =3D memory_region_get_dirty(w->mem_section.mr, - fb_line_addr, scrn_width, DIRTY_MEMORY_VGA); + is_dirty =3D memory_region_snapshot_get_dirty(w->mem_secti= on.mr, + snap, fb_line_addr, scrn_width); =20 if (s->invalidate || is_dirty) { if (first_line =3D=3D -1) { @@ -1309,9 +1312,7 @@ static void exynos4210_fimd_update(void *opaque) fb_line_addr +=3D inc_size; is_dirty =3D false; } - memory_region_reset_dirty(w->mem_section.mr, - w->mem_section.offset_within_region, - w->fb_len, DIRTY_MEMORY_VGA); + g_free(snap); blend =3D true; } } --=20 2.9.3 From nobody Sat Apr 27 14:57:45 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 1492766309930692.6090915912691; Fri, 21 Apr 2017 02:18:29 -0700 (PDT) Received: from localhost ([::1]:58102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Uhv-0002xm-7j for importer@patchew.org; Fri, 21 Apr 2017 05:18:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgF-0001wa-Qg for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1UgD-0001Fv-Ly for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42169) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgD-0001Ek-Cg for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C59A34075E for ; Fri, 21 Apr 2017 09:16:40 +0000 (UTC) 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 B1F4380710; Fri, 21 Apr 2017 09:16:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id A8AEB814DA; Fri, 21 Apr 2017 11:16:34 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6C59A34075E Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6C59A34075E From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:30 +0200 Message-Id: <20170421091632.30900-8-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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); 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 7/9] g364fb: 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/g364fb.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c index 8cdc205dd9..86557d14a9 100644 --- a/hw/display/g364fb.c +++ b/hw/display/g364fb.c @@ -64,17 +64,8 @@ typedef struct G364State { =20 static inline int check_dirty(G364State *s, ram_addr_t page) { - return memory_region_get_dirty(&s->mem_vram, page, G364_PAGE_SIZE, - DIRTY_MEMORY_VGA); -} - -static inline void reset_dirty(G364State *s, - ram_addr_t page_min, ram_addr_t page_max) -{ - memory_region_reset_dirty(&s->mem_vram, - page_min, - page_max + G364_PAGE_SIZE - page_min - 1, - DIRTY_MEMORY_VGA); + return memory_region_test_and_clear_dirty(&s->mem_vram, page, G364_PAG= E_SIZE, + DIRTY_MEMORY_VGA); } =20 static void g364fb_draw_graphic8(G364State *s) @@ -83,7 +74,7 @@ static void g364fb_draw_graphic8(G364State *s) int i, w; uint8_t *vram; uint8_t *data_display, *dd; - ram_addr_t page, page_min, page_max; + ram_addr_t page; int x, y; int xmin, xmax; int ymin, ymax; @@ -114,8 +105,6 @@ static void g364fb_draw_graphic8(G364State *s) } =20 page =3D 0; - page_min =3D (ram_addr_t)-1; - page_max =3D 0; =20 x =3D y =3D 0; xmin =3D s->width; @@ -137,9 +126,6 @@ static void g364fb_draw_graphic8(G364State *s) if (check_dirty(s, page)) { if (y < ymin) ymin =3D ymax =3D y; - if (page_min =3D=3D (ram_addr_t)-1) - page_min =3D page; - page_max =3D page; if (x < xmin) xmin =3D x; for (i =3D 0; i < G364_PAGE_SIZE; i++) { @@ -196,10 +182,7 @@ static void g364fb_draw_graphic8(G364State *s) ymax =3D y; } else { int dy; - if (page_min !=3D (ram_addr_t)-1) { - reset_dirty(s, page_min, page_max); - page_min =3D (ram_addr_t)-1; - page_max =3D 0; + if (xmax || ymax) { dpy_gfx_update(s->con, xmin, ymin, xmax - xmin + 1, ymax - ymin + 1); xmin =3D s->width; @@ -219,9 +202,8 @@ static void g364fb_draw_graphic8(G364State *s) } =20 done: - if (page_min !=3D (ram_addr_t)-1) { + if (xmax || ymax) { dpy_gfx_update(s->con, xmin, ymin, xmax - xmin + 1, ymax - ymin + = 1); - reset_dirty(s, page_min, page_max); } } =20 --=20 2.9.3 From nobody Sat Apr 27 14:57:45 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 1492766309774604.977923589739; Fri, 21 Apr 2017 02:18:29 -0700 (PDT) Received: from localhost ([::1]:58100 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Uhv-0002x2-28 for importer@patchew.org; Fri, 21 Apr 2017 05:18:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1UgF-0001wZ-Pl 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-0001FM-92 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53392) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1UgD-0001EZ-37 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 05:16:41 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 217367575C for ; Fri, 21 Apr 2017 09:16:40 +0000 (UTC) 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 B2F027959F; Fri, 21 Apr 2017 09:16:39 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id CA13D814DB; Fri, 21 Apr 2017 11:16:34 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 217367575C Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=kraxel@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 217367575C From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 11:16:31 +0200 Message-Id: <20170421091632.30900-9-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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); 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 8/9] vmsvga: fix vmsvga_update_display 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" Fix standard vga mode check: Both s->config and s->enabled must be set to enable vmware command fifo processing. Drop dirty tracking code from the fifo rendering code path, it isn't used anyway because vmsvga turns off dirty tracking when leaving standard vga mode. Signed-off-by: Gerd Hoffmann --- hw/display/vmware_vga.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index 6599cf078d..ec5f27d67e 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -1118,9 +1118,9 @@ static void vmsvga_update_display(void *opaque) { struct vmsvga_state_s *s =3D opaque; DisplaySurface *surface; - bool dirty =3D false; =20 - if (!s->enable) { + if (!s->enable || !s->config) { + /* in standard vga mode */ s->vga.hw_ops->gfx_update(&s->vga); return; } @@ -1131,26 +1131,11 @@ static void vmsvga_update_display(void *opaque) vmsvga_fifo_run(s); vmsvga_update_rect_flush(s); =20 - /* - * Is it more efficient to look at vram VGA-dirty bits or wait - * for the driver to issue SVGA_CMD_UPDATE? - */ - if (memory_region_is_logging(&s->vga.vram, DIRTY_MEMORY_VGA)) { - vga_sync_dirty_bitmap(&s->vga); - dirty =3D memory_region_get_dirty(&s->vga.vram, 0, - surface_stride(surface) * surface_height(surface), - DIRTY_MEMORY_VGA); - } - if (s->invalidated || dirty) { + if (s->invalidated) { s->invalidated =3D 0; dpy_gfx_update(s->vga.con, 0, 0, surface_width(surface), surface_height(surface)); } - if (dirty) { - memory_region_reset_dirty(&s->vga.vram, 0, - surface_stride(surface) * surface_height(surface), - DIRTY_MEMORY_VGA); - } } =20 static void vmsvga_reset(DeviceState *dev) --=20 2.9.3 From nobody Sat Apr 27 14:57:45 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 149276644082073.18517560263592; Fri, 21 Apr 2017 02:20:40 -0700 (PDT) Received: from localhost ([::1]:58112 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Uk3-0004Zz-Es for importer@patchew.org; Fri, 21 Apr 2017 05:20:39 -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) 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) 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 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+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 | 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 *sur= face) static void sm501_draw_crt(SM501State * s) { DisplaySurface *surface =3D qemu_console_surface(s->con); + DirtyBitmapSnapshot *snap; int y; int width =3D (s->dc_crt_h_total & 0x00000FFF) + 1; int height =3D (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 =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 =3D 0; =20 /* choose draw_line function */ @@ -1326,15 +1325,15 @@ static void sm501_draw_crt(SM501State * s) =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; y < height; y++) { int update_hwc =3D draw_hwc_line ? within_hwc_y_range(s, y, 1) : 0; int update =3D full_update || update_hwc; - ram_addr_t page0 =3D offset; - ram_addr_t page1 =3D offset + width * src_bpp - 1; =20 /* 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) { @@ -1351,10 +1350,6 @@ static void sm501_draw_crt(SM501State * s) =20 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 */ @@ -1366,17 +1361,11 @@ static void sm501_draw_crt(SM501State * s) src +=3D width * src_bpp; offset +=3D width * src_bpp; } + 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 void sm501_update_display(void *opaque) --=20 2.9.3