From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJkay-0005tE-1p for qemu-devel@nongnu.org; Thu, 04 Oct 2012 08:32:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJkaq-00062H-4T for qemu-devel@nongnu.org; Thu, 04 Oct 2012 08:32:03 -0400 Message-ID: <506D81B3.2040401@redhat.com> Date: Thu, 04 Oct 2012 14:31:47 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1349265000-23834-1-git-send-email-Bharat.Bhushan@freescale.com> <1349265000-23834-3-git-send-email-Bharat.Bhushan@freescale.com> In-Reply-To: <1349265000-23834-3-git-send-email-Bharat.Bhushan@freescale.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] Adding BAR0 for e500 PCI controller List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharat Bhushan Cc: Bharat Bhushan , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de On 10/03/2012 01:50 PM, Bharat Bhushan wrote: > sysbus_connect_irq(s, 0, mpic[pci_irq_nrs[0]]); > diff --git a/hw/ppce500_pci.c b/hw/ppce500_pci.c > index 92b1dc0..16e4af2 100644 > --- a/hw/ppce500_pci.c > +++ b/hw/ppce500_pci.c > @@ -87,6 +87,7 @@ struct PPCE500PCIState { > /* mmio maps */ > MemoryRegion container; > MemoryRegion iomem; > + void *bar0; > }; void *? Why? > > typedef struct PPCE500PCIState PPCE500PCIState; > @@ -315,6 +316,8 @@ static int e500_pcihost_initfn(SysBusDevice *dev) > int i; > MemoryRegion *address_space_mem = get_system_memory(); > MemoryRegion *address_space_io = get_system_io(); > + PCIDevice *pdev; > + MemoryRegion bar0; > > h = PCI_HOST_BRIDGE(dev); > s = PPC_E500_PCI_HOST_BRIDGE(dev); > @@ -342,6 +345,10 @@ static int e500_pcihost_initfn(SysBusDevice *dev) > memory_region_add_subregion(&s->container, PCIE500_REG_BASE, &s->iomem); > sysbus_init_mmio(dev, &s->container); > > + bar0 = *(MemoryRegion *)s->bar0; > + pdev = pci_find_device(b, 0, 0); > + pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &bar0); > + This is broken, you're registering an object on the stack which will be freed as soon as the function returns. Just pass &s->bar0 as Alex suggests. However this is best done from the pci device's initialization function, not here (the MemoryRegion should be a member of the pci device as well). > return 0; > } > -- error compiling committee.c: too many arguments to function