From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHtQ0-0003hg-4f for qemu-devel@nongnu.org; Wed, 22 Jul 2015 08:46:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHtPv-0005g1-OJ for qemu-devel@nongnu.org; Wed, 22 Jul 2015 08:46:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57811) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHtPv-0005fr-JF for qemu-devel@nongnu.org; Wed, 22 Jul 2015 08:46:35 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 36351A2038 for ; Wed, 22 Jul 2015 12:46:35 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-49.ams2.redhat.com [10.36.112.49]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6MCkWDp020440 for ; Wed, 22 Jul 2015 08:46:34 -0400 From: Paolo Bonzini Date: Wed, 22 Jul 2015 14:46:30 +0200 Message-Id: <1437569191-4881-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1437569191-4881-1-git-send-email-pbonzini@redhat.com> References: <1437569191-4881-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH for-2.4 1/2] memory: count number of active VGA logging clients List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org For a board that has multiple framebuffer devices, both of them might want to use DIRTY_MEMORY_VGA on the same memory region. The lack of reference counting in memory_region_set_log makes this very awkward to implement. Suggested-by: Peter Maydell Signed-off-by: Paolo Bonzini --- include/exec/memory.h | 1 + memory.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 1394715..94d20ea 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -180,6 +180,7 @@ struct MemoryRegion { bool warning_printed; /* For reservations */ bool flush_coalesced_mmio; bool global_locking; + uint8_t vga_logging_count; MemoryRegion *alias; hwaddr alias_offset; int32_t priority; diff --git a/memory.c b/memory.c index 0acebb1..5e5f325 100644 --- a/memory.c +++ b/memory.c @@ -1433,8 +1433,15 @@ void memory_region_notify_iommu(MemoryRegion *mr, void memory_region_set_log(MemoryRegion *mr, bool log, unsigned client) { uint8_t mask = 1 << client; + uint8_t old_logging; assert(client == DIRTY_MEMORY_VGA); + old_logging = mr->vga_logging_count; + mr->vga_logging_count += log ? 1 : -1; + if (!!old_logging == !!mr->vga_logging_count) { + return; + } + memory_region_transaction_begin(); mr->dirty_log_mask = (mr->dirty_log_mask & ~mask) | (log * mask); memory_region_update_pending |= mr->enabled; -- 2.4.3