Skip to contentSkip to conversation

Hexagon: Add real SoC-style machines

PATCH Superseded Brian Cain 4 participants 36 messages Oct 19 – Oct 27 Arm/Amlogic Meson SoC support

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Brian Cain

author
#0 lore raw

cover Hexagon: Add real SoC-style machines

Previously we added synthetic machines intended for compatibility with programs created by the Hexagon SDK. These simple configurations have a memory/irq map that doesn't match any real chips, and they are limited to an interrupt controller and a timer device.

Here we add DSP machines that reflect real-world devices and run some of the commercial firmware to test it. Note that for now the boot will not progress much beyond the initial kernel boot. Dependencies on other yet-to-be-modeled devices are preventing the firmware from coming up fully to a steady/idle state.

Brian Cain (14):
Hexagon: add v85 CPU model
hw/hexagon: let a machine place its DDR
hw/hexagon: introduce hex-board abstraction
hw/hexagon: convert virt board to hex-board
hw/misc: add the QDSP6SS PLL, RCG
hw/hexagon: add the QCS6490 CDSP machine
hw/hexagon: add the SA8775P CDSP machine
hw/hexagon: add the SC8480XP NSP0 machine
hw/hexagon: add the SA8797P NSP0 machine
hw/hexagon: add the SM8975 NSP machine
hw/hexagon: add v79NA1 machine
hw/hexagon: add subsystem-base property
target/hexagon: fix the allocframe framekey
tests/functional/hexagon: boot DSP firmware

 MAINTAINERS                                   |   6 +
 docs/system/hexagon/emulation.rst             |   2 +-
 include/hw/hexagon/hex-board.h                |  65 +++
 include/hw/hexagon/hexagon.h                  |  10 +
 include/hw/hexagon/qcom_dsp.h                 |  81 ++++
 include/hw/hexagon/virt.h                     |   6 -
 include/hw/misc/qcom-qdsp6ss-clk.h            |  15 +
 target/hexagon/cpu-qom.h                      |   4 +
 hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc     |  65 +++
 hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc     |   6 +-
 hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc     |  56 +++
 hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc    |  52 +++
 hw/hexagon/machine_cfg_sm8975_nsp.h.inc       |  55 +++
 hw/hexagon/machine_cfg_v79na_1.h.inc          |  34 ++
 hw/hexagon/hex-board.c                        | 265 ++++++++++++
 hw/hexagon/hex-subsys.c                       |   4 +-
 hw/hexagon/hexagon_dsp.c                      |  84 +++-
 hw/hexagon/qcom_dsp.c                         | 399 ++++++++++++++++++
 hw/hexagon/qcs6490_cdsp.c                     |  64 +++
 hw/hexagon/sa8775p_cdsp.c                     |  59 +++
 hw/hexagon/sa8797p_nsp0.c                     |  68 +++
 hw/hexagon/sc8480xp_nsp0.c                    |  90 ++++
 hw/hexagon/sm8975_nsp.c                       | 102 +++++
 hw/hexagon/virt.c                             | 309 ++------------
 hw/misc/qcom-qdsp6ss-clk.c                    | 208 +++++++++
 linux-user/hexagon/elfload.c                  |   4 +
 target/hexagon/cpu.c                          |   2 +
 target/hexagon/idef-parser/parser-helpers.c   |   2 +-
 tests/qtest/hexagon-config-test.c             |  78 ++++
 tests/qtest/l2vic-test.c                      |  10 +
 tests/qtest/qcom-dsp-test.c                   | 113 +++++
 tests/qtest/qct-qtimer-test.c                 |  10 +
 tests/tcg/hexagon/framekey.c                  |  67 +++
 hw/hexagon/Kconfig                            |  48 ++-
 hw/hexagon/meson.build                        |   7 +
 hw/misc/Kconfig                               |   3 +
 hw/misc/meson.build                           |   3 +
 tests/functional/hexagon/meson.build          |   2 +
 .../hexagon/test_qcom_dsp_firmware.py         |  89 ++++
 tests/qtest/meson.build                       |   4 +-
 tests/tcg/hexagon/meson.build                 |   1 +
 41 files changed, 2254 insertions(+), 298 deletions(-)
 create mode 100644 include/hw/hexagon/hex-board.h
 create mode 100644 include/hw/hexagon/qcom_dsp.h
 create mode 100644 include/hw/misc/qcom-qdsp6ss-clk.h
 create mode 100644 hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc
 create mode 100644 hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc
 create mode 100644 hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc
 create mode 100644 hw/hexagon/machine_cfg_sm8975_nsp.h.inc
 create mode 100644 hw/hexagon/machine_cfg_v79na_1.h.inc
 create mode 100644 hw/hexagon/hex-board.c
 create mode 100644 hw/hexagon/qcom_dsp.c
 create mode 100644 hw/hexagon/qcs6490_cdsp.c
 create mode 100644 hw/hexagon/sa8775p_cdsp.c
 create mode 100644 hw/hexagon/sa8797p_nsp0.c
 create mode 100644 hw/hexagon/sc8480xp_nsp0.c
 create mode 100644 hw/hexagon/sm8975_nsp.c
 create mode 100644 hw/misc/qcom-qdsp6ss-clk.c
 create mode 100644 tests/qtest/hexagon-config-test.c
 create mode 100644 tests/qtest/qcom-dsp-test.c
 create mode 100644 tests/tcg/hexagon/framekey.c
 create mode 100755 tests/functional/hexagon/test_qcom_dsp_firmware.py
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/14 Hexagon: add v85 CPU model

---
 docs/system/hexagon/emulation.rst | 2 +-
 target/hexagon/cpu-qom.h          | 4 ++++
 linux-user/hexagon/elfload.c      | 4 ++++
 target/hexagon/cpu.c              | 2 ++
 4 files changed, 11 insertions(+), 1 deletion(-)
docs/system/hexagon/emulation.rst +1 -1
index 12385311aa4..fb57c77ae90 100644
@@ -6,7 +6,7 @@ Hexagon CPU architecture support
 ================================
 
 QEMU's TCG emulation includes support for v65, v66, v67, v68, v69, v71, v73,
-v75, v77, v79, v81.
+v75, v77, v79, v81, v83, v85.
 It also has support for the following architecture extensions:
 
 - HVX (Hexagon Vector eXtensions)
target/hexagon/cpu-qom.h +4 -0
index 2bfa4d5d0fc..d4c8413ded3 100644
@@ -28,6 +28,8 @@ typedef enum {
     HEX_VER_V75 = 0x75,
     HEX_VER_V79 = 0x79,
     HEX_VER_V81 = 0x81,
+    HEX_VER_V83 = 0x83,
+    HEX_VER_V85 = 0x85,
     HEX_VER_ANY = 0xff,
 } HexagonVersion;
 
@@ -55,6 +57,8 @@ typedef struct {
 #define TYPE_HEXAGON_CPU_V75 HEXAGON_CPU_TYPE_NAME("v75")
 #define TYPE_HEXAGON_CPU_V79 HEXAGON_CPU_TYPE_NAME("v79")
 #define TYPE_HEXAGON_CPU_V81 HEXAGON_CPU_TYPE_NAME("v81")
+#define TYPE_HEXAGON_CPU_V83 HEXAGON_CPU_TYPE_NAME("v83")
+#define TYPE_HEXAGON_CPU_V85 HEXAGON_CPU_TYPE_NAME("v85")
 
 OBJECT_DECLARE_CPU_TYPE(HexagonCPU, HexagonCPUClass, HEXAGON_CPU)
 
linux-user/hexagon/elfload.c +4 -0
index 3a6ba4e1304..9f98ad8fb86 100644
@@ -113,6 +113,10 @@ const char *get_elf_cpu_model(uint32_t eflags)
         return "v79";
     case 0x81:
         return "v81";
+    case 0x83:
+        return "v83";
+    case 0x85:
+        return "v85";
     }
 
     err = snprintf(buf, sizeof(buf), "unknown (0x%x)", eflags);
target/hexagon/cpu.c +2 -0
index f20d6de6f63..1e3df5d0d03 100644
@@ -934,6 +934,8 @@ static const TypeInfo hexagon_cpu_type_infos[] = {
     DEFINE_CPU(TYPE_HEXAGON_CPU_V75,              HEX_VER_V75),
     DEFINE_CPU(TYPE_HEXAGON_CPU_V79,              HEX_VER_V79),
     DEFINE_CPU(TYPE_HEXAGON_CPU_V81,              HEX_VER_V81),
+    DEFINE_CPU(TYPE_HEXAGON_CPU_V83,              HEX_VER_V83),
+    DEFINE_CPU(TYPE_HEXAGON_CPU_V85,              HEX_VER_V85),
 };
 
 DEFINE_TYPES(hexagon_cpu_type_infos)
Signature · 1 line
2.34.1
Reviewed-by Anton Johansson on v1 1/14
#2 lore raw

Re: [PATCH 01/14] Hexagon: add v85 CPU model

Quoted 27 lines · Brian Cain
---
 docs/system/hexagon/emulation.rst | 2 +-
 target/hexagon/cpu-qom.h          | 4 ++++
 linux-user/hexagon/elfload.c      | 4 ++++
 target/hexagon/cpu.c              | 2 ++
 4 files changed, 11 insertions(+), 1 deletion(-)
docs/system/hexagon/emulation.rst +1 -1
index 12385311aa4..fb57c77ae90 100644
@@ -6,7 +6,7 @@ Hexagon CPU architecture support
 ================================
 
 QEMU's TCG emulation includes support for v65, v66, v67, v68, v69, v71, v73,
-v75, v77, v79, v81.
+v75, v77, v79, v81, v83, v85.
 It also has support for the following architecture extensions:
 
 - HVX (Hexagon Vector eXtensions)
target/hexagon/cpu-qom.h +0 -0
index 2bfa4d5d0fc..d4c8413ded3 100644

target/hexagon/cpu-qom.h typedef enum { · line 34

Quoted 7 lines
target/hexagon/cpu-qom.h +2 -0
@@ -28,6 +28,8 @@ typedef enum {
     HEX_VER_V75 = 0x75,
     HEX_VER_V79 = 0x79,
     HEX_VER_V81 = 0x81,
+    HEX_VER_V83 = 0x83,
+    HEX_VER_V85 = 0x85,
     HEX_VER_ANY = 0xff,
 } HexagonVersion;

I think you missed adding HEX_VER_V85 to get_elf_hwcap(), currently it would take the default case and return 0.

Otherwise,

author
#3 lore raw

Re: [PATCH 01/14] Hexagon: add v85 CPU model

Quoted 22 lines · Anton Johansson
Quoted 21 lines · Brian Cain
---
  docs/system/hexagon/emulation.rst | 2 +-
  target/hexagon/cpu-qom.h          | 4 ++++
  linux-user/hexagon/elfload.c      | 4 ++++
  target/hexagon/cpu.c              | 2 ++
  4 files changed, 11 insertions(+), 1 deletion(-)
docs/system/hexagon/emulation.rst +1 -1
index 12385311aa4..fb57c77ae90 100644
@@ -6,7 +6,7 @@ Hexagon CPU architecture support
  ================================
 
  QEMU's TCG emulation includes support for v65, v66, v67, v68, v69, v71, v73,
-v75, v77, v79, v81.
+v75, v77, v79, v81, v83, v85.
  It also has support for the following architecture extensions:
 
Quoted 15 lines

target/hexagon/cpu-qom.h typedef enum { · line 34

Quoted 13 lines
docs/system/hexagon/emulation.rst +0 -0
  - HVX (Hexagon Vector eXtensions)
target/hexagon/cpu-qom.h +2 -0
index 2bfa4d5d0fc..d4c8413ded3 100644
@@ -28,6 +28,8 @@ typedef enum {
      HEX_VER_V75 = 0x75,
      HEX_VER_V79 = 0x79,
      HEX_VER_V81 = 0x81,
+    HEX_VER_V83 = 0x83,
+    HEX_VER_V85 = 0x85,
      HEX_VER_ANY = 0xff,
  } HexagonVersion;

I think you missed adding HEX_VER_V85 to get_elf_hwcap(), currently it would take the default case and return 0.

Thanks!  I borrowed this patch from another series so that these two mostly-independent ones could be reviewed separately.  In that one, I did include the get_elf_hwcap() update.

See https://lore.kernel.org/qemu-devel/[email protected]/

Quoted 3 lines

Otherwise,

author
#4 lore raw

PATCH 2/14 hw/hexagon: let a machine place its DDR

In reply to Brian Cain

hex_subsys_create() always maps the main DDR at address 0. This is appropriate for hexagon-sim-style machines, but real SoCs map it elsewhere.

---
 include/hw/hexagon/hexagon.h | 2 ++
 hw/hexagon/hex-subsys.c      | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
include/hw/hexagon/hexagon.h +2 -0
index 9b5d33ffc3b..6955e600aee 100644
@@ -145,6 +145,8 @@ union hexagon_config_table {
 };
 
 struct hexagon_machine_config {
+    /* Base address of the main DDR region */
+    hwaddr ddr_base;
     /* Base address of config table */
     uint32_t cfgbase;
     /* Size of L2 TCM */
hw/hexagon/hex-subsys.c +2 -2
index 9818cf58878..382f45bd09f 100644
@@ -136,10 +136,10 @@ void hex_subsys_create(HexagonCommonMachineState *hms,
     MachineState *machine = MACHINE(hms);
     MemoryRegion *sysmem = get_system_memory();
 
-    /* Main DDR at the reset vector. */
+    /* Main DDR. */
     memory_region_init_ram(&hms->ram, NULL, "ddr.ram", machine->ram_size,
                            &error_fatal);
-    memory_region_add_subregion(sysmem, 0x0, &hms->ram);
+    memory_region_add_subregion(sysmem, m_cfg->ddr_base, &hms->ram);
 
     /* Config-table ROM and the blob that backs it. */
     memory_region_init_rom(&hms->cfgtable_rom, NULL, "config_table.rom",
Signature · 1 line
2.34.1
Reviewed-by on v1 2/14
#5 lore raw

Re: [PATCH 02/14] hw/hexagon: let a machine place its DDR

Quoted 9 lines · Brian Cain

hex_subsys_create() always maps the main DDR at address 0. This is appropriate for hexagon-sim-style machines, but real SoCs map it elsewhere.

---
 include/hw/hexagon/hexagon.h | 2 ++
 hw/hexagon/hex-subsys.c      | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
author
#6 lore raw

PATCH 3/14 hw/hexagon: introduce hex-board abstraction

In reply to Brian Cain

Move what virt.c does to build a board out of it into helpers in a new hex-board.c, so that other Hexagon machines that describe themselves with a generated device tree can reuse it.

This will be used by future commits.

---
 MAINTAINERS                    |   2 +
 include/hw/hexagon/hex-board.h |  65 ++++++++
 hw/hexagon/hex-board.c         | 265 +++++++++++++++++++++++++++++++++
 hw/hexagon/Kconfig             |   9 +-
 hw/hexagon/meson.build         |   1 +
 5 files changed, 340 insertions(+), 2 deletions(-)
 create mode 100644 include/hw/hexagon/hex-board.h
 create mode 100644 hw/hexagon/hex-board.c
MAINTAINERS +2 -0
index 22caaee9671..4c9eb1892c1 100644
@@ -256,6 +256,8 @@ F: tests/qtest/l2vic-test.c
 F: hw/timer/qct-qtimer.c
 F: include/hw/timer/qct-qtimer.h
 F: tests/qtest/qct-qtimer-test.c
+F: hw/hexagon/hex-board.c
+F: include/hw/hexagon/hex-board.h
 X: target/hexagon/idef-parser/
 X: target/hexagon/gen_idef_parser_funcs.py
 F: linux-user/hexagon/
include/hw/hexagon/hex-board.h new file +65 -0

65 lines not on this page · raw message

hw/hexagon/hex-board.c new file +265 -0

265 lines not on this page · raw message

hw/hexagon/Kconfig +7 -2
index bb8a254fd26..63ee8836aca 100644
@@ -7,12 +7,17 @@ config HEX_DSP
     select HEX_QTIMER
     select ARM_COMPATIBLE_SEMIHOSTING
 
-config HEX_VIRT
+config HEX_BOARD
     bool
-    default y
     depends on HEX_DSP && FDT
     select DEVICE_TREE
     select VIRTIO_MMIO
     select PL011
+
+config HEX_VIRT
+    bool
+    default y
+    depends on HEX_DSP && FDT
+    select HEX_BOARD
     select VIRTIO_BLK
     select VIRTIO_SCSI
hw/hexagon/meson.build +1 -0
index c4b257dfa28..57bff31ad00 100644
@@ -4,6 +4,7 @@ hexagon_ss.add(files('hexagon_globalreg.c'))
 hexagon_ss.add(files('hexagon_hvx_context.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hex-subsys.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c'))
+hexagon_ss.add(when: 'CONFIG_HEX_BOARD', if_true: files('hex-board.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))
 
 hw_arch += {'hexagon': hexagon_ss}
Signature · 1 line
2.34.1
Reviewed-by on v1 3/14
#7 lore raw

Re: [PATCH 03/14] hw/hexagon: introduce hex-board abstraction

Quoted 7 lines · Brian Cain

Move what virt.c does to build a board out of it into helpers in a new hex-board.c, so that other Hexagon machines that describe themselves with a generated device tree can reuse it.

This will be used by future commits.

Quoted 10 lines
---
 MAINTAINERS                    |   2 +
 include/hw/hexagon/hex-board.h |  65 ++++++++
 hw/hexagon/hex-board.c         | 265 +++++++++++++++++++++++++++++++++
 hw/hexagon/Kconfig             |   9 +-
 hw/hexagon/meson.build         |   1 +
 5 files changed, 340 insertions(+), 2 deletions(-)
 create mode 100644 include/hw/hexagon/hex-board.h
 create mode 100644 hw/hexagon/hex-board.c
author
#8 lore raw

PATCH 4/14 hw/hexagon: convert virt board to hex-board

In reply to Brian Cain

Build the virt machine with the hex-board helpers instead of its own copies, and drop the machine state that nothing used. The machine, its device tree and its devices are unchanged; virt writes interrupts as the bare line number.

---
 include/hw/hexagon/virt.h |   6 -
 hw/hexagon/virt.c         | 309 ++++----------------------------------
 2 files changed, 26 insertions(+), 289 deletions(-)
include/hw/hexagon/virt.h +0 -6
index 4ca2f1ef859..dc9f22a83c4 100644
@@ -17,15 +17,9 @@ struct HexagonVirtMachineState {
     HexagonCommonMachineState parent_obj;
 
     int fdt_size;
-    MemoryRegion *sys;
     MemoryRegion tcm;
-    MemoryRegion bios;
-    Clock *apb_clk;
-    DeviceState *virtio_mmio[VIRTIO_DEV_COUNT];
 };
 
-void hexagon_load_fdt(const struct HexagonVirtMachineState *vms);
-
 #define TYPE_HEXAGON_VIRT_MACHINE MACHINE_TYPE_NAME("virt")
 OBJECT_DECLARE_SIMPLE_TYPE(HexagonVirtMachineState, HEXAGON_VIRT_MACHINE)
 
hw/hexagon/virt.c +26 -283

349 lines not on this page · raw message

Signature · 1 line
2.34.1
Reviewed-by on v1 4/14
#9 lore raw

Re: [PATCH 04/14] hw/hexagon: convert virt board to hex-board

Quoted 11 lines · Brian Cain

Build the virt machine with the hex-board helpers instead of its own copies, and drop the machine state that nothing used. The machine, its device tree and its devices are unchanged; virt writes interrupts as the bare line number.

---
 include/hw/hexagon/virt.h |   6 -
 hw/hexagon/virt.c         | 309 ++++----------------------------------
 2 files changed, 26 insertions(+), 289 deletions(-)
author
#10 lore raw

PATCH 5/14 hw/misc: add the QDSP6SS PLL, RCG

In reply to Brian Cain

Firmware brings a Hexagon DSP's clocks up by programming a PLL and polling its lock-detect. Then it asks the RCG to switch to the new clock.

---
 MAINTAINERS                        |   2 +
 include/hw/misc/qcom-qdsp6ss-clk.h |  15 +++
 hw/misc/qcom-qdsp6ss-clk.c         | 208 +++++++++++++++++++++++++++++
 hw/misc/Kconfig                    |   3 +
 hw/misc/meson.build                |   3 +
 5 files changed, 231 insertions(+)
 create mode 100644 include/hw/misc/qcom-qdsp6ss-clk.h
 create mode 100644 hw/misc/qcom-qdsp6ss-clk.c
MAINTAINERS +2 -0
index 4c9eb1892c1..ef619991b4b 100644
@@ -1380,7 +1380,9 @@ M: Brian Cain <[email protected]>
 R: Pierrick Bouvier <[email protected]>
 S: Supported
 F: hw/hexagon/
+F: hw/misc/qcom-qdsp6ss-clk.c
 F: include/hw/hexagon/
+F: include/hw/misc/qcom-qdsp6ss-clk.h
 F: configs/devices/hexagon-softmmu/default.mak
 F: docs/system/hexagon/
 F: tests/functional/hexagon/
include/hw/misc/qcom-qdsp6ss-clk.h new file +15 -0
new file mode 100644
index 00000000000..9e3c58b5726
@@ -0,0 +1,15 @@
+/*
+ * Qualcomm QDSP6SS clock blocks: the Lucid alpha PLL and the root clock
+ * generator that firmware programs while bringing a Hexagon DSP up.
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_MISC_QCOM_QDSP6SS_CLK_H
+#define HW_MISC_QCOM_QDSP6SS_CLK_H
+
+#define TYPE_QCOM_LUCID_PLL "qcom-lucid-pll"
+#define TYPE_QCOM_RCG "qcom-rcg"
+
+#endif /* HW_MISC_QCOM_QDSP6SS_CLK_H */
hw/misc/qcom-qdsp6ss-clk.c new file +208 -0

208 lines not on this page · raw message

hw/misc/Kconfig +3 -0
index 7abd22869a4..363930230b4 100644
@@ -267,3 +267,6 @@ config SOPHGO_CV1800B_CLK
     bool
 
 source macio/Kconfig
+
+config QCOM_QDSP6SS_CLK
+    bool
hw/misc/meson.build +3 -0
index 8a94aba751d..2b437f53d6a 100644
@@ -179,3 +179,6 @@ system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c'))
 system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c'))
 
 system_ss.add(when: 'CONFIG_AXIADO_CLK', if_true: files('axiado_clk.c'))
+
+# Qualcomm Hexagon DSP subsystems
+system_ss.add(when: 'CONFIG_QCOM_QDSP6SS_CLK', if_true: files('qcom-qdsp6ss-clk.c'))
Signature · 1 line
2.34.1
Reviewed-by on v1 5/14
#11 lore raw

Re: [PATCH 05/14] hw/misc: add the QDSP6SS PLL, RCG

Quoted 4 lines · Brian Cain

Firmware brings a Hexagon DSP's clocks up by programming a PLL and polling its lock-detect. Then it asks the RCG to switch to the new clock.

Quoted 10 lines
---
 MAINTAINERS                        |   2 +
 include/hw/misc/qcom-qdsp6ss-clk.h |  15 +++
 hw/misc/qcom-qdsp6ss-clk.c         | 208 +++++++++++++++++++++++++++++
 hw/misc/Kconfig                    |   3 +
 hw/misc/meson.build                |   3 +
 5 files changed, 231 insertions(+)
 create mode 100644 include/hw/misc/qcom-qdsp6ss-clk.h
 create mode 100644 hw/misc/qcom-qdsp6ss-clk.c
author
#12 lore raw

PATCH 6/14 hw/hexagon: add the QCS6490 CDSP machine

In reply to Brian Cain
---
 MAINTAINERS                               |   1 +
 include/hw/hexagon/hexagon.h              |   1 +
 include/hw/hexagon/qcom_dsp.h             |  81 +++++
 hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc |  65 ++++
 hw/hexagon/qcom_dsp.c                     | 399 ++++++++++++++++++++++
 hw/hexagon/qcs6490_cdsp.c                 |  64 ++++
 tests/qtest/l2vic-test.c                  |   2 +
 tests/qtest/qcom-dsp-test.c               |  93 +++++
 tests/qtest/qct-qtimer-test.c             |   2 +
 hw/hexagon/Kconfig                        |  15 +
 hw/hexagon/meson.build                    |   2 +
 tests/qtest/meson.build                   |   3 +-
 12 files changed, 727 insertions(+), 1 deletion(-)
 create mode 100644 include/hw/hexagon/qcom_dsp.h
 create mode 100644 hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc
 create mode 100644 hw/hexagon/qcom_dsp.c
 create mode 100644 hw/hexagon/qcs6490_cdsp.c
 create mode 100644 tests/qtest/qcom-dsp-test.c
MAINTAINERS +1 -0
index ef619991b4b..04df9db77dc 100644
@@ -1386,6 +1386,7 @@ F: include/hw/misc/qcom-qdsp6ss-clk.h
 F: configs/devices/hexagon-softmmu/default.mak
 F: docs/system/hexagon/
 F: tests/functional/hexagon/
+F: tests/qtest/qcom-dsp-test.c
 F: docs/devel/hexagon-sys.rst
 
 LoongArch Machines
include/hw/hexagon/hexagon.h +1 -0
index 6955e600aee..1d0d55ea938 100644
@@ -23,6 +23,7 @@ typedef enum {
     v66_rev = 0xa666,
     v67_rev = 0x2667,
     v68_rev = 0x8d68,
+    v68_qcs6490_rev = 0x8a68,
     v69_rev = 0x8c69,
     v71_rev = 0x8c71,
     v73_rev = 0x8c73,
include/hw/hexagon/qcom_dsp.h new file +81 -0

81 lines not on this page · raw message

hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc new file +65 -0

65 lines not on this page · raw message

hw/hexagon/qcom_dsp.c new file +399 -0

399 lines not on this page · raw message

hw/hexagon/qcs6490_cdsp.c new file +64 -0

64 lines not on this page · raw message

tests/qtest/l2vic-test.c +2 -0
index adb4dc7281e..2e0d7dcb0f1 100644
@@ -11,6 +11,7 @@
 
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
+#include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
 
 /* L2VIC register offsets exercised by this test */
 #define L2VIC_INT_ENABLEn 0x100 /* Read/Write */
@@ -45,6 +46,7 @@ typedef struct {
 static const L2VICMachineCfg l2vic_machines[] = {
     { "virt",      &v68n_1024 },
     { "V66G_1024", &v66g_1024 },
+    { "qcs6490-cdsp", &qcs6490_cdsp },
 };
 
 static uint32_t l2vic_read32(uint64_t base, uint32_t offset)
tests/qtest/qcom-dsp-test.c new file +93 -0

93 lines not on this page · raw message

tests/qtest/qct-qtimer-test.c +2 -0
index fd8bb0af776..263751b55bf 100644
@@ -12,6 +12,7 @@
 
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
+#include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
 
 #define QTIMER_DEFAULT_FREQ_HZ 19200000ULL
 
@@ -342,6 +343,7 @@ typedef struct {
 static const QtimerMachineCfg qtimer_machines[] = {
     { "virt",      &v68n_1024 },
     { "V66G_1024", &v66g_1024 },
+    { "qcs6490-cdsp", &qcs6490_cdsp },
 };
 
 static void test_qtimer_on_machine(gconstpointer data)
hw/hexagon/Kconfig +15 -0
index 63ee8836aca..ffc8623691c 100644
@@ -21,3 +21,18 @@ config HEX_VIRT
     select HEX_BOARD
     select VIRTIO_BLK
     select VIRTIO_SCSI
+
+config HEX_QCOM_DSP
+    bool
+    depends on HEX_DSP && FDT
+    select HEX_BOARD
+    select UNIMP
+    select QCOM_QDSP6SS_CLK
+    select VIRTIO_BLK
+    select VIRTIO_SCSI
+
+config HEX_QCS6490_CDSP
+    bool
+    default y
+    depends on HEX_DSP && FDT
+    select HEX_QCOM_DSP
hw/hexagon/meson.build +2 -0
index 57bff31ad00..7145e8a65df 100644
@@ -6,5 +6,7 @@ hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hex-subsys.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_BOARD', if_true: files('hex-board.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))
+hexagon_ss.add(when: 'CONFIG_HEX_QCOM_DSP', if_true: files('qcom_dsp.c'))
+hexagon_ss.add(when: 'CONFIG_HEX_QCS6490_CDSP', if_true: files('qcs6490_cdsp.c'))
 
 hw_arch += {'hexagon': hexagon_ss}
tests/qtest/meson.build +2 -1
index 019c63ca60b..0bbca236659 100644
@@ -320,7 +320,8 @@ qtests_riscv64 = ['riscv-csr-test'] + \
    ['k230-ddr-test', 'k230-wdt-test', 'k230-gsdma-test', 'k230-decomp-gzip-test'] : []) + \
    ['milkv-duo-test']
 
-qtests_hexagon = ['boot-serial-test', 'l2vic-test', 'qct-qtimer-test']
+qtests_hexagon = ['boot-serial-test', 'l2vic-test', 'qcom-dsp-test',
+                  'qct-qtimer-test']
 
 qos_test_ss = ss.source_set()
 qos_test_ss.add(
Signature · 1 line
2.34.1
Reviewed-by on v1 6/14
#13 lore raw

Re: [PATCH 06/14] hw/hexagon: add the QCS6490 CDSP machine

Quoted 12 lines · Brian Cain
---
 MAINTAINERS                               |   1 +
 include/hw/hexagon/hexagon.h              |   1 +
 include/hw/hexagon/qcom_dsp.h             |  81 +++++
 hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc |  65 ++++
 hw/hexagon/qcom_dsp.c                     | 399 ++++++++++++++++++++++
 hw/hexagon/qcs6490_cdsp.c                 |  64 ++++
 tests/qtest/l2vic-test.c                  |   2 +
 tests/qtest/qcom-dsp-test.c               |  93 +++++
 tests/qtest/qct-qtimer-test.c             |   2 +
 hw/hexagon/Kconfig                        |  15 +
Quoted 9 lines
 hw/hexagon/meson.build                    |   2 +
 tests/qtest/meson.build                   |   3 +-
 12 files changed, 727 insertions(+), 1 deletion(-)
 create mode 100644 include/hw/hexagon/qcom_dsp.h
 create mode 100644 hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc
 create mode 100644 hw/hexagon/qcom_dsp.c
 create mode 100644 hw/hexagon/qcs6490_cdsp.c
 create mode 100644 tests/qtest/qcom-dsp-test.c
#14 lore raw

Re: [PATCH 06/14] hw/hexagon: add the QCS6490 CDSP machine

In reply to Brian Cain
Quoted 434 lines · Brian Cain
---
 MAINTAINERS                               |   1 +
 include/hw/hexagon/hexagon.h              |   1 +
 include/hw/hexagon/qcom_dsp.h             |  81 +++++
 hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc |  65 ++++
 hw/hexagon/qcom_dsp.c                     | 399 ++++++++++++++++++++++
 hw/hexagon/qcs6490_cdsp.c                 |  64 ++++
 tests/qtest/l2vic-test.c                  |   2 +
 tests/qtest/qcom-dsp-test.c               |  93 +++++
 tests/qtest/qct-qtimer-test.c             |   2 +
 hw/hexagon/Kconfig                        |  15 +
 hw/hexagon/meson.build                    |   2 +
 tests/qtest/meson.build                   |   3 +-
 12 files changed, 727 insertions(+), 1 deletion(-)
 create mode 100644 include/hw/hexagon/qcom_dsp.h
 create mode 100644 hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc
 create mode 100644 hw/hexagon/qcom_dsp.c
 create mode 100644 hw/hexagon/qcs6490_cdsp.c
 create mode 100644 tests/qtest/qcom-dsp-test.c
MAINTAINERS +1 -0
index ef619991b4b..04df9db77dc 100644
@@ -1386,6 +1386,7 @@ F: include/hw/misc/qcom-qdsp6ss-clk.h
 F: configs/devices/hexagon-softmmu/default.mak
 F: docs/system/hexagon/
 F: tests/functional/hexagon/
+F: tests/qtest/qcom-dsp-test.c
 F: docs/devel/hexagon-sys.rst
 
 LoongArch Machines
include/hw/hexagon/hexagon.h +1 -0
index 6955e600aee..1d0d55ea938 100644
@@ -23,6 +23,7 @@ typedef enum {
     v66_rev = 0xa666,
     v67_rev = 0x2667,
     v68_rev = 0x8d68,
+    v68_qcs6490_rev = 0x8a68,
     v69_rev = 0x8c69,
     v71_rev = 0x8c71,
     v73_rev = 0x8c73,
include/hw/hexagon/qcom_dsp.h new file +81 -0
new file mode 100644
index 00000000000..d127b0b0b10
@@ -0,0 +1,81 @@
+/*
+ * Qualcomm DSP subsystem machines: the board layer shared by the SoC models.
+ *
+ * Each SoC provides a QcomDspMachineInfo describing its subsystem, and the
+ * layer supplies what every one of them has in common: the CPUs, a QEMU-only
+ * PL011 console, virtio-mmio slots, a generated device tree, and the
+ * -bios/-kernel/-initrd boot flow.
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_HEXAGON_QCOM_DSP_H
+#define HW_HEXAGON_QCOM_DSP_H
+
+#include "hw/hexagon/hexagon.h"
+#include "qom/object.h"
+
+#define TYPE_QCOM_DSP_MACHINE MACHINE_TYPE_NAME("qcom-dsp")
+OBJECT_DECLARE_TYPE(QcomDspMachineState, QcomDspMachineClass, QCOM_DSP_MACHINE)
+
+/* Number of virtio-mmio transports every machine provides. */
+#define QCOM_DSP_VIRTIO_COUNT 8
+
+typedef struct QcomDspMachineInfo {
+    const char *desc;
+    const char *cpu_type;
+    unsigned int cpus;
+    Rev_t rev;
+    const struct hexagon_machine_config *cfg;
+    /* Where the H2 loadlinux of this SoC expects to find the Linux kernel. */
+    hwaddr kernel_addr;
+    /* Add the devices that are specific to this SoC; may be NULL. */
+    void (*init_devices)(MachineState *ms);
+} QcomDspMachineInfo;
+
+struct QcomDspMachineState {
+    HexagonCommonMachineState parent_obj;
+
+    MemoryRegion tcm;
+    MemoryRegion l2_ecc;
+    int fdt_size;
+    hwaddr fdt_addr;
+    char *firmware_path;
+};
+
+struct QcomDspMachineClass {
+    MachineClass parent_class;
+
+    const QcomDspMachineInfo *info;
+};
+
+/* Describes a register window the machine stubs out as unimplemented. */
+typedef struct QcomDspRegion {
+    const char *name;
+    hwaddr base;
+    /* Zero means one 4 KiB page. */
+    hwaddr size;
+} QcomDspRegion;
+
+/*
+ * Stub out register windows the guest may probe, named
+ * "<machine>.<name>@<base>".
+ */
+void qcom_dsp_add_regions(MachineState *ms, const QcomDspRegion *regions,
+                          unsigned int count);
+
+/* Create the sysbus device @type and map it at @base. */
+void qcom_dsp_add_device(const char *type, hwaddr base);
+
+/*
+ * Stub out @ports consecutive QUP GENI serial engines of @size bytes.  They
+ * belong to the SoC @soc rather than to the DSP.
+ */
+void qcom_soc_add_qup_geni_ports(const char *soc, hwaddr base,
+                                 unsigned int ports, hwaddr size);
+
+/* Class init for a machine type whose class_data is a QcomDspMachineInfo. */
+void qcom_dsp_class_init(ObjectClass *oc, const void *data);
+
+#endif /* HW_HEXAGON_QCOM_DSP_H */
hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc new file +65 -0
new file mode 100644
index 00000000000..11302da2238
@@ -0,0 +1,65 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+static const struct hexagon_machine_config qcs6490_cdsp = {
+    .ddr_base =          0x80000000,
+    .cfgbase =           0x09980000,
+    .l2tcm_size =        0x00000000,
+    .l2vic_base =        0x0a390000,
+    .l2vic_size =        0x00001000,
+    .csr_base =          0x0a3a0000,
+    .qtmr_region =       0x0a3a1000,
+    .cfgtable = {
+        .l2tcm_base = 0x00000980,
+        .reserved0 = 0x00000000,
+        .subsystem_base = 0x00000a38,
+        .etm_base = 0x00000999,
+        .l2cfg_base = 0x0000099a,
+        .reserved1 = 0x0000099b,
+        .l1s0_base = 0x000009c0,
+        .axi2_lowaddr = 0x00000000,
+        .streamer_base = 0x0000099c,
+        .reserved2 = 0x0000099d,
+        .fastl2vic_base = 0x0000099e,
+        .jtlb_size_entries = 0x00000080,
+        .coproc_present = 0x00000001,
+        .ext_contexts = 0x00000002,
+        .vtcm_base = 0x000009c0,
+        .vtcm_size_kb = 0x00000800,
+        .l2tag_size = 0x00000400,
+        .l2ecomem_size = 0x00000400,
+        .thread_enable_mask = 0x0000003f,
+        .eccreg_base = 0x0000099f,
+        .l2line_size = 0x00000080,
+        .tiny_core = 0x00000000,
+        .l2itcm_size = 0x00000000,
+        .l2itcm_base = 0x00000980,
+        .reserved3 = 0x00000000,
+        .dtm_present = 0x00000000,
+        .dma_version = 0x00000001,
+        .hvx_vec_log_length = 0x00000007,
+        .core_id = 0x00000000,
+        .core_count = 0x00000000,
+        .coproc2_reg0 = 0x00000040,
+        .coproc2_reg1 = 0x00000020,
+        .v2x_mode = 0x00000001,
+        .coproc2_reg2 = 0x00000002,
+        .coproc2_reg3 = 0x00000000,
+        .coproc2_reg4 = 0x00000000,
+        .coproc2_reg5 = 0x00000000,
+        .coproc2_reg6 = 0x00000000,
+        .coproc2_reg7 = 0x00000000,
+        .acd_preset = 0x00000001,
+        .mnd_preset = 0x00000001,
+        .l1d_size_kb = 0x00000010,
+        .l1i_size_kb = 0x00000020,
+        .l1d_write_policy = 0x00000002,
+        .vtcm_bank_width = 0x00000040,
+        .reserved4 = 0x00000001,
+        .reserved5 = 0x00000000,
+        .reserved6 = 0x00000000,
+        .coproc2_cvt_mpy_size = 0x0000000a,
+        .consistency_domain = 0x00000000,
+        .capacity_domain = 0x00000000,
+        .axi3_lowaddr = 0x00000000,
+    },
+};
hw/hexagon/qcom_dsp.c new file +225 -0
new file mode 100644
index 00000000000..5520366bb28
@@ -0,0 +1,399 @@
+/*
+ * DSP subsystem machines: the board layer shared by the SoC models.
+ *
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "hw/core/boards.h"
+#include "hw/core/loader.h"
+#include "hw/core/sysbus.h"
+#include "hw/hexagon/hexagon.h"
+#include "hw/hexagon/hex-board.h"
+#include "hw/hexagon/hex-subsys.h"
+#include "hw/hexagon/qcom_dsp.h"
+#include "hw/misc/unimp.h"
+#include "qemu/datadir.h"
+#include "qemu/error-report.h"
+#include "qemu/units.h"
+#include "system/address-spaces.h"
+#include "system/device_tree.h"
+
+enum {
+    QCOM_DSP_UART0,
+    QCOM_DSP_VIRTIO,
+    QCOM_DSP_GPT,
+    QCOM_DSP_BOOT,
+};
+
+static const MemMapEntry qcom_dsp_memmap[] = {
+    [QCOM_DSP_UART0] = { 0x37000000, 0x00001000 },
+    [QCOM_DSP_VIRTIO] = { 0x37010000, 0x00001000 },
+    /* Not a device: the window the kernel's H2 timer driver binds to. */
+    [QCOM_DSP_GPT] = { 0xab000000, 0x00001000 },
+    [QCOM_DSP_BOOT] = { 0x99c00000, 0x00000200 },
+};
+
+static const int QCOM_DSP_UART0_IRQ = 15;
+/* Virtio IRQs run from QCOM_DSP_VIRTIO_IRQ to QCOM_DSP_VIRTIO_IRQ + 7 */
+static const int QCOM_DSP_VIRTIO_IRQ = 96;
+static const int QCOM_DSP_GPT_IRQ = 12;
+
+#define QCOM_DSP_L2_ECC_SIZE 0x1000
+
+#define QCOM_DSP_MAX_KERNEL_RAM (896 * MiB)
+
+static const uint32_t bootloader[] = {
+    /* Load fdt_base_low value into r0: */
+    0x099c4000, /* { immext(#0x99c00000) */
+    0x7800c606, /*   r6 = ##-0x662fffd0 } */
+    0x9186c000, /* { r0 = memw(r6+#0x0) } */
+
+    /* Load fdt_base_high value into r1: */
+    0x099c4000, /* { immext(#0x99c00000) */
+    0x7800c586, /*   r6 = ##-0x662fffd4 } */
+    0x9186c001, /* { r1 = memw(r6+#0x0) } */
+
+    /* Load next_stage_entry value into r7: */
+    0x099c4000, /* { immext(#0x99c00000) */
+    0x7800c687, /*   r7 = ##-0x662fffcc } */
+    0x9187c007, /* { r7 = memw(r7+#0x0) } */
+
+    /* Jump to next_stage_entry, r1:0 now contains fdt_base: */
+    0x5287c000, /* { jumpr r7 } */
+    0x0, /* Invalid packet */
+    0x0, /* Pad for fdt_base_high */
+    0x0, /* Pad for fdt_base_low */
+    0x0, /* Pad for next_stage_entry */
+};
+
+enum {
+    FDT_HI = 11,
+    FDT_LO,
+    ENTRY_ADDR,
+};
+
+static const QcomDspMachineInfo *qcom_dsp_info(MachineState *ms)
+{
+    return QCOM_DSP_MACHINE_GET_CLASS(ms)->info;
+}
+
+void qcom_dsp_add_regions(MachineState *ms, const QcomDspRegion *regions,
+                          unsigned int count)
+{
+    const char *machine = MACHINE_GET_CLASS(ms)->name;
+
+    for (unsigned int i = 0; i < count; i++) {
+        g_autofree char *name = g_strdup_printf("%s.%s@%" HWADDR_PRIx, machine,
+                                                regions[i].name,
+                                                regions[i].base);
+
+        create_unimplemented_device(name, regions[i].base,
+                                    regions[i].size ? regions[i].size : 0x1000);
+    }
+}
+
+void qcom_dsp_add_device(const char *type, hwaddr base)
+{
+    DeviceState *dev = qdev_new(type);
+
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
+}
+
+void qcom_soc_add_qup_geni_ports(const char *soc, hwaddr base,
+                                 unsigned int ports, hwaddr size)
+{
+    for (unsigned int i = 0; i < ports; i++) {
+        g_autofree char *name = g_strdup_printf("%s.qup-geni@%" HWADDR_PRIx,
+                                                soc, base + i * size);
+
+        create_unimplemented_device(name, base + i * size, size);
+    }
+}
+
+/*
+ * The firmware programs the L2 ECC registers and polls them until what it
+ * wrote reads back, so they need to hold state.
+ */
+static void qcom_dsp_add_l2_ecc_regs(QcomDspMachineState *qms,
+                                     const QcomDspMachineInfo *info)
+{
+    hwaddr base = (hwaddr)info->cfg->cfgtable.eccreg_base << 16;
+
+    if (!base) {
+        return;
+    }
+    memory_region_init_ram(&qms->l2_ecc, NULL, "l2-ecc-regs",
+                           QCOM_DSP_L2_ECC_SIZE, &error_fatal);
+    memory_region_add_subregion(get_system_memory(), base, &qms->l2_ecc);
+}
+
+static void qcom_dsp_create_fdt(QcomDspMachineState *qms)
+{
+    MachineState *ms = MACHINE(qms);
+    g_autofree char *compatible = g_strdup_printf("qcom,%s",
+                                             MACHINE_GET_CLASS(ms)->name);
+
+    hex_board_create_fdt(ms, MACHINE_GET_CLASS(ms)->desc, compatible,
+                         &qms->fdt_size);
+    qemu_fdt_setprop_string(ms->fdt, "/soc", "compatible", "simple-bus");
+}
+
+/*
+ * The H2 hypervisor provides the guest timer through hypercalls, so this
+ * node only tells the kernel's timer driver which interrupt to expect.
+ */
+static void qcom_dsp_fdt_add_gpt(MachineState *ms)
+{
+    static const char compat[] = "qcom,h2-timer\0hvm-timer";
+    g_autofree char *name = g_strdup_printf("/soc/gpt@%" PRIx64,
+                                            qcom_dsp_memmap[QCOM_DSP_GPT].base);
+
+    qemu_fdt_add_subnode(ms->fdt, name);
+    qemu_fdt_setprop(ms->fdt, name, "compatible", compat, sizeof(compat));
+    qemu_fdt_setprop_cells(ms->fdt, name, "interrupts", QCOM_DSP_GPT_IRQ, 0);
+    qemu_fdt_setprop_cells(ms->fdt, name, "reg", 0x0,
+                           qcom_dsp_memmap[QCOM_DSP_GPT].base,
+                           qcom_dsp_memmap[QCOM_DSP_GPT].size);
+}
+
+static void qcom_dsp_fdt_add_memory(MachineState *ms)
+{
+    hwaddr kernel_addr = qcom_dsp_info(ms)->kernel_addr;
+    hwaddr ram_end = qcom_dsp_info(ms)->cfg->ddr_base + ms->ram_size;
+    hwaddr size = MIN(ram_end - kernel_addr, QCOM_DSP_MAX_KERNEL_RAM);
+    g_autofree char *nodename = g_strdup_printf("/memory@%" HWADDR_PRIx,
+                                                kernel_addr);
+
+    qemu_fdt_add_subnode(ms->fdt, nodename);
+    qemu_fdt_setprop_string(ms->fdt, nodename, "device_type", "memory");
+    qemu_fdt_setprop_cells(ms->fdt, nodename, "reg", 0, kernel_addr,
+                           size);
+}
+
+static uint64_t qcom_dsp_kernel_translate(void *opaque, uint64_t addr)
+{
+    return addr + qcom_dsp_info(MACHINE(opaque))->kernel_addr;
+}
+
+static uint64_t qcom_dsp_load_kernel(MachineState *ms, bool through_firmware,
+                                     hwaddr *image_high)
+{
+    return hex_board_load_elf(ms->kernel_filename,
+                              through_firmware ? qcom_dsp_kernel_translate
+                                               : NULL,
+                              ms, image_high);
+}
+
+static uint64_t qcom_dsp_load_firmware(QcomDspMachineState *qms)
+{
+    return hex_board_load_elf(qms->firmware_path, NULL, NULL, NULL);
+}
+
+/*
+ * Place the FDT after the kernel image, inside the RAM window the kernel
+ * maps, and the initrd after that.
+ */
+static void qcom_dsp_load_initrd(QcomDspMachineState *qms)
+{
+    MachineState *ms = MACHINE(qms);
+    hwaddr start = qms->fdt_addr + 4 * MiB;
+    hwaddr ram_end = qcom_dsp_info(ms)->cfg->ddr_base + ms->ram_size;
+    ssize_t size;
+
+    if (!ms->initrd_filename) {
+        return;
+    }
+
+    if (start >= ram_end) {
+        error_report("no room for the initrd: RAM ends at 0x%" HWADDR_PRIx
+                     " but the initrd would start at 0x%" HWADDR_PRIx,
+                     ram_end, start);
+        exit(1);
+    }
+
+    size = load_image_targphys_as(ms->initrd_filename, start, ram_end - start,
+                                  &address_space_memory, &error_fatal);
+
+    qemu_fdt_setprop_u64(ms->fdt, "/chosen", "linux,initrd-start", start);
+    qemu_fdt_setprop_u64(ms->fdt, "/chosen", "linux,initrd-end", start + size);
+}
+
+/*

hw/hexagon/qcom_dsp.c line 235

Quoted 10 lines
hw/hexagon/qcom_dsp.c new file +10 -0
+ * A boot stub that passes the FDT address to the firmware in r1:r0, then
+ * jumps to the firmware's entry point.
+ */
+static uint64_t qcom_dsp_setup_boot_stub(QcomDspMachineState *qms,
+                                         uint64_t firmware_entry)
+{
+    hwaddr bootl_base = qcom_dsp_memmap[QCOM_DSP_BOOT].base;
+    uint32_t stub[ARRAY_SIZE(bootloader)];
+
+    memcpy(stub, bootloader, sizeof(stub));

Maybe I'm missing something, but wouldn't we need to endian swap the instruction words in bootloader on big-endian hosts?

Quoted 43 lines
hw/hexagon/qcom_dsp.c new file +43 -0
+    stub[FDT_LO] = cpu_to_le32(extract64(qms->fdt_addr, 0, 32));
+    stub[FDT_HI] = cpu_to_le32(extract64(qms->fdt_addr, 32, 32));
+    stub[ENTRY_ADDR] = cpu_to_le32(extract64(firmware_entry, 0, 32));
+
+    g_assert(sizeof(stub) <= qcom_dsp_memmap[QCOM_DSP_BOOT].size);
+    rom_add_blob_fixed_as("bootloader", stub, sizeof(stub), bootl_base,
+                          &address_space_memory);
+
+    return bootl_base;
+}
+
+/* Reject boot options that do not make sense together, and find -bios. */
+static void qcom_dsp_check_boot_options(QcomDspMachineState *qms)
+{
+    MachineState *ms = MACHINE(qms);
+    hwaddr ddr_base = qcom_dsp_info(ms)->cfg->ddr_base;
+    hwaddr kernel_addr = qcom_dsp_info(ms)->kernel_addr;
+
+    if (ms->firmware) {
+        qms->firmware_path = qemu_find_file(QEMU_FILE_TYPE_BIOS, ms->firmware);
+        if (!qms->firmware_path) {
+            error_report("Could not find firmware '%s'", ms->firmware);
+            exit(1);
+        }
+    }
+
+    if (ms->initrd_filename && !(ms->kernel_filename && qms->firmware_path)) {
+        error_report("-initrd needs both -kernel and the H2 loadlinux "
+                     "firmware given with -bios");
+        exit(1);
+    }
+
+    if (ms->kernel_filename && qms->firmware_path &&
+        (ddr_base > qcom_dsp_memmap[QCOM_DSP_BOOT].base ||
+         ddr_base + ms->ram_size <= kernel_addr)) {
+        error_report("RAM (%" PRIu64 " MiB at 0x%" HWADDR_PRIx ") is too "
+                     "small: the kernel is loaded at 0x%" HWADDR_PRIx,
+                     ms->ram_size / MiB, ddr_base, kernel_addr);
+        exit(1);
+    }
+}
+
+/* Load what -bios and -kernel name and return where CPU 0 starts, if known. */

hw/hexagon/qcom_dsp.c line 288

Quoted 10 lines
hw/hexagon/qcom_dsp.c new file +10 -0
+static bool qcom_dsp_load_images(QcomDspMachineState *qms, uint64_t *start)
+{
+    MachineState *ms = MACHINE(qms);
+    hwaddr image_high = 0;
+
+    if (ms->kernel_filename && qms->firmware_path) {
+        uint64_t firmware_entry = qcom_dsp_load_firmware(qms);
+
+        qcom_dsp_load_kernel(ms, true, &image_high);
+        qms->fdt_addr = QEMU_ALIGN_UP(image_high + 16 * MiB, 4 * MiB);

checks against ram_end only occur when -initrd is specified in qcom_dsp_load_initrd(), so without -initrd you could get a fdt_addr that's outside the range of ram.

Quoted 15 lines
hw/hexagon/qcom_dsp.c new file +15 -0
+        qcom_dsp_load_initrd(qms);
+        *start = qcom_dsp_setup_boot_stub(qms, firmware_entry);
+        return true;
+    }
+    if (ms->kernel_filename) {
+        *start = qcom_dsp_load_kernel(ms, false, &image_high);
+        return true;
+    }
+    if (qms->firmware_path) {
+        *start = qcom_dsp_load_firmware(qms);
+        return true;
+    }
+    return false;
+}
+
Signature · 2 lines
Anton Johansson
rev.ng Labs Srl.
author
#15 lore raw

PATCH 7/14 hw/hexagon: add the SA8775P CDSP machine

In reply to Brian Cain
---
 hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc |  6 ++-
 hw/hexagon/sa8775p_cdsp.c                 | 59 +++++++++++++++++++++++
 tests/qtest/l2vic-test.c                  |  2 +
 tests/qtest/qcom-dsp-test.c               |  1 +
 tests/qtest/qct-qtimer-test.c             |  2 +
 hw/hexagon/Kconfig                        |  6 +++
 hw/hexagon/meson.build                    |  1 +
 7 files changed, 76 insertions(+), 1 deletion(-)
 create mode 100644 hw/hexagon/sa8775p_cdsp.c
hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc +5 -1
index 442cbe3be31..7e2ef42b9e2 100644
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 
 static const struct hexagon_machine_config SA8775P_cdsp0 = {
+    .ddr_base =        0x80000000,
     .cfgbase =         0x24000000 + 0x180000,
     .l2tcm_size =      0x00000000,
     .l2vic_base =      0x26300000 + 0x90000,
@@ -25,7 +26,7 @@ static const struct hexagon_machine_config SA8775P_cdsp0 = {
         .vtcm_base = 0x00002500,
         .vtcm_size_kb = 0x00002000,
         .l2tag_size = 0x00000400,
-        .l2ecomem_size = 0x00000000,
+        .l2ecomem_size = 0x00000400,
         .thread_enable_mask = 0x0000003f,
         .eccreg_base = 0x0000241f,
         .l2line_size = 0x00000080,
@@ -60,5 +61,8 @@ static const struct hexagon_machine_config SA8775P_cdsp0 = {
         .consistency_domain = 0x000000e0,
         .capacity_domain = 0x00000080,
         .axi3_lowaddr = 0x00000000,
+        .coproc2_int8_subcolumns = 0x00000002,
+        .corecfg_present = 0x00000005,
+        .coproc2_fp16_acc_exp = 0x00000007,
     },
 };
hw/hexagon/sa8775p_cdsp.c new file +59 -0

59 lines not on this page · raw message

tests/qtest/l2vic-test.c +2 -0
index 2e0d7dcb0f1..5d30d18a9fd 100644
@@ -12,6 +12,7 @@
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
+#include "hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc"
 
 /* L2VIC register offsets exercised by this test */
 #define L2VIC_INT_ENABLEn 0x100 /* Read/Write */
@@ -47,6 +48,7 @@ static const L2VICMachineCfg l2vic_machines[] = {
     { "virt",      &v68n_1024 },
     { "V66G_1024", &v66g_1024 },
     { "qcs6490-cdsp", &qcs6490_cdsp },
+    { "sa8775p-cdsp", &SA8775P_cdsp0 },
 };
 
 static uint32_t l2vic_read32(uint64_t base, uint32_t offset)
tests/qtest/qcom-dsp-test.c +1 -0
index 39d6e53bc4e..586e113c181 100644
@@ -24,6 +24,7 @@
 
 static const char *const qcom_dsp_machines[] = {
     "qcs6490-cdsp",
+    "sa8775p-cdsp",
 };
 
 static void test_console(const void *machine)
tests/qtest/qct-qtimer-test.c +2 -0
index 263751b55bf..b20d4a2bced 100644
@@ -13,6 +13,7 @@
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
+#include "hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc"
 
 #define QTIMER_DEFAULT_FREQ_HZ 19200000ULL
 
@@ -344,6 +345,7 @@ static const QtimerMachineCfg qtimer_machines[] = {
     { "virt",      &v68n_1024 },
     { "V66G_1024", &v66g_1024 },
     { "qcs6490-cdsp", &qcs6490_cdsp },
+    { "sa8775p-cdsp", &SA8775P_cdsp0 },
 };
 
 static void test_qtimer_on_machine(gconstpointer data)
hw/hexagon/Kconfig +6 -0
index ffc8623691c..bdda7872878 100644
@@ -36,3 +36,9 @@ config HEX_QCS6490_CDSP
     default y
     depends on HEX_DSP && FDT
     select HEX_QCOM_DSP
+
+config HEX_SA8775P_CDSP
+    bool
+    default y
+    depends on HEX_DSP && FDT
+    select HEX_QCOM_DSP
hw/hexagon/meson.build +1 -0
index 7145e8a65df..b7496426c9a 100644
@@ -8,5 +8,6 @@ hexagon_ss.add(when: 'CONFIG_HEX_BOARD', if_true: files('hex-board.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_QCOM_DSP', if_true: files('qcom_dsp.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_QCS6490_CDSP', if_true: files('qcs6490_cdsp.c'))
+hexagon_ss.add(when: 'CONFIG_HEX_SA8775P_CDSP', if_true: files('sa8775p_cdsp.c'))
 
 hw_arch += {'hexagon': hexagon_ss}
Signature · 1 line
2.34.1
Reviewed-by on v1 7/14
#16 lore raw

Re: [PATCH 07/14] hw/hexagon: add the SA8775P CDSP machine

Quoted 12 lines · Brian Cain
---
 hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc |  6 ++-
 hw/hexagon/sa8775p_cdsp.c                 | 59 +++++++++++++++++++++++
 tests/qtest/l2vic-test.c                  |  2 +
 tests/qtest/qcom-dsp-test.c               |  1 +
 tests/qtest/qct-qtimer-test.c             |  2 +
 hw/hexagon/Kconfig                        |  6 +++
 hw/hexagon/meson.build                    |  1 +
 7 files changed, 76 insertions(+), 1 deletion(-)
 create mode 100644 hw/hexagon/sa8775p_cdsp.c
author
#17 lore raw

PATCH 8/14 hw/hexagon: add the SC8480XP NSP0 machine

In reply to Brian Cain
---
 include/hw/hexagon/hexagon.h               |  1 +
 hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc | 52 +++++++++++++
 hw/hexagon/sc8480xp_nsp0.c                 | 90 ++++++++++++++++++++++
 tests/qtest/l2vic-test.c                   |  2 +
 tests/qtest/qcom-dsp-test.c                |  1 +
 tests/qtest/qct-qtimer-test.c              |  2 +
 hw/hexagon/Kconfig                         |  6 ++
 hw/hexagon/meson.build                     |  1 +
 8 files changed, 155 insertions(+)
 create mode 100644 hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc
 create mode 100644 hw/hexagon/sc8480xp_nsp0.c
include/hw/hexagon/hexagon.h +1 -0
index 1d0d55ea938..5f993214784 100644
@@ -29,6 +29,7 @@ typedef enum {
     v73_rev = 0x8c73,
     v73m_rev = 0xcc73,
     v81_rev = 0x8781,
+    v81_sc8480xp_rev = 0x8081,
     v81dgb_1_rev = 0xcc81,
 } Rev_t;
 #define HEXAGON_LATEST_REV v73
hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc new file +52 -0

52 lines not on this page · raw message

hw/hexagon/sc8480xp_nsp0.c new file +90 -0

90 lines not on this page · raw message

tests/qtest/l2vic-test.c +2 -0
index 5d30d18a9fd..7afeabdbed8 100644
@@ -12,6 +12,7 @@
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
+#include "hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc"
 
 /* L2VIC register offsets exercised by this test */
@@ -49,6 +50,7 @@ static const L2VICMachineCfg l2vic_machines[] = {
     { "V66G_1024", &v66g_1024 },
     { "qcs6490-cdsp", &qcs6490_cdsp },
     { "sa8775p-cdsp", &SA8775P_cdsp0 },
+    { "sc8480xp-nsp0", &sc8480xp_nsp0 },
 };
 
 static uint32_t l2vic_read32(uint64_t base, uint32_t offset)
tests/qtest/qcom-dsp-test.c +1 -0
index 586e113c181..46bbae47881 100644
@@ -25,6 +25,7 @@
 static const char *const qcom_dsp_machines[] = {
     "qcs6490-cdsp",
     "sa8775p-cdsp",
+    "sc8480xp-nsp0",
 };
 
 static void test_console(const void *machine)
tests/qtest/qct-qtimer-test.c +2 -0
index b20d4a2bced..629a11802ef 100644
@@ -13,6 +13,7 @@
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
+#include "hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc"
 
 #define QTIMER_DEFAULT_FREQ_HZ 19200000ULL
@@ -346,6 +347,7 @@ static const QtimerMachineCfg qtimer_machines[] = {
     { "V66G_1024", &v66g_1024 },
     { "qcs6490-cdsp", &qcs6490_cdsp },
     { "sa8775p-cdsp", &SA8775P_cdsp0 },
+    { "sc8480xp-nsp0", &sc8480xp_nsp0 },
 };
 
 static void test_qtimer_on_machine(gconstpointer data)
hw/hexagon/Kconfig +6 -0
index bdda7872878..8785129da0e 100644
@@ -42,3 +42,9 @@ config HEX_SA8775P_CDSP
     default y
     depends on HEX_DSP && FDT
     select HEX_QCOM_DSP
+
+config HEX_SC8480XP_NSP0
+    bool
+    default y
+    depends on HEX_DSP && FDT
+    select HEX_QCOM_DSP
hw/hexagon/meson.build +1 -0
index b7496426c9a..b42a37b14de 100644
@@ -9,5 +9,6 @@ hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_QCOM_DSP', if_true: files('qcom_dsp.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_QCS6490_CDSP', if_true: files('qcs6490_cdsp.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_SA8775P_CDSP', if_true: files('sa8775p_cdsp.c'))
+hexagon_ss.add(when: 'CONFIG_HEX_SC8480XP_NSP0', if_true: files('sc8480xp_nsp0.c'))
 
 hw_arch += {'hexagon': hexagon_ss}
Signature · 1 line
2.34.1
Reviewed-by on v1 8/14
#18 lore raw

Re: [PATCH 08/14] hw/hexagon: add the SC8480XP NSP0 machine

Quoted 14 lines · Brian Cain
---
 include/hw/hexagon/hexagon.h               |  1 +
 hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc | 52 +++++++++++++
 hw/hexagon/sc8480xp_nsp0.c                 | 90 ++++++++++++++++++++++
 tests/qtest/l2vic-test.c                   |  2 +
 tests/qtest/qcom-dsp-test.c                |  1 +
 tests/qtest/qct-qtimer-test.c              |  2 +
 hw/hexagon/Kconfig                         |  6 ++
 hw/hexagon/meson.build                     |  1 +
 8 files changed, 155 insertions(+)
 create mode 100644 hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc
 create mode 100644 hw/hexagon/sc8480xp_nsp0.c
author
#19 lore raw

PATCH 9/14 hw/hexagon: add the SA8797P NSP0 machine

In reply to Brian Cain
---
 hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc | 56 +++++++++++++++++++
 hw/hexagon/sa8797p_nsp0.c                 | 68 +++++++++++++++++++++++
 tests/qtest/l2vic-test.c                  |  2 +
 tests/qtest/qcom-dsp-test.c               |  1 +
 tests/qtest/qct-qtimer-test.c             |  2 +
 hw/hexagon/Kconfig                        |  6 ++
 hw/hexagon/meson.build                    |  1 +
 7 files changed, 136 insertions(+)
 create mode 100644 hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc
 create mode 100644 hw/hexagon/sa8797p_nsp0.c
hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc new file +56 -0
new file mode 100644
index 00000000000..abc02a3e9ce
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/*
+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+ */
+
+static const struct hexagon_machine_config sa8797p_nsp0 = {
+    .ddr_base = 0x80000000,
+    .cfgbase = 0x30180000,
+    .l2vic_base = 0x32390000,
+    .l2vic_size = 0x1000,
+    .l2tcm_size = 0x100000,
+    .csr_base = 0x323a0000,
+    .qtmr_region = 0x323a1000,
+    .cfgtable = {
+        .l2tcm_base = 0x3000,
+        .subsystem_base = 0x3238,
+        .etm_base = 0x3019,
+        .l2cfg_base = 0x301a,
+        .l1s0_base = 0x3100,
+        .fastl2vic_base = 0x301e,
+        .jtlb_size_entries = 0x80,
+        .coproc_present = 0xd,
+        .ext_contexts = 8,
+        .vtcm_base = 0x3100,
+        .vtcm_size_kb = 0x4000,
+        .l2tag_size = 0x400,
+        .l2ecomem_size = 0x400,
+        .thread_enable_mask = 0xfff,
+        .eccreg_base = 0x301f,
+        .l2line_size = 0x80,
+        .l2itcm_base = 0x3000,
+        .dma_version = 8,
+        .hvx_vec_log_length = 7,
+        .coproc2_reg0 = 0x10,
+        .coproc2_reg1 = 8,
+        .v2x_mode = 1,
+        .acd_preset = 1,
+        .mnd_preset = 1,
+        .l1d_size_kb = 0x40,
+        .l1i_size_kb = 0x40,
+        .l1d_write_policy = 2,
+        .vtcm_bank_width = 0x80,
+        .reserved4 = 1,
+        .reserved6 = 3,
+        .consistency_domain = 0xe0,
+        .capacity_domain = 0x80,
+        .corecfg_present = 0xd,
+        .coproc2_fp16_acc_exp = 1,
+        .AXIM_data_width = 0x100,
+        .l1d_ways = 8,
+        .l1i_ways = 4,
+        .l2way_num = 8,
+        .dma_jtlb_entries = 0x40,
+    },
+};
hw/hexagon/sa8797p_nsp0.c new file +68 -0

68 lines not on this page · raw message

tests/qtest/l2vic-test.c +2 -0
index 7afeabdbed8..4cd0319e8b5 100644
@@ -12,6 +12,7 @@
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
+#include "hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc"
 
@@ -51,6 +52,7 @@ static const L2VICMachineCfg l2vic_machines[] = {
     { "qcs6490-cdsp", &qcs6490_cdsp },
     { "sa8775p-cdsp", &SA8775P_cdsp0 },
     { "sc8480xp-nsp0", &sc8480xp_nsp0 },
+    { "sa8797p-nsp0", &sa8797p_nsp0 },
 };
 
 static uint32_t l2vic_read32(uint64_t base, uint32_t offset)
tests/qtest/qcom-dsp-test.c +1 -0
index 46bbae47881..def389a0e9e 100644
@@ -26,6 +26,7 @@ static const char *const qcom_dsp_machines[] = {
     "qcs6490-cdsp",
     "sa8775p-cdsp",
     "sc8480xp-nsp0",
+    "sa8797p-nsp0",
 };
 
 static void test_console(const void *machine)
tests/qtest/qct-qtimer-test.c +2 -0
index 629a11802ef..21870de5649 100644
@@ -13,6 +13,7 @@
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
+#include "hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc"
 
@@ -348,6 +349,7 @@ static const QtimerMachineCfg qtimer_machines[] = {
     { "qcs6490-cdsp", &qcs6490_cdsp },
     { "sa8775p-cdsp", &SA8775P_cdsp0 },
     { "sc8480xp-nsp0", &sc8480xp_nsp0 },
+    { "sa8797p-nsp0", &sa8797p_nsp0 },
 };
 
 static void test_qtimer_on_machine(gconstpointer data)
hw/hexagon/Kconfig +6 -0
index 8785129da0e..bcf368cb8b7 100644
@@ -48,3 +48,9 @@ config HEX_SC8480XP_NSP0
     default y
     depends on HEX_DSP && FDT
     select HEX_QCOM_DSP
+
+config HEX_SA8797P_NSP0
+    bool
+    default y
+    depends on HEX_DSP && FDT
+    select HEX_QCOM_DSP
hw/hexagon/meson.build +1 -0
index b42a37b14de..5a10ae694fe 100644
@@ -10,5 +10,6 @@ hexagon_ss.add(when: 'CONFIG_HEX_QCOM_DSP', if_true: files('qcom_dsp.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_QCS6490_CDSP', if_true: files('qcs6490_cdsp.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_SA8775P_CDSP', if_true: files('sa8775p_cdsp.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_SC8480XP_NSP0', if_true: files('sc8480xp_nsp0.c'))
+hexagon_ss.add(when: 'CONFIG_HEX_SA8797P_NSP0', if_true: files('sa8797p_nsp0.c'))
 
 hw_arch += {'hexagon': hexagon_ss}
Signature · 1 line
2.34.1
Reviewed-by on v1 9/14
#20 lore raw

Re: [PATCH 09/14] hw/hexagon: add the SA8797P NSP0 machine

Quoted 13 lines · Brian Cain
---
 hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc | 56 +++++++++++++++++++
 hw/hexagon/sa8797p_nsp0.c                 | 68 +++++++++++++++++++++++
 tests/qtest/l2vic-test.c                  |  2 +
 tests/qtest/qcom-dsp-test.c               |  1 +
 tests/qtest/qct-qtimer-test.c             |  2 +
 hw/hexagon/Kconfig                        |  6 ++
 hw/hexagon/meson.build                    |  1 +
 7 files changed, 136 insertions(+)
 create mode 100644 hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc
 create mode 100644 hw/hexagon/sa8797p_nsp0.c
author
#21 lore raw

PATCH 10/14 hw/hexagon: add the SM8975 NSP machine

In reply to Brian Cain
---
 include/hw/hexagon/hexagon.h            |   1 +
 hw/hexagon/machine_cfg_sm8975_nsp.h.inc |  55 +++++++++++++
 hw/hexagon/sm8975_nsp.c                 | 102 ++++++++++++++++++++++++
 tests/qtest/l2vic-test.c                |   2 +
 tests/qtest/qcom-dsp-test.c             |  17 ++++
 tests/qtest/qct-qtimer-test.c           |   2 +
 hw/hexagon/Kconfig                      |   6 ++
 hw/hexagon/meson.build                  |   1 +
 8 files changed, 186 insertions(+)
 create mode 100644 hw/hexagon/machine_cfg_sm8975_nsp.h.inc
 create mode 100644 hw/hexagon/sm8975_nsp.c
include/hw/hexagon/hexagon.h +1 -0
index 5f993214784..26b0a1b3757 100644
@@ -31,6 +31,7 @@ typedef enum {
     v81_rev = 0x8781,
     v81_sc8480xp_rev = 0x8081,
     v81dgb_1_rev = 0xcc81,
+    v85_sm8975_rev = 0x8085,
 } Rev_t;
 #define HEXAGON_LATEST_REV v73
 #define HEXAGON_LATEST_REV_UPPER V73
hw/hexagon/machine_cfg_sm8975_nsp.h.inc new file +55 -0

55 lines not on this page · raw message

hw/hexagon/sm8975_nsp.c new file +102 -0

102 lines not on this page · raw message

tests/qtest/l2vic-test.c +2 -0
index 4cd0319e8b5..82f93fd58f9 100644
@@ -12,6 +12,7 @@
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
+#include "hw/hexagon/machine_cfg_sm8975_nsp.h.inc"
 #include "hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc"
@@ -53,6 +54,7 @@ static const L2VICMachineCfg l2vic_machines[] = {
     { "sa8775p-cdsp", &SA8775P_cdsp0 },
     { "sc8480xp-nsp0", &sc8480xp_nsp0 },
     { "sa8797p-nsp0", &sa8797p_nsp0 },
+    { "sm8975-nsp", &sm8975_nsp },
 };
 
 static uint32_t l2vic_read32(uint64_t base, uint32_t offset)
tests/qtest/qcom-dsp-test.c +17 -0
index def389a0e9e..9cca6a835d0 100644
@@ -9,6 +9,8 @@
 #include "qemu/osdep.h"
 #include "libqtest.h"
 #include "libqtest-single.h"
+#include "hw/hexagon/hexagon.h"
+#include "hw/hexagon/machine_cfg_sm8975_nsp.h.inc"
 
 #define QCOM_DSP_UART_BASE 0x37000000
 #define QCOM_DSP_VIRTIO_BASE 0x37010000
@@ -27,6 +29,7 @@ static const char *const qcom_dsp_machines[] = {
     "sa8775p-cdsp",
     "sc8480xp-nsp0",
     "sa8797p-nsp0",
+    "sm8975-nsp",
 };
 
 static void test_console(const void *machine)
@@ -76,6 +79,18 @@ static void test_default_drive(const void *machine)
     qtest_end();
 }
 
+static void test_tcm(const void *unused)
+{
+    uint64_t base = (uint64_t)sm8975_nsp.cfgtable.l2tcm_base << 16;
+
+    qtest_start("-machine sm8975-nsp");
+    writel(base, 0xdeadbeef);
+    writel(base + sm8975_nsp.l2tcm_size - 4, 0xcafef00d);
+    g_assert_cmphex(readl(base), ==, 0xdeadbeef);
+    g_assert_cmphex(readl(base + sm8975_nsp.l2tcm_size - 4), ==, 0xcafef00d);
+    qtest_end();
+}
+
 int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
@@ -92,5 +107,7 @@ int main(int argc, char **argv)
         qtest_add_data_func(path, name, test_default_drive);
     }
 
+    qtest_add_data_func("/qcom-dsp/sm8975-nsp/tcm", NULL, test_tcm);
+
     return g_test_run();
 }
tests/qtest/qct-qtimer-test.c +2 -0
index 21870de5649..b4c1b9e37f4 100644
@@ -13,6 +13,7 @@
 #include "hw/hexagon/machine_cfg_v68n_1024.h.inc"
 #include "hw/hexagon/machine_cfg_v66g_1024.h.inc"
 #include "hw/hexagon/machine_cfg_qcs6490_cdsp.h.inc"
+#include "hw/hexagon/machine_cfg_sm8975_nsp.h.inc"
 #include "hw/hexagon/machine_cfg_sa8797p_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sc8480xp_nsp0.h.inc"
 #include "hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc"
@@ -350,6 +351,7 @@ static const QtimerMachineCfg qtimer_machines[] = {
     { "sa8775p-cdsp", &SA8775P_cdsp0 },
     { "sc8480xp-nsp0", &sc8480xp_nsp0 },
     { "sa8797p-nsp0", &sa8797p_nsp0 },
+    { "sm8975-nsp", &sm8975_nsp },
 };
 
 static void test_qtimer_on_machine(gconstpointer data)
hw/hexagon/Kconfig +6 -0
index bcf368cb8b7..177d87f7f94 100644
@@ -54,3 +54,9 @@ config HEX_SA8797P_NSP0
     default y
     depends on HEX_DSP && FDT
     select HEX_QCOM_DSP
+
+config HEX_SM8975_NSP
+    bool
+    default y
+    depends on HEX_DSP && FDT
+    select HEX_QCOM_DSP
hw/hexagon/meson.build +1 -0
index 5a10ae694fe..fa5bc5eb9f1 100644
@@ -11,5 +11,6 @@ hexagon_ss.add(when: 'CONFIG_HEX_QCS6490_CDSP', if_true: files('qcs6490_cdsp.c')
 hexagon_ss.add(when: 'CONFIG_HEX_SA8775P_CDSP', if_true: files('sa8775p_cdsp.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_SC8480XP_NSP0', if_true: files('sc8480xp_nsp0.c'))
 hexagon_ss.add(when: 'CONFIG_HEX_SA8797P_NSP0', if_true: files('sa8797p_nsp0.c'))
+hexagon_ss.add(when: 'CONFIG_HEX_SM8975_NSP', if_true: files('sm8975_nsp.c'))
 
 hw_arch += {'hexagon': hexagon_ss}
Signature · 1 line
2.34.1
Reviewed-by on v1 10/14
#22 lore raw

Re: [PATCH 10/14] hw/hexagon: add the SM8975 NSP machine

Quoted 14 lines · Brian Cain
---
 include/hw/hexagon/hexagon.h            |   1 +
 hw/hexagon/machine_cfg_sm8975_nsp.h.inc |  55 +++++++++++++
 hw/hexagon/sm8975_nsp.c                 | 102 ++++++++++++++++++++++++
 tests/qtest/l2vic-test.c                |   2 +
 tests/qtest/qcom-dsp-test.c             |  17 ++++
 tests/qtest/qct-qtimer-test.c           |   2 +
 hw/hexagon/Kconfig                      |   6 ++
 hw/hexagon/meson.build                  |   1 +
 8 files changed, 186 insertions(+)
 create mode 100644 hw/hexagon/machine_cfg_sm8975_nsp.h.inc
 create mode 100644 hw/hexagon/sm8975_nsp.c
author
#23 lore raw

PATCH 11/14 hw/hexagon: add v79NA1 machine

In reply to Brian Cain

Add the Hexagon V79NA_1 simulator machine, with the config table of the v79 core and eight CPUs by default.

---
 include/hw/hexagon/hexagon.h         |  1 +
 hw/hexagon/machine_cfg_v79na_1.h.inc | 34 ++++++++++++++++++++++++++++
 hw/hexagon/hexagon_dsp.c             | 22 ++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 hw/hexagon/machine_cfg_v79na_1.h.inc
include/hw/hexagon/hexagon.h +1 -0
index 26b0a1b3757..7d15a9e1eb0 100644
@@ -28,6 +28,7 @@ typedef enum {
     v71_rev = 0x8c71,
     v73_rev = 0x8c73,
     v73m_rev = 0xcc73,
+    v79_rev = 0x8c79,
     v81_rev = 0x8781,
     v81_sc8480xp_rev = 0x8081,
     v81dgb_1_rev = 0xcc81,
hw/hexagon/machine_cfg_v79na_1.h.inc new file +34 -0
new file mode 100644
index 00000000000..70a7ae58bc5
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+static const struct hexagon_machine_config v79na_1 = {
+    .cfgbase =             0xd8180000,
+    .l2tcm_size =          0x00000000,
+    .l2vic_base =          0xfc910000,
+    .l2vic_size =          0x00001000,
+    .csr_base =            0xfc900000,
+    .qtmr_region =         0xfc921000,
+    .cfgtable = {
+        .l2tcm_base = 0x0000d800, .subsystem_base = 0x00002000,
+        .etm_base = 0x0000d819, .l2cfg_base = 0x0000d81a,
+        .l1s0_base = 0x0000d900, .axi2_lowaddr = 0x00003000,
+        .fastl2vic_base = 0x0000d81e, .jtlb_size_entries = 0x00000080,
+        .coproc_present = 0x0000000d, .ext_contexts = 0x00000006,
+        .vtcm_base = 0x0000d900, .vtcm_size_kb = 0x00002000,
+        .l2tag_size = 0x00000400, .l2ecomem_size = 0x00000400,
+        .thread_enable_mask = 0x000000ff, .l2line_size = 0x00000080,
+        .l2itcm_base = 0x0000d800, .dma_version = 0x00000006,
+        .hvx_vec_log_length = 0x00000007, .coproc2_reg0 = 0x00000040,
+        .coproc2_reg1 = 0x00000020, .v2x_mode = 0x00000001,
+        .coproc2_reg2 = 0x00000010, .coproc2_reg3 = 0x00000020,
+        .coproc2_reg4 = 0x00000020, .coproc2_reg5 = 0x00000008,
+        .coproc2_reg6 = 0x00000016, .coproc2_reg7 = 0x00000008,
+        .acd_preset = 0x00000001, .mnd_preset = 0x00000001,
+        .l1d_size_kb = 0x00000020, .l1i_size_kb = 0x00000020,
+        .l1d_write_policy = 0x00000002, .vtcm_bank_width = 0x00000080,
+        .reserved4 = 0x00000001, .coproc2_cvt_mpy_size = 0x0000000a,
+        .consistency_domain = 0x000000e0, .capacity_domain = 0x00000080,
+        .axi3_lowaddr = 0x00004000, .coproc2_int8_subcolumns = 0x00000002,
+        .corecfg_present = 0x0000000d, .coproc2_fp16_acc_exp = 0x00000007,
+        .AXIM2_secondary_base = 0x00004000, .AXIM_data_width = 0x00000100,
+    },
+};
hw/hexagon/hexagon_dsp.c +22 -0
index 8824fe10a59..9f6f34ef9be 100644
@@ -30,6 +30,7 @@
 
 #include "machine_cfg_v66g_1024.h.inc"
 #include "machine_cfg_v68n_1024.h.inc"
+#include "machine_cfg_v79na_1.h.inc"
 #include "machine_cfg_v81dgb_1.h.inc"
 #include "machine_cfg_v81qa_1.h.inc"
 
@@ -205,6 +206,22 @@ static void v81dgb_1_config_init(MachineState *machine)
     hexagon_common_init(machine, v81dgb_1_rev, &v81dgb_1);
 }
 
+static void v79na_1_config_init(MachineState *machine)
+{
+    hexagon_common_init(machine, v79_rev, &v79na_1);
+}
+
+static void v79na_1_init(ObjectClass *oc, const void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "Hexagon V79NA_1";
+    mc->init = v79na_1_config_init;
+    init_mc(mc);
+    mc->default_cpu_type = TYPE_HEXAGON_CPU_V79;
+    mc->default_cpus = 8;
+}
+
 static void v81dgb_1_init(ObjectClass *oc, const void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -258,6 +275,11 @@ static const TypeInfo hexagon_machine_types[] = {
         .parent = TYPE_HEXAGON_DSP_MACHINE,
         .class_init = v68n_1024_init,
     },
+    {
+        .name = MACHINE_TYPE_NAME("V79NA_1"),
+        .parent = TYPE_HEXAGON_DSP_MACHINE,
+        .class_init = v79na_1_init,
+    },
     {
         .name = MACHINE_TYPE_NAME("V81DGB_1"),
         .parent = TYPE_HEXAGON_DSP_MACHINE,
Signature · 1 line
2.34.1
Reviewed-by on v1 11/14
#24 lore raw

Re: [PATCH 11/14] hw/hexagon: add v79NA1 machine

Quoted 11 lines · Brian Cain

Add the Hexagon V79NA_1 simulator machine, with the config table of the v79 core and eight CPUs by default.

---
 include/hw/hexagon/hexagon.h         |  1 +
 hw/hexagon/machine_cfg_v79na_1.h.inc | 34 ++++++++++++++++++++++++++++
 hw/hexagon/hexagon_dsp.c             | 22 ++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 hw/hexagon/machine_cfg_v79na_1.h.inc
author
#25 lore raw

PATCH 12/14 hw/hexagon: add subsystem-base property

In reply to Brian Cain

Let the hexagon-sim-style machines their QDSP6 subsystem, and with it the l2vic and QTimer.

The config table's subsystem base is updated to align with the chosen address.

---
 MAINTAINERS                       |  1 +
 include/hw/hexagon/hexagon.h      |  4 ++
 hw/hexagon/hexagon_dsp.c          | 62 +++++++++++++++++++++++-
 tests/qtest/hexagon-config-test.c | 78 +++++++++++++++++++++++++++++++
 tests/qtest/meson.build           |  3 +-
 5 files changed, 146 insertions(+), 2 deletions(-)
 create mode 100644 tests/qtest/hexagon-config-test.c
MAINTAINERS +1 -0
index 04df9db77dc..f1fbc971fed 100644
@@ -1386,6 +1386,7 @@ F: include/hw/misc/qcom-qdsp6ss-clk.h
 F: configs/devices/hexagon-softmmu/default.mak
 F: docs/system/hexagon/
 F: tests/functional/hexagon/
+F: tests/qtest/hexagon-config-test.c
 F: tests/qtest/qcom-dsp-test.c
 F: docs/devel/hexagon-sys.rst
 
include/hw/hexagon/hexagon.h +4 -0
index 7d15a9e1eb0..32acc2aa26b 100644
@@ -44,6 +44,10 @@ typedef enum {
 
 #define HEXAGON_CFGSPACE_ENTRIES (128)
 
+/* Offsets of q6ss cfg peripherals from the subsystem base. */
+#define HEXAGON_L2VIC_OFFSET  0x10000
+#define HEXAGON_QTIMER_OFFSET 0x21000
+
 union hexagon_config_table {
     struct {
         /* Base address of L2TCM space */
hw/hexagon/hexagon_dsp.c +61 -1

128 lines not on this page · raw message

tests/qtest/hexagon-config-test.c new file +78 -0

78 lines not on this page · raw message

tests/qtest/meson.build +2 -1
index 0bbca236659..1cbf8cd391a 100644
@@ -320,7 +320,8 @@ qtests_riscv64 = ['riscv-csr-test'] + \
    ['k230-ddr-test', 'k230-wdt-test', 'k230-gsdma-test', 'k230-decomp-gzip-test'] : []) + \
    ['milkv-duo-test']
 
-qtests_hexagon = ['boot-serial-test', 'l2vic-test', 'qcom-dsp-test',
+qtests_hexagon = ['boot-serial-test', 'hexagon-config-test', 'l2vic-test',
+                  'qcom-dsp-test',
                   'qct-qtimer-test']
 
 qos_test_ss = ss.source_set()
Signature · 1 line
2.34.1
Reviewed-by on v1 12/14
#26 lore raw

Re: [PATCH 12/14] hw/hexagon: add subsystem-base property

Quoted 7 lines · Brian Cain

Let the hexagon-sim-style machines their QDSP6 subsystem, and with it the l2vic and QTimer.

The config table's subsystem base is updated to align with the chosen address.

Quoted 9 lines
---
 MAINTAINERS                       |  1 +
 include/hw/hexagon/hexagon.h      |  4 ++
 hw/hexagon/hexagon_dsp.c          | 62 +++++++++++++++++++++++-
 tests/qtest/hexagon-config-test.c | 78 +++++++++++++++++++++++++++++++
 tests/qtest/meson.build           |  3 +-
 5 files changed, 146 insertions(+), 2 deletions(-)
 create mode 100644 tests/qtest/hexagon-config-test.c
#27 lore raw

Re: [PATCH 12/14] hw/hexagon: add subsystem-base property

In reply to Brian Cain
Quoted 124 lines · Brian Cain

Let the hexagon-sim-style machines their QDSP6 subsystem, and with it the l2vic and QTimer.

The config table's subsystem base is updated to align with the chosen address.

---
 MAINTAINERS                       |  1 +
 include/hw/hexagon/hexagon.h      |  4 ++
 hw/hexagon/hexagon_dsp.c          | 62 +++++++++++++++++++++++-
 tests/qtest/hexagon-config-test.c | 78 +++++++++++++++++++++++++++++++
 tests/qtest/meson.build           |  3 +-
 5 files changed, 146 insertions(+), 2 deletions(-)
 create mode 100644 tests/qtest/hexagon-config-test.c
MAINTAINERS +1 -0
index 04df9db77dc..f1fbc971fed 100644
@@ -1386,6 +1386,7 @@ F: include/hw/misc/qcom-qdsp6ss-clk.h
 F: configs/devices/hexagon-softmmu/default.mak
 F: docs/system/hexagon/
 F: tests/functional/hexagon/
+F: tests/qtest/hexagon-config-test.c
 F: tests/qtest/qcom-dsp-test.c
 F: docs/devel/hexagon-sys.rst
 
include/hw/hexagon/hexagon.h +4 -0
index 7d15a9e1eb0..32acc2aa26b 100644
@@ -44,6 +44,10 @@ typedef enum {
 
 #define HEXAGON_CFGSPACE_ENTRIES (128)
 
+/* Offsets of q6ss cfg peripherals from the subsystem base. */
+#define HEXAGON_L2VIC_OFFSET  0x10000
+#define HEXAGON_QTIMER_OFFSET 0x21000
+
 union hexagon_config_table {
     struct {
         /* Base address of L2TCM space */
hw/hexagon/hexagon_dsp.c +48 -0
index 9f6f34ef9be..1f92a8adccf 100644
@@ -17,6 +17,7 @@
 #include "hw/hexagon/hex-subsys.h"
 #include "hw/core/loader.h"
 #include "qapi/error.h"
+#include "qapi/visitor.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "elf.h"
@@ -35,6 +36,7 @@
 #include "machine_cfg_v81qa_1.h.inc"
 
 #define TYPE_HEXAGON_DSP_MACHINE "hexagon-dsp-machine"
+#define HEXAGON_DSP_SUBSYSTEM_BASE 0xfc900000
 OBJECT_DECLARE_SIMPLE_TYPE(HexagonDspMachineState, HEXAGON_DSP_MACHINE)
 
 struct HexagonDspMachineState {
@@ -42,6 +44,8 @@ struct HexagonDspMachineState {
 
     hwaddr isdb_secure_flag;
     hwaddr isdb_trusted_flag;
+    uint32_t subsystem_base;
+    struct hexagon_machine_config config;
 };
 
 static HexagonDspMachineState *current_dms;
@@ -107,6 +111,50 @@ static void do_cpu_reset(void *opaque)
     cpu_reset(cs);
 }
 
+static void hexagon_sim_get_subsystem_base(Object *obj, Visitor *v,
+                                           const char *name, void *opaque,
+                                           Error **errp)
+{
+    HexagonDspMachineState *dms = HEXAGON_DSP_MACHINE(obj);
+    uint32_t value = dms->subsystem_base;
+
+    visit_type_uint32(v, name, &value, errp);
+}
+
+static void hexagon_sim_set_subsystem_base(Object *obj, Visitor *v,
+                                           const char *name, void *opaque,
+                                           Error **errp)
+{
+    HexagonDspMachineState *dms = HEXAGON_DSP_MACHINE(obj);
+    uint32_t value;
+
+    if (!visit_type_uint32(v, name, &value, errp)) {
+        return;
+    }
+    if (!value || !QEMU_IS_ALIGNED(value, 64 * KiB)) {
+        error_setg(errp, "subsystem-base must be nonzero and 64 KiB aligned");
+        return;
+    }
+
+    dms->subsystem_base = value;
+}
+
+static void add_dsp_properties(ObjectClass *oc)
+{
+    object_class_property_add(oc, "subsystem-base", "uint32",
+                              hexagon_sim_get_subsystem_base,
+                              hexagon_sim_set_subsystem_base, NULL, NULL);
+    object_class_property_set_description(oc, "subsystem-base",
+                                          "Simulator subsystem base address");
+}
+
+static void hexagon_dsp_init(Object *obj)
+{
+    HexagonDspMachineState *dms = HEXAGON_DSP_MACHINE(obj);
+
+    dms->subsystem_base = HEXAGON_DSP_SUBSYSTEM_BASE;
+}
+
 static void hexagon_common_init(MachineState *machine, Rev_t rev,
                                 const struct hexagon_machine_config *m_cfg)
 {

hw/hexagon/hexagon_dsp.c static void hexagon_common_init(MachineState *machine, Rev_t rev, · line 175

Quoted 8 lines
hw/hexagon/hexagon_dsp.c +4 -1
@@ -121,7 +169,13 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,
 
     machine->enable_graphics = 0;
 
-    hex_subsys_create(hms, m_cfg, rev);
+    dms->config = *m_cfg;
+    dms->config.csr_base = dms->subsystem_base;
+    dms->config.l2vic_base = dms->subsystem_base + HEXAGON_L2VIC_OFFSET;
+    dms->config.qtmr_region = dms->subsystem_base + HEXAGON_QTIMER_OFFSET;

Since the only requirement on subsystem_base is that it's non-zero and 64 KiB aligned, this addition can overflow with e.g. subsystem-base=0xffff0000, adding an upper-bounds check to the set function could be nice to avoid any footguns in the future.

Quoted 12 lines
hw/hexagon/hexagon_dsp.c +4 -0
+    dms->config.cfgtable.subsystem_base = dms->subsystem_base >> 16;
+
+    hex_subsys_create(hms, &dms->config, rev);
 
     g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, machine->smp.cpus);
 
@@ -183,6 +237,7 @@ static void v66g_1024_init(ObjectClass *oc, const void *data)
     mc->is_default = true;
     mc->default_cpu_type = TYPE_HEXAGON_CPU_V66;
     mc->default_cpus = 4;
+    add_dsp_properties(oc);
 }
Signature · 2 lines
Anton Johansson
rev.ng Labs Srl.
author
#28 lore raw

PATCH 13/14 target/hexagon: fix the allocframe framekey

In reply to Brian Cain

The frame that allocframe pushes is {LR, FP}, and what is scrambled is the LR word: FRAMEKEY is XOR'd into the upper 32 bits. The generated code for fFRAME_SCRAMBLE built the key from FRAMEKEY in both halves of a 64-bit value, so it scrambled FP as well. deallocframe and dealloc_return only undo the upper word, so a FP restored from a frame pushed with a non-zero FRAMEKEY was corrupt.

Uncovered by testing some boot images using QuRT.

---
 target/hexagon/idef-parser/parser-helpers.c |  2 +-
 tests/tcg/hexagon/framekey.c                | 67 +++++++++++++++++++++
 tests/tcg/hexagon/meson.build               |  1 +
 3 files changed, 69 insertions(+), 1 deletion(-)
 create mode 100644 tests/tcg/hexagon/framekey.c
target/hexagon/idef-parser/parser-helpers.c +1 -1
index 49cc11fddd8..14840d98737 100644
@@ -1989,7 +1989,7 @@ HexValue gen_rvalue_fscr(Context *c, YYLTYPE *locp, HexValue *value)
     *value = gen_rvalue_extend(c, locp, value);
     OUT(c, locp, "gen_read_reg(", &frame_key, ", HEX_REG_FRAMEKEY);\n");
     OUT(c, locp, "tcg_gen_concat_i32_i64(",
-        &key, ", ", &frame_key, ", ", &frame_key, ");\n");
+        &key, ", tcg_constant_tl(0), ", &frame_key, ");\n");
     OUT(c, locp, "tcg_gen_xor_i64(", &res, ", ", value, ", ", &key, ");\n");
     return res;
 }
tests/tcg/hexagon/framekey.c new file +67 -0

67 lines not on this page · raw message

tests/tcg/hexagon/meson.build +1 -0
index a6ace4c77c2..0fd62ce7e4c 100644
@@ -68,6 +68,7 @@ tests += {
   'overflow.c': {'cflags': cflags, 'exe_name': 'hex-overflow'},
   'preg_alias.c': {'cflags': cflags},
   'dual_stores.c': {'cflags': cflags},
+  'framekey.c': {'cflags': cflags},
   'multi_result.c': {'cflags': cflags},
   'mem_noshuf.c': {'cflags': cflags},
   'mem_noshuf_exception.c': {'cflags': cflags},
Signature · 1 line
2.34.1
author
#29 lore raw

PATCH 14/14 tests/functional/hexagon: boot DSP firmware

In reply to Brian Cain

Download the firmware and run it on the corresponding DSP machine.

The images are third-party binaries, so the tests run only when untrusted code is allowed.

---
 tests/functional/hexagon/meson.build          |  2 +
 .../hexagon/test_qcom_dsp_firmware.py         | 89 +++++++++++++++++++
 2 files changed, 91 insertions(+)
 create mode 100755 tests/functional/hexagon/test_qcom_dsp_firmware.py
tests/functional/hexagon/meson.build +2 -0
index e182bc98a06..0fd90e491a2 100644
@@ -2,10 +2,12 @@
 
 tests_hexagon_system_thorough = [
   'arch_tests',
+  'qcom_dsp_firmware',
   'systests',
   'minivm',
 ]
 
 test_hexagon_timeouts = {
+  'qcom_dsp_firmware': 240,
   'systests': 180,
 }
tests/functional/hexagon/test_qcom_dsp_firmware.py new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.34.1
#30 lore raw

Re: [PATCH 14/14] tests/functional/hexagon: boot DSP firmware

Quoted 26 lines · Brian Cain

Download the firmware and run it on the corresponding DSP machine.

The images are third-party binaries, so the tests run only when untrusted code is allowed.

---
  tests/functional/hexagon/meson.build          |  2 +
  .../hexagon/test_qcom_dsp_firmware.py         | 89 +++++++++++++++++++
  2 files changed, 91 insertions(+)

create mode 100755 tests/functional/hexagon/test_qcom_dsp_firmware.py

tests/functional/hexagon/test_qcom_dsp_firmware.py new file +7 -0
new file mode 100755
index 00000000000..86a0628d9f3
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+#
+# Boot the production DSP firmware on the Qualcomm DSP machines
+#
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later

tests/functional/hexagon/test_qcom_dsp_firmware.py line 17

Quoted 10 lines
tests/functional/hexagon/test_qcom_dsp_firmware.py new file +10 -0
+
+from qemu_test import QemuSystemTest, Asset, skipUntrustedTest
+from qemu_test import wait_for_console_pattern
+
+
+class QcomDspFirmwareTest(QemuSystemTest):
+    """Base class: the firmware is the ELF that -kernel starts running."""
+
+    REPO = 'https://gitlab.com/kernel-firmware/linux-firmware/-/raw/' \
+           'd947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom'

404: Page not found

author
#31 lore raw

Re: [PATCH 14/14] tests/functional/hexagon: boot DSP firmware

Quoted 32 lines · Philippe Mathieu-Daudé
Quoted 31 lines · Brian Cain

Download the firmware and run it on the corresponding DSP machine.

The images are third-party binaries, so the tests run only when untrusted code is allowed.

---
  tests/functional/hexagon/meson.build          |  2 + .../hexagon/test_qcom_dsp_firmware.py         | 89 +++++++++++++++++++

  2 files changed, 91 insertions(+)

  create mode 100755 tests/functional/hexagon/test_qcom_dsp_firmware.py

tests/functional/hexagon/test_qcom_dsp_firmware.py new file +12 -0
new file mode 100755
index 00000000000..86a0628d9f3
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+#
+# Boot the production DSP firmware on the Qualcomm DSP machines
+#
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import QemuSystemTest, Asset, skipUntrustedTest
+from qemu_test import wait_for_console_pattern
+
+
Quoted 8 lines
Quoted 6 lines
tests/functional/hexagon/test_qcom_dsp_firmware.py new file +2 -0
+class QcomDspFirmwareTest(QemuSystemTest):
+    """Base class: the firmware is the ELF that -kernel starts 

running."""
+
+    REPO = 'https://gitlab.com/kernel-firmware/linux-firmware/-/raw/' \
+           'd947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom'

404: Page not found

Huh.  Maybe I picked a funny commit and somehow the asset cache fooled me?  Will take a closer look.

-Brian

author
#32 lore raw

Re: [PATCH 14/14] tests/functional/hexagon: boot DSP firmware

Quoted 46 lines · Brian Cain
Quoted 34 lines · Philippe Mathieu-Daudé
Quoted 33 lines · Brian Cain

Download the firmware and run it on the corresponding DSP machine.

The images are third-party binaries, so the tests run only when untrusted code is allowed.

---
  tests/functional/hexagon/meson.build          |  2 + .../hexagon/test_qcom_dsp_firmware.py         | 89
+++++++++++++++++++

  2 files changed, 91 insertions(+)

  create mode 100755 tests/functional/hexagon/test_qcom_dsp_firmware.py

tests/functional/hexagon/test_qcom_dsp_firmware.py new file +13 -0
new file mode 100755
index 00000000000..86a0628d9f3
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+#
+# Boot the production DSP firmware on the Qualcomm DSP machines
+#
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import QemuSystemTest, Asset, skipUntrustedTest
+from qemu_test import wait_for_console_pattern
+
+
+class QcomDspFirmwareTest(QemuSystemTest):
Quoted 8 lines
Quoted 6 lines
tests/functional/hexagon/test_qcom_dsp_firmware.py new file +1 -0
+    """Base class: the firmware is the ELF that -kernel starts 

running."""
+
+    REPO = 'https://gitlab.com/kernel-firmware/linux-firmware/-/raw/' \
+           'd947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom'

404: Page not found

Quoted 1 line

Huh.  Maybe I picked a funny commit and somehow the asset cache fooled me?  Will take a closer look.

Disregard: all is well.  A "wget" of one of these assets works for me.  If I paste the URL into chrome, it downloads the asset.

But if I browse to https://gitlab.com/kernel-firmware/linux-firmware/-/raw/d947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom I do get a 404.  I think this is the expected behavior, though. That "raw" mode for the URL expects a path to a file object that git could serve up.

If you browse to https://gitlab.com/kernel-firmware/linux-firmware/-/tree/d947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom you can see the directory listing that you might have expected. If you apply these changes to master I would expect check-functional will download and run them (w/the untrusted code bit set).

The sha in the URL is inconvenient and unclear so in v2 I will switch to a recent tag instead.

Quoted 3 lines

-Brian

#33 lore raw

Re: [PATCH 14/14] tests/functional/hexagon: boot DSP firmware

Quoted 48 lines · Brian Cain
Quoted 46 lines · Brian Cain
Quoted 42 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Brian Cain

Download the firmware and run it on the corresponding DSP machine.

The images are third-party binaries, so the tests run only when untrusted code is allowed.

---
  tests/functional/hexagon/meson.build          |  2 + .../hexagon/test_qcom_dsp_firmware.py         | 89 +++++++++++++++
++++

  2 files changed, 91 insertions(+)

  create mode 100755 tests/functional/hexagon/test_qcom_dsp_firmware.py

tests/functional/hexagon/test_qcom_dsp_firmware.py new file +14 -0
new file mode 100755
index 00000000000..86a0628d9f3
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+#
+# Boot the production DSP firmware on the Qualcomm DSP machines
+#
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import QemuSystemTest, Asset, skipUntrustedTest
+from qemu_test import wait_for_console_pattern
+
+
+class QcomDspFirmwareTest(QemuSystemTest):
+    """Base class: the firmware is the ELF that -kernel starts 
Quoted 5 lines

running."""
+
+    REPO = 'https://gitlab.com/kernel-firmware/linux-firmware/-/ raw/' \
+           'd947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom'

404: Page not found

Quoted 7 lines
Quoted 1 line

Huh.  Maybe I picked a funny commit and somehow the asset cache fooled me?  Will take a closer look.

Disregard: all is well.  A "wget" of one of these assets works for me. If I paste the URL into chrome, it downloads the asset.

But if I browse to https://gitlab.com/kernel-firmware/linux-firmware/-/ raw/d947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom I do get a 404.  I think this is the expected behavior, though. That "raw" mode for the URL expects a path to a file object that git could serve up.

If you browse to https://gitlab.com/kernel-firmware/linux-firmware/-/ tree/d947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom you can see the directory listing that you might have expected.

Oops sorry, I indeed checked a wrong URL 🤦🏼‍♂️

Quoted 9 lines

If you apply these changes to master I would expect check-functional will download and run them (w/the untrusted code bit set).

The sha in the URL is inconvenient and unclear so in v2 I will switch to a recent tag instead.

Quoted 3 lines

-Brian

#34 lore raw

Re: [PATCH 14/14] tests/functional/hexagon: boot DSP firmware

In reply to Philippe Mathieu-Daudé
Quoted 33 lines · Philippe Mathieu-Daudé
Quoted 32 lines · Brian Cain

Download the firmware and run it on the corresponding DSP machine.

The images are third-party binaries, so the tests run only when untrusted code is allowed.

---
  tests/functional/hexagon/meson.build          |  2 + .../hexagon/test_qcom_dsp_firmware.py         | 89 +++++++++++++++++++

  2 files changed, 91 insertions(+)

  create mode 100755 tests/functional/hexagon/test_qcom_dsp_firmware.py

(quoted diff) renamed from tests/functional/hexagon/test_qcom_dsp_firmware.py +0 -0

tests/functional/hexagon/test_qcom_dsp_firmware.py new file mode 100755
index 00000000000..86a0628d9f3

tests/functional/hexagon/test_qcom_dsp_firmware.py new file +12 -0
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+#
+# Boot the production DSP firmware on the Qualcomm DSP machines
+#
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import QemuSystemTest, Asset, skipUntrustedTest
+from qemu_test import wait_for_console_pattern
+
+
Quoted 8 lines
Quoted 6 lines
tests/functional/hexagon/test_qcom_dsp_firmware.py new file +2 -0
+class QcomDspFirmwareTest(QemuSystemTest):
+    """Base class: the firmware is the ELF that -kernel starts

running."""
+
+    REPO = 'https://gitlab.com/kernel-firmware/linux-firmware/-/raw/' \
+           'd947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom'

404: Page not found

This URL is incomplete at this point, it's just a folder and not the final file. When concatenating sub paths, like "qcm6490/cdsp.mbn" it works fine.

It's confusing to our (qemu functional tests) mind since we are blindly used to see the assets full URL here, instead of it being set in each subtest.

@Brian: To follow the existing convention, I would recommend to duplicate full URL between assets following something what is done in:
tests/functional/aarch64/test_aspeed_ast2700a2.py

It's a bit "Do repeat yourself", but at least it's not surprising. It has also the advantage to be easier to replace url if files are moved at any point.

Regards,
Pierrick

author
#35 lore raw

Re: [PATCH 14/14] tests/functional/hexagon: boot DSP firmware

Quoted 44 lines · Pierrick Bouvier
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Brian Cain

Download the firmware and run it on the corresponding DSP machine.

The images are third-party binaries, so the tests run only when untrusted code is allowed.

---
   tests/functional/hexagon/meson.build          |  2 +
   .../hexagon/test_qcom_dsp_firmware.py         | 89 +++++++++++++++++++
   2 files changed, 91 insertions(+)

  create mode 100755 tests/functional/hexagon/test_qcom_dsp_firmware.py

(quoted diff) renamed from tests/functional/hexagon/test_qcom_dsp_firmware.py +0 -0

tests/functional/hexagon/test_qcom_dsp_firmware.py new file mode 100755
index 00000000000..86a0628d9f3

tests/functional/hexagon/test_qcom_dsp_firmware.py new file +11 -0
@@ -0,0 +1,89 @@
+#!/usr/bin/env python3
+#
+# Boot the production DSP firmware on the Qualcomm DSP machines
+#
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from qemu_test import QemuSystemTest, Asset, skipUntrustedTest
+from qemu_test import wait_for_console_pattern
+
Quoted 8 lines
Quoted 7 lines
tests/functional/hexagon/test_qcom_dsp_firmware.py new file +3 -0
+
+class QcomDspFirmwareTest(QemuSystemTest):
+    """Base class: the firmware is the ELF that -kernel starts

running."""
+
+    REPO = 'https://gitlab.com/kernel-firmware/linux-firmware/-/raw/' \
+           'd947e4e8e314e9254a1242dc1a5d9cede2cce33d/qcom'

404: Page not found

This URL is incomplete at this point, it's just a folder and not the final file. When concatenating sub paths, like "qcm6490/cdsp.mbn" it works fine.

Quoted 7 lines

It's confusing to our (qemu functional tests) mind since we are blindly used to see the assets full URL here, instead of it being set in each subtest.

@Brian: To follow the existing convention, I would recommend to duplicate full URL between assets following something what is done in:
tests/functional/aarch64/test_aspeed_ast2700a2.py

Ok, will do.

Quoted 6 lines

It's a bit "Do repeat yourself", but at least it's not surprising. It has also the advantage to be easier to replace url if files are moved at any point.

Regards,
Pierrick