From: Alexander Graf <agraf@suse.de>
To: alvise rigo <a.rigo@virtualopensystems.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Rob Herring <rob.herring@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Claudio Fontana <claudio.fontana@huawei.com>,
"stuart.yoder@freescale.com" <stuart.yoder@freescale.com>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 3/4] arm: Add PCIe host bridge in virt machine
Date: Mon, 12 Jan 2015 17:57:25 +0100 [thread overview]
Message-ID: <54B3FCF5.7080102@suse.de> (raw)
In-Reply-To: <CAH47eN2ru7RWizXUgG5mvoZ+Up=osgMGLqfi0Vskh++NN8HLaw@mail.gmail.com>
On 12.01.15 17:49, alvise rigo wrote:
> Hi Alexander,
>
> Just a comment below.
>
> On Tue, Jan 6, 2015 at 5:03 PM, Alexander Graf <agraf@suse.de> wrote:
>> Now that we have a working "generic" PCIe host bridge driver, we can plug
>> it into ARMs virt machine to always have PCIe available to normal ARM VMs.
>>
>> I've successfully managed to expose a Bochs VGA device, XHCI and an e1000
>> into an AArch64 VM with this and they all lived happily ever after.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>>
>> ---
>>
>> Linux 3.19 only supports the generic PCIe host bridge driver for 32bit ARM
>> systems. If you want to use it with AArch64 guests, please apply the following
>> patch or wait until upstream cleaned up the code properly:
>>
>> http://csgraf.de/agraf/pci/pci-3.19.patch
>> ---
>> default-configs/arm-softmmu.mak | 2 +
>> hw/arm/virt.c | 83 ++++++++++++++++++++++++++++++++++++++---
>> 2 files changed, 80 insertions(+), 5 deletions(-)
>>
>> diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
>> index f3513fa..7671ee2 100644
>> --- a/default-configs/arm-softmmu.mak
>> +++ b/default-configs/arm-softmmu.mak
>> @@ -82,6 +82,8 @@ CONFIG_ZYNQ=y
>> CONFIG_VERSATILE_PCI=y
>> CONFIG_VERSATILE_I2C=y
>>
>> +CONFIG_PCI_GENERIC=y
>> +
>> CONFIG_SDHCI=y
>> CONFIG_INTEGRATOR_DEBUG=y
>>
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index 2353440..b7635ac 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -42,6 +42,7 @@
>> #include "exec/address-spaces.h"
>> #include "qemu/bitops.h"
>> #include "qemu/error-report.h"
>> +#include "hw/pci-host/gpex.h"
>>
>> #define NUM_VIRTIO_TRANSPORTS 32
>>
>> @@ -69,6 +70,7 @@ enum {
>> VIRT_MMIO,
>> VIRT_RTC,
>> VIRT_FW_CFG,
>> + VIRT_PCIE,
>> };
>>
>> typedef struct MemMapEntry {
>> @@ -129,13 +131,14 @@ static const MemMapEntry a15memmap[] = {
>> [VIRT_FW_CFG] = { 0x09020000, 0x0000000a },
>> [VIRT_MMIO] = { 0x0a000000, 0x00000200 },
>> /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
>> - /* 0x10000000 .. 0x40000000 reserved for PCI */
>> + [VIRT_PCIE] = { 0x10000000, 0x30000000 },
>> [VIRT_MEM] = { 0x40000000, 30ULL * 1024 * 1024 * 1024 },
>> };
>>
>> static const int a15irqmap[] = {
>> [VIRT_UART] = 1,
>> [VIRT_RTC] = 2,
>> + [VIRT_PCIE] = 3,
>> [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
>> };
>>
>> @@ -312,7 +315,7 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi)
>> }
>> }
>>
>> -static void fdt_add_gic_node(const VirtBoardInfo *vbi)
>> +static uint32_t fdt_add_gic_node(const VirtBoardInfo *vbi)
>> {
>> uint32_t gic_phandle;
>>
>> @@ -331,9 +334,11 @@ static void fdt_add_gic_node(const VirtBoardInfo *vbi)
>> 2, vbi->memmap[VIRT_GIC_CPU].base,
>> 2, vbi->memmap[VIRT_GIC_CPU].size);
>> qemu_fdt_setprop_cell(vbi->fdt, "/intc", "phandle", gic_phandle);
>> +
>> + return gic_phandle;
>> }
>>
>> -static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
>> +static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
>> {
>> /* We create a standalone GIC v2 */
>> DeviceState *gicdev;
>> @@ -380,7 +385,7 @@ static void create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
>> pic[i] = qdev_get_gpio_in(gicdev, i);
>> }
>>
>> - fdt_add_gic_node(vbi);
>> + return fdt_add_gic_node(vbi);
>> }
>>
>> static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
>> @@ -556,6 +561,71 @@ static void create_fw_cfg(const VirtBoardInfo *vbi)
>> g_free(nodename);
>> }
>>
>> +static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
>> + uint32_t gic_phandle)
>> +{
>> + hwaddr base = vbi->memmap[VIRT_PCIE].base;
>> + hwaddr size = vbi->memmap[VIRT_PCIE].size;
>> + hwaddr size_ioport = 64 * 1024;
>> + hwaddr size_ecam = PCIE_MMCFG_SIZE_MIN;
>> + hwaddr size_mmio = size - size_ecam - size_ioport;
>> + hwaddr base_mmio = base;
>> + hwaddr base_ioport = base_mmio + size_mmio;
>> + hwaddr base_ecam = base_ioport + size_ioport;
>> + int irq = vbi->irqmap[VIRT_PCIE];
>> + MemoryRegion *mmio_alias;
>> + MemoryRegion *mmio_reg;
>> + DeviceState *dev;
>> + char *nodename;
>> +
>> + dev = qdev_create(NULL, TYPE_GPEX_HOST);
>> +
>> + qdev_prop_set_uint64(dev, "mmio_window_size", size_mmio);
>> + qdev_init_nofail(dev);
>> +
>> + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base_ecam);
>> + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_ioport);
>> +
>> + /* Map the MMIO window at the same spot in bus and cpu layouts */
>> + mmio_alias = g_new0(MemoryRegion, 1);
>> + mmio_reg = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 1);
>> + memory_region_init_alias(mmio_alias, OBJECT(dev), "pcie-mmio",
>> + mmio_reg, base_mmio, size_mmio);
>
> Is it safe to have both mmio_alias and mmio_reg of size_mmio bytes?
> Shouldn't be the container region at least (offset + size - 1) big?
You're right. The bridge's memory region shouldn't have any size
limitation, it should just be a flat 64bit memory region that the device
creator than maps aliases into its own address space from.
Alex
next prev parent reply other threads:[~2015-01-12 16:57 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-06 16:03 [Qemu-devel] [PATCH 0/4] ARM: Add support for a generic PCI Express host bridge Alexander Graf
2015-01-06 16:03 ` [Qemu-devel] [PATCH 1/4] pci: Split pcie_host_mmcfg_map() Alexander Graf
2015-01-12 16:28 ` Claudio Fontana
2015-01-06 16:03 ` [Qemu-devel] [PATCH 2/4] pci: Add generic PCIe host bridge Alexander Graf
2015-01-12 16:29 ` Claudio Fontana
2015-01-12 17:36 ` alvise rigo
2015-01-12 17:38 ` Alexander Graf
2015-01-12 20:08 ` Peter Maydell
2015-01-12 21:06 ` Alexander Graf
2015-01-12 21:20 ` Peter Maydell
2015-01-13 0:13 ` Alexander Graf
2015-01-13 10:07 ` Peter Maydell
2015-01-13 9:09 ` Claudio Fontana
2015-01-06 16:03 ` [Qemu-devel] [PATCH 3/4] arm: Add PCIe host bridge in virt machine Alexander Graf
2015-01-07 15:52 ` Claudio Fontana
2015-01-07 21:47 ` Alexander Graf
2015-01-08 12:55 ` Claudio Fontana
2015-01-08 13:26 ` Alexander Graf
2015-01-08 15:01 ` Claudio Fontana
2015-01-12 16:23 ` Claudio Fontana
2015-01-12 16:35 ` Alexander Graf
2015-01-08 13:36 ` alvise rigo
2015-01-08 10:31 ` Peter Maydell
2015-01-08 12:30 ` Claudio Fontana
2015-01-12 16:20 ` Claudio Fontana
2015-01-12 16:36 ` Alexander Graf
2015-01-12 16:49 ` alvise rigo
2015-01-12 16:57 ` Alexander Graf [this message]
2015-01-06 16:03 ` [Qemu-devel] [PATCH 4/4] arm: enable Bochs PCI VGA Alexander Graf
2015-01-06 16:16 ` Peter Maydell
2015-01-06 21:08 ` Alexander Graf
2015-01-06 21:28 ` Peter Maydell
2015-01-06 21:42 ` Alexander Graf
2015-01-07 6:22 ` Paolo Bonzini
2015-01-07 13:52 ` [Qemu-devel] [PATCH 0/4] ARM: Add support for a generic PCI Express host bridge Claudio Fontana
2015-01-07 14:07 ` Alexander Graf
2015-01-07 14:26 ` Claudio Fontana
2015-01-07 14:36 ` Alexander Graf
2015-01-07 15:16 ` Claudio Fontana
2015-01-07 16:31 ` Peter Maydell
2015-01-12 16:24 ` Claudio Fontana
2015-01-21 12:59 ` Claudio Fontana
2015-01-21 13:01 ` Alexander Graf
2015-01-21 13:02 ` Peter Maydell
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=54B3FCF5.7080102@suse.de \
--to=agraf@suse.de \
--cc=a.rigo@virtualopensystems.com \
--cc=ard.biesheuvel@linaro.org \
--cc=claudio.fontana@huawei.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rob.herring@linaro.org \
--cc=stuart.yoder@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.