From: Avi Kivity <avi@redhat.com>
To: Bharat Bhushan <r65777@freescale.com>
Cc: Bharat Bhushan <bharat.bhushan@freescale.com>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org, agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH 2/2] Adding BAR0 for e500 PCI controller
Date: Thu, 04 Oct 2012 14:31:47 +0200 [thread overview]
Message-ID: <506D81B3.2040401@redhat.com> (raw)
In-Reply-To: <1349265000-23834-3-git-send-email-Bharat.Bhushan@freescale.com>
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
next prev parent reply other threads:[~2012-10-04 12:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-03 11:49 [Qemu-devel] [PATCH 0/2] e500: creating CCSR region and registering bar0 Bharat Bhushan
2012-10-03 11:49 ` [Qemu-devel] [PATCH 1/2] e500: Adding CCSR memory region Bharat Bhushan
2012-10-03 12:08 ` Alexander Graf
2012-10-03 12:16 ` Bhushan Bharat-R65777
2012-10-03 12:18 ` Alexander Graf
2012-10-03 11:50 ` [Qemu-devel] [PATCH 2/2] Adding BAR0 for e500 PCI controller Bharat Bhushan
2012-10-03 12:11 ` Alexander Graf
2012-10-03 12:23 ` Bhushan Bharat-R65777
2012-10-04 12:31 ` Avi Kivity [this message]
2012-10-04 13:46 ` Bhushan Bharat-R65777
2012-10-04 14:58 ` Avi Kivity
2012-10-04 16:03 ` Bhushan Bharat-R65777
2012-10-04 16:07 ` Alexander Graf
2012-10-04 16:48 ` Bhushan Bharat-R65777
2012-10-04 16:50 ` Alexander Graf
2012-10-04 17:02 ` Avi Kivity
2012-10-05 7:11 ` Bhushan Bharat-R65777
2012-10-05 11:59 ` Alexander Graf
2012-10-07 9:48 ` Avi Kivity
2012-10-07 11:57 ` Alexander Graf
2012-10-07 12:41 ` Avi Kivity
2012-10-08 8:23 ` Bhushan Bharat-R65777
2012-10-08 8:50 ` Alexander Graf
2012-10-08 13:57 ` Andreas Färber
2012-10-04 15:54 ` Andreas Färber
2012-10-04 16:01 ` Alexander Graf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=506D81B3.2040401@redhat.com \
--to=avi@redhat.com \
--cc=agraf@suse.de \
--cc=bharat.bhushan@freescale.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=r65777@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.