All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Joel Stanley <joel@jms.id.au>,
	 Alistair Francis <alistair.francis@wdc.com>,
	Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>,
	 Michael Ellerman <mpe@kernel.org>,
	Joel Stanley <jms@oss.tenstorrent.com>,
	 Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>,
	qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v3 10/13] hw/riscv/atlantis: Add PCIe controller
Date: Tue, 21 Apr 2026 19:10:31 +1000	[thread overview]
Message-ID: <aeceurHJHEa_HgvZ@lima-default> (raw)
In-Reply-To: <d133505a-8a81-458d-a0f0-8b17ff5c0eab@linaro.org>

On Tue, Apr 21, 2026 at 07:59:32AM +0200, Philippe Mathieu-Daudé wrote:
> On 21/4/26 07:31, Joel Stanley wrote:
> > From: Nicholas Piggin <npiggin@gmail.com>
> > 
> > tt-atlantis is likely to use a generic ECAM compatible PCIe memory map,
> > so gpex is not far off the OS programming model
> > 
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > Signed-off-by: Joel Stanley <joel@jms.id.au>
> > ---
> > v3: Avoid leaks in the dt string allocation
> > ---
> >   include/hw/riscv/tt_atlantis.h |   2 +
> >   hw/riscv/tt_atlantis.c         | 225 ++++++++++++++++++++++++++++++++-
> >   hw/riscv/Kconfig               |   2 +
> >   3 files changed, 228 insertions(+), 1 deletion(-)
> 
> 
> > +static void create_fdt_pcie(void *fdt,
> > +                            const MemMapEntry *mem_ecam,
> > +                            const MemMapEntry *mem_pio,
> > +                            const MemMapEntry *mem_mmio32,
> > +                            const MemMapEntry *mem_mmio64,
> > +                            int legacy_irq,
> > +                            uint32_t aplic_s_phandle,
> > +                            uint32_t imsic_s_phandle)
> > +{
> > +    g_autofree char *name = g_strdup_printf("/soc/pci@%"HWADDR_PRIX,
> > +                                            mem_ecam->base);
> > +
> > +    qemu_fdt_setprop_cell(fdt, name, "#address-cells", FDT_PCI_ADDR_CELLS);
> > +    qemu_fdt_setprop_cell(fdt, name, "#interrupt-cells", FDT_PCI_INT_CELLS);
> > +    qemu_fdt_setprop_cell(fdt, name, "#size-cells", 0x2);
> > +    qemu_fdt_setprop_string(fdt, name, "compatible", "pci-host-ecam-generic");
> > +    qemu_fdt_setprop_string(fdt, name, "device_type", "pci");
> > +    qemu_fdt_setprop_cells(fdt, name, "bus-range", 0,
> > +                           mem_ecam->size / PCIE_MMCFG_SIZE_MIN - 1);
> > +    qemu_fdt_setprop(fdt, name, "dma-coherent", NULL, 0);
> > +    qemu_fdt_setprop_cell(fdt, name, "msi-parent", imsic_s_phandle);
> > +
> > +    qemu_fdt_setprop_sized_cells(fdt, name, "reg",
> > +                                 2, mem_ecam->base,
> > +                                 2, mem_ecam->size);
> > +    if (!(mem_mmio32->base & 0xffffffffUL)) {
> > +        /* XXX: this is a silly hack because it would collide with PIO */
> 
> Could you explain a bit more?

Ah this is a bit incomplete sorry I didn't catch it earlier. Before the
mapping was finalised I just added this hacky way to determining PCIe IO
address based on the physical address.

This should just go away and the IO addresses come from a different table.

> 
> > +        error_report("mmio32 base must not be 0 mod 2^32");
> > +        exit(1);
> > +    }
> > +    uint32_t flags = FDT_PCI_RANGE_MMIO_64BIT | FDT_PCI_RANGE_PREFETCHABLE;
> > +    qemu_fdt_setprop_sized_cells(fdt, name, "ranges",
> > +                                 1, FDT_PCI_RANGE_IOPORT,
> > +                                 2, 0x0,
> > +                                 2, mem_pio->base,
> > +                                 2, mem_pio->size,
> > +                                 1, FDT_PCI_RANGE_MMIO,
> > +                                 2, (mem_mmio32->base & 0xffffffffUL),
> > +                                 2, mem_mmio32->base,
> > +                                 2, mem_mmio32->size,
> > +                                 1, flags,
> > +                                 2, mem_mmio64->base,
> > +                                 2, mem_mmio64->base,
> > +                                 2, mem_mmio64->size);
> > +
> > +    create_pcie_irq_map(fdt, name, legacy_irq, aplic_s_phandle);
> > +}
> 
> 
> > diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
> > index 0601ae1a7494..2ddee591eb90 100644
> > --- a/hw/riscv/Kconfig
> > +++ b/hw/riscv/Kconfig
> > @@ -129,6 +129,8 @@ config TENSTORRENT
> >       select DEVICE_TREE
> >       select RISCV_NUMA
> >       select PVPANIC_MMIO
> > +    select PCI
> 
> Do not select PCI explicitly, let the bridge (below) do it.
> Rationale is this machine does not expose a PCI bus directly,
> the bridge device does.

Good to know, thank you.

Thanks,
Nick


  reply	other threads:[~2026-04-21  9:11 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21  5:31 [PATCH v3 00/13] hw/riscv: Add the Tenstorrent Atlantis machine Joel Stanley
2026-04-21  5:31 ` [PATCH v3 01/13] hw/i2c: Add designware i2c controller Joel Stanley
2026-04-21  5:31 ` [PATCH v3 02/13] hw/riscv/boot: Describe discontiguous memory in boot_info Joel Stanley
2026-04-22  0:04   ` Alistair Francis
2026-04-21  5:31 ` [PATCH v3 03/13] hw/riscv/boot: Account for discontiguous memory when loading firmware Joel Stanley
2026-04-21  5:47   ` Philippe Mathieu-Daudé
2026-04-23  1:58     ` Joel Stanley
2026-04-21  5:31 ` [PATCH v3 04/13] hw/riscv/boot: Provide a simple halting payload Joel Stanley
2026-04-21  5:48   ` Philippe Mathieu-Daudé
2026-04-23  2:04     ` Joel Stanley
2026-04-23  8:29       ` Philippe Mathieu-Daudé
2026-04-21  5:31 ` [PATCH v3 05/13] hw/riscv/virt: Move AIA initialisation to helper file Joel Stanley
2026-04-21  6:11   ` Philippe Mathieu-Daudé
2026-04-21  5:31 ` [PATCH v3 06/13] hw/riscv/aia: Provide number of irq sources Joel Stanley
2026-04-21  5:49   ` Philippe Mathieu-Daudé
2026-04-21  5:31 ` [PATCH v3 07/13] target/riscv: tt-ascalon: Enable Zkr extension Joel Stanley
2026-04-22  8:24   ` Chao Liu
2026-04-21  5:31 ` [PATCH v3 08/13] target/riscv: tt-ascalon: Add Svadu extension Joel Stanley
2026-04-21  5:31 ` [PATCH v3 09/13] hw/riscv: Add Tenstorrent Atlantis machine Joel Stanley
2026-04-21  5:52   ` Philippe Mathieu-Daudé
2026-04-22  9:12   ` Chao Liu
2026-04-21  5:31 ` [PATCH v3 10/13] hw/riscv/atlantis: Add PCIe controller Joel Stanley
2026-04-21  5:59   ` Philippe Mathieu-Daudé
2026-04-21  9:10     ` Nicholas Piggin [this message]
2026-04-21 12:59       ` Philippe Mathieu-Daudé
2026-04-21  5:31 ` [PATCH v3 11/13] tests/functional/riscv64: Add tt-atlantis tests Joel Stanley
2026-04-21  6:05   ` Philippe Mathieu-Daudé
2026-04-21  9:45     ` Nicholas Piggin
2026-04-21 15:35       ` Philippe Mathieu-Daudé
2026-04-23  2:25         ` Joel Stanley
2026-04-21  5:31 ` [PATCH v3 12/13] hw/riscv/atlantis: Integrate i2c buses Joel Stanley
2026-04-21  6:07   ` Philippe Mathieu-Daudé
2026-04-21  5:31 ` [PATCH v3 13/13] hw/riscv/atlantis: Add some i2c peripherals Joel Stanley
2026-04-21  6:09   ` Philippe Mathieu-Daudé
2026-04-23  2:23     ` Joel Stanley

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=aeceurHJHEa_HgvZ@lima-default \
    --to=npiggin@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=asrinivasan@oss.tenstorrent.com \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=jms@oss.tenstorrent.com \
    --cc=joel@jms.id.au \
    --cc=mpe@kernel.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    /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.