From patchwork Mon Jun 25 07:01:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 166976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D9578B6FA5 for ; Mon, 25 Jun 2012 17:31:04 +1000 (EST) Received: from localhost ([::1]:44447 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sj3J5-0002G6-Se for incoming@patchwork.ozlabs.org; Mon, 25 Jun 2012 03:01:55 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sj3IY-0001A5-5c for qemu-devel@nongnu.org; Mon, 25 Jun 2012 03:01:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sj3IQ-0000cC-PW for qemu-devel@nongnu.org; Mon, 25 Jun 2012 03:01:21 -0400 Received: from david.siemens.de ([192.35.17.14]:27001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sj3IQ-0000bi-FV for qemu-devel@nongnu.org; Mon, 25 Jun 2012 03:01:14 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.13.6/8.13.6) with ESMTP id q5P718Lh002688; Mon, 25 Jun 2012 09:01:08 +0200 Received: from mchn199C.mchp.siemens.de ([139.22.34.212]) by mail1.siemens.de (8.13.6/8.13.6) with SMTP id q5P7135t001108; Mon, 25 Jun 2012 09:01:06 +0200 From: Jan Kiszka To: Anthony Liguori , qemu-devel Date: Mon, 25 Jun 2012 09:01:00 +0200 Message-Id: <47c076c8519f27cdfbf3f1e55432a162e5334e02.1340607659.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.14 Cc: Liu Ping Fan , Avi Kivity , kvm , Marcelo Tosatti Subject: [Qemu-devel] [PATCH 3/5] memory: Flush coalesced MMIO on mapping and state changes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Flush pending coalesced MMIO before performing mapping or state changes that could affect the event orderings or route the buffered requests to a wrong region. Signed-off-by: Jan Kiszka In addition, we also have to --- memory.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-) diff --git a/memory.c b/memory.c index ba55b3e..141f92b 100644 --- a/memory.c +++ b/memory.c @@ -759,6 +759,7 @@ static void memory_region_update_topology(MemoryRegion *mr) void memory_region_transaction_begin(void) { + qemu_flush_coalesced_mmio_buffer(); ++memory_region_transaction_depth; } @@ -1109,6 +1110,9 @@ void memory_region_sync_dirty_bitmap(MemoryRegion *mr) void memory_region_set_readonly(MemoryRegion *mr, bool readonly) { + if (!QTAILQ_EMPTY(&mr->coalesced)) { + qemu_flush_coalesced_mmio_buffer(); + } if (mr->readonly != readonly) { mr->readonly = readonly; memory_region_update_topology(mr); @@ -1117,6 +1121,9 @@ void memory_region_set_readonly(MemoryRegion *mr, bool readonly) void memory_region_rom_device_set_readable(MemoryRegion *mr, bool readable) { + if (!QTAILQ_EMPTY(&mr->coalesced)) { + qemu_flush_coalesced_mmio_buffer(); + } if (mr->readable != readable) { mr->readable = readable; memory_region_update_topology(mr); @@ -1190,6 +1197,8 @@ void memory_region_clear_coalescing(MemoryRegion *mr) { CoalescedMemoryRange *cmr; + qemu_flush_coalesced_mmio_buffer(); + while (!QTAILQ_EMPTY(&mr->coalesced)) { cmr = QTAILQ_FIRST(&mr->coalesced); QTAILQ_REMOVE(&mr->coalesced, cmr, link); @@ -1219,6 +1228,9 @@ void memory_region_add_eventfd(MemoryRegion *mr, }; unsigned i; + if (!QTAILQ_EMPTY(&mr->coalesced)) { + qemu_flush_coalesced_mmio_buffer(); + } for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_before(mrfd, mr->ioeventfds[i])) { break; @@ -1249,6 +1261,9 @@ void memory_region_del_eventfd(MemoryRegion *mr, }; unsigned i; + if (!QTAILQ_EMPTY(&mr->coalesced)) { + qemu_flush_coalesced_mmio_buffer(); + } for (i = 0; i < mr->ioeventfd_nb; ++i) { if (memory_region_ioeventfd_equal(mrfd, mr->ioeventfds[i])) { break; @@ -1269,6 +1284,8 @@ static void memory_region_add_subregion_common(MemoryRegion *mr, { MemoryRegion *other; + qemu_flush_coalesced_mmio_buffer(); + assert(!subregion->parent); subregion->parent = mr; subregion->addr = offset; @@ -1327,6 +1344,8 @@ void memory_region_add_subregion_overlap(MemoryRegion *mr, void memory_region_del_subregion(MemoryRegion *mr, MemoryRegion *subregion) { + qemu_flush_coalesced_mmio_buffer(); + assert(subregion->parent == mr); subregion->parent = NULL; QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link); @@ -1335,6 +1354,8 @@ void memory_region_del_subregion(MemoryRegion *mr, void memory_region_set_enabled(MemoryRegion *mr, bool enabled) { + qemu_flush_coalesced_mmio_buffer(); + if (enabled == mr->enabled) { return; } @@ -1367,6 +1388,8 @@ void memory_region_set_alias_offset(MemoryRegion *mr, target_phys_addr_t offset) { target_phys_addr_t old_offset = mr->alias_offset; + qemu_flush_coalesced_mmio_buffer(); + assert(mr->alias); mr->alias_offset = offset;