From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsfgI-0002OV-Kb for qemu-devel@nongnu.org; Sun, 14 Aug 2011 14:45:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QsfgH-0002Sf-Jq for qemu-devel@nongnu.org; Sun, 14 Aug 2011 14:45:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QsfgH-0002SA-BH for qemu-devel@nongnu.org; Sun, 14 Aug 2011 14:45:05 -0400 Message-ID: <4E4817AC.8020705@redhat.com> Date: Sun, 14 Aug 2011 11:45:00 -0700 From: Avi Kivity MIME-Version: 1.0 References: <1312823229-12822-1-git-send-email-avi@redhat.com> <1312823229-12822-18-git-send-email-avi@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 17/24] arm11mpcore: use sysbus_init_mmio_cb2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org On 08/12/2011 06:23 AM, Peter Maydell wrote: > > static int realview_mpcore_init(SysBusDevice *dev) > > { > > mpcore_rirq_state *s = FROM_SYSBUS(mpcore_rirq_state, dev); > > @@ -79,7 +84,7 @@ static int realview_mpcore_init(SysBusDevice *dev) > > } > > } > > qdev_init_gpio_in(&dev->qdev, mpcore_rirq_set_irq, 64); > > - sysbus_init_mmio_cb(dev, 0x2000, mpcore_rirq_map); > > + sysbus_init_mmio_cb2(dev, mpcore_rirq_map, mpcore_rirq_unmap); > > return 0; > > } > > Since the mpcore code here is only using sysbus mmio callbacks as > a way to pass things through to a sysbus mmio provided by another > device, I think it would be cleaner to just have a way to say "my > mmio is actually provided by this other device". > > For instance you could have > MemoryRegion* sysbus_mmio_get_region(SysBusDevice *dev, int n)) > { > return dev->mmio[n].memory; > } > > and then realview_mpcore_init() can just > sysbus_init_mmio_region(dev, sysbus_mmio_get_region(s->priv, 0)); > > Or you could have a sysbus_pass_mmio() which worked like > sysbus_pass_irq() and just said "my mmios are all this other > device's mmios"; that's less flexible though. > > Yes. Yet another option is to create a container MemoryRegion and pass it upwards, then allow the device that actually implements that mmio to register its regions with the container. I'll leave this to the device maintainer though. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.