qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: Shannon Zhao <zhaoshenglong@huawei.com>
Cc: peter.maydell@linaro.org, hangaohuai@huawei.com, mst@redhat.com,
	a.spyridakis@virtualopensystems.com, claudio.fontana@huawei.com,
	qemu-devel@nongnu.org, peter.huangpeng@huawei.com,
	hanjun.guo@linaro.org, imammedo@redhat.com, pbonzini@redhat.com,
	lersek@redhat.com, christoffer.dall@linaro.org,
	shannon.zhao@linaro.org
Subject: Re: [Qemu-devel] [PATCH v9 03/24] hw/arm/virt: Record PCIe ranges in MemMapEntry array
Date: Wed, 27 May 2015 09:17:24 +0100	[thread overview]
Message-ID: <87y4kaph7v.fsf@linaro.org> (raw)
In-Reply-To: <1432522520-8068-4-git-send-email-zhaoshenglong@huawei.com>


Shannon Zhao <zhaoshenglong@huawei.com> writes:

> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> To generate ACPI table for PCIe controller, we need the base and size of
> the PCIe ranges. Record these ranges in MemMapEntry array, then we could
> share and use them for generating ACPI table.
>
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/arm/virt.c         | 37 +++++++++++++------------------------
>  include/hw/arm/virt.h |  3 +++
>  2 files changed, 16 insertions(+), 24 deletions(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 8959d0c..250b9bc 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -112,14 +112,9 @@ 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 */
> -    /*
> -     * PCIE verbose map:
> -     *
> -     * MMIO window      { 0x10000000, 0x2eff0000 },
> -     * PIO window       { 0x3eff0000, 0x00010000 },
> -     * ECAM             { 0x3f000000, 0x01000000 },
> -     */
> -    [VIRT_PCIE] =       { 0x10000000, 0x30000000 },
> +    [VIRT_PCIE_MMIO] =  { 0x10000000, 0x2eff0000 },
> +    [VIRT_PCIE_PIO] =   { 0x3eff0000, 0x00010000 },
> +    [VIRT_PCIE_ECAM] =  { 0x3f000000, 0x01000000 },
>      [VIRT_MEM] =        { 0x40000000, 30ULL * 1024 * 1024 * 1024 },
>  };
>  
> @@ -625,16 +620,14 @@ static void create_pcie_irq_map(const VirtBoardInfo *vbi, uint32_t gic_phandle,
>  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 end = base + size;
> -    hwaddr size_mmio;
> -    hwaddr size_ioport = 64 * 1024;
> -    int nr_pcie_buses = 16;
> -    hwaddr size_ecam = PCIE_MMCFG_SIZE_MIN * nr_pcie_buses;
> -    hwaddr base_mmio = base;
> -    hwaddr base_ioport;
> -    hwaddr base_ecam;
> +    hwaddr base_mmio = vbi->memmap[VIRT_PCIE_MMIO].base;
> +    hwaddr size_mmio = vbi->memmap[VIRT_PCIE_MMIO].size;
> +    hwaddr base_pio = vbi->memmap[VIRT_PCIE_PIO].base;
> +    hwaddr size_pio = vbi->memmap[VIRT_PCIE_PIO].size;
> +    hwaddr base_ecam = vbi->memmap[VIRT_PCIE_ECAM].base;
> +    hwaddr size_ecam = vbi->memmap[VIRT_PCIE_ECAM].size;
> +    hwaddr base = base_mmio;
> +    int nr_pcie_buses = size_ecam / PCIE_MMCFG_SIZE_MIN;
>      int irq = vbi->irqmap[VIRT_PCIE];
>      MemoryRegion *mmio_alias;
>      MemoryRegion *mmio_reg;
> @@ -644,10 +637,6 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
>      char *nodename;
>      int i;
>  
> -    base_ecam = QEMU_ALIGN_DOWN(end - size_ecam, size_ecam);
> -    base_ioport = QEMU_ALIGN_DOWN(base_ecam - size_ioport, size_ioport);
> -    size_mmio = base_ioport - base;
> -
>      dev = qdev_create(NULL, TYPE_GPEX_HOST);
>      qdev_init_nofail(dev);
>  
> @@ -670,7 +659,7 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
>      memory_region_add_subregion(get_system_memory(), base_mmio, mmio_alias);
>  
>      /* Map IO port space */
> -    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_ioport);
> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, base_pio);
>  
>      for (i = 0; i < GPEX_NUM_IRQS; i++) {
>          sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, pic[irq + i]);
> @@ -690,7 +679,7 @@ static void create_pcie(const VirtBoardInfo *vbi, qemu_irq *pic,
>                                   2, base_ecam, 2, size_ecam);
>      qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "ranges",
>                                   1, FDT_PCI_RANGE_IOPORT, 2, 0,
> -                                 2, base_ioport, 2, size_ioport,
> +                                 2, base_pio, 2, size_pio,
>                                   1, FDT_PCI_RANGE_MMIO, 2, base_mmio,
>                                   2, base_mmio, 2, size_mmio);
>  
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index 2fe0d2e..49a85cc 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -45,6 +45,9 @@ enum {
>      VIRT_RTC,
>      VIRT_FW_CFG,
>      VIRT_PCIE,
> +    VIRT_PCIE_MMIO,
> +    VIRT_PCIE_PIO,
> +    VIRT_PCIE_ECAM,
>  };

We could probably do with some comments with the enum as to what the
different types of VIRT_PCIE* are. I can guess at MMIO and PIO but
without being overly familiar with PCIe what is ECAM?

And this patch removes the VIRT_PCIE regions to replace with
MMIO/PIO/EMAC regions but we still have a VIRT_PCIE irq. I think this implies
the the MMIO/PIO/ECAM regions are just sub-regions of the device which
has the one IRQ but a decent comment making this explicit would help
understanding (especially for someone not super familiar with the PCIe
spec ;-)

Cheers,

-- 
Alex Bennée

  reply	other threads:[~2015-05-27  8:17 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25  2:54 [Qemu-devel] [PATCH v9 00/24] Generate ACPI v5.1 tables and expose them to guest over fw_cfg on ARM Shannon Zhao
2015-05-25  2:54 ` [Qemu-devel] [PATCH v9 01/24] hw/acpi/aml-build: Make enum values to be upper case to match coding style Shannon Zhao
2015-05-25  2:54 ` [Qemu-devel] [PATCH v9 02/24] hw/arm/virt: Move common definitions to virt.h Shannon Zhao
2015-05-27  8:07   ` Alex Bennée
2015-05-25  2:54 ` [Qemu-devel] [PATCH v9 03/24] hw/arm/virt: Record PCIe ranges in MemMapEntry array Shannon Zhao
2015-05-27  8:17   ` Alex Bennée [this message]
2015-05-27  8:43     ` Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 04/24] hw/arm/virt-acpi-build: Basic framework for building ACPI tables on ARM Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 05/24] hw/acpi/aml-build: Add aml_memory32_fixed() term Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 06/24] hw/acpi/aml-build: Add aml_interrupt() term Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 07/24] hw/arm/virt-acpi-build: Generation of DSDT table for virt devices Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 08/24] hw/arm/virt-acpi-build: Generate FADT table and update ACPI headers Shannon Zhao
2015-05-27  8:25   ` Alex Bennée
2015-05-27  8:36     ` Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 09/24] hw/arm/virt-acpi-build: Generate MADT table Shannon Zhao
2015-05-26 16:00   ` Igor Mammedov
2015-05-27  6:18     ` Shannon Zhao
2015-05-27  9:34       ` Igor Mammedov
2015-05-27 11:10         ` Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 10/24] hw/arm/virt-acpi-build: Generate GTDT table Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 11/24] hw/arm/virt-acpi-build: Generate RSDT table Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 12/24] hw/arm/virt-acpi-build: Generate RSDP table Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 13/24] hw/arm/virt-acpi-build: Generate MCFG table Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 14/24] hw/acpi/aml-build: Make aml_buffer() definition consistent with the spec Shannon Zhao
2015-05-27 10:09   ` Michael S. Tsirkin
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 15/24] hw/acpi/aml-build: Add ToUUID macro Shannon Zhao
2015-05-27 10:09   ` Michael S. Tsirkin
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 16/24] hw/acpi/aml-build: Add aml_or() term Shannon Zhao
2015-05-27 10:09   ` Michael S. Tsirkin
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 17/24] hw/acpi/aml-build: Add aml_lnot() term Shannon Zhao
2015-05-27 10:10   ` Michael S. Tsirkin
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 18/24] hw/acpi/aml-build: Add aml_else() term Shannon Zhao
2015-05-27 10:10   ` Michael S. Tsirkin
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 19/24] hw/acpi/aml-build: Add aml_create_dword_field() term Shannon Zhao
2015-05-27 10:10   ` Michael S. Tsirkin
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 20/24] hw/acpi/aml-build: Add aml_dword_io() term Shannon Zhao
2015-05-27 10:10   ` Michael S. Tsirkin
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 21/24] hw/acpi/aml-build: Add Unicode macro Shannon Zhao
2015-05-27 10:11   ` Michael S. Tsirkin
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 22/24] hw/arm/virt-acpi-build: Add PCIe controller in ACPI DSDT table Shannon Zhao
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 23/24] ACPI: split CONFIG_ACPI into 4 pieces Shannon Zhao
2015-05-27  8:37   ` Alex Bennée
2015-05-25  2:55 ` [Qemu-devel] [PATCH v9 24/24] hw/arm/virt: Enable dynamic generation of ACPI v5.1 tables Shannon Zhao
2015-05-27  9:43 ` [Qemu-devel] [PATCH v9 00/24] Generate ACPI v5.1 tables and expose them to guest over fw_cfg on ARM Igor Mammedov
2015-05-27 10:16   ` Michael S. Tsirkin
2015-05-27 11:58     ` Peter Maydell
2015-05-27 12:01       ` Michael S. Tsirkin
2015-05-27 12:07         ` Peter Maydell
2015-05-27 14:07           ` Michael S. Tsirkin
2015-05-28 14:46             ` 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=87y4kaph7v.fsf@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=a.spyridakis@virtualopensystems.com \
    --cc=christoffer.dall@linaro.org \
    --cc=claudio.fontana@huawei.com \
    --cc=hangaohuai@huawei.com \
    --cc=hanjun.guo@linaro.org \
    --cc=imammedo@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shannon.zhao@linaro.org \
    --cc=zhaoshenglong@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).