From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbBkE-0005NF-Ej for qemu-devel@nongnu.org; Thu, 26 Mar 2015 13:39:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YbBk8-0003Xh-AX for qemu-devel@nongnu.org; Thu, 26 Mar 2015 13:39:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33560) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbBk8-0003XZ-1G for qemu-devel@nongnu.org; Thu, 26 Mar 2015 13:38:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2QHctGZ020803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 26 Mar 2015 13:38:55 -0400 Received: from donizetti.redhat.com (ovpn-112-86.ams2.redhat.com [10.36.112.86]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2QHcflC025898 for ; Thu, 26 Mar 2015 13:38:54 -0400 From: Paolo Bonzini Date: Thu, 26 Mar 2015 18:38:24 +0100 Message-Id: <1427391520-29497-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1427391520-29497-1-git-send-email-pbonzini@redhat.com> References: <1427391520-29497-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 06/22] framebuffer: check memory_region_is_logging List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org framebuffer.c expects DIRTY_MEMORY_VGA logging to be always on, but that will not be the case soon. Because framebuffer.c computes the memory region on the fly for every update (with memory_region_find), it cannot enable/disable logging by itself. Instead, always treat updates as invalidations if dirty logging is not enabled, assuming that the board will enable logging on the RAM region that includes the framebuffer. To simplify the code, replace memory_region_get_dirty with memory_region_test_and_clear_dirty. Then memory_region_reset_dirty is only needed in the invalidate case. Signed-off-by: Paolo Bonzini --- hw/display/framebuffer.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/hw/display/framebuffer.c b/hw/display/framebuffer.c index 4546e42..49fe204 100644 --- a/hw/display/framebuffer.c +++ b/hw/display/framebuffer.c @@ -62,7 +62,16 @@ void framebuffer_update_display( assert(mem); assert(mem_section.offset_within_address_space == base); - memory_region_sync_dirty_bitmap(mem); + if (memory_region_is_logging(mem) & (1 << DIRTY_MEMORY_VGA)) { + memory_region_sync_dirty_bitmap(mem); + if (invalidate) { + memory_region_reset_dirty(mem, mem_section.offset_within_region, + src_len, DIRTY_MEMORY_VGA); + } + } else { + invalidate = true; + } + src_base = cpu_physical_memory_map(base, &src_len, 0); /* If we can't map the framebuffer then bail. We could try harder, but it's not really worth it as dirty flag tracking will probably @@ -88,9 +97,13 @@ void framebuffer_update_display( dest += i * dest_row_pitch; for (; i < rows; i++) { - dirty = memory_region_get_dirty(mem, addr, src_width, - DIRTY_MEMORY_VGA); - if (dirty || invalidate) { + if (invalidate) { + dirty = true; + } else { + dirty = memory_region_test_and_clear_dirty(mem, addr, src_width, + DIRTY_MEMORY_VGA); + } + if (dirty) { fn(opaque, dest, src, cols, dest_col_pitch); if (first == -1) first = i; @@ -104,8 +117,6 @@ void framebuffer_update_display( if (first < 0) { goto out; } - memory_region_reset_dirty(mem, mem_section.offset_within_region, src_len, - DIRTY_MEMORY_VGA); *first_row = first; *last_row = last; out: -- 2.3.3