From patchwork Mon Jan 2 16:33:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 133881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7008B1007D2 for ; Tue, 3 Jan 2012 04:25:04 +1100 (EST) Received: from localhost ([::1]:35084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rhkr3-0008Vm-AM for incoming@patchwork.ozlabs.org; Mon, 02 Jan 2012 11:35:21 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rhkpe-0005Zy-4s for qemu-devel@nongnu.org; Mon, 02 Jan 2012 11:34:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rhkpb-0007HB-0p for qemu-devel@nongnu.org; Mon, 02 Jan 2012 11:33:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rhkpa-0007Gr-QY for qemu-devel@nongnu.org; Mon, 02 Jan 2012 11:33:50 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q02GXoKI008633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 2 Jan 2012 11:33:50 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q02GXmS7028666 for ; Mon, 2 Jan 2012 11:33:49 -0500 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 37F88250BA2; Mon, 2 Jan 2012 18:33:43 +0200 (IST) From: Avi Kivity To: qemu-devel@nongnu.org Date: Mon, 2 Jan 2012 18:33:23 +0200 Message-Id: <1325522015-503-5-git-send-email-avi@redhat.com> In-Reply-To: <1325522015-503-1-git-send-email-avi@redhat.com> References: <1325522015-503-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 04/16] memory: remove MemoryRegion::backend_registered 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 backend_registered was used to lazify the process of registering an mmio region, since the it is different for the I/O address space and the memory address space. However, it also makes registration dependent on the region being visible in the address space. This is not the case for "fake" regions, like watchpoints or IO_MEM_UNASSIGNED. Remove backend_registered and always initialize the region. If it turns out to be part of the I/O address space, we've wasted an I/O slot, but that's not too bad. In any case this will be optimized later on. Signed-off-by: Avi Kivity --- memory.c | 26 ++++---------------------- memory.h | 1 - 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/memory.c b/memory.c index 5c46833..63dc3dc 100644 --- a/memory.c +++ b/memory.c @@ -303,14 +303,10 @@ static void access_with_adjusted_size(target_phys_addr_t addr, } } -static void memory_region_prepare_ram_addr(MemoryRegion *mr); - static void as_memory_range_add(AddressSpace *as, FlatRange *fr) { ram_addr_t phys_offset, region_offset; - memory_region_prepare_ram_addr(fr->mr); - phys_offset = fr->mr->ram_addr; region_offset = fr->offset_in_region; /* cpu_register_physical_memory_log() wants region_offset for @@ -1032,19 +1028,6 @@ static void memory_region_write_thunk_l(void *mr, target_phys_addr_t addr, memory_region_write_thunk_l, }; -static void memory_region_prepare_ram_addr(MemoryRegion *mr) -{ - if (mr->backend_registered) { - return; - } - - mr->destructor = memory_region_destructor_iomem; - mr->ram_addr = cpu_register_io_memory(memory_region_read_thunk, - memory_region_write_thunk, - mr); - mr->backend_registered = true; -} - void memory_region_init_io(MemoryRegion *mr, const MemoryRegionOps *ops, void *opaque, @@ -1055,7 +1038,10 @@ void memory_region_init_io(MemoryRegion *mr, mr->ops = ops; mr->opaque = opaque; mr->terminates = true; - mr->backend_registered = false; + mr->destructor = memory_region_destructor_iomem; + mr->ram_addr = cpu_register_io_memory(memory_region_read_thunk, + memory_region_write_thunk, + mr); } void memory_region_init_ram(MemoryRegion *mr, @@ -1067,7 +1053,6 @@ void memory_region_init_ram(MemoryRegion *mr, mr->terminates = true; mr->destructor = memory_region_destructor_ram; mr->ram_addr = qemu_ram_alloc(size, mr); - mr->backend_registered = true; } void memory_region_init_ram_ptr(MemoryRegion *mr, @@ -1080,7 +1065,6 @@ void memory_region_init_ram_ptr(MemoryRegion *mr, mr->terminates = true; mr->destructor = memory_region_destructor_ram_from_ptr; mr->ram_addr = qemu_ram_alloc_from_ptr(size, ptr, mr); - mr->backend_registered = true; } void memory_region_init_alias(MemoryRegion *mr, @@ -1110,7 +1094,6 @@ void memory_region_init_rom_device(MemoryRegion *mr, memory_region_write_thunk, mr); mr->ram_addr |= IO_MEM_ROMD; - mr->backend_registered = true; } void memory_region_destroy(MemoryRegion *mr) @@ -1453,7 +1436,6 @@ void memory_region_set_alias_offset(MemoryRegion *mr, target_phys_addr_t offset) ram_addr_t memory_region_get_ram_addr(MemoryRegion *mr) { - assert(mr->backend_registered); return mr->ram_addr; } diff --git a/memory.h b/memory.h index 8041e90..77984bb 100644 --- a/memory.h +++ b/memory.h @@ -116,7 +116,6 @@ struct MemoryRegion { Int128 size; target_phys_addr_t addr; target_phys_addr_t offset; - bool backend_registered; void (*destructor)(MemoryRegion *mr); ram_addr_t ram_addr; IORange iorange;