hw/riscv: Add the Tenstorrent Atlantis machine
Subsystems (3)
cover hw/riscv: Add the Tenstorrent Atlantis machine
Introducing Tenstorrent Atlantis!
The Tenstorrent Atlantis platform is a collaboration between Tenstorrent and CoreLab Technology. It is based on the Atlantis SoC, which includes the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology.
The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant RISC-V CPU.
This initial series adds the base machine support including:
- AIA (Advanced Interrupt Architecture) support
- PCIe controller and DesignWare I2C integration
- Serial console and device tree generation
- Functional tests for OpenSBI+Linux boot
Changes outside of adding the machine:
- Atlantis maps DRAM high in the address space but maintains an alias for the first 2GB at 0x0. We have updated the RISC-V boot loader code to support boot_info for discontiguous memory layouts.
- The riscv64 virt machine AIA initialisation has been moved to a helper file to allow code reuse with the Atlantis machine
- Revived the DesignWare I2C controller model (previously proposed for ARM virt) with permission from the original author.
I hope to get early feedback on the base machine now. We intend to continue modelling the soc so it can be useful for firmware and operating system development and testing, so expect more patches to do that soon.
Chris Rauer (1):
hw/i2c: Add designware i2c controller
Joel Stanley (6):
target/riscv: tt-ascalon: Add Tenstorrent mvendorid hw/riscv: Move AIA initialisation to helper file hw/riscv/aia: Provide number of irq sources hw/riscv: Add Tenstorrent Atlantis machine hw/riscv/atlantis: Integrate i2c buses hw/riscv/atlantis: Add some i2c peripherals
Nicholas Piggin (9):
target/riscv: tt-ascalon: Enable Zkr extension target/riscv: tt-ascalon: Add Svadu extension riscv/boot: Describe discontiguous memory in boot_info riscv/boot: Account for discontiguous memory when loading firmware hw/riscv/atlantis: Add PCIe controller tests/functional/riscv64: Add tt-atlantis tests hw/riscv/boot: Warn if a ELF format file is loaded as a binary hw/riscv/boot: Provide a simple halting payload hw/riscv/atlantis: Use halting kernel if there is no payload
MAINTAINERS | 15 + docs/system/riscv/tt_atlantis.rst | 38 + docs/system/target-riscv.rst | 1 + hw/riscv/aia.h | 59 ++ include/hw/i2c/designware_i2c.h | 101 ++ include/hw/riscv/boot.h | 14 +- include/hw/riscv/tt_atlantis.h | 95 ++ include/hw/riscv/virt.h | 30 +- target/riscv/cpu_vendorid.h | 2 + hw/i2c/designware_i2c.c | 813 ++++++++++++++++ hw/riscv/aia.c | 89 ++ hw/riscv/boot.c | 73 +- hw/riscv/microchip_pfsoc.c | 6 +- hw/riscv/opentitan.c | 6 +- hw/riscv/shakti_c.c | 6 +- hw/riscv/sifive_u.c | 3 +- hw/riscv/spike.c | 6 +- hw/riscv/tt_atlantis.c | 917 +++++++++++++++++++ hw/riscv/virt-acpi-build.c | 24 +- hw/riscv/virt.c | 94 +- hw/riscv/xiangshan_kmh.c | 6 +- target/riscv/cpu.c | 4 +- hw/i2c/Kconfig | 4 + hw/i2c/meson.build | 1 + hw/riscv/Kconfig | 21 + hw/riscv/meson.build | 3 +- tests/functional/riscv64/meson.build | 1 + tests/functional/riscv64/test_opensbi.py | 4 + tests/functional/riscv64/test_tt_atlantis.py | 68 ++ 29 files changed, 2365 insertions(+), 139 deletions(-) create mode 100644 docs/system/riscv/tt_atlantis.rst create mode 100644 hw/riscv/aia.h create mode 100644 include/hw/i2c/designware_i2c.h create mode 100644 include/hw/riscv/tt_atlantis.h create mode 100644 hw/i2c/designware_i2c.c create mode 100644 hw/riscv/aia.c create mode 100644 hw/riscv/tt_atlantis.c create mode 100755 tests/functional/riscv64/test_tt_atlantis.py
Signature · 1 line
2.47.3
PATCH 1/16 target/riscv: tt-ascalon: Enable Zkr extension
From: Nicholas Piggin <[email protected]>
Ascalon supports Zkr and the SEED CSR.
--- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/riscv/cpu.c +1 -0
@@ -3169,6 +3169,7 @@ static const TypeInfo riscv_cpu_type_infos[] = { .cfg.ext_zba = true, .cfg.ext_zbb = true, .cfg.ext_zbs = true, + .cfg.ext_zkr = true, .cfg.ext_zkt = true, .cfg.ext_zvbb = true, .cfg.ext_zvbc = true,
Signature · 1 line
2.47.3
PATCH 2/16 target/riscv: tt-ascalon: Add Svadu extension
In reply to Joel StanleyFrom: Nicholas Piggin <[email protected]>
Ascalon supports Svadu (hardware A/D bit updates).
QEMU makes Svadu and Svade mutually exclusive, remove Svadu so Ascalon comes up with Svadu working.
--- target/riscv/cpu.c | 1 - 1 file changed, 1 deletion(-)
target/riscv/cpu.c +0 -1
@@ -3183,7 +3183,6 @@ static const TypeInfo riscv_cpu_type_infos[] = { .cfg.ext_ssaia = true, .cfg.ext_sscofpmf = true, .cfg.ext_sstc = true, - .cfg.ext_svade = true, .cfg.ext_svinval = true, .cfg.ext_svnapot = true, .cfg.ext_svpbmt = true,
Signature · 1 line
2.47.3
PATCH 3/16 target/riscv: tt-ascalon: Add Tenstorrent mvendorid
In reply to Joel StanleyJEP106 has two vendor IDs for Tenstorrent. We will use Bank 16, hex 0xa1:
((16 - 1) << 7) | (0xa1 & ~0x80) = 0x7a1
Add it to the Ascalon CPU definition as the mvendorid CSR.
--- target/riscv/cpu_vendorid.h | 2 ++ target/riscv/cpu.c | 2 ++ 2 files changed, 4 insertions(+)
target/riscv/cpu_vendorid.h +2 -0
@@ -7,4 +7,6 @@#define VEYRON_V1_MIMPID 0x111#define VEYRON_V1_MVENDORID 0x61f +#define TENSTORRENT_VENDOR_ID 0x7a1 +#endif /* TARGET_RISCV_CPU_VENDORID_H */
target/riscv/cpu.c +2 -0
@@ -3187,6 +3187,8 @@ static const TypeInfo riscv_cpu_type_infos[] = { .cfg.ext_svnapot = true, .cfg.ext_svpbmt = true, + .cfg.mvendorid = TENSTORRENT_VENDOR_ID, + .cfg.max_satp_mode = VM_1_10_SV57, ),
Signature · 1 line
2.47.3
PATCH 4/16 riscv/boot: Describe discontiguous memory in boot_info
In reply to Joel StanleyFrom: Nicholas Piggin <[email protected]>
Machines that have discontiguous memory may need to adjust where firmware and images are loaded at boot. Provide an interfaces for machines to describe a discontiguous low/high RAM scheme for this purpose.
--- include/hw/riscv/boot.h | 7 +++++++ hw/riscv/boot.c | 11 +++++++++++ 2 files changed, 18 insertions(+)
include/hw/riscv/boot.h +7 -0
@@ -28,6 +28,10 @@#define RISCV64_BIOS_BIN "opensbi-riscv64-generic-fw_dynamic.bin" typedef struct RISCVBootInfo { + /* First contiguous RAM region. If size is zero then assume entire RAM */ + hwaddr ram_low_start; + hwaddr ram_low_size; + ssize_t kernel_size; hwaddr image_low_addr; hwaddr image_high_addr;
@@ -43,6 +47,9 @@ bool riscv_is_32bit(RISCVHartArrayState *harts);char *riscv_plic_hart_config_string (int hart_count);void riscv_boot_info_init (RISCVBootInfo *info,RISCVHartArrayState *harts); +void riscv_boot_info_init_discontig_mem (RISCVBootInfo *info, +RISCVHartArrayState *harts, +hwaddr start,hwaddr size);hwaddr riscv_calc_kernel_start_addr (RISCVBootInfo *info,hwaddr firmware_end_addr); hwaddr riscv_find_and_load_firmware(MachineState *machine,
hw/riscv/boot.c +11 -0
@@ -69,11 +69,22 @@ char *riscv_plic_hart_config_string(int hart_count)void riscv_boot_info_init (RISCVBootInfo *info,RISCVHartArrayState *harts) { + info->ram_low_start =0 ; + info->ram_low_size =0 ; info->kernel_size =0 ; info->initrd_size =0 ; info->is_32bit =riscv_is_32bit (harts); } +void riscv_boot_info_init_discontig_mem (RISCVBootInfo *info, +RISCVHartArrayState *harts, +hwaddr start,hwaddr size) +{ +riscv_boot_info_init (info, harts); + info->ram_low_start = start; + info->ram_low_size = size; +} +hwaddr riscv_calc_kernel_start_addr (RISCVBootInfo *info,hwaddr firmware_end_addr) {if (info->is_32bit) {
Signature · 1 line
2.47.3
PATCH 5/16 riscv/boot: Account for discontiguous memory when loading firmware
In reply to Joel StanleyFrom: Nicholas Piggin <[email protected]>
This loads firmware into the first (low) memory range, accounting for machines having discontiguous memory regions.
--- include/hw/riscv/boot.h | 5 ++++- hw/riscv/boot.c | 18 ++++++++++++------ hw/riscv/microchip_pfsoc.c | 6 ++++-- hw/riscv/opentitan.c | 6 ++++-- hw/riscv/shakti_c.c | 6 +++++- hw/riscv/sifive_u.c | 3 ++- hw/riscv/spike.c | 6 ++++-- hw/riscv/virt.c | 7 ++++--- hw/riscv/xiangshan_kmh.c | 6 +++++- 9 files changed, 44 insertions(+), 19 deletions(-)
include/hw/riscv/boot.h +4 -1
@@ -53,13 +53,16 @@ void riscv_boot_info_init_discontig_mem(RISCVBootInfo *info,hwaddr riscv_calc_kernel_start_addr (RISCVBootInfo *info,hwaddr firmware_end_addr);hwaddr riscv_find_and_load_firmware (MachineState *machine, +RISCVBootInfo *info,const char *default_machine_firmware,hwaddr *firmware_load_addr,symbol_fn_t sym_cb);const char *riscv_default_firmware_name (RISCVHartArrayState *harts);char *riscv_find_firmware (const char *firmware_filename,const char *default_machine_firmware); -hwaddr riscv_load_firmware (const char *firmware_filename, +hwaddr riscv_load_firmware (MachineState *machine, +RISCVBootInfo *info, +const char *firmware_filename,hwaddr *firmware_load_addr,symbol_fn_t sym_cb); void riscv_load_kernel(MachineState *machine,
hw/riscv/boot.c +12 -6
@@ -145,6 +145,7 @@ char *riscv_find_firmware(const char *firmware_filename, }hwaddr riscv_find_and_load_firmware (MachineState *machine, +RISCVBootInfo *info,const char *default_machine_firmware,hwaddr *firmware_load_addr,symbol_fn_t sym_cb)
@@ -157,7 +158,8 @@ hwaddr riscv_find_and_load_firmware(MachineState *machine,if (firmware_filename) {/* If not "none" load the firmware */ - firmware_end_addr =riscv_load_firmware (firmware_filename, + firmware_end_addr =riscv_load_firmware (machine, info, + firmware_filename, firmware_load_addr, sym_cb);g_free (firmware_filename); }
@@ -165,10 +167,13 @@ hwaddr riscv_find_and_load_firmware(MachineState *machine,return firmware_end_addr; } -hwaddr riscv_load_firmware (const char *firmware_filename, +hwaddr riscv_load_firmware (MachineState *machine, +RISCVBootInfo *info, +const char *firmware_filename,hwaddr *firmware_load_addr,symbol_fn_t sym_cb) { +uint64_t mem_size = info->ram_low_size ?: machine->ram_size;uint64_t firmware_entry, firmware_end;ssize_t firmware_size;
@@ -183,7 +188,7 @@ hwaddr riscv_load_firmware(const char *firmware_filename, firmware_size =load_image_targphys_as (firmware_filename, *firmware_load_addr, - current_machine->ram_size,NULL , + mem_size,NULL ,NULL );if (firmware_size >0 ) {
@@ -197,7 +202,7 @@ hwaddr riscv_load_firmware(const char *firmware_filename,static void riscv_load_initrd (MachineState *machine,RISCVBootInfo *info) {const char *filename = machine->initrd_filename; -uint64_t mem_size = machine->ram_size; +uint64_t mem_size = info->ram_low_size ?: machine->ram_size;void *fdt = machine->fdt;hwaddr start, end;ssize_t size;
@@ -243,6 +248,7 @@ void riscv_load_kernel(MachineState *machine,bool load_initrd, symbol_fn_t sym_cb) { + uint64_t mem_size = info->ram_low_size ?: machine->ram_size;const char *kernel_filename = machine->kernel_filename;ssize_t kernel_size;void *fdt = machine->fdt;
@@ -274,7 +280,7 @@ void riscv_load_kernel(MachineState *machine, } kernel_size =load_image_targphys_as (kernel_filename, kernel_start_addr, - current_machine->ram_size,NULL ,NULL ); + mem_size,NULL ,NULL );if (kernel_size >0 ) { info->kernel_size = kernel_size; info->image_low_addr = kernel_start_addr;
@@ -370,7 +376,7 @@ uint64_t riscv_compute_fdt_addr(hwaddr dram_base, hwaddr dram_size, dtb_start =QEMU_ALIGN_DOWN (temp - fdtsize,2 * MiB);if (dtb_start_limit && (dtb_start < dtb_start_limit)) { -error_report ("No enough memory to place DTB after kernel/initrd" ); +error_report ("Not enough memory to place DTB after kernel/initrd" );exit (1 ); }
hw/riscv/microchip_pfsoc.c +4 -2
@@ -614,18 +614,20 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) firmware_load_addr =RESET_VECTOR ; } +riscv_boot_info_init (&boot_info, &s->soc.u_cpus); +/* Load the firmware if necessary */ firmware_end_addr = firmware_load_addr;if (firmware_name) {char *filename =riscv_find_firmware (firmware_name,NULL );if (filename) { - firmware_end_addr =riscv_load_firmware (filename, + firmware_end_addr =riscv_load_firmware (machine, &boot_info, + filename, &firmware_load_addr,NULL );g_free (filename); } } -riscv_boot_info_init (&boot_info, &s->soc.u_cpus);if (machine->kernel_filename) { kernel_start_addr =riscv_calc_kernel_start_addr (&boot_info, firmware_end_addr);
hw/riscv/opentitan.c +4 -2
@@ -99,12 +99,14 @@ static void opentitan_machine_init(MachineState *machine)memory_region_add_subregion (sys_mem, memmap[IBEX_DEV_RAM ].base, machine->ram); +riscv_boot_info_init (&boot_info, &s->soc.cpus); +if (machine->firmware) {hwaddr firmware_load_addr = memmap[IBEX_DEV_RAM ].base; -riscv_load_firmware (machine->firmware, &firmware_load_addr,NULL ); +riscv_load_firmware (machine, &boot_info, machine->firmware, + &firmware_load_addr,NULL ); } -riscv_boot_info_init (&boot_info, &s->soc.cpus);if (machine->kernel_filename) { riscv_load_kernel(machine, &boot_info, memmap[IBEX_DEV_RAM].base,
hw/riscv/shakti_c.c +5 -1
@@ -45,6 +45,7 @@ static void shakti_c_machine_state_init(MachineState *mstate) {ShaktiCMachineState *sms =RISCV_SHAKTI_MACHINE (mstate);MemoryRegion *system_memory =get_system_memory (); +RISCVBootInfo boot_info;hwaddr firmware_load_addr = shakti_c_memmap[SHAKTI_C_RAM ].base;/* Initialize SoC */
@@ -57,8 +58,11 @@ static void shakti_c_machine_state_init(MachineState *mstate) shakti_c_memmap[SHAKTI_C_RAM ].base, mstate->ram); +riscv_boot_info_init (&boot_info, &sms->soc.cpus); +if (mstate->firmware) { -riscv_load_firmware (mstate->firmware, &firmware_load_addr,NULL ); +riscv_load_firmware (mstate, &boot_info, mstate->firmware, + &firmware_load_addr,NULL ); }/* ROM reset vector */
hw/riscv/sifive_u.c +2 -1
@@ -589,7 +589,8 @@ static void sifive_u_machine_init(MachineState *machine) } firmware_name =riscv_default_firmware_name (&s->soc.u_cpus); - firmware_end_addr =riscv_find_and_load_firmware (machine, firmware_name, + firmware_end_addr =riscv_find_and_load_firmware (machine, &boot_info, + firmware_name, &start_addr,NULL );riscv_boot_info_init (&boot_info, &s->soc.u_cpus);
hw/riscv/spike.c +4 -2
@@ -289,9 +289,12 @@ static void spike_board_init(MachineState *machine) } } +riscv_boot_info_init (&boot_info, &s->soc[0 ]); +/* Load firmware */ if (firmware_name) { - firmware_end_addr =riscv_load_firmware (firmware_name, + firmware_end_addr =riscv_load_firmware (machine, &boot_info, + firmware_name, &firmware_load_addr, htif_symbol_callback);g_free (firmware_name);
@@ -301,7 +304,6 @@ static void spike_board_init(MachineState *machine)create_fdt (s, memmap,riscv_is_32bit (&s->soc[0 ]), htif_custom_base);/* Load kernel */ -riscv_boot_info_init (&boot_info, &s->soc[0 ]);if (machine->kernel_filename) { kernel_start_addr =riscv_calc_kernel_start_addr (&boot_info, firmware_end_addr);
hw/riscv/virt.c +4 -3
@@ -1465,7 +1465,10 @@ static void virt_machine_done(Notifier *notifier, void *data) } } - firmware_end_addr =riscv_find_and_load_firmware (machine, firmware_name, +riscv_boot_info_init (&boot_info, &s->soc[0 ]); + + firmware_end_addr =riscv_find_and_load_firmware (machine, &boot_info, + firmware_name, &start_addr,NULL ); pflash_blk0 =pflash_cfi01_get_blk (s->flash[0 ]);
@@ -1488,8 +1491,6 @@ static void virt_machine_done(Notifier *notifier, void *data) } } -riscv_boot_info_init (&boot_info, &s->soc[0 ]); -if (machine->kernel_filename && !kernel_entry) { kernel_start_addr =riscv_calc_kernel_start_addr (&boot_info, firmware_end_addr);
hw/riscv/xiangshan_kmh.c +5 -1
@@ -166,6 +166,7 @@ static void xiangshan_kmh_machine_init(MachineState *machine)const MemMapEntry *memmap = xiangshan_kmh_memmap;MemoryRegion *system_memory =get_system_memory ();hwaddr start_addr = memmap[XIANGSHAN_KMH_DRAM ].base; +RISCVBootInfo boot_info;/* Initialize SoC */ object_initialize_child(OBJECT(machine), "soc", &s->soc,
@@ -177,13 +178,16 @@ static void xiangshan_kmh_machine_init(MachineState *machine) memmap[XIANGSHAN_KMH_DRAM ].base, machine->ram); +riscv_boot_info_init (&boot_info, &s->soc.cpus); +/* ROM reset vector */ riscv_setup_rom_reset_vec (machine, &s->soc.cpus, start_addr, memmap[XIANGSHAN_KMH_ROM ].base, memmap[XIANGSHAN_KMH_ROM ].size,0 ,0 );if (machine->firmware) { -riscv_load_firmware (machine->firmware, &start_addr,NULL ); +riscv_load_firmware (machine, &boot_info, machine->firmware, + &start_addr,NULL ); }/* Note: dtb has been integrated into firmware(OpenSBI) when compiling */
Signature · 1 line
2.47.3
PATCH 6/16 hw/riscv: Move AIA initialisation to helper file
In reply to Joel StanleyThe AIA init will be used by any server class riscv machine. Separate it out in order to share code with such systems.
--- hw/riscv/aia.h | 58 +++++++++++++++++++++++++ include/hw/riscv/virt.h | 29 ------------- hw/riscv/aia.c | 88 ++++++++++++++++++++++++++++++++++++++ hw/riscv/virt-acpi-build.c | 2 + hw/riscv/virt.c | 85 ++++-------------------------------- hw/riscv/meson.build | 2 +- 6 files changed, 158 insertions(+), 106 deletions(-) create mode 100644 hw/riscv/aia.h create mode 100644 hw/riscv/aia.c
hw/riscv/aia.h new file +58 -0
@@ -0,0 +1,58 @@ +/* +* QEMU RISC-V Advanced Interrupt Architecture (AIA) +* +* Copyright (C) 2019 Western Digital Corporation or its affiliates. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_RISCV_AIA_H +#define HW_RISCV_AIA_H + +#include "exec/hwaddr.h" + +/* +* The virt machine physical address space used by some of the devices +* namely ACLINT, PLIC, APLIC, and IMSIC depend on number of Sockets, +* number of CPUs, and number of IMSIC guest files. +* +* Various limits defined by VIRT_SOCKETS_MAX_BITS, VIRT_CPUS_MAX_BITS, +* and VIRT_IRQCHIP_MAX_GUESTS_BITS are tuned for maximum utilization +* of virt machine physical address space. +*/ + +#define VIRT_SOCKETS_MAX_BITS 2 +#define VIRT_CPUS_MAX_BITS 9 +#define VIRT_CPUS_MAX (1 << VIRT_CPUS_MAX_BITS) +#define VIRT_SOCKETS_MAX (1 << VIRT_SOCKETS_MAX_BITS) + +#define VIRT_IRQCHIP_NUM_MSIS 255 +#define VIRT_IRQCHIP_NUM_SOURCES 96 +#define VIRT_IRQCHIP_NUM_PRIO_BITS 3 +#define VIRT_IRQCHIP_MAX_GUESTS_BITS 3 +#define VIRT_IRQCHIP_MAX_GUESTS ((1U << VIRT_IRQCHIP_MAX_GUESTS_BITS) - 1U) + + +#define VIRT_IMSIC_GROUP_MAX_SIZE (1U << IMSIC_MMIO_GROUP_MIN_SHIFT) +#if VIRT_IMSIC_GROUP_MAX_SIZE < \ +IMSIC_GROUP_SIZE (VIRT_CPUS_MAX_BITS ,VIRT_IRQCHIP_MAX_GUESTS_BITS ) +#error "Can't accommodate single IMSIC group in address space" +#endif + +#define VIRT_IMSIC_MAX_SIZE (VIRT_SOCKETS_MAX * \ + VIRT_IMSIC_GROUP_MAX_SIZE) +#if 0x4000000 <VIRT_IMSIC_MAX_SIZE +#error "Can't accommodate all IMSIC groups in address space" +#endif + +uint32_t imsic_num_bits (uint32_t count); + +DeviceState *riscv_create_aia (bool msimode,int aia_guests, +const MemMapEntry *aplic_m, +const MemMapEntry *aplic_s, +const MemMapEntry *imsic_m, +const MemMapEntry *imsic_s, +int socket,int base_hartid,int hart_count); + + +#endif
include/hw/riscv/virt.h +0 -29
@@ -102,12 +102,6 @@ enum {#define VIRT_PLATFORM_BUS_NUM_IRQS 32 -#define VIRT_IRQCHIP_NUM_MSIS 255 -#define VIRT_IRQCHIP_NUM_SOURCES 96 -#define VIRT_IRQCHIP_NUM_PRIO_BITS 3 -#define VIRT_IRQCHIP_MAX_GUESTS_BITS 3 -#define VIRT_IRQCHIP_MAX_GUESTS ((1U << VIRT_IRQCHIP_MAX_GUESTS_BITS) - 1U) -#define VIRT_PLIC_PRIORITY_BASE 0x00#define VIRT_PLIC_PENDING_BASE 0x1000#define VIRT_PLIC_ENABLE_BASE 0x2000
@@ -135,28 +129,5 @@ enum {bool virt_is_acpi_enabled (RISCVVirtState *s);bool virt_is_iommu_sys_enabled (RISCVVirtState *s);void virt_acpi_setup (RISCVVirtState *vms); -uint32_t imsic_num_bits (uint32_t count); - -/* -* The virt machine physical address space used by some of the devices -* namely ACLINT, PLIC, APLIC, and IMSIC depend on number of Sockets, -* number of CPUs, and number of IMSIC guest files. -* -* Various limits defined by VIRT_SOCKETS_MAX_BITS, VIRT_CPUS_MAX_BITS, -* and VIRT_IRQCHIP_MAX_GUESTS_BITS are tuned for maximum utilization -* of virt machine physical address space. -*/ - -#define VIRT_IMSIC_GROUP_MAX_SIZE (1U << IMSIC_MMIO_GROUP_MIN_SHIFT) -#if VIRT_IMSIC_GROUP_MAX_SIZE < \ -IMSIC_GROUP_SIZE (VIRT_CPUS_MAX_BITS ,VIRT_IRQCHIP_MAX_GUESTS_BITS ) -#error "Can't accommodate single IMSIC group in address space" -#endif - -#define VIRT_IMSIC_MAX_SIZE (VIRT_SOCKETS_MAX * \ - VIRT_IMSIC_GROUP_MAX_SIZE) -#if 0x4000000 <VIRT_IMSIC_MAX_SIZE -#error "Can't accommodate all IMSIC groups in address space" -#endif #endif
hw/riscv/aia.c new file +88 -0
88 lines not on this page · raw message
hw/riscv/virt-acpi-build.c +2 -0
@@ -40,6 +40,8 @@#include "qemu/error-report.h" #include "system/reset.h" +#include "aia.h" +#define ACPI_BUILD_TABLE_SIZE 0x20000#define ACPI_BUILD_INTC_ID (socket, index) ((socket << 24) | (index))
hw/riscv/virt.c +9 -76
109 lines not on this page · raw message
hw/riscv/meson.build +1 -1
@@ -1,5 +1,5 @@ riscv_ss = ss.source_set() -riscv_ss.add(files('boot.c')) +riscv_ss.add(files('boot.c', 'aia.c')) riscv_ss.add(when: 'CONFIG_RISCV_NUMA', if_true: files('numa.c')) riscv_ss.add(files('riscv_hart.c')) riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c'))
Signature · 1 line
2.47.3
PATCH 7/16 hw/riscv/aia: Provide number of irq sources
In reply to Joel StanleyInstead of hard coding the number of IRQ sources used by the APLIC, pass it in as a parameter. This allows other machines to configure this as required.
--- hw/riscv/aia.h | 1 + include/hw/riscv/virt.h | 1 + hw/riscv/aia.c | 5 +++-- hw/riscv/virt-acpi-build.c | 22 +++++++++++++--------- hw/riscv/virt.c | 2 ++ 5 files changed, 20 insertions(+), 11 deletions(-)
hw/riscv/aia.h +1 -0
@@ -48,6 +48,7 @@uint32_t imsic_num_bits (uint32_t count); DeviceState *riscv_create_aia(bool msimode, int aia_guests, + uint16_t num_sources, const MemMapEntry *aplic_m, const MemMapEntry *aplic_s, const MemMapEntry *imsic_m,
include/hw/riscv/virt.h +1 -0
@@ -64,6 +64,7 @@ struct RISCVVirtState {struct GPEXHost *gpex_host;OnOffAuto iommu_sys;uint16_t pci_iommu_bdf; +uint16_t num_sources; };enum {
hw/riscv/aia.c +3 -2
@@ -25,6 +25,7 @@ uint32_t imsic_num_bits(uint32_t count) } DeviceState *riscv_create_aia(bool msimode, int aia_guests, + uint16_t num_sources, const MemMapEntry *aplic_m, const MemMapEntry *aplic_s, const MemMapEntry *imsic_m,
@@ -65,7 +66,7 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guests, aplic_m->size, (msimode) ?0 : base_hartid, (msimode) ?0 : hart_count, -VIRT_IRQCHIP_NUM_SOURCES , + num_sources,VIRT_IRQCHIP_NUM_PRIO_BITS , msimode, true, NULL); }
@@ -76,7 +77,7 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guests, aplic_s->size, (msimode) ?0 : base_hartid, (msimode) ?0 : hart_count, -VIRT_IRQCHIP_NUM_SOURCES , + num_sources,VIRT_IRQCHIP_NUM_PRIO_BITS , msimode, false, aplic_m_dev);
hw/riscv/virt-acpi-build.c +13 -9
@@ -144,6 +144,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s) }static void acpi_dsdt_add_plic_aplic (Aml *scope,uint8_t socket_count, +uint16_t num_sources,uint64_t mmio_base,uint64_t mmio_size,const char *hid) {
@@ -153,7 +154,7 @@ static void acpi_dsdt_add_plic_aplic(Aml *scope, uint8_t socket_count,for (socket =0 ; socket < socket_count; socket++) { plic_aplic_addr = mmio_base + mmio_size * socket; - gsi_base =VIRT_IRQCHIP_NUM_SOURCES * socket; + gsi_base = num_sources * socket;Aml *dev =aml_device ("IC%.02X" , socket);aml_append (dev,aml_name_decl ("_HID" ,aml_string ("%s" , hid)));aml_append (dev,aml_name_decl ("_UID" ,aml_int (socket)));
@@ -469,10 +470,13 @@ static void build_dsdt(GArray *table_data, socket_count =riscv_socket_count (ms);if (s->aia_type ==VIRT_AIA_TYPE_NONE ) { -acpi_dsdt_add_plic_aplic (scope, socket_count, memmap[VIRT_PLIC ].base, - memmap[VIRT_PLIC ].size,"RSCV0001" ); +acpi_dsdt_add_plic_aplic (scope, socket_count, s->num_sources, + memmap[VIRT_PLIC ].base, + memmap[VIRT_PLIC ].size, +"RSCV0001" ); }else { -acpi_dsdt_add_plic_aplic (scope, socket_count, memmap[VIRT_APLIC_S ].base, +acpi_dsdt_add_plic_aplic (scope, socket_count, s->num_sources, + memmap[VIRT_APLIC_S ].base, memmap[VIRT_APLIC_S ].size,"RSCV0002" ); }
@@ -489,15 +493,15 @@ static void build_dsdt(GArray *table_data, }else if (socket_count ==2 ) {virtio_acpi_dsdt_add (scope, memmap[VIRT_VIRTIO ].base, memmap[VIRT_VIRTIO ].size, -VIRTIO_IRQ +VIRT_IRQCHIP_NUM_SOURCES ,0 , +VIRTIO_IRQ + s->num_sources,0 ,VIRTIO_COUNT ); -acpi_dsdt_add_gpex_host (scope,PCIE_IRQ +VIRT_IRQCHIP_NUM_SOURCES ); +acpi_dsdt_add_gpex_host (scope,PCIE_IRQ + s->num_sources); }else {virtio_acpi_dsdt_add (scope, memmap[VIRT_VIRTIO ].base, memmap[VIRT_VIRTIO ].size, -VIRTIO_IRQ +VIRT_IRQCHIP_NUM_SOURCES ,0 , +VIRTIO_IRQ + s->num_sources,0 ,VIRTIO_COUNT ); -acpi_dsdt_add_gpex_host (scope,PCIE_IRQ +VIRT_IRQCHIP_NUM_SOURCES *2 ); +acpi_dsdt_add_gpex_host (scope,PCIE_IRQ + s->num_sources *2 ); }aml_append (dsdt, scope);
@@ -576,7 +580,7 @@ static void build_madt(GArray *table_data,for (socket =0 ; socket <riscv_socket_count (ms); socket++) { aplic_addr = s->memmap[VIRT_APLIC_S ].base + s->memmap[VIRT_APLIC_S ].size * socket; - gsi_base =VIRT_IRQCHIP_NUM_SOURCES * socket; + gsi_base = s->num_sources * socket;build_append_int_noprefix (table_data,0x1A ,1 );/* Type */ build_append_int_noprefix (table_data,36 ,1 );/* Length */ build_append_int_noprefix (table_data,1 ,1 );/* Version */
hw/riscv/virt.c +2 -0
@@ -1556,6 +1556,7 @@ static void virt_machine_init(MachineState *machine) }else { s->irqchip[i] = riscv_create_aia(s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC, s->aia_guests, + s->num_sources, &s->memmap[VIRT_APLIC_M], &s->memmap[VIRT_APLIC_S], &s->memmap[VIRT_IMSIC_M],
@@ -1690,6 +1691,7 @@ static void virt_machine_instance_init(Object *obj) s->oem_table_id =g_strndup (ACPI_BUILD_APPNAME8 ,8 ); s->acpi =ON_OFF_AUTO_AUTO ; s->iommu_sys =ON_OFF_AUTO_AUTO ; + s->num_sources =VIRT_IRQCHIP_NUM_SOURCES ; }static char *virt_get_aia_guests (Object *obj,Error **errp)
Signature · 1 line
2.47.3
PATCH 8/16 hw/riscv: Add Tenstorrent Atlantis machine
In reply to Joel StanleyThe Tenstorrent Atlantis platform is a collaboration between Tenstorrent and CoreLab Technology. It is based on the Atlantis SoC, which includes the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology.
The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant RISC-V CPU.
This adds the machine containing serial console, interrupt controllers and device tree support.
qemu-system-riscv64 -M tt-atlantis -m 512M \ -kernel Image -initrd rootfs.cpio -nographic
--- MAINTAINERS | 8 + docs/system/riscv/tt_atlantis.rst | 38 ++ docs/system/target-riscv.rst | 1 + include/hw/riscv/tt_atlantis.h | 81 ++++ hw/riscv/tt_atlantis.c | 643 ++++++++++++++++++++++++++++++ hw/riscv/Kconfig | 16 + hw/riscv/meson.build | 1 + 7 files changed, 788 insertions(+) create mode 100644 docs/system/riscv/tt_atlantis.rst create mode 100644 include/hw/riscv/tt_atlantis.h create mode 100644 hw/riscv/tt_atlantis.c
MAINTAINERS +8 -0
@@ -1724,6 +1724,14 @@ F: hw/*/*sifive*.c F: include/hw/*/*sifive*.h F: tests/functional/test_riscv64_sifive_u.py +Tenstorrent Machines +M: Joel Stanley <[email protected]> +L: [email protected] +S: Supported +F: docs/system/riscv/tt_*.rst +F: hw/riscv/tt_*.c +F: include/hw/riscv/tt_*.h + AMD Microblaze-V Generic Board M: Sai Pavan Boddu <[email protected]> S: Maintained
docs/system/riscv/tt_atlantis.rst new file +38 -0
@@ -0,0 +1,38 @@ +Tenstorrent Atlantis (``tt-atlantis``) +====================================== + +The Tenstorrent Atlantis platform is a collaboration between Tenstorrent +and CoreLab Technology. It is based on the Atlantis SoC, which includes +the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology. + +The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant +RISC-V CPU. + +Features +-------- + +* 8-core Ascalon-X CPU Cluster +* Dual x32 LPDDR5 @ 6400 MT/s +* RISC-V compliant Advanced Interrupt Architecture +* PCIe Gen4 +* RISC-V compliant IOMMU +* GPU and Video subsystem +* 2x USB3.1 & 2x USB2.0 +* 2x 1GbE Ethernet +* 2x eMMC5.1/SDIO3.0 storage +* Extensive connectivity (SPI, I2C, UART, GPIO, CANFD) + +Note: the QEMU tt-atlantis machine does not model the platform +exactly or all devices, but it is undergoing improvement. + +Supported software +------------------ + +The Tenstorrent Ascalon CPUs avoid proprietary or non-standard +extensions, so compatibility with existing software is generally +good. The QEMU tt-atlantis machine works with upstream OpenSBI +and Linux with default configurations. + +The development board hardware will require some implementation +specific setup in firmware which is being developed and may +become a requirement or option for the tt-atlantis machine.
docs/system/target-riscv.rst +1 -0
@@ -70,6 +70,7 @@ undocumented; you can get a complete list by running riscv/microchip-icicle-kit riscv/shakti-c riscv/sifive_u + riscv/tt_atlantis riscv/virt riscv/xiangshan-kunminghu
include/hw/riscv/tt_atlantis.h new file +81 -0
81 lines not on this page · raw message
hw/riscv/tt_atlantis.c new file +643 -0
643 lines not on this page · raw message
hw/riscv/Kconfig +16 -0
@@ -128,3 +128,19 @@ config XIANGSHAN_KUNMINGHU select RISCV_APLIC select RISCV_IMSIC select SERIAL_MM + +config TENSTORRENT + bool + default y + depends on RISCV64 + imply PCI_DEVICES + imply TEST_DEVICES + select DEVICE_TREE + select RISCV_NUMA + select PVPANIC_MMIO + select SERIAL_MM + select RISCV_ACLINT + select RISCV_APLIC + select RISCV_IMSIC + select FW_CFG_DMA + select PLATFORM_BUS
hw/riscv/meson.build +1 -0
@@ -9,6 +9,7 @@ riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c')) riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c')) riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c')) riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c')) +riscv_ss.add(when: 'CONFIG_TENSTORRENT', if_true: files('tt_atlantis.c')) riscv_ss.add(when: 'CONFIG_ACPI', if_true: files('virt-acpi-build.c')) riscv_ss.add(when: 'CONFIG_RISCV_IOMMU', if_true: files( 'riscv-iommu.c', 'riscv-iommu-pci.c', 'riscv-iommu-sys.c', 'riscv-iommu-hpm.c'))
Signature · 1 line
2.47.3
PATCH 9/16 hw/riscv/atlantis: Add PCIe controller
In reply to Joel StanleyFrom: Nicholas Piggin <[email protected]>
tt-atlantis is likely to use a generic ECAM compatible PCIe memory map, so gpex is not far off the OS programming model
--- include/hw/riscv/tt_atlantis.h | 5 + hw/riscv/tt_atlantis.c | 218 +++++++++++++++++++++++++++++++++ hw/riscv/Kconfig | 2 + 3 files changed, 225 insertions(+)
include/hw/riscv/tt_atlantis.h +5 -0
@@ -18,6 +18,8 @@#define TYPE_TT_ATLANTIS_MACHINE MACHINE_TYPE_NAME("tt-atlantis") OBJECT_DECLARE_SIMPLE_TYPE(TTAtlantisState, TT_ATLANTIS_MACHINE) +#define TT_ATL_NUM_I2C 4 +struct TTAtlantisState {/*< private >*/ MachineState parent;
@@ -30,6 +32,8 @@ struct TTAtlantisState {RISCVHartArrayState soc;DeviceState *irqchip; +GPEXHost gpex_host; +DesignWareI2CState i2c[TT_ATL_NUM_I2C ];int fdt_size;int aia_guests;/* TODO: This should be hard coded once known */
@@ -42,6 +46,7 @@ enum {TT_ATL_UART2_IRQ =40 ,TT_ATL_UART3_IRQ =41 ,TT_ATL_UART4_IRQ =42 , + TT_ATL_PCIE0_INTA_IRQ = 96, }; enum {
hw/riscv/tt_atlantis.c +218 -0
272 lines not on this page · raw message
hw/riscv/Kconfig +2 -0
@@ -138,6 +138,8 @@ config TENSTORRENT select DEVICE_TREE select RISCV_NUMA select PVPANIC_MMIO + select PCI + select PCI_EXPRESS_GENERIC_BRIDGE select SERIAL_MM select RISCV_ACLINT select RISCV_APLIC
Signature · 1 line
2.47.3
PATCH 10/16 tests/functional/riscv64: Add tt-atlantis tests
In reply to Joel StanleyFrom: Nicholas Piggin <[email protected]>
Add OpenSBI and Linux boot tests for the tt-atlantis machine.
--- MAINTAINERS | 1 + tests/functional/riscv64/meson.build | 1 + tests/functional/riscv64/test_opensbi.py | 4 ++ tests/functional/riscv64/test_tt_atlantis.py | 68 ++++++++++++++++++++ 4 files changed, 74 insertions(+) create mode 100755 tests/functional/riscv64/test_tt_atlantis.py
MAINTAINERS +1 -0
@@ -1731,6 +1731,7 @@ S: Supported F: docs/system/riscv/tt_*.rst F: hw/riscv/tt_*.c F: include/hw/riscv/tt_*.h +F: tests/functional/test_riscv64_tt_*.py AMD Microblaze-V Generic Board M: Sai Pavan Boddu <[email protected]>
tests/functional/riscv64/meson.build +1 -0
@@ -11,5 +11,6 @@ tests_riscv64_system_quick = [ tests_riscv64_system_thorough = [ 'sifive_u', + 'tt_atlantis', 'tuxrun', ]
tests/functional/riscv64/test_opensbi.py +4 -0
@@ -28,6 +28,10 @@ def test_riscv_sifive_u(self): self.set_machine('sifive_u') self.boot_opensbi() + def test_riscv_tt_atlantis(self): + self.set_machine('tt-atlantis') + self.boot_opensbi() + def test_riscv_virt(self): self.set_machine('virt') self.boot_opensbi()
tests/functional/riscv64/test_tt_atlantis.py new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.47.3
PATCH 11/16 hw/i2c: Add designware i2c controller
In reply to Joel StanleyFrom: Chris Rauer <[email protected]>
--- MAINTAINERS | 6 + include/hw/i2c/designware_i2c.h | 101 ++++ hw/i2c/designware_i2c.c | 813 ++++++++++++++++++++++++++++++++ hw/i2c/Kconfig | 4 + hw/i2c/meson.build | 1 + 5 files changed, 925 insertions(+) create mode 100644 include/hw/i2c/designware_i2c.h create mode 100644 hw/i2c/designware_i2c.c
MAINTAINERS +6 -0
@@ -2675,6 +2675,12 @@ S: Orphaned F: hw/gpio/pcf8574.c F: include/gpio/pcf8574.h +DesignWare I2C +M: Chris Rauer <[email protected]> +S: Maintained +F: hw/i2c/designware_i2c.c +F: include/hw/i2c/designware_i2c.h + Generic Loader M: Alistair Francis <[email protected]> S: Maintained
include/hw/i2c/designware_i2c.h new file +101 -0
101 lines not on this page · raw message
hw/i2c/designware_i2c.c new file +813 -0
813 lines not on this page · raw message
hw/i2c/Kconfig +4 -0
@@ -18,6 +18,10 @@ config ARM_SBCON_I2C bool select BITBANG_I2C +config DESIGNWARE_I2C + bool + select I2C + config ACPI_SMBUS bool select SMBUS
hw/i2c/meson.build +1 -0
@@ -11,6 +11,7 @@ i2c_ss.add(when: 'CONFIG_MPC_I2C', if_true: files('mpc_i2c.c')) i2c_ss.add(when: 'CONFIG_ALLWINNER_I2C', if_true: files('allwinner-i2c.c')) i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c')) i2c_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_smbus.c')) +i2c_ss.add(when: 'CONFIG_DESIGNWARE_I2C', if_true: files('designware_i2c.c')) i2c_ss.add(when: 'CONFIG_SMBUS_EEPROM', if_true: files('smbus_eeprom.c')) i2c_ss.add(when: 'CONFIG_ARM_SBCON_I2C', if_true: files('arm_sbcon_i2c.c')) i2c_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_i2c.c'))
Signature · 1 line
2.47.3
PATCH 12/16 hw/riscv/atlantis: Integrate i2c buses
In reply to Joel StanleyNow that we have the DesignWare model we can add buses to the tt-atlantis machine.
--- include/hw/riscv/tt_atlantis.h | 9 ++++++++ hw/riscv/tt_atlantis.c | 38 ++++++++++++++++++++++++++++++++++ hw/riscv/Kconfig | 1 + 3 files changed, 48 insertions(+)
include/hw/riscv/tt_atlantis.h +9 -0
@@ -14,6 +14,7 @@#include "hw/sysbus.h" #include "hw/block/flash.h" #include "hw/intc/riscv_imsic.h" +#include "hw/i2c/designware_i2c.h" #define TYPE_TT_ATLANTIS_MACHINE MACHINE_TYPE_NAME("tt-atlantis")OBJECT_DECLARE_SIMPLE_TYPE (TTAtlantisState,TT_ATLANTIS_MACHINE )
@@ -41,6 +42,11 @@ struct TTAtlantisState {enum {TT_ATL_SYSCON_IRQ =10 , +TT_ATL_I2C0_IRQ =33 , +TT_ATL_I2C1_IRQ =34 , +TT_ATL_I2C2_IRQ =35 , +TT_ATL_I2C3_IRQ =36 , +TT_ATL_I2C4_IRQ =37 ,TT_ATL_UART0_IRQ =38 ,TT_ATL_UART1_IRQ =39 ,TT_ATL_UART2_IRQ =40 ,
@@ -56,6 +62,9 @@ enum {TT_ATL_DDR_HI ,TT_ATL_FW_CFG ,TT_ATL_I2C0 , +TT_ATL_I2C1 , +TT_ATL_I2C2 , +TT_ATL_I2C3 ,TT_ATL_MAPLIC ,TT_ATL_MIMSIC , TT_ATL_PCIE_ECAM0,
hw/riscv/tt_atlantis.c +38 -0
@@ -69,6 +69,10 @@ static const MemMapEntry tt_atlantis_memmap[] = { [TT_ATL_WDT0] = { 0xa8030000, 0x10000 }, [TT_ATL_PCI_MMU_CFG] = { 0xaa000000, 0x100000 }, [TT_ATL_UART0] = { 0xb0100000, 0x10000 }, + [TT_ATL_I2C0] = { 0xb0400000, 0x10000 }, + [TT_ATL_I2C1] = { 0xb0500000, 0x10000 }, + [TT_ATL_I2C2] = { 0xb0600000, 0x10000 }, + [TT_ATL_I2C3] = { 0xb0700000, 0x10000 }, [TT_ATL_MAPLIC] = { 0xcc000000, 0x4000000 }, [TT_ATL_SAPLIC] = { 0xe8000000, 0x4000000 }, [TT_ATL_DDR_HI] = { 0x100000000, 0x1000000000 },
@@ -480,6 +484,20 @@ static void create_fdt_fw_cfg(void *fdt, const MemMapEntry *mem)qemu_fdt_setprop (fdt, name,"dma-coherent" ,NULL ,0 ); } +static void create_fdt_i2c (void *fdt,const MemMapEntry *mem,uint32_t irq, +int irqchip_phandle) +{ + g_autofree char *name = g_strdup_printf("/soc/i2c@%" PRIx64, mem->base); + +qemu_fdt_add_subnode (fdt, name); +qemu_fdt_setprop_string (fdt, name,"compatible" ,"snps,designware-i2c" ); +qemu_fdt_setprop_sized_cells (fdt, name,"reg" ,2 , mem->base,2 , mem->size); +qemu_fdt_setprop_cell (fdt, name,"interrupt-parent" , irqchip_phandle); +qemu_fdt_setprop_cells (fdt, name,"interrupts" , irq,0x4 ); +qemu_fdt_setprop_cell (fdt, name,"#address-cells" ,1 ); +qemu_fdt_setprop_cell (fdt, name,"#size-cells" ,0 ); +} +static void finalize_fdt (TTAtlantisState *s) {uint32_t aplic_s_phandle =next_phandle ();
@@ -507,6 +525,13 @@ static void finalize_fdt(TTAtlantisState *s)create_fdt_uart (fdt, &s->memmap[TT_ATL_UART0 ],TT_ATL_UART0_IRQ , aplic_s_phandle); + +for (int i =0 ; i <TT_ATL_NUM_I2C ; i++) { +create_fdt_i2c (fdt, + &s->memmap[TT_ATL_I2C0 + i], +TT_ATL_I2C0_IRQ + i, + aplic_s_phandle); + } }static void create_fdt (TTAtlantisState *s)
@@ -815,6 +840,19 @@ static void tt_atlantis_machine_init(MachineState *machine)qdev_get_gpio_in (s->irqchip,TT_ATL_UART0_IRQ ), 115200, serial_hd(0), DEVICE_LITTLE_ENDIAN); +/* I2C */ +for (int i =0 ; i <TT_ATL_NUM_I2C ; i++) { +object_initialize_child (OBJECT (s),"i2c[*]" , &s->i2c[i], +TYPE_DESIGNWARE_I2C ); +sysbus_realize (SYS_BUS_DEVICE (&s->i2c[i]), &error_fatal); +SysBusDevice *sbd =SYS_BUS_DEVICE (&s->i2c[i]); +memory_region_add_subregion (system_memory, + s->memmap[TT_ATL_I2C0 + i].base, +sysbus_mmio_get_region (sbd,0 )); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c[i]),0 , +qdev_get_gpio_in (s->irqchip,TT_ATL_I2C0_IRQ + i)); + } +/* Load or create device tree */ if (machine->dtb) { machine->fdt =load_device_tree (machine->dtb, &s->fdt_size);
hw/riscv/Kconfig +1 -0
@@ -146,3 +146,4 @@ config TENSTORRENT select RISCV_IMSIC select FW_CFG_DMA select PLATFORM_BUS + select DESIGNWARE_I2C
Signature · 1 line
2.47.3
PATCH 13/16 hw/riscv/atlantis: Add some i2c peripherals
In reply to Joel StanleyAdd an I2C RTC device and a temperature sensor. These are not present on the board but help for testing.
--- hw/riscv/tt_atlantis.c | 18 ++++++++++++++++++ hw/riscv/Kconfig | 2 ++ 2 files changed, 20 insertions(+)
hw/riscv/tt_atlantis.c +18 -0
@@ -498,6 +498,19 @@ static void create_fdt_i2c(void *fdt, const MemMapEntry *mem, uint32_t irq,qemu_fdt_setprop_cell (fdt, name,"#size-cells" ,0 ); } +static void create_fdt_i2c_device (TTAtlantisState *s,int bus, +const char *compat,int addr) +{ +void *fdt =MACHINE (s)->fdt; +hwaddr base = s->memmap[TT_ATL_I2C0 + bus].base; + g_autofree char *name = g_strdup_printf("/soc/i2c@%"PRIx64"/sensor@%d", + base, addr); + +qemu_fdt_add_subnode (fdt, name); +qemu_fdt_setprop_string (fdt, name,"compatible" , compat); +qemu_fdt_setprop_cell (fdt, name,"reg" , addr); +} +static void finalize_fdt (TTAtlantisState *s) {uint32_t aplic_s_phandle =next_phandle ();
@@ -532,6 +545,9 @@ static void finalize_fdt(TTAtlantisState *s)TT_ATL_I2C0_IRQ + i, aplic_s_phandle); } + +create_fdt_i2c_device (s,0 ,"national,lm75" ,0x48 ); +create_fdt_i2c_device (s,0 ,"dallas,ds1338" ,0x6f ); }static void create_fdt (TTAtlantisState *s)
@@ -852,6 +868,8 @@ static void tt_atlantis_machine_init(MachineState *machine)sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c[i]),0 ,qdev_get_gpio_in (s->irqchip,TT_ATL_I2C0_IRQ + i)); } +i2c_slave_create_simple (s->i2c[0 ].bus,"ds1338" ,0x6f ); +i2c_slave_create_simple (s->i2c[0 ].bus,"tmp105" ,0x48 );/* Load or create device tree */ if (machine->dtb) {
hw/riscv/Kconfig +2 -0
@@ -147,3 +147,5 @@ config TENSTORRENT select FW_CFG_DMA select PLATFORM_BUS select DESIGNWARE_I2C + select DS1338 + select TMP105
Signature · 1 line
2.47.3
PATCH 14/16 hw/riscv/boot: Warn if a ELF format file is loaded as a binary
In reply to Joel StanleyFrom: Nicholas Piggin <[email protected]>
It is possible that an ELF file can not be loaded, in that case the loader falls back to loading the file as a binary blob. Print a warning in this case because it is likely that it is not intended.
--- hw/riscv/boot.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
hw/riscv/boot.c +19 -4
@@ -179,13 +179,27 @@ hwaddr riscv_load_firmware(MachineState *machine,g_assert (firmware_filename !=NULL ); -if (load_elf_ram_sym (firmware_filename,NULL ,NULL ,NULL , - &firmware_entry,NULL , &firmware_end,NULL , -0 ,EM_RISCV ,1 ,0 ,NULL , true, sym_cb) >0 ) { + firmware_size =load_elf_ram_sym (firmware_filename,NULL ,NULL ,NULL , + &firmware_entry,NULL , &firmware_end, +NULL ,0 ,EM_RISCV ,1 ,0 ,NULL , false, + sym_cb); +if (firmware_size >0 ) { *firmware_load_addr = firmware_entry;return firmware_end; } +if (firmware_size !=ELF_LOAD_NOT_ELF ) { +/* +* If the user specified an ELF format firmware that could not be +* loaded as an ELF, it's possible that loading it as a binary is +* not what was intended. +*/ +warn_report ("could not load ELF format firmware '%s' (%s). " +"Attempting to load as binary." , + firmware_filename, +load_elf_strerror (firmware_size)); + } + firmware_size = load_image_targphys_as(firmware_filename, *firmware_load_addr, mem_size, NULL,
@@ -195,7 +209,8 @@ hwaddr riscv_load_firmware(MachineState *machine,return *firmware_load_addr + firmware_size; } -error_report ("could not load firmware '%s'" , firmware_filename); +error_report ("could not load firmware '%s': %s" , firmware_filename, +load_elf_strerror (firmware_size));exit (1 ); }
Signature · 1 line
2.47.3
PATCH 15/16 hw/riscv/boot: Provide a simple halting payload
In reply to Joel StanleyFrom: Nicholas Piggin <[email protected]>
OpenSBI hangs before any console output if the domain init code sees the next stage is not in an executable region.
If no kernel payload is provided to QEMU, the next stage address is NULL, and the riscv virt machine memory map ends up covering the 0 address with the catch all S-mode RWX region and so OpenSBI prints console messages and does not hang until the next stage boot.
The TT Atlantis address map has RAM starting at 0 and it loads OpenSBI there, so it is M-mode and not accessible by S-mode, tripping the early check and hang.
Add a helper to set up a simple payload that gets OpenSBI messages to console.
--- include/hw/riscv/boot.h | 2 ++ hw/riscv/boot.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+)
include/hw/riscv/boot.h +2 -0
@@ -78,6 +78,8 @@ void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState *harts hwaddr rom_base, hwaddr rom_size, uint64_t kernel_entry, uint64_t fdt_load_addr); +void riscv_setup_halting_payload (MachineState *machine, +RISCVBootInfo *info,hwaddr addr); void riscv_rom_copy_firmware_info(MachineState *machine, RISCVHartArrayState *harts, hwaddr rom_base,
hw/riscv/boot.c +21 -0
@@ -518,6 +518,27 @@ void riscv_setup_rom_reset_vec(MachineState *machine, RISCVHartArrayState *harts kernel_entry); } +/* Simple payload so OpenSBI does not hang early with no output */ +void riscv_setup_halting_payload (MachineState *machine, +RISCVBootInfo *info,hwaddr addr) +{ +int i; +uint32_t payload_vec[] = { +0x10500073 ,/* 1: wfi */ +0xffdff06f ,/* j 1b */ + }; +/* copy in the payload vector in little_endian byte order */ +for (i =0 ; i <ARRAY_SIZE (payload_vec); i++) { + payload_vec[i] =cpu_to_le32 (payload_vec[i]); + } +rom_add_blob_fixed_as ("mrom.payload" , payload_vec,sizeof (payload_vec), + addr, &address_space_memory); + + info->kernel_size =sizeof (payload_vec); + info->image_low_addr = addr; + info->image_high_addr = info->image_low_addr + info->kernel_size; +} +void riscv_setup_direct_kernel (hwaddr kernel_addr,hwaddr fdt_addr) {CPUState *cs;
Signature · 1 line
2.47.3
PATCH 16/16 hw/riscv/atlantis: Use halting kernel if there is no payload
In reply to Joel StanleyFrom: Nicholas Piggin <[email protected]>
To avoid OpenSBI hanging with no messages if there is no kernel provided, add the simple payload in that case.
--- hw/riscv/tt_atlantis.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/riscv/tt_atlantis.c +4 -4
@@ -746,15 +746,15 @@ static void tt_atlantis_machine_done(Notifier *notifier, void *data) firmware_name, &start_addr, NULL); + kernel_start_addr =riscv_calc_kernel_start_addr (&boot_info, + firmware_end_addr);if (machine->kernel_filename) { - kernel_start_addr =riscv_calc_kernel_start_addr (&boot_info, - firmware_end_addr);riscv_load_kernel (machine, &boot_info, kernel_start_addr, true,NULL ); - kernel_entry = boot_info.image_low_addr; }else { - kernel_entry =0 ; +riscv_setup_halting_payload (machine, &boot_info, kernel_start_addr); } + kernel_entry = boot_info.image_low_addr; fdt_load_addr = riscv_compute_fdt_addr(s->memmap[TT_ATL_DDR_LO].base, s->memmap[TT_ATL_DDR_LO].size,
Signature · 1 line
2.47.3
Quoted 2 lines · Joel Stanley
Introducing Tenstorrent Atlantis!
Note that this was based on v10.2.0 and passed CI before I sent it:
https://gitlab.com/shenki/qemu/-/pipelines/2246526243
However master has moved along and there are now some merge conflicts. I'll hold off sending a v2 for now, but in case anyone is trying to test, a rebased tree is here:
https://gitlab.com/shenki/qemu/-/tree/tt-atlantis
Cheers,
Joel
Hey!
Quoted 6 lines · Joel Stanley
Quoted 2 lines · Joel Stanley
Introducing Tenstorrent Atlantis!
Note that this was based on v10.2.0 and passed CI before I sent it:
Quoted 7 lines
https://gitlab.com/shenki/qemu/-/pipelines/2246526243However master has moved along and there are now some merge conflicts. I'll hold off sending a v2 for now, but in case anyone is trying to test, a rebased tree is here:
In fact the (non-documented) practice in qemu-riscv is to send patches based on the maintainer's tree (https://github.com/alistair23/qemu.git) branch 'riscv-to-apply.next'.
The patches don't apply in that tree too btw, but it's fine to wait for code reviews before re-sending it.
Thanks,
Daniel
Quoted 4 lines
Cheers,
Joel
Quoted 25 lines · Joel Stanley
Introducing Tenstorrent Atlantis!
The Tenstorrent Atlantis platform is a collaboration between Tenstorrent and CoreLab Technology. It is based on the Atlantis SoC, which includes the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology.
The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant RISC-V CPU.
This initial series adds the base machine support including:
- AIA (Advanced Interrupt Architecture) support
- PCIe controller and DesignWare I2C integration
- Serial console and device tree generation
- Functional tests for OpenSBI+Linux bootChanges outside of adding the machine:
- Atlantis maps DRAM high in the address space but maintains an alias for the first 2GB at
0x0. We have updated the RISC-V boot loader code to supportboot_infofor discontiguous memory layouts.- The riscv64 virt machine AIA initialisation has been moved to a helper file to allow code reuse with the Atlantis machine
Quoted 7 lines
- Revived the DesignWare I2C controller model (previously proposed for ARM virt) with permission from the original author.
I hope to get early feedback on the base machine now. We intend to continue modelling the soc so it can be useful for firmware and operating system development and testing, so expect more patches to do that soon.
Good choice on the machine name. Looking forward for what's coming next (Poseidon, Varuna, Anuket, Leviathan ...)
As for the patches I see stuff that could be sent separately in a prep series, mostly the 4 patches on hw/boot and the 2 hw/aia patches. You can refer to this prep series as a prerequisite for the main series that would include just the machine specific stuff.
This prep series would be easier to review and would probably be merged first, alleviating the review effort in the Atlantis series.
Also, the designware i2c controller patch seems fully reviewed. I advise sending it standalone to be merged right away. I believe Alistair wouldn't mind pushing it via qemu-riscv.
Thanks,
Daniel
Quoted 62 lines
Chris Rauer (1):
hw/i2c: Add designware i2c controllerJoel Stanley (6):
target/riscv: tt-ascalon: Add Tenstorrent mvendorid hw/riscv: Move AIA initialisation to helper file hw/riscv/aia: Provide number of irq sources hw/riscv: Add Tenstorrent Atlantis machine hw/riscv/atlantis: Integrate i2c buses hw/riscv/atlantis: Add some i2c peripheralsNicholas Piggin (9):
target/riscv: tt-ascalon: Enable Zkr extension target/riscv: tt-ascalon: Add Svadu extension riscv/boot: Describe discontiguous memory inboot_inforiscv/boot: Account for discontiguous memory when loading firmware hw/riscv/atlantis: Add PCIe controller tests/functional/riscv64: Add tt-atlantis tests hw/riscv/boot: Warn if a ELF format file is loaded as a binary hw/riscv/boot: Provide a simple halting payload hw/riscv/atlantis: Use halting kernel if there is no payloadMAINTAINERS | 15 + docs/system/riscv/tt_atlantis.rst | 38 + docs/system/target-riscv.rst | 1 + hw/riscv/aia.h | 59 ++ include/hw/i2c/designware_i2c.h | 101 ++ include/hw/riscv/boot.h | 14 +- include/hw/riscv/tt_atlantis.h | 95 ++ include/hw/riscv/virt.h | 30 +- target/riscv/cpu_vendorid.h | 2 + hw/i2c/designware_i2c.c | 813 ++++++++++++++++ hw/riscv/aia.c | 89 ++ hw/riscv/boot.c | 73 +- hw/riscv/microchip_pfsoc.c | 6 +- hw/riscv/opentitan.c | 6 +- hw/riscv/shakti_c.c | 6 +- hw/riscv/sifive_u.c | 3 +- hw/riscv/spike.c | 6 +- hw/riscv/tt_atlantis.c | 917 +++++++++++++++++++ hw/riscv/virt-acpi-build.c | 24 +- hw/riscv/virt.c | 94 +- hw/riscv/xiangshan_kmh.c | 6 +- target/riscv/cpu.c | 4 +- hw/i2c/Kconfig | 4 + hw/i2c/meson.build | 1 + hw/riscv/Kconfig | 21 + hw/riscv/meson.build | 3 +- tests/functional/riscv64/meson.build | 1 + tests/functional/riscv64/test_opensbi.py | 4 + tests/functional/riscv64/test_tt_atlantis.py | 68 ++ 29 files changed, 2365 insertions(+), 139 deletions(-)create mode 100644
docs/system/riscv/tt_atlantis.rstcreate mode 100644hw/riscv/aia.h
create mode 100644include/hw/i2c/designware_i2c.hcreate mode 100644include/hw/riscv/tt_atlantis.hcreate mode 100644hw/i2c/designware_i2c.c
create mode 100644hw/riscv/aia.c
create mode 100644hw/riscv/tt_atlantis.c
create mode 100755tests/functional/riscv64/test_tt_atlantis.py
Quoted 13 lines · Daniel Henrique Barboza
Quoted 4 lines · Joel Stanley
I hope to get early feedback on the base machine now. We intend to continue modelling the soc so it can be useful for firmware and operating system development and testing, so expect more patches to do that soon.
Good choice on the machine name. Looking forward for what's coming next (Poseidon, Varuna, Anuket, Leviathan ...)
Quoted 7 lines
As for the patches I see stuff that could be sent separately in a prep series, mostly the 4 patches on hw/boot and the 2 hw/aia patches. You can refer to this prep series as a prerequisite for the main series that would include just the machine specific stuff.
This prep series would be easier to review and would probably be merged first, alleviating the review effort in the Atlantis series.
Good plan. I'll send a series of prep patches out, based on riscv-to-apply.next.
Quoted 3 lines
Also, the designware i2c controller patch seems fully reviewed. I advise sending it standalone to be merged right away. I believe Alistair wouldn't mind pushing it via qemu-riscv.
Okay, I'll do that too. Thanks for the advice.
Cheers,
Joel