From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjqI4-0006qD-Je for qemu-devel@nongnu.org; Tue, 04 Jun 2013 08:24:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjqHz-0006aZ-PV for qemu-devel@nongnu.org; Tue, 04 Jun 2013 08:24:40 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:36187) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjqHz-0006aK-J4 for qemu-devel@nongnu.org; Tue, 04 Jun 2013 08:24:35 -0400 Received: by mail-pd0-f171.google.com with SMTP id z11so161175pdj.30 for ; Tue, 04 Jun 2013 05:24:34 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1370348041-6768-7-git-send-email-pbonzini@redhat.com> References: <1370348041-6768-1-git-send-email-pbonzini@redhat.com> <1370348041-6768-7-git-send-email-pbonzini@redhat.com> From: Peter Maydell Date: Tue, 4 Jun 2013 13:24:14 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH v2 06/17] sysbus: add sysbus_pass_mmio List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On 4 June 2013 13:13, Paolo Bonzini wrote: > This matches sysbus_pass_irq in cases where a device is a thin wrapper > of another. MMIO regions will keep the subdevice as the owner. > > Signed-off-by: Paolo Bonzini > --- > hw/core/sysbus.c | 12 ++++++++++++ > hw/cpu/arm11mpcore.c | 2 +- > include/hw/sysbus.h | 1 + > 3 files changed, 14 insertions(+), 1 deletion(-) > > diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c > index 9004d8c..6dbd1f8 100644 > --- a/hw/core/sysbus.c > +++ b/hw/core/sysbus.c > @@ -117,6 +117,18 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory) > dev->mmio[n].memory = memory; > } > > +/* Pass MMIOs from a target device. */ > +void sysbus_pass_mmio(SysBusDevice *dev, SysBusDevice *target) > +{ > + int i; > + assert(dev->num_mmio == 0); > + dev->num_mmio = target->num_mmio; > + for (i = 0; i < dev->num_mmio; i++) { > + assert(target->mmio[i].addr == -1); > + dev->mmio[i] = target->mmio[i]; > + } > +} This is much less flexible than just using sysbus_mmio_get_region(), because it only lets you pass the whole set of MMIOs from the other device through, not just the ones you want. Please just make reference counting work properly with passing MemoryRegion*s around. -- PMM