All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudio Fontana <claudio.fontana@huawei.com>
To: Alvise Rigo <a.rigo@virtualopensystems.com>, qemu-devel@nongnu.org
Cc: rob.herring@linaro.org, tech@virtualopensystems.com,
	peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [RFC v2 4/4] hw/arm/virt: Add generic-pci device support
Date: Mon, 24 Nov 2014 11:38:49 +0100	[thread overview]
Message-ID: <54730AB9.9020208@huawei.com> (raw)
In-Reply-To: <1416593261-13751-5-git-send-email-a.rigo@virtualopensystems.com>

On 21.11.2014 19:07, Alvise Rigo wrote:
> Instantiate a generic-pci PCI controller to add a PCI bus to the
> mach-virt platform. The platform memory map has now three more memory
> ranges to map the device's memory regions (Configuration region, I/O
> region and Memory region). Now that a PCI bus is provided, the machine
> could be launched with multiple PCI devices through the -device option
> (e.g., -device virtio-blk-pci).
> 
> Signed-off-by: Alvise Rigo <a.rigo@virtualopensystems.com>
> ---
>  hw/arm/virt.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 55 insertions(+)
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 4e7b869..74e6838 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -32,6 +32,7 @@
>  #include "hw/arm/arm.h"
>  #include "hw/arm/primecell.h"
>  #include "hw/devices.h"
> +#include "hw/pci-host/generic-pci.h"
>  #include "net/net.h"
>  #include "sysemu/block-backend.h"
>  #include "sysemu/device_tree.h"
> @@ -44,6 +45,7 @@
>  #include "qemu/error-report.h"
>  
>  #define NUM_VIRTIO_TRANSPORTS 32
> +#define NUM_PCI_IRQS 20
>  
>  /* Number of external interrupt lines to configure the GIC with */
>  #define NUM_IRQS 128
> @@ -68,6 +70,9 @@ enum {
>      VIRT_UART,
>      VIRT_MMIO,
>      VIRT_RTC,
> +    VIRT_PCI_CFG,
> +    VIRT_PCI_IO,
> +    VIRT_PCI_MEM,
>  };
>  
>  typedef void (*modify_dtb_func)(void *fdt, DeviceState *dev);
> @@ -120,6 +125,9 @@ static const MemMapEntry a15memmap[] = {
>      [VIRT_MMIO] =       { 0x0a000000, 0x00000200 },
>      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
>      /* 0x10000000 .. 0x40000000 reserved for PCI */
> +    [VIRT_PCI_CFG] =    { 0x10000000, 0x01000000 },
> +    [VIRT_PCI_IO] =     { 0x11000000, 0x00010000 },
> +    [VIRT_PCI_MEM] =    { 0x12000000, 0x2e000000 },
>      [VIRT_MEM] =        { 0x40000000, 30ULL * 1024 * 1024 * 1024 },
>  };
>  
> @@ -127,6 +135,7 @@ static const int a15irqmap[] = {
>      [VIRT_UART] = 1,
>      [VIRT_RTC] = 2,
>      [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
> +    [VIRT_PCI_CFG] = 47,

why not say
[VIRT_PCI_CFG] = 16 + NUM_VIRTIO_TRANSPORTS

instead of "47"?

By the way isn't 47 wrong anyway? From 16 to 47 it's virtio transports no?
Should it not be 48?

>  };
>  
>  static VirtBoardInfo machines[] = {
> @@ -550,6 +559,50 @@ static void create_flash(const VirtBoardInfo *vbi)
>      g_free(nodename);
>  }
>  
> +static void create_pci_host(const VirtBoardInfo *vbi, qemu_irq *pic)
> +{
> +    PCIBus *pci_bus;
> +    DeviceState *dev;
> +    SysBusDevice *busdev;
> +    PCIGenState *pgdev;
> +    GenericPCIPlatformData *pdata;
> +    int i;
> +    const MemMapEntry *mme = NULL;
> +
> +    dev = qdev_create(NULL, "generic_pci");
> +    busdev = SYS_BUS_DEVICE(dev);
> +    pgdev = PCI_GEN(dev);
> +
> +    mme = vbi->memmap;
> +
> +    /* Pass platform dependent data to the controller. */
> +    pdata = &pgdev->plat_data;
> +    pdata->addr_map[PCI_CFG].addr = mme[VIRT_PCI_CFG].base;
> +    pdata->addr_map[PCI_CFG].size = mme[VIRT_PCI_CFG].size;
> +    pdata->addr_map[PCI_IO].addr = mme[VIRT_PCI_IO].base;
> +    pdata->addr_map[PCI_IO].size = mme[VIRT_PCI_IO].size;
> +    pdata->addr_map[PCI_MEM].addr = mme[VIRT_PCI_MEM].base;
> +    pdata->addr_map[PCI_MEM].size = mme[VIRT_PCI_MEM].size;
> +    pdata->gic_node_name = "/intc";
> +    pdata->base_irq = vbi->irqmap[VIRT_PCI_CFG];
> +    pdata->irqs = NUM_PCI_IRQS;
> +    qdev_init_nofail(dev);
> +
> +    sysbus_mmio_map(busdev, 0, mme[VIRT_PCI_CFG].base); /* PCI config */
> +    sysbus_mmio_map(busdev, 1, mme[VIRT_PCI_IO].base);  /* PCI I/O */
> +    sysbus_mmio_map(busdev, 2, mme[VIRT_PCI_MEM].base); /* PCI memory window */
> +
> +    for ( i = 0; i < NUM_PCI_IRQS; i++) {
> +        sysbus_connect_irq(busdev, i, pic[vbi->irqmap[VIRT_PCI_CFG] + i]);
> +    }
> +
> +    pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
> +    pci_create_simple(pci_bus, -1, "pci-ohci");
> +    pci_create_simple(pci_bus, -1, "lsi53c895a");
> +
> +    add_dtb_modifier(pci_controller_build_dt_node, dev);
> +}
> +
>  static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
>  {
>      const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;
> @@ -658,6 +711,8 @@ static void machvirt_init(MachineState *machine)
>       */
>      create_virtio_devices(vbi, pic);
>  
> +    create_pci_host(vbi, pic);
> +
>      Notifier *finalize_dtb_notifier = g_new(Notifier, 1);
>      finalize_dtb_notifier->notify = machvirt_finalize_dt;
>      qemu_add_machine_init_done_notifier(finalize_dtb_notifier);
> 

  parent reply	other threads:[~2014-11-24 10:39 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-21 18:07 [Qemu-devel] [RFC v2 0/4] Add Generic PCI host device update Alvise Rigo
2014-11-21 18:07 ` [Qemu-devel] [RFC v2 1/4] hw/arm/virt: Allow multiple agents to modify dt Alvise Rigo
2014-11-24 11:47   ` Claudio Fontana
2015-01-05 15:36     ` Peter Maydell
2015-01-05 16:14       ` alvise rigo
2015-01-05 16:41         ` Peter Maydell
2015-01-05 17:35           ` alvise rigo
2015-01-05 18:07             ` Peter Maydell
2015-01-06  9:56               ` alvise rigo
2015-01-06  9:18         ` Eric Auger
2015-01-06  9:29           ` alvise rigo
2015-01-06  9:51           ` Peter Maydell
2015-01-06 10:05             ` Eric Auger
2014-11-21 18:07 ` [Qemu-devel] [RFC v2 2/4] hw/arm/virt: find_machine_info: handle NULL value Alvise Rigo
2015-01-05 15:36   ` Peter Maydell
2015-01-05 16:31     ` alvise rigo
2015-01-05 16:42       ` Peter Maydell
2014-11-21 18:07 ` [Qemu-devel] [RFC v2 3/4] hw/pci-host: Add a generic PCI host controller for virtual platforms Alvise Rigo
2014-11-24 10:34   ` Claudio Fontana
2014-11-24 14:57     ` alvise rigo
2014-11-25 10:20       ` Claudio Fontana
2015-01-05 17:13   ` Alexander Graf
2015-01-06  8:47     ` alvise rigo
2015-01-06 11:18       ` Alexander Graf
     [not found] ` <1416593261-13751-5-git-send-email-a.rigo@virtualopensystems.com>
2014-11-24 10:38   ` Claudio Fontana [this message]
2014-11-24 10:47     ` [Qemu-devel] [RFC v2 4/4] hw/arm/virt: Add generic-pci device support alvise rigo
2014-11-24 15:50 ` [Qemu-devel] [RFC v2 0/4] Add Generic PCI host device update Claudio Fontana
2014-11-25 10:28   ` alvise rigo
2015-01-12 16:26 ` Claudio Fontana

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=54730AB9.9020208@huawei.com \
    --to=claudio.fontana@huawei.com \
    --cc=a.rigo@virtualopensystems.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rob.herring@linaro.org \
    --cc=tech@virtualopensystems.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.