Add hexagon l2vic, qtimer devices
v5 cover Add hexagon l2vic, qtimer devices
The previously independent threads for l2vic and qtimer are now combined, which seems to make the most sense because qtimer testing effectively depends on l2vic.
Changes in v5:
- access-control checks factored out into access_ok()
- qct-qtimer.c moved from specific_ss to system_ss
- cnttid_{0,1} values derived from nr_frames
- test coverage for access control, irqs
l2vic v4: https://lore.kernel.org/qemu-devel/[email protected]/
l2vic v3: https://lore.kernel.org/qemu-devel/[email protected]/
l2vic v2: https://lore.kernel.org/qemu-devel/[email protected]/
l2vic v1: https://lore.kernel.org/qemu-devel/[email protected]/
qtimer v1: https://lore.kernel.org/qemu-devel/[email protected]/
Brian Cain (17):
hw/hexagon: add hex-subsys
hw/hexagon: move VTCM to the common machine state hw/hexagon: move global registers to hex-subsys hw/hexagon: move the TLB to hex-subsys
hw/hexagon: group the CPUs in a cluster
bitops.h: Add find_first_bit32()
hw/hexagon: extract get_reg_value/set_reg_value stubs in globalreg hw/hexagon: connect l2vic device
hw/hexagon/virt: instantiate virtio-mmio transports hw/hexagon/virt: add l2vic interrupt-controller and virtio-mmio FDT
nodes
hw/hexagon/virt: connect pl011 UART interrupt tests/qtest: add L2VIC qtest
tests/functional/hexagon: add arch_tests functional test hw/timer: Add QCT QTimer device model
hw/hexagon: connect qtimer device
tests/qtest: add qct-qtimer qtest tests/functional/hexagon: enable more arch_tests cases
Sid Manning (1):
hw/intc: Add l2vic interrupt controller
MAINTAINERS | 7 + docs/devel/hexagon-l2vic.rst | 55 ++ docs/devel/index-internals.rst | 1 + include/hw/hexagon/hex-subsys.h | 32 + include/hw/hexagon/hexagon.h | 6 + include/hw/hexagon/hexagon_globalreg.h | 8 + include/hw/hexagon/virt.h | 4 +- include/hw/intc/hex-l2vic.h | 61 ++ include/hw/timer/qct-qtimer.h | 43 ++ include/qemu/bitops.h | 30 +- target/hexagon/cpu.h | 2 + hw/hexagon/hex-subsys.c | 175 +++++ hw/hexagon/hexagon_dsp.c | 45 +- hw/hexagon/hexagon_globalreg.c | 65 +- hw/hexagon/virt.c | 130 ++-- hw/intc/hex-l2vic.c | 556 ++++++++++++++++ hw/timer/qct-qtimer.c | 667 ++++++++++++++++++++ target/hexagon/cpu.c | 2 + target/hexagon/op_helper.c | 16 +- tests/qtest/l2vic-test.c | 249 ++++++++ tests/qtest/qct-qtimer-test.c | 385 +++++++++++ hw/hexagon/Kconfig | 3 + hw/hexagon/meson.build | 1 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + hw/timer/Kconfig | 3 + hw/timer/meson.build | 2 + hw/timer/trace-events | 5 + tests/functional/hexagon/test_arch_tests.py | 38 ++ tests/qtest/meson.build | 2 +- 31 files changed, 2512 insertions(+), 90 deletions(-) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 include/hw/hexagon/hex-subsys.h create mode 100644 include/hw/intc/hex-l2vic.h create mode 100644 include/hw/timer/qct-qtimer.h create mode 100644 hw/hexagon/hex-subsys.c create mode 100644 hw/intc/hex-l2vic.c create mode 100644 hw/timer/qct-qtimer.c create mode 100644 tests/qtest/l2vic-test.c create mode 100644 tests/qtest/qct-qtimer-test.c
Signature · 1 line
2.34.1
PATCH v5 1/18 hw/hexagon: add hex-subsys
The virt and DSP machine models build the same core subsystem, let's abstract out that part. Start with the DDR and config table ROM setup.
--- include/hw/hexagon/hex-subsys.h | 17 +++++++++++++++++ hw/hexagon/hex-subsys.c | 32 ++++++++++++++++++++++++++++++++ hw/hexagon/hexagon_dsp.c | 17 ++--------------- hw/hexagon/virt.c | 14 ++------------ hw/hexagon/meson.build | 1 + 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 include/hw/hexagon/hex-subsys.h create mode 100644 hw/hexagon/hex-subsys.c
include/hw/hexagon/hex-subsys.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Hexagon subsystem helpers shared between the machine models. +* +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_HEXAGON_HEX_SUBSYS_H +#define HW_HEXAGON_HEX_SUBSYS_H + +#include "hw/hexagon/hexagon.h" + +/* Create the subsystem shared by every Hexagon machine. */ +void hex_subsys_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg); + +#endif /* HW_HEXAGON_HEX_SUBSYS_H */
hw/hexagon/hex-subsys.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Hexagon subsystem helpers shared between the machine 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/hexagon/hex-subsys.h" +#include "hw/core/loader.h" +#include "system/address-spaces.h" + +void hex_subsys_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +MachineState *machine =MACHINE (hms); +MemoryRegion *sysmem =get_system_memory (); + +/* Main DDR at the reset vector. */ +memory_region_init_ram (&hms->ram,NULL ,"ddr.ram" , machine->ram_size, + &error_fatal); +memory_region_add_subregion (sysmem,0x0 , &hms->ram); + +/* Config-table ROM and the blob that backs it. */ +memory_region_init_rom (&hms->cfgtable_rom,NULL ,"config_table.rom" , +sizeof (m_cfg->cfgtable), &error_fatal); +memory_region_add_subregion (sysmem, m_cfg->cfgbase, &hms->cfgtable_rom); +rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, +sizeof (m_cfg->cfgtable), m_cfg->cfgbase, + &address_space_memory); +}
hw/hexagon/hexagon_dsp.c +2 -15
@@ -14,6 +14,7 @@#include "hw/core/boards.h" #include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h"
@@ -108,7 +109,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, {HexagonCommonMachineState *hms =HEXAGON_COMMON_MACHINE (machine);HexagonDspMachineState *dms =HEXAGON_DSP_MACHINE (machine); -MemoryRegion *address_space;DeviceState *glob_regs_dev;DeviceState *tlb_dev;
@@ -120,16 +120,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, machine->enable_graphics =0 ; - address_space =get_system_memory (); - -memory_region_init_rom (&hms->cfgtable_rom,NULL ,"config_table.rom" , -sizeof (m_cfg->cfgtable), &error_fatal); -memory_region_add_subregion (address_space, m_cfg->cfgbase, - &hms->cfgtable_rom); - -memory_region_init_ram (&hms->ram,NULL ,"ddr.ram" , - machine->ram_size, &error_fatal); -memory_region_add_subregion (address_space,0x0 , &hms->ram); +hex_subsys_create (hms, m_cfg); glob_regs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); object_property_add_child(OBJECT(machine), "global-regs",
@@ -162,10 +153,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, OBJECT(tlb_dev), &error_fatal);qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); } - -rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, -sizeof (m_cfg->cfgtable), m_cfg->cfgbase, - &address_space_memory); }static void init_mc (MachineClass *mc)
hw/hexagon/virt.c +2 -12
@@ -13,6 +13,7 @@#include "hw/core/clock.h" #include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h"
@@ -244,9 +245,7 @@ static void virt_init(MachineState *ms) vms->apb_clk =clock_new (OBJECT (ms),"apb-pclk" );clock_set_hz (vms->apb_clk,24000000 ); -memory_region_init_ram (&vms->parent_obj.ram,NULL ,"ddr.ram" , - ms->ram_size, &error_fatal); -memory_region_add_subregion (vms->sys,0x0 , &vms->parent_obj.ram); +hex_subsys_create (&vms->parent_obj, m_cfg);if (m_cfg->l2tcm_size) { memory_region_init_ram(&vms->tcm, NULL, "tcm.ram", m_cfg->l2tcm_size,
@@ -255,11 +254,6 @@ static void virt_init(MachineState *ms) &vms->tcm); } -memory_region_init_rom (&vms->parent_obj.cfgtable_rom,NULL , -"config_table.rom" ,sizeof (m_cfg->cfgtable), - &error_fatal); -memory_region_add_subregion (vms->sys, m_cfg->cfgbase, - &vms->parent_obj.cfgtable_rom);fdt_add_hvx (vms, m_cfg); gsregs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG );
@@ -302,10 +296,6 @@ static void virt_init(MachineState *ms) clk_phandle =fdt_add_clocks (vms);fdt_add_uart (vms,VIRT_UART0 , clk_phandle); -rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, -sizeof (m_cfg->cfgtable), m_cfg->cfgbase, - &address_space_memory); -hexagon_load_fdt (vms); }
hw/hexagon/meson.build +1 -0
@@ -1,6 +1,7 @@ hexagon_ss = ss.source_set() hexagon_ss.add(files('hexagon_tlb.c')) hexagon_ss.add(files('hexagon_globalreg.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_VIRT', if_true: files('virt.c'))
Signature · 1 line
2.34.1
PATCH v5 2/18 hw/hexagon: move VTCM to the common machine state
In reply to Brian CainThe VTCM is described by the config table, so every machine can set it up the same way.
--- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/virt.h | 1 - hw/hexagon/hex-subsys.c | 8 ++++++++ hw/hexagon/virt.c | 5 ----- 4 files changed, 9 insertions(+), 6 deletions(-)
include/hw/hexagon/hexagon.h +1 -0
@@ -156,6 +156,7 @@ struct HexagonCommonMachineState {MemoryRegion ram;MemoryRegion cfgtable_rom; + MemoryRegion vtcm; };#endif
include/hw/hexagon/virt.h +0 -1
@@ -17,7 +17,6 @@ struct HexagonVirtMachineState {int fdt_size;MemoryRegion *sys;MemoryRegion tcm; -MemoryRegion vtcm;MemoryRegion bios;Clock *apb_clk; };
hw/hexagon/hex-subsys.c +8 -0
@@ -29,4 +29,12 @@ void hex_subsys_create(HexagonCommonMachineState *hms,rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable,sizeof (m_cfg->cfgtable), m_cfg->cfgbase, &address_space_memory); + +if (m_cfg->cfgtable.vtcm_size_kb >0 ) { +memory_region_init_ram (&hms->vtcm,NULL ,"vtcm.ram" , + m_cfg->cfgtable.vtcm_size_kb *1024 , + &error_fatal); +memory_region_add_subregion (sysmem, m_cfg->cfgtable.vtcm_base <<16 , + &hms->vtcm); + } }
hw/hexagon/virt.c +0 -5
@@ -75,11 +75,6 @@ static void fdt_add_hvx(HexagonVirtMachineState *vms,const MachineState *ms =MACHINE (vms);uint32_t vtcm_size_bytes = m_cfg->cfgtable.vtcm_size_kb *1024 ;if (vtcm_size_bytes >0 ) { -memory_region_init_ram (&vms->vtcm,NULL ,"vtcm.ram" , vtcm_size_bytes, - &error_fatal); -memory_region_add_subregion (vms->sys, m_cfg->cfgtable.vtcm_base <<16 , - &vms->vtcm); -qemu_fdt_add_subnode (ms->fdt,"/soc/vtcm" );qemu_fdt_setprop_string (ms->fdt,"/soc/vtcm" ,"compatible" ,"qcom,hexagon_vtcm" );
Signature · 1 line
2.34.1
PATCH v5 3/18 hw/hexagon: move global registers to hex-subsys
In reply to Brian CainBoth machines create the global register device the same way, so let hex-subsys own it and link it to each CPU as it is realized.
--- include/hw/hexagon/hex-subsys.h | 6 +++++- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 29 ++++++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 15 ++------------- hw/hexagon/virt.c | 23 +++++------------------ 5 files changed, 41 insertions(+), 33 deletions(-)
include/hw/hexagon/hex-subsys.h +5 -1
@@ -9,9 +9,13 @@#define HW_HEXAGON_HEX_SUBSYS_H #include "hw/hexagon/hexagon.h" +#include "hw/core/qdev.h" /* Create the subsystem shared by every Hexagon machine. */ void hex_subsys_create (HexagonCommonMachineState *hms, -const struct hexagon_machine_config *m_cfg); +const struct hexagon_machine_config *m_cfg,Rev_t rev); + +/* Realize a CPU into the subsystem. */ +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu);#endif /* HW_HEXAGON_HEX_SUBSYS_H */
include/hw/hexagon/hexagon.h +1 -0
@@ -157,6 +157,7 @@ struct HexagonCommonMachineState {MemoryRegion ram;MemoryRegion cfgtable_rom;MemoryRegion vtcm; + DeviceState *glob_regs; };#endif
hw/hexagon/hex-subsys.c +28 -1
@@ -8,11 +8,29 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/hexagon/hex-subsys.h" +#include "hw/hexagon/hexagon_globalreg.h" #include "hw/core/loader.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/qdev.h" +#include "hw/core/sysbus.h" #include "system/address-spaces.h" +static DeviceState *globalreg_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg, +Rev_t rev) +{ +DeviceState *glob_regs =qdev_new (TYPE_HEXAGON_GLOBALREG ); + +object_property_add_child (OBJECT (hms),"global-regs" ,OBJECT (glob_regs)); +qdev_prop_set_uint64 (glob_regs,"config-table-addr" , m_cfg->cfgbase); +qdev_prop_set_uint32 (glob_regs,"dsp-rev" , rev); +sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs), &error_fatal); + +return glob_regs; +} +void hex_subsys_create (HexagonCommonMachineState *hms, -const struct hexagon_machine_config *m_cfg) +const struct hexagon_machine_config *m_cfg,Rev_t rev) {MachineState *machine =MACHINE (hms);MemoryRegion *sysmem =get_system_memory ();
@@ -37,4 +55,13 @@ void hex_subsys_create(HexagonCommonMachineState *hms,memory_region_add_subregion (sysmem, m_cfg->cfgtable.vtcm_base <<16 , &hms->vtcm); } + + hms->glob_regs =globalreg_create (hms, m_cfg, rev); +} + +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) +{ +object_property_set_link (OBJECT (cpu),"global-regs" , +OBJECT (hms->glob_regs), &error_fatal); +qdev_realize_and_unref (cpu,NULL , &error_fatal); }
hw/hexagon/hexagon_dsp.c +2 -13
@@ -15,7 +15,6 @@#include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "qapi/error.h"
@@ -109,7 +108,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, {HexagonCommonMachineState *hms =HEXAGON_COMMON_MACHINE (machine);HexagonDspMachineState *dms =HEXAGON_DSP_MACHINE (machine); -DeviceState *glob_regs_dev;DeviceState *tlb_dev;memset (&hexagon_binfo,0 ,sizeof (hexagon_binfo));
@@ -120,14 +118,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, machine->enable_graphics =0 ; -hex_subsys_create (hms, m_cfg); - - glob_regs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); -object_property_add_child (OBJECT (machine),"global-regs" , -OBJECT (glob_regs_dev)); -qdev_prop_set_uint64 (glob_regs_dev,"config-table-addr" , m_cfg->cfgbase); -qdev_prop_set_uint32 (glob_regs_dev,"dsp-rev" , rev); -sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs_dev), &error_fatal); +hex_subsys_create (hms, m_cfg, rev); tlb_dev =qdev_new (TYPE_HEXAGON_TLB );object_property_add_child (OBJECT (machine),"tlb" ,OBJECT (tlb_dev));
@@ -147,11 +138,9 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,if (i ==0 ) {hexagon_init_bootstrap (dms, cpu); } -object_property_set_link (OBJECT (cpu),"global-regs" , -OBJECT (glob_regs_dev), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +hex_subsys_realize_cpu (hms,DEVICE (cpu)); } }
hw/hexagon/virt.c +5 -18
@@ -14,7 +14,6 @@#include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h"
@@ -226,9 +225,7 @@ static void virt_init(MachineState *ms) {HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms);const struct hexagon_machine_config *m_cfg = &v68n_1024; -DeviceState *gsregs_dev;DeviceState *tlb_dev; -DeviceState *cpu0;int32_t clk_phandle;create_fdt (vms);
@@ -240,7 +237,7 @@ static void virt_init(MachineState *ms) vms->apb_clk =clock_new (OBJECT (ms),"apb-pclk" );clock_set_hz (vms->apb_clk,24000000 ); -hex_subsys_create (&vms->parent_obj, m_cfg); +hex_subsys_create (&vms->parent_obj, m_cfg, v68_rev);if (m_cfg->l2tcm_size) { memory_region_init_ram(&vms->tcm, NULL, "tcm.ram", m_cfg->l2tcm_size,
@@ -251,42 +248,32 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); - gsregs_dev =qdev_new (TYPE_HEXAGON_GLOBALREG ); -object_property_add_child (OBJECT (ms),"global-regs" ,OBJECT (gsregs_dev)); -qdev_prop_set_uint64 (gsregs_dev,"config-table-addr" , m_cfg->cfgbase); -qdev_prop_set_uint32 (gsregs_dev,"dsp-rev" , v68_rev); -sysbus_realize_and_unref (SYS_BUS_DEVICE (gsregs_dev), &error_fatal); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB );object_property_add_child (OBJECT (ms),"tlb" ,OBJECT (tlb_dev));qdev_prop_set_uint32 (tlb_dev,"num-entries" , m_cfg->cfgtable.jtlb_size_entries);sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb_dev), &error_fatal); - cpu0 =NULL ;for (int i =0 ; i < ms->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);if (i ==0 ) { - cpu0 =DEVICE (cpu);if (ms->kernel_filename) {uint64_t entry =load_kernel (vms); -qdev_prop_set_uint32 (cpu0,"exec-start-addr" , entry); +qdev_prop_set_uint32 (DEVICE (cpu),"exec-start-addr" , entry); }else if (ms->firmware) {uint64_t entry =load_bios (vms); -qdev_prop_set_uint32 (cpu0,"exec-start-addr" , entry); +qdev_prop_set_uint32 (DEVICE (cpu),"exec-start-addr" , entry); } }qdev_prop_set_uint32 (DEVICE (cpu),"htid" , i);qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 )); -object_property_set_link (OBJECT (cpu),"global-regs" , -OBJECT (gsregs_dev), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (tlb_dev), &error_fatal); - -qdev_realize_and_unref (DEVICE (cpu),NULL , &error_fatal); +hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpu)); } +fdt_add_cpu_nodes (vms); clk_phandle =fdt_add_clocks (vms);fdt_add_uart (vms,VIRT_UART0 , clk_phandle);
Signature · 1 line
2.34.1
PATCH v5 4/18 hw/hexagon: move the TLB to hex-subsys
In reply to Brian CainThe TLB device is sized from the config table, so both machines create it identically.
--- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 16 ++++++++++++++++ hw/hexagon/hexagon_dsp.c | 10 ---------- hw/hexagon/virt.c | 10 ---------- 4 files changed, 17 insertions(+), 20 deletions(-)
include/hw/hexagon/hexagon.h +1 -0
@@ -158,6 +158,7 @@ struct HexagonCommonMachineState {MemoryRegion cfgtable_rom;MemoryRegion vtcm;DeviceState *glob_regs; + DeviceState *tlb; };#endif
hw/hexagon/hex-subsys.c +16 -0
@@ -9,6 +9,7 @@#include "qapi/error.h" #include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev.h"
@@ -29,6 +30,18 @@ static DeviceState *globalreg_create(HexagonCommonMachineState *hms,return glob_regs; } +static DeviceState *tlb_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +DeviceState *tlb =qdev_new (TYPE_HEXAGON_TLB ); + +object_property_add_child (OBJECT (hms),"tlb" ,OBJECT (tlb)); +qdev_prop_set_uint32 (tlb,"num-entries" , m_cfg->cfgtable.jtlb_size_entries); +sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb), &error_fatal); + +return tlb; +} +void hex_subsys_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev) {
@@ -57,11 +70,14 @@ void hex_subsys_create(HexagonCommonMachineState *hms, } hms->glob_regs =globalreg_create (hms, m_cfg, rev); + hms->tlb =tlb_create (hms, m_cfg); }void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) {object_property_set_link (OBJECT (cpu),"global-regs" ,OBJECT (hms->glob_regs), &error_fatal); +object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (hms->tlb), + &error_fatal);qdev_realize_and_unref (cpu,NULL , &error_fatal); }
hw/hexagon/hexagon_dsp.c +0 -10
@@ -15,7 +15,6 @@#include "hw/core/qdev-properties.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "qapi/error.h" #include "qemu/error-report.h"
@@ -108,7 +107,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, {HexagonCommonMachineState *hms =HEXAGON_COMMON_MACHINE (machine);HexagonDspMachineState *dms =HEXAGON_DSP_MACHINE (machine); -DeviceState *tlb_dev;memset (&hexagon_binfo,0 ,sizeof (hexagon_binfo));if (machine->kernel_filename) {
@@ -120,12 +118,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,hex_subsys_create (hms, m_cfg, rev); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); -object_property_add_child (OBJECT (machine),"tlb" ,OBJECT (tlb_dev)); -qdev_prop_set_uint32 (tlb_dev,"num-entries" , - m_cfg->cfgtable.jtlb_size_entries); -sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb_dev), &error_fatal); -for (int i =0 ; i < machine->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (machine->cpu_type));qemu_register_reset (do_cpu_reset, cpu);
@@ -138,8 +130,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,if (i ==0 ) {hexagon_init_bootstrap (dms, cpu); } -object_property_set_link (OBJECT (cpu),"tlb" , -OBJECT (tlb_dev), &error_fatal);hex_subsys_realize_cpu (hms,DEVICE (cpu)); } }
hw/hexagon/virt.c +0 -10
@@ -14,7 +14,6 @@#include "hw/core/sysbus-fdt.h" #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hex-subsys.h" -#include "hw/hexagon/hexagon_tlb.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev-clock.h"
@@ -225,7 +224,6 @@ static void virt_init(MachineState *ms) {HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms);const struct hexagon_machine_config *m_cfg = &v68n_1024; -DeviceState *tlb_dev;int32_t clk_phandle;create_fdt (vms);
@@ -248,12 +246,6 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); - tlb_dev =qdev_new (TYPE_HEXAGON_TLB ); -object_property_add_child (OBJECT (ms),"tlb" ,OBJECT (tlb_dev)); -qdev_prop_set_uint32 (tlb_dev,"num-entries" , - m_cfg->cfgtable.jtlb_size_entries); -sysbus_realize_and_unref (SYS_BUS_DEVICE (tlb_dev), &error_fatal); -for (int i =0 ; i < ms->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);
@@ -269,8 +261,6 @@ static void virt_init(MachineState *ms) }qdev_prop_set_uint32 (DEVICE (cpu),"htid" , i);qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 )); -object_property_set_link (OBJECT (cpu),"tlb" , -OBJECT (tlb_dev), &error_fatal);hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpu)); }
Signature · 1 line
2.34.1
PATCH v5 5/18 hw/hexagon: group the CPUs in a cluster
In reply to Brian CainThe CPUs are now grouped in a TYPE_CPU_CLUSTER.
--- include/hw/hexagon/hex-subsys.h | 12 +++++++++++- include/hw/hexagon/hexagon.h | 1 + hw/hexagon/hex-subsys.c | 30 +++++++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 11 ++++++++++- hw/hexagon/virt.c | 11 ++++++++++- hw/hexagon/Kconfig | 1 + 6 files changed, 62 insertions(+), 4 deletions(-)
include/hw/hexagon/hex-subsys.h +11 -1
@@ -15,7 +15,17 @@void hex_subsys_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev); -/* Realize a CPU into the subsystem. */ +/* +* Parent a CPU into the subsystem's cluster and wire its links. Call for +* every CPU before hex_subsys_realize_cluster(), then realize each CPU with +* hex_subsys_realize_cpu(). +*/ +void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu); + +/* Realize the CPU cluster, once all CPUs have been parented into it. */ +void hex_subsys_realize_cluster (HexagonCommonMachineState *hms); + +/* Realize a CPU previously parented via hex_subsys_add_cpu(). */ void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu);#endif /* HW_HEXAGON_HEX_SUBSYS_H */
include/hw/hexagon/hexagon.h +1 -0
@@ -157,6 +157,7 @@ struct HexagonCommonMachineState {MemoryRegion ram;MemoryRegion cfgtable_rom;MemoryRegion vtcm; +DeviceState *cluster;DeviceState *glob_regs;DeviceState *tlb; };
hw/hexagon/hex-subsys.c +29 -1
@@ -10,6 +10,7 @@#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev.h"
@@ -42,6 +43,16 @@ static DeviceState *tlb_create(HexagonCommonMachineState *hms,return tlb; } +static DeviceState *cluster_create (HexagonCommonMachineState *hms) +{ +DeviceState *cluster =qdev_new (TYPE_CPU_CLUSTER ); + +object_property_add_child (OBJECT (hms),"cluster" ,OBJECT (cluster)); +qdev_prop_set_uint32 (cluster,"cluster-id" ,0 ); + +return cluster; +} +void hex_subsys_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev) {
@@ -69,15 +80,32 @@ void hex_subsys_create(HexagonCommonMachineState *hms, &hms->vtcm); } + hms->cluster =cluster_create (hms); hms->glob_regs =globalreg_create (hms, m_cfg, rev); hms->tlb =tlb_create (hms, m_cfg); } -void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) +void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) { +object_property_add_child (OBJECT (hms->cluster),"cpu[*]" ,OBJECT (cpu));object_property_set_link (OBJECT (cpu),"global-regs" ,OBJECT (hms->glob_regs), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (hms->tlb), &error_fatal); +} + +void hex_subsys_realize_cluster (HexagonCommonMachineState *hms) +{ +/* +* The cluster must be realized after its CPUs have been parented into it +* (see hex_subsys_add_cpu()) but before any CPU is itself realized, since +* qdev_realize_and_unref() on a CPU latches cluster_index into the TCG +* cflags at that point. +*/ +qdev_realize_and_unref (hms->cluster,NULL , &error_fatal); +} + +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) +{qdev_realize_and_unref (cpu,NULL , &error_fatal); }
hw/hexagon/hexagon_dsp.c +10 -1
@@ -118,6 +118,8 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,hex_subsys_create (hms, m_cfg, rev); + g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, machine->smp.cpus); +for (int i =0 ; i < machine->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (machine->cpu_type));qemu_register_reset (do_cpu_reset, cpu);
@@ -130,7 +132,14 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,if (i ==0 ) {hexagon_init_bootstrap (dms, cpu); } -hex_subsys_realize_cpu (hms,DEVICE (cpu)); +hex_subsys_add_cpu (hms,DEVICE (cpu)); + cpus[i] = cpu; + } + +hex_subsys_realize_cluster (hms); + +for (int i =0 ; i < machine->smp.cpus; i++) { +hex_subsys_realize_cpu (hms,DEVICE (cpus[i])); } }
hw/hexagon/virt.c +10 -1
@@ -246,6 +246,8 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); + g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, ms->smp.cpus); +for (int i =0 ; i < ms->smp.cpus; i++) {HexagonCPU *cpu =HEXAGON_CPU (object_new (ms->cpu_type));qemu_register_reset (do_cpu_reset, cpu);
@@ -261,7 +263,14 @@ static void virt_init(MachineState *ms) }qdev_prop_set_uint32 (DEVICE (cpu),"htid" , i);qdev_prop_set_bit (DEVICE (cpu),"start-powered-off" , (i !=0 )); -hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpu)); +hex_subsys_add_cpu (&vms->parent_obj,DEVICE (cpu)); + cpus[i] = cpu; + } + +hex_subsys_realize_cluster (&vms->parent_obj); + +for (int i =0 ; i < ms->smp.cpus; i++) { +hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpus[i])); }fdt_add_cpu_nodes (vms);
hw/hexagon/Kconfig +1 -0
@@ -2,6 +2,7 @@ config HEX_DSP bool default y depends on HEXAGON + select CPU_CLUSTER config HEX_VIRT bool
Signature · 1 line
2.34.1
PATCH v5 6/18 bitops.h: Add find_first_bit32()
In reply to Brian Cainset_bit32()/test_bit32()/etc already let devices operate on guest-visible uint32_t register arrays without depending on the host's 'unsigned long' size. Add find_first_bit32() so callers need not cast a uint32_t array to 'unsigned long *'.
--- include/qemu/bitops.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
include/qemu/bitops.h +26 -4
@@ -43,10 +43,9 @@* be some guest-visible register view of the bit array. * * We do not currently implement uint32_t versions of find_last_bit(), -* find_next_bit(), find_next_zero_bit(), find_first_bit() or -* find_first_zero_bit(), because we haven't yet needed them. If you -* need them you should implement them similarly to the 'unsigned long' -* versions. +* find_next_bit(), find_next_zero_bit() or find_first_zero_bit(), +* because we haven't yet needed them. If you need them you should +* implement them similarly to the 'unsigned long' versions. * * You can declare a bitmap to be used with these functions via the * DECLARE_BITMAP and DECLARE_BITMAP32 macros in bitmap.h.
@@ -382,6 +381,29 @@ static inline int test_bit32(long nr, const uint32_t *addr)return 1U & (addr[BIT32_WORD (nr)] >> (nr &31 )); } +/** +* find_first_bit32 - find the first set bit in a memory region +* @addr: The address to start the search at +* @size: The maximum size to search +* +* Returns the bit number of the first set bit, +* or @size if there is no set bit in the bitmap. +*/ +static inline uint32_t find_first_bit32 (const uint32_t *addr,uint32_t size) +{ +uint32_t result; + +for (result =0 ; result < size; result +=32 ) { +uint32_t tmp = *addr++; +if (tmp) { + result +=ctz32 (tmp); +return result < size ? result : size; + } + } +/* Not found */ +return size; +} +/** * DOC: Miscellaneous bit operations on single values *
Signature · 1 line
2.34.1
PATCH v5 7/18 hw/intc: Add l2vic interrupt controller
In reply to Brian CainFrom: Sid Manning <[email protected]>
The Hexagon DSP requires an L2VIC to route up to 1024 external interrupt sources through 4 VID output groups into the core's 8 interrupt inputs. Add a device model for it.
--- MAINTAINERS | 3 + docs/devel/hexagon-l2vic.rst | 55 ++++ docs/devel/index-internals.rst | 1 + include/hw/intc/hex-l2vic.h | 61 ++++ target/hexagon/cpu.h | 2 + hw/intc/hex-l2vic.c | 556 +++++++++++++++++++++++++++++++++ target/hexagon/cpu.c | 2 + target/hexagon/op_helper.c | 16 +- hw/hexagon/Kconfig | 1 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 12 files changed, 705 insertions(+), 1 deletion(-) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 include/hw/intc/hex-l2vic.h create mode 100644 hw/intc/hex-l2vic.c
MAINTAINERS +3 -0
@@ -250,6 +250,8 @@ M: Brian Cain <[email protected]> R: Pierrick Bouvier <[email protected]> S: Supported F: target/hexagon/ +F: hw/intc/hex-l2vic.c +F: include/hw/intc/hex-l2vic.h X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
@@ -262,6 +264,7 @@ F: gdbstub/gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst F: docs/system/hexagon/ F: docs/devel/hexagon-sys.rst +F: docs/devel/hexagon-l2vic.rst T: git https://github.com/qualcomm/qemu.git hex-next Hexagon idef-parser
docs/devel/hexagon-l2vic.rst new file +55 -0
55 lines not on this page · raw message
docs/devel/index-internals.rst +1 -0
@@ -15,6 +15,7 @@ Details about QEMU's various subsystems including how to add features to them. clocks ebpf_rss hexagon-sys + hexagon-l2vic migration/index multi-process reset
include/hw/intc/hex-l2vic.h new file +61 -0
61 lines not on this page · raw message
target/hexagon/cpu.h +2 -0
@@ -39,6 +39,7 @@ typedef struct HexagonGlobalRegState HexagonGlobalRegState;#include "qemu/bitmap.h" #include "target/hexagon/reg_fields.h" +#include "hw/intc/hex-l2vic.h" #define NUM_PREGS 4#define TOTAL_PER_THREAD_REGS 64
@@ -198,6 +199,7 @@ struct ArchCPU {uint32_t boot_addr;HexagonGlobalRegState *globalregs;uint32_t htid; +HexL2VicInterface *l2vic;#endif };
hw/intc/hex-l2vic.c new file +556 -0
556 lines not on this page · raw message
target/hexagon/cpu.c +2 -0
@@ -65,6 +65,8 @@ static const Property hexagon_cpu_properties[] = {DEFINE_PROP_LINK ("tlb" , HexagonCPU, tlb,TYPE_HEXAGON_TLB , HexagonTLBState *),DEFINE_PROP_UINT32 ("exec-start-addr" , HexagonCPU, boot_addr,0xffffffff ), +DEFINE_PROP_LINK ("l2vic" , HexagonCPU, l2vic, + TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *),DEFINE_PROP_LINK ("global-regs" , HexagonCPU, globalregs, TYPE_HEXAGON_GLOBALREG, HexagonGlobalRegState *), DEFINE_PROP_UINT32("htid", HexagonCPU, htid, 0),
target/hexagon/op_helper.c +15 -1
@@ -40,6 +40,7 @@#include "hw/hexagon/hexagon_globalreg.h" #include "hex_mmu.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/intc/hex-l2vic.h" #include "hex_interrupts.h" #include "hexswi.h" #endif
@@ -1564,7 +1565,20 @@ void HELPER(raise_stack_overflow)(CPUHexagonState *env, uint32_t slot,void HELPER (ciad )(CPUHexagonState *env,uint32_t mask) { -g_assert_not_reached (); +uint32_t ipendad; +uint32_t iad; +HexagonCPU *cpu; + +BQL_LOCK_GUARD (); + cpu =env_archcpu (env); + ipendad =hexagon_globalreg_read (cpu->globalregs,HEX_SREG_IPENDAD , + env->threadId); + iad =fGET_FIELD (ipendad,IPENDAD_IAD ); +fSET_FIELD (ipendad,IPENDAD_IAD , iad & ~(mask)); +hexagon_globalreg_write (cpu->globalregs,HEX_SREG_IPENDAD , + ipendad, env->threadId); +l2vic_clear_interrupt (cpu->l2vic); +hex_interrupt_update (env); }void HELPER (siad )(CPUHexagonState *env,uint32_t mask)
hw/hexagon/Kconfig +1 -0
@@ -3,6 +3,7 @@ config HEX_DSP default y depends on HEXAGON select CPU_CLUSTER + select HEX_L2VIC config HEX_VIRT bool
hw/intc/Kconfig +3 -0
@@ -8,6 +8,9 @@ config I8259 config PL190 bool +config HEX_L2VIC + bool + config IOAPIC bool select I8259
hw/intc/meson.build +2 -0
@@ -74,6 +74,8 @@ specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('xics_spapr.c', 'spapr_xi specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) + +specific_ss.add(when: 'CONFIG_HEX_L2VIC', if_true: files('hex-l2vic.c')) specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI_COMMON', if_true: files('loongson_ipi_common.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI', if_true: files('loongson_ipi.c'))
hw/intc/trace-events +4 -0
@@ -337,6 +337,10 @@ sh_intc_register(const char *s, int id, unsigned short v, int c, int m) "%s %u - sh_intc_read(unsigned size, uint64_t offset, unsigned long val) "size %u 0x%" PRIx64 " -> 0x%lx" sh_intc_write(unsigned size, uint64_t offset, unsigned long val) "size %u 0x%" PRIx64 " <- 0x%lx" sh_intc_set(int id, int enable) "setting interrupt group %d to %d" +# hex-l2vic.c +hex_l2vic_reg_write(unsigned int addr, uint32_t value) "addr: 0x%03x value: 0x%08"PRIx32 +hex_l2vic_reg_read(unsigned int addr, uint32_t value) "addr: 0x%03x value: 0x%08"PRIx32 +hex_l2vic_delivered(int irq, int vid) "l2vic: delivered %d (vid %d)" # loongson_ipi.c loongson_ipi_read(unsigned size, uint64_t addr, uint64_t val) "size: %u addr: 0x%"PRIx64 "val: 0x%"PRIx64
Signature · 1 line
2.34.1
PATCH v5 8/18 hw/hexagon: extract get_reg_value/set_reg_value stubs in globalreg
In reply to Brian CainRoute the globalreg read/write accessors through new get_reg_value()/set_reg_value() helpers instead of touching s->regs[reg] directly.
This will be exploited by a subsequent patch that redirects VID/VID1 accesses to the L2VIC.
--- hw/hexagon/hexagon_globalreg.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
hw/hexagon/hexagon_globalreg.c +18 -5
@@ -135,6 +135,17 @@ static inline uint32_t apply_write_mask(uint32_t new_val, uint32_t cur_val,return new_val; } +static uint32_t get_reg_value (HexagonGlobalRegState *s,uint32_t reg) +{ +return s->regs[reg]; +} + +static void set_reg_value (HexagonGlobalRegState *s,uint32_t reg, +uint32_t value) +{ + s->regs[reg] = value; +} +uint32_t hexagon_globalreg_read (HexagonGlobalRegState *s,uint32_t reg,uint32_t htid) {
@@ -146,7 +157,7 @@ uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg,g_assert (reg <NUM_SREGS );g_assert (reg >=HEX_SREG_GLB_START ); - value = s->regs[reg]; + value =get_reg_value (s, reg);trace_hexagon_globalreg_read (htid,get_sreg_name (reg), value);return value;
@@ -160,7 +171,7 @@ void hexagon_globalreg_write(HexagonGlobalRegState *s, uint32_t reg, }g_assert (reg <NUM_SREGS );g_assert (reg >=HEX_SREG_GLB_START ); - s->regs[reg] = value; +set_reg_value (s, reg, value);trace_hexagon_globalreg_write (htid,get_sreg_name (reg), value); }
@@ -168,6 +179,7 @@ uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s, uint32_t reg, uint32_t value) {uint32_t reg_mask; +uint32_t cur_val;if (!s) {return value;
@@ -175,9 +187,10 @@ uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s, uint32_t reg,g_assert (reg <NUM_SREGS );g_assert (reg >=HEX_SREG_GLB_START ); reg_mask = global_sreg_immut_masks[reg]; + cur_val =get_reg_value (s, reg);return reg_mask ==IMMUTABLE ? - s->regs[reg] : -apply_write_mask (value, s->regs[reg], reg_mask); + cur_val : +apply_write_mask (value, cur_val, reg_mask); } void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg,
@@ -186,7 +199,7 @@ void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg,if (!s) {return ; } - s->regs[reg] =hexagon_globalreg_masked_value (s, reg, value); +set_reg_value (s, reg,hexagon_globalreg_masked_value (s, reg, value)); }uint64_t hexagon_globalreg_get_pcycle_base (HexagonGlobalRegState *s)
Signature · 1 line
2.34.1
PATCH v5 9/18 hw/hexagon: connect l2vic device
In reply to Brian CainAdd the l2vic to the shared hex-subsys so both machine models pick it up. Map its register banks, wire the interrupt lines to CPU[0] and link each vCPU, globalregs.
--- include/hw/hexagon/hex-subsys.h | 5 ++-- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_globalreg.h | 4 +++ hw/hexagon/hex-subsys.c | 38 +++++++++++++++++++++++++- hw/hexagon/hexagon_dsp.c | 2 +- hw/hexagon/hexagon_globalreg.c | 25 +++++++++++++++++ hw/hexagon/virt.c | 2 +- 7 files changed, 72 insertions(+), 5 deletions(-)
include/hw/hexagon/hex-subsys.h +3 -2
@@ -18,7 +18,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms,/* * Parent a CPU into the subsystem's cluster and wire its links. Call for * every CPU before hex_subsys_realize_cluster(), then realize each CPU with -* hex_subsys_realize_cpu(). +* hex_subsys_realize_cpu(). CPU[0] receives the L2VIC outputs. */ void hex_subsys_add_cpu (HexagonCommonMachineState *hms,DeviceState *cpu);
@@ -26,6 +26,7 @@ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu);void hex_subsys_realize_cluster (HexagonCommonMachineState *hms);/* Realize a CPU previously parented via hex_subsys_add_cpu(). */ -void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu); +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu, +bool boot_cpu);#endif /* HW_HEXAGON_HEX_SUBSYS_H */
include/hw/hexagon/hexagon.h +1 -0
@@ -158,6 +158,7 @@ struct HexagonCommonMachineState {MemoryRegion cfgtable_rom;MemoryRegion vtcm;DeviceState *cluster; +DeviceState *l2vic;DeviceState *glob_regs;DeviceState *tlb; };
include/hw/hexagon/hexagon_globalreg.h +4 -0
@@ -10,6 +10,7 @@#include "hw/core/qdev.h" #include "hw/core/sysbus.h" +#include "hw/intc/hex-l2vic.h" #include "qom/object.h" #include "target/hexagon/cpu.h"
@@ -22,6 +23,9 @@ struct HexagonGlobalRegState {/* Array of system registers */ uint32_t regs[NUM_SREGS ]; +/* L2VIC interface used to back the VID/VID1 registers */ +HexL2VicInterface *l2vic; +/* Global performance cycle counter base */ uint64_t g_pcycle_base;
hw/hexagon/hex-subsys.c +37 -1
@@ -10,6 +10,7 @@#include "hw/hexagon/hex-subsys.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/intc/hex-l2vic.h" #include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h"
@@ -17,6 +18,31 @@#include "hw/core/sysbus.h" #include "system/address-spaces.h" +#define HEX_L2VIC_CPU_IRQS 8 + +static DeviceState *l2vic_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +DeviceState *l2vic =qdev_new (TYPE_HEX_L2VIC ); + +object_property_add_child (OBJECT (hms),"l2vic" ,OBJECT (l2vic)); +sysbus_realize_and_unref (SYS_BUS_DEVICE (l2vic), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (l2vic),0 , m_cfg->l2vic_base); +sysbus_mmio_map (SYS_BUS_DEVICE (l2vic),1 , + m_cfg->cfgtable.fastl2vic_base <<16 ); + +return l2vic; +} + +static void l2vic_connect_cpu (DeviceState *l2vic,DeviceState *cpu) +{ +int i; + +for (i =0 ; i <HEX_L2VIC_CPU_IRQS ; i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (l2vic), i,qdev_get_gpio_in (cpu, i)); + } +} +static DeviceState *globalreg_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev)
@@ -26,6 +52,8 @@ static DeviceState *globalreg_create(HexagonCommonMachineState *hms,object_property_add_child (OBJECT (hms),"global-regs" ,OBJECT (glob_regs));qdev_prop_set_uint64 (glob_regs,"config-table-addr" , m_cfg->cfgbase);qdev_prop_set_uint32 (glob_regs,"dsp-rev" , rev); +object_property_set_link (OBJECT (glob_regs),"l2vic" ,OBJECT (hms->l2vic), + &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs), &error_fatal);return glob_regs;
@@ -81,6 +109,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, } hms->cluster =cluster_create (hms); + hms->l2vic =l2vic_create (hms, m_cfg); hms->glob_regs =globalreg_create (hms, m_cfg, rev); hms->tlb =tlb_create (hms, m_cfg); }
@@ -92,6 +121,8 @@ void hex_subsys_add_cpu(HexagonCommonMachineState *hms, DeviceState *cpu) OBJECT(hms->glob_regs), &error_fatal);object_property_set_link (OBJECT (cpu),"tlb" ,OBJECT (hms->tlb), &error_fatal); +object_property_set_link (OBJECT (cpu),"l2vic" ,OBJECT (hms->l2vic), + &error_fatal); }void hex_subsys_realize_cluster (HexagonCommonMachineState *hms)
@@ -105,7 +136,12 @@ void hex_subsys_realize_cluster(HexagonCommonMachineState *hms)qdev_realize_and_unref (hms->cluster,NULL , &error_fatal); } -void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu) +void hex_subsys_realize_cpu (HexagonCommonMachineState *hms,DeviceState *cpu, +bool boot_cpu) {qdev_realize_and_unref (cpu,NULL , &error_fatal); + +if (boot_cpu) { +l2vic_connect_cpu (hms->l2vic, cpu); + } }
hw/hexagon/hexagon_dsp.c +1 -1
@@ -139,7 +139,7 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,hex_subsys_realize_cluster (hms);for (int i =0 ; i < machine->smp.cpus; i++) { -hex_subsys_realize_cpu (hms,DEVICE (cpus[i])); +hex_subsys_realize_cpu (hms,DEVICE (cpus[i]), (i ==0 )); } }
hw/hexagon/hexagon_globalreg.c +25 -0
@@ -11,6 +11,7 @@#include "hw/core/qdev-properties.h" #include "hw/core/sysbus.h" #include "hw/core/resettable.h" +#include "hw/intc/hex-l2vic.h" #include "migration/vmstate.h" #include "qom/object.h" #include "target/hexagon/cpu.h"
@@ -135,8 +136,16 @@ static inline uint32_t apply_write_mask(uint32_t new_val, uint32_t cur_val,return new_val; } +static inline bool is_vid_reg (uint32_t reg) +{ +return reg ==HEX_SREG_VID || reg ==HEX_SREG_VID1 ; +} +static uint32_t get_reg_value (HexagonGlobalRegState *s,uint32_t reg) { +if (is_vid_reg (reg)) { +return l2vic_read_vid (s->l2vic, reg ==HEX_SREG_VID ?0 :1 ); + }return s->regs[reg]; }
@@ -144,6 +153,9 @@ static void set_reg_value(HexagonGlobalRegState *s, uint32_t reg, uint32_t value) { s->regs[reg] = value; +if (is_vid_reg (reg)) { +l2vic_update_vid (s->l2vic, reg ==HEX_SREG_VID ?0 :1 , value); + } } uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg,
@@ -269,6 +281,16 @@ static void hexagon_globalreg_reset_hold(Object *obj, ResetType type)do_hexagon_globalreg_reset (s); } +static void hexagon_globalreg_realize (DeviceState *dev,Error **errp) +{ +HexagonGlobalRegState *s =HEXAGON_GLOBALREG (dev); + +if (!s->l2vic) { +error_setg (errp,"hexagon_globalreg: 'l2vic' link property not set" ); +return ; + } +} +static const VMStateDescription vmstate_hexagon_globalreg = { .name ="hexagon_globalreg" , .version_id =1 ,
@@ -288,6 +310,8 @@ static const VMStateDescription vmstate_hexagon_globalreg = { };static const Property hexagon_globalreg_properties[] = { +DEFINE_PROP_LINK ("l2vic" , HexagonGlobalRegState, l2vic, + TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *),DEFINE_PROP_UINT32 ("boot-evb" , HexagonGlobalRegState, boot_evb,0x0 ),DEFINE_PROP_UINT64 ("config-table-addr" , HexagonGlobalRegState, config_table_addr,0xffffffffULL ),
@@ -308,6 +332,7 @@ static void hexagon_globalreg_class_init(ObjectClass *klass, const void *data)ResettableClass *rc =RESETTABLE_CLASS (klass); rc->phases.hold = hexagon_globalreg_reset_hold; + dc->realize = hexagon_globalreg_realize; dc->vmsd = &vmstate_hexagon_globalreg; dc->user_creatable = false;device_class_set_props (dc, hexagon_globalreg_properties);
hw/hexagon/virt.c +1 -1
@@ -270,7 +270,7 @@ static void virt_init(MachineState *ms)hex_subsys_realize_cluster (&vms->parent_obj);for (int i =0 ; i < ms->smp.cpus; i++) { -hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpus[i])); +hex_subsys_realize_cpu (&vms->parent_obj,DEVICE (cpus[i]), (i ==0 )); }fdt_add_cpu_nodes (vms);
Signature · 1 line
2.34.1
PATCH v5 10/18 hw/hexagon/virt: instantiate virtio-mmio transports
In reply to Brian CainAdd a VIRT_MMIO region and virtio-mmio transports, wired into l2vic.
--- include/hw/hexagon/virt.h | 3 +++ hw/hexagon/virt.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
include/hw/hexagon/virt.h +3 -0
@@ -11,6 +11,8 @@#include "hw/hexagon/hexagon.h" #include "target/hexagon/cpu.h" +#define VIRTIO_DEV_COUNT 8 +struct HexagonVirtMachineState {HexagonCommonMachineState parent_obj;
@@ -19,6 +21,7 @@ struct HexagonVirtMachineState {MemoryRegion tcm;MemoryRegion bios;Clock *apb_clk; +DeviceState *virtio_mmio[VIRTIO_DEV_COUNT ]; };void hexagon_load_fdt (const struct HexagonVirtMachineState *vms);
hw/hexagon/virt.c +28 -0
@@ -30,11 +30,19 @@enum {VIRT_UART0 , +VIRT_MMIO ,VIRT_FDT , }; +/* +* Virtio IRQs run from VIRTIO_IRQ_BASE to +* VIRTIO_IRQ_BASE + VIRTIO_DEV_COUNT - 1 +*/ +static const int VIRTIO_IRQ_BASE =16 ; +static const MemMapEntry base_memmap[] = { [VIRT_UART0 ] = {0x10000000 ,0x00000200 }, + [VIRT_MMIO ] = {0x11000000 ,0x00001000 }, [VIRT_FDT ] = {0x99800000 ,0x00400000 }, };
@@ -167,7 +175,25 @@ static void fdt_add_cpu_nodes(const HexagonVirtMachineState *vms) } } +static void create_virtio_devices (HexagonVirtMachineState *vms) +{ +hwaddr size = base_memmap[VIRT_MMIO ].size; +for (int i =0 ; i <VIRTIO_DEV_COUNT ; i++) { +int irq =VIRTIO_IRQ_BASE + i; +hwaddr base = base_memmap[VIRT_MMIO ].base + i * size; +DeviceState *dev =qdev_new ("virtio-mmio" ); +SysBusDevice *s =SYS_BUS_DEVICE (dev); + +object_property_add_child (OBJECT (MACHINE (vms)),"virtio-mmio[*]" , +OBJECT (dev)); +sysbus_realize_and_unref (s, &error_fatal); +sysbus_mmio_map (s,0 , base); +sysbus_connect_irq (s,0 , +qdev_get_gpio_in (vms->parent_obj.l2vic, irq)); + vms->virtio_mmio[i] = dev; + } +}void hexagon_load_fdt (const HexagonVirtMachineState *vms) {
@@ -246,6 +272,8 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); +create_virtio_devices (vms); + g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, ms->smp.cpus);for (int i =0 ; i < ms->smp.cpus; i++) {
Signature · 1 line
2.34.1
PATCH v5 11/18 hw/hexagon/virt: add l2vic interrupt-controller and virtio-mmio FDT nodes
In reply to Brian CainExpose l2vic as a device-tree interrupt-controller node and reference it via interrupt-parent, so guest kernels can discover the virtio-mmio transports.
--- hw/hexagon/virt.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-)
hw/hexagon/virt.c +41 -2
@@ -75,6 +75,30 @@ static void create_fdt(HexagonVirtMachineState *vms)qemu_fdt_setprop (fdt,"/chosen" ,"rng-seed" , rng_seed,sizeof (rng_seed)); } +static int32_t fdt_add_l2vic (HexagonVirtMachineState *vms, +const struct hexagon_machine_config *m_cfg) +{ +MachineState *ms =MACHINE (vms); +int32_t l2vic_phandle =qemu_fdt_alloc_phandle (ms->fdt); +char *nodename =g_strdup_printf ("/soc/interrupt-controller@%x" , + m_cfg->l2vic_base); +const char compat[] ="qcom,h2-pic\0hvm-pic" ; + +qemu_fdt_setprop_cell (ms->fdt,"/soc" ,"interrupt-parent" , l2vic_phandle); + +qemu_fdt_add_subnode (ms->fdt, nodename); +qemu_fdt_setprop_cell (ms->fdt, nodename,"#address-cells" ,0x0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"#interrupt-cells" ,0x1 ); +qemu_fdt_setprop (ms->fdt, nodename,"compatible" , compat,sizeof (compat)); +qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , + m_cfg->l2vic_base, m_cfg->l2vic_size); +qemu_fdt_setprop (ms->fdt, nodename,"interrupt-controller" ,NULL ,0 ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"phandle" , l2vic_phandle); + +g_free (nodename); +return l2vic_phandle; +} +static void fdt_add_hvx (HexagonVirtMachineState *vms,const struct hexagon_machine_config *m_cfg) {
@@ -175,13 +199,16 @@ static void fdt_add_cpu_nodes(const HexagonVirtMachineState *vms) } } -static void create_virtio_devices (HexagonVirtMachineState *vms) +static void create_virtio_devices (HexagonVirtMachineState *vms, +int32_t l2vic_phandle) { +MachineState *ms =MACHINE (vms);hwaddr size = base_memmap[VIRT_MMIO ].size;for (int i =0 ; i <VIRTIO_DEV_COUNT ; i++) {int irq =VIRTIO_IRQ_BASE + i;hwaddr base = base_memmap[VIRT_MMIO ].base + i * size; +char *nodename =g_strdup_printf ("/soc/virtio_mmio@%" PRIx64, base);DeviceState *dev =qdev_new ("virtio-mmio" );SysBusDevice *s =SYS_BUS_DEVICE (dev);
@@ -192,6 +219,16 @@ static void create_virtio_devices(HexagonVirtMachineState *vms)sysbus_connect_irq (s,0 ,qdev_get_gpio_in (vms->parent_obj.l2vic, irq)); vms->virtio_mmio[i] = dev; + +qemu_fdt_add_subnode (ms->fdt, nodename); +qemu_fdt_setprop_string (ms->fdt, nodename,"compatible" , +"virtio,mmio" ); +qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , base, size); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupts" , irq); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + l2vic_phandle); + +g_free (nodename); } }
@@ -251,6 +288,7 @@ static void virt_init(MachineState *ms)HexagonVirtMachineState *vms =HEXAGON_VIRT_MACHINE (ms);const struct hexagon_machine_config *m_cfg = &v68n_1024;int32_t clk_phandle; +int32_t l2vic_phandle;create_fdt (vms);qemu_fdt_setprop_string (ms->fdt,"/chosen" ,"bootargs" , ms->kernel_cmdline);
@@ -272,7 +310,8 @@ static void virt_init(MachineState *ms)fdt_add_hvx (vms, m_cfg); -create_virtio_devices (vms); + l2vic_phandle =fdt_add_l2vic (vms, m_cfg); +create_virtio_devices (vms, l2vic_phandle); g_autofree HexagonCPU **cpus = g_new(HexagonCPU *, ms->smp.cpus);
Signature · 1 line
2.34.1
PATCH v5 12/18 hw/hexagon/virt: connect pl011 UART interrupt
In reply to Brian CainWire pl011's sysbus IRQ into l2vic at IRQ 15.
--- hw/hexagon/virt.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
hw/hexagon/virt.c +8 -2
@@ -39,6 +39,7 @@ enum {* VIRTIO_IRQ_BASE + VIRTIO_DEV_COUNT - 1 */ static const int VIRTIO_IRQ_BASE =16 ; +static const int VIRT_UART0_IRQ =15 ;static const MemMapEntry base_memmap[] = { [VIRT_UART0 ] = {0x10000000 ,0x00000200 },
@@ -143,7 +144,7 @@ static int32_t fdt_add_clocks(const HexagonVirtMachineState *vms) }static void fdt_add_uart (const HexagonVirtMachineState *vms,int uart, -int32_t clk_phandle) +int32_t clk_phandle,int32_t l2vic_phandle) {char *nodename;hwaddr base = base_memmap[uart].base;
@@ -161,6 +162,8 @@ static void fdt_add_uart(const HexagonVirtMachineState *vms, int uart,qdev_connect_clock_in (dev,"clk" , vms->apb_clk);sysbus_realize_and_unref (s, &error_fatal);sysbus_mmio_map (s,0 , base); +sysbus_connect_irq (s,0 , +qdev_get_gpio_in (vms->parent_obj.l2vic,VIRT_UART0_IRQ )); nodename =g_strdup_printf ("/pl011@%" PRIx64, base);qemu_fdt_add_subnode (ms->fdt, nodename);
@@ -168,6 +171,9 @@ static void fdt_add_uart(const HexagonVirtMachineState *vms, int uart,/* Note that we can't use setprop_string because of the embedded NUL */ qemu_fdt_setprop (ms->fdt, nodename,"compatible" , compat,sizeof (compat));qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , base, size); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupts" ,VIRT_UART0_IRQ ); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + l2vic_phandle);qemu_fdt_setprop_cells (ms->fdt, nodename,"clocks" , clk_phandle, clk_phandle); qemu_fdt_setprop(ms->fdt, nodename, "clock-names", clocknames,
@@ -342,7 +348,7 @@ static void virt_init(MachineState *ms)fdt_add_cpu_nodes (vms); clk_phandle =fdt_add_clocks (vms); -fdt_add_uart (vms,VIRT_UART0 , clk_phandle); +fdt_add_uart (vms,VIRT_UART0 , clk_phandle, l2vic_phandle);hexagon_load_fdt (vms); }
Signature · 1 line
2.34.1
PATCH v5 13/18 tests/qtest: add L2VIC qtest
In reply to Brian CainAdd a qtest exercising L2VIC register access and interrupt enable/disable.
--- MAINTAINERS | 1 + tests/qtest/l2vic-test.c | 249 +++++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 3 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/l2vic-test.c
MAINTAINERS +1 -0
@@ -252,6 +252,7 @@ S: Supported F: target/hexagon/ F: hw/intc/hex-l2vic.c F: include/hw/intc/hex-l2vic.h +F: tests/qtest/l2vic-test.c X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
tests/qtest/l2vic-test.c new file +249 -0
249 lines not on this page · raw message
tests/qtest/meson.build +1 -1
@@ -299,7 +299,7 @@ qtests_riscv64 = ['riscv-csr-test'] + \ ['iommu-riscv-test'] : []) + \ (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) -qtests_hexagon = ['boot-serial-test'] +qtests_hexagon = ['boot-serial-test', 'l2vic-test'] qos_test_ss = ss.source_set() qos_test_ss.add(
Signature · 1 line
2.34.1
PATCH v5 14/18 tests/functional/hexagon: add arch_tests functional test
In reply to Brian CainAdd the test_int_steering case from hexagon-arch-tests.
--- tests/functional/hexagon/test_arch_tests.py | 6 ++++++ 1 file changed, 6 insertions(+)
tests/functional/hexagon/test_arch_tests.py +6 -0
@@ -52,6 +52,12 @@ def test_guest_mode(self) -> None: """ self.run_uart_test("test_guest_mode") + def test_int_steering(self) -> None: + """Tests interrupt steering via priority-based routing to + specific threads using STID priority and iassignw. + """ + self.run_uart_test("test_int_steering") + if __name__ == "__main__": QemuSystemTest.main()
Signature · 1 line
2.34.1
PATCH v5 15/18 hw/timer: Add QCT QTimer device model
In reply to Brian CainImplement the QCT QTimer generic timer device used by Hexagon DSP systems.
--- MAINTAINERS | 2 + include/hw/timer/qct-qtimer.h | 43 +++ hw/timer/qct-qtimer.c | 667 ++++++++++++++++++++++++++++++++++ hw/timer/Kconfig | 3 + hw/timer/meson.build | 2 + hw/timer/trace-events | 5 + 6 files changed, 722 insertions(+) create mode 100644 include/hw/timer/qct-qtimer.h create mode 100644 hw/timer/qct-qtimer.c
MAINTAINERS +2 -0
@@ -253,6 +253,8 @@ F: target/hexagon/ F: hw/intc/hex-l2vic.c F: include/hw/intc/hex-l2vic.h F: tests/qtest/l2vic-test.c +F: hw/timer/qct-qtimer.c +F: include/hw/timer/qct-qtimer.h X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
include/hw/timer/qct-qtimer.h new file +43 -0
43 lines not on this page · raw message
hw/timer/qct-qtimer.c new file +667 -0
667 lines not on this page · raw message
hw/timer/Kconfig +3 -0
@@ -65,3 +65,6 @@ config STELLARIS_GPTM config AVR_TIMER16 bool + +config HEX_QTIMER + bool
hw/timer/meson.build +2 -0
@@ -34,3 +34,5 @@ specific_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_timer.c')) system_ss.add(when: 'CONFIG_SIFIVE_PWM', if_true: files('sifive_pwm.c')) system_ss.add(when: 'CONFIG_AVR_TIMER16', if_true: files('avr_timer16.c')) + +system_ss.add(when: 'CONFIG_HEX_QTIMER', if_true: files('qct-qtimer.c'))
hw/timer/trace-events +5 -0
@@ -128,3 +128,8 @@ imx_epit_get_freq(uint32_t freq) "ptimer frequency is %u" imx_epit_read(const char *name, uint32_t value) "(%s) = 0x%08x" imx_epit_write(const char *name, uint64_t value) "(%s, value = 0x%08" PRIx64 ")" imx_epit_cmp(uint32_t sr) "sr was %d" + +# qct-qtimer.c +qtimer_interrupt(void) "qtimer interrupt line updated" +qtimer_read(uint64_t offset) "offset 0x%" PRIx64 +qtimer_write(uint64_t offset, uint64_t value) "offset 0x%" PRIx64 " value 0x%" PRIx64
Signature · 1 line
2.34.1
Re: [PATCH v5 15/18] hw/timer: Add QCT QTimer device model
Quoted 9 lines · Brian Cain
Implement the QCT QTimer generic timer device used by Hexagon DSP systems.
Co-authored-by Damien Hedde <[email protected]>Co-authored-by Tobias Röhmel <[email protected]>Co-authored-by Sid Manning <[email protected]>Co-authored-by Thomas Marceron <[email protected]>Co-authored-by Mahmoud Kamel <[email protected]>Signed-off-by Brian Cain <[email protected]>
Quoted 11 lines
--- MAINTAINERS | 2 + include/hw/timer/qct-qtimer.h | 43 +++ hw/timer/qct-qtimer.c | 667 ++++++++++++++++++++++++++++++++++ hw/timer/Kconfig | 3 + hw/timer/meson.build | 2 + hw/timer/trace-events | 5 + 6 files changed, 722 insertions(+) create mode 100644 include/hw/timer/qct-qtimer.h create mode 100644 hw/timer/qct-qtimer.c
PATCH v5 16/18 hw/hexagon: connect qtimer device
In reply to Brian CainAdd the QTimer to the shared hex-subsys so both machine models pick it up. Map its view region, wire its interrupt lines into l2vic, and link it to the globalreg device backing HEX_SREG_TIMERLO/TIMERHI.
--- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_globalreg.h | 4 ++++ hw/hexagon/hex-subsys.c | 28 ++++++++++++++++++++++++++ hw/hexagon/hexagon_globalreg.c | 17 ++++++++++++++++ hw/hexagon/Kconfig | 1 + 5 files changed, 51 insertions(+)
include/hw/hexagon/hexagon.h +1 -0
@@ -159,6 +159,7 @@ struct HexagonCommonMachineState {MemoryRegion vtcm;DeviceState *cluster;DeviceState *l2vic; +DeviceState *qtimer;DeviceState *glob_regs;DeviceState *tlb; };
include/hw/hexagon/hexagon_globalreg.h +4 -0
@@ -11,6 +11,7 @@#include "hw/core/qdev.h" #include "hw/core/sysbus.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "qom/object.h" #include "target/hexagon/cpu.h"
@@ -26,6 +27,9 @@ struct HexagonGlobalRegState {/* L2VIC interface used to back the VID/VID1 registers */ HexL2VicInterface *l2vic; +/* QTimer interface used to back the TIMERLO/TIMERHI registers */ +QctQtimerInterface *qtimer; +/* Global performance cycle counter base */ uint64_t g_pcycle_base;
hw/hexagon/hex-subsys.c +28 -0
@@ -11,6 +11,7 @@#include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "hw/cpu/cluster.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h"
@@ -20,6 +21,11 @@#define HEX_L2VIC_CPU_IRQS 8 +/* Number of QTimer frames instantiated for every Hexagon machine. */ +#define HEX_QTIMER_NR_FRAMES 3 + +#define HEX_QTIMER_L2VIC_IRQ_BASE 2 +static DeviceState *l2vic_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg) {
@@ -43,6 +49,25 @@ static void l2vic_connect_cpu(DeviceState *l2vic, DeviceState *cpu) } } +static DeviceState *qtimer_create (HexagonCommonMachineState *hms, +const struct hexagon_machine_config *m_cfg) +{ +DeviceState *qtimer =qdev_new (TYPE_QCT_QTIMER ); + +object_property_add_child (OBJECT (hms),"qtimer" ,OBJECT (qtimer)); +qdev_prop_set_uint32 (qtimer,"nr_frames" ,HEX_QTIMER_NR_FRAMES ); +sysbus_realize_and_unref (SYS_BUS_DEVICE (qtimer), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (qtimer),0 , m_cfg->csr_base); +sysbus_mmio_map (SYS_BUS_DEVICE (qtimer),1 , m_cfg->qtmr_region); +for (unsigned int i =0 ; i <HEX_QTIMER_NR_FRAMES ; i++) { +sysbus_connect_irq (SYS_BUS_DEVICE (qtimer), i, +qdev_get_gpio_in (hms->l2vic, +HEX_QTIMER_L2VIC_IRQ_BASE + i)); + } + +return qtimer; +} +static DeviceState *globalreg_create (HexagonCommonMachineState *hms,const struct hexagon_machine_config *m_cfg,Rev_t rev)
@@ -54,6 +79,8 @@ static DeviceState *globalreg_create(HexagonCommonMachineState *hms,qdev_prop_set_uint32 (glob_regs,"dsp-rev" , rev);object_property_set_link (OBJECT (glob_regs),"l2vic" ,OBJECT (hms->l2vic), &error_fatal); +object_property_set_link (OBJECT (glob_regs),"qtimer" ,OBJECT (hms->qtimer), + &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (glob_regs), &error_fatal);return glob_regs;
@@ -110,6 +137,7 @@ void hex_subsys_create(HexagonCommonMachineState *hms, hms->cluster =cluster_create (hms); hms->l2vic =l2vic_create (hms, m_cfg); + hms->qtimer =qtimer_create (hms, m_cfg); hms->glob_regs =globalreg_create (hms, m_cfg, rev); hms->tlb =tlb_create (hms, m_cfg); }
hw/hexagon/hexagon_globalreg.c +17 -0
@@ -12,6 +12,7 @@#include "hw/core/sysbus.h" #include "hw/core/resettable.h" #include "hw/intc/hex-l2vic.h" +#include "hw/timer/qct-qtimer.h" #include "migration/vmstate.h" #include "qom/object.h" #include "target/hexagon/cpu.h"
@@ -141,11 +142,21 @@ static inline bool is_vid_reg(uint32_t reg)return reg ==HEX_SREG_VID || reg ==HEX_SREG_VID1 ; } +static inline bool is_timer_reg (uint32_t reg) +{ +return reg ==HEX_SREG_TIMERLO || reg ==HEX_SREG_TIMERHI ; +} +static uint32_t get_reg_value (HexagonGlobalRegState *s,uint32_t reg) {if (is_vid_reg (reg)) {return l2vic_read_vid (s->l2vic, reg ==HEX_SREG_VID ?0 :1 ); } +if (is_timer_reg (reg)) { +return reg ==HEX_SREG_TIMERLO ? +qct_qtimer_get_timer_lo (s->qtimer) : +qct_qtimer_get_timer_hi (s->qtimer); + }return s->regs[reg]; }
@@ -289,6 +300,10 @@ static void hexagon_globalreg_realize(DeviceState *dev, Error **errp)error_setg (errp,"hexagon_globalreg: 'l2vic' link property not set" );return ; } +if (!s->qtimer) { +error_setg (errp,"hexagon_globalreg: 'qtimer' link property not set" ); +return ; + } }static const VMStateDescription vmstate_hexagon_globalreg = {
@@ -312,6 +327,8 @@ static const VMStateDescription vmstate_hexagon_globalreg = {static const Property hexagon_globalreg_properties[] = {DEFINE_PROP_LINK ("l2vic" , HexagonGlobalRegState, l2vic, TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *), +DEFINE_PROP_LINK ("qtimer" , HexagonGlobalRegState, qtimer, + TYPE_QCT_QTIMER_INTERFACE, QctQtimerInterface *),DEFINE_PROP_UINT32 ("boot-evb" , HexagonGlobalRegState, boot_evb,0x0 ),DEFINE_PROP_UINT64 ("config-table-addr" , HexagonGlobalRegState, config_table_addr,0xffffffffULL ),
hw/hexagon/Kconfig +1 -0
@@ -4,6 +4,7 @@ config HEX_DSP depends on HEXAGON select CPU_CLUSTER select HEX_L2VIC + select HEX_QTIMER config HEX_VIRT bool
Signature · 1 line
2.34.1
PATCH v5 17/18 tests/qtest: add qct-qtimer qtest
In reply to Brian CainAdd a qtest exercising the QCT QTimer's register access, view-region frame addressing, and one-shot timer firing behavior.
--- MAINTAINERS | 1 + tests/qtest/qct-qtimer-test.c | 385 ++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 2 +- 3 files changed, 387 insertions(+), 1 deletion(-) create mode 100644 tests/qtest/qct-qtimer-test.c
MAINTAINERS +1 -0
@@ -255,6 +255,7 @@ F: include/hw/intc/hex-l2vic.h 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 X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
tests/qtest/qct-qtimer-test.c new file +385 -0
385 lines not on this page · raw message
tests/qtest/meson.build +1 -1
@@ -299,7 +299,7 @@ qtests_riscv64 = ['riscv-csr-test'] + \ ['iommu-riscv-test'] : []) + \ (config_all_devices.has_key('CONFIG_K230') ? ['k230-wdt-test'] : []) -qtests_hexagon = ['boot-serial-test', 'l2vic-test'] +qtests_hexagon = ['boot-serial-test', 'l2vic-test', 'qct-qtimer-test'] qos_test_ss = ss.source_set() qos_test_ss.add(
Signature · 1 line
2.34.1
PATCH v5 18/18 tests/functional/hexagon: enable more arch_tests cases
In reply to Brian CainAdd more tests from hexagon-arch-tests, enabled by QTimer device.
These exercise cache maintenance ops, l2vic, thread start/stop, tlb/mmu operations, and user-mode transitions.
--- tests/functional/hexagon/test_arch_tests.py | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+)
tests/functional/hexagon/test_arch_tests.py +32 -0
@@ -58,6 +58,38 @@ def test_int_steering(self) -> None: """ self.run_uart_test("test_int_steering") + def test_cache(self) -> None: + """Tests cache operations: dckill/ickill, l2kill, dczeroa, + dccleaninva, cache disable/enable, barriers, and dcinva/dccleana. + """ + self.run_uart_test("test_cache") + + def test_l2vic(self) -> None: + """Tests the L2VIC interrupt controller: enable readback, + interrupt type readback, VID capture, and the fast interface. + """ + self.run_uart_test("test_l2vic") + + def test_threads(self) -> None: + """Tests hardware thread management: start/stop, MODECTL state, + per-thread HTID, shared memory, wait/resume, STID priority, and + SCHEDCFG/BESTWAIT readback. + """ + self.run_uart_test("test_threads") + + def test_tlb_mmu(self) -> None: + """Tests TLB/MMU operations: write/read/probe/invalidate, + global entries, multiple entries, overwrite, ASID matching, + and permission checks. + """ + self.run_uart_test("test_tlb_mmu") + + def test_user_mode(self) -> None: + """Tests user mode / privilege transitions: supervisor mode, + SSR UM/IE/XE/CE/PE bits, and the trap0 user-mode exit handler. + """ + self.run_uart_test("test_user_mode") + if __name__ == "__main__": QemuSystemTest.main()
Signature · 1 line
2.34.1