hw/hexagon: move the TLB to hex-subsys
The TLB device is sized from the config table, so both machines create it identically. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> Link: https://lore.kernel.org/qemu-devel/20260806042723.3785369-5-brian.cain@oss.qualcomm.com Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Brian Cain committed
Aug 5, 2026 at 21:27 UTC
d24f9c80f62f95cb8f6c2b8666d3efd1e021fb99
4 files changed
+17
-20
hw/hexagon/hex-subsys.c
+16
@@ -9,6 +9,7 @@
9
#include "qapi/error.h"
10
#include "hw/hexagon/hex-subsys.h"
11
#include "hw/hexagon/hexagon_globalreg.h"
12
+#include "hw/hexagon/hexagon_tlb.h"
13
#include "hw/core/loader.h"
14
#include "hw/core/qdev-properties.h"
15
#include "hw/core/qdev.h"
@@ -29,6 +30,18 @@ static DeviceState *globalreg_create(HexagonCommonMachineState *hms,
30
return glob_regs;
31
}
32
33
+static DeviceState *tlb_create(HexagonCommonMachineState *hms,
34
+ const struct hexagon_machine_config *m_cfg)
35
+{
36
+ DeviceState *tlb = qdev_new(TYPE_HEXAGON_TLB);
37
+
38
+ object_property_add_child(OBJECT(hms), "tlb", OBJECT(tlb));
39
+ qdev_prop_set_uint32(tlb, "num-entries", m_cfg->cfgtable.jtlb_size_entries);
40
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(tlb), &error_fatal);
41
+
42
+ return tlb;
43
+}
44
+
45
void hex_subsys_create(HexagonCommonMachineState *hms,
46
const struct hexagon_machine_config *m_cfg, Rev_t rev)
47
{
@@ -57,11 +70,14 @@ void hex_subsys_create(HexagonCommonMachineState *hms,
70
}
71
72
hms->glob_regs = globalreg_create(hms, m_cfg, rev);
73
+ hms->tlb = tlb_create(hms, m_cfg);
74
}
75
76
void hex_subsys_realize_cpu(HexagonCommonMachineState *hms, DeviceState *cpu)
77
{
78
object_property_set_link(OBJECT(cpu), "global-regs",
79
OBJECT(hms->glob_regs), &error_fatal);
80
+ object_property_set_link(OBJECT(cpu), "tlb", OBJECT(hms->tlb),
81
+ &error_fatal);
82
qdev_realize_and_unref(cpu, NULL, &error_fatal);
83
}
hw/hexagon/hexagon_dsp.c
-10
@@ -15,7 +15,6 @@
15
#include "hw/core/qdev-properties.h"
16
#include "hw/hexagon/hexagon.h"
17
#include "hw/hexagon/hex-subsys.h"
18
-#include "hw/hexagon/hexagon_tlb.h"
18
#include "hw/core/loader.h"
19
#include "qapi/error.h"
20
#include "qemu/error-report.h"
@@ -108,7 +107,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,
107
{
108
HexagonCommonMachineState *hms = HEXAGON_COMMON_MACHINE(machine);
109
HexagonDspMachineState *dms = HEXAGON_DSP_MACHINE(machine);
111
- DeviceState *tlb_dev;
110
111
memset(&hexagon_binfo, 0, sizeof(hexagon_binfo));
112
if (machine->kernel_filename) {
@@ -120,12 +118,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,
118
119
hex_subsys_create(hms, m_cfg, rev);
120
123
- tlb_dev = qdev_new(TYPE_HEXAGON_TLB);
124
- object_property_add_child(OBJECT(machine), "tlb", OBJECT(tlb_dev));
125
- qdev_prop_set_uint32(tlb_dev, "num-entries",
126
- m_cfg->cfgtable.jtlb_size_entries);
127
- sysbus_realize_and_unref(SYS_BUS_DEVICE(tlb_dev), &error_fatal);
128
-
121
for (int i = 0; i < machine->smp.cpus; i++) {
122
HexagonCPU *cpu = HEXAGON_CPU(object_new(machine->cpu_type));
123
qemu_register_reset(do_cpu_reset, cpu);
@@ -138,8 +130,6 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,
130
if (i == 0) {
131
hexagon_init_bootstrap(dms, cpu);
132
}
141
- object_property_set_link(OBJECT(cpu), "tlb",
142
- OBJECT(tlb_dev), &error_fatal);
133
hex_subsys_realize_cpu(hms, DEVICE(cpu));
134
}
135
}
hw/hexagon/virt.c
-10
@@ -14,7 +14,6 @@
14
#include "hw/core/sysbus-fdt.h"
15
#include "hw/hexagon/hexagon.h"
16
#include "hw/hexagon/hex-subsys.h"
17
-#include "hw/hexagon/hexagon_tlb.h"
17
#include "hw/core/loader.h"
18
#include "hw/core/qdev-properties.h"
19
#include "hw/core/qdev-clock.h"
@@ -225,7 +224,6 @@ static void virt_init(MachineState *ms)
224
{
225
HexagonVirtMachineState *vms = HEXAGON_VIRT_MACHINE(ms);
226
const struct hexagon_machine_config *m_cfg = &v68n_1024;
228
- DeviceState *tlb_dev;
227
int32_t clk_phandle;
228
229
create_fdt(vms);
@@ -248,12 +246,6 @@ static void virt_init(MachineState *ms)
246
247
fdt_add_hvx(vms, m_cfg);
248
251
- tlb_dev = qdev_new(TYPE_HEXAGON_TLB);
252
- object_property_add_child(OBJECT(ms), "tlb", OBJECT(tlb_dev));
253
- qdev_prop_set_uint32(tlb_dev, "num-entries",
254
- m_cfg->cfgtable.jtlb_size_entries);
255
- sysbus_realize_and_unref(SYS_BUS_DEVICE(tlb_dev), &error_fatal);
256
-
249
for (int i = 0; i < ms->smp.cpus; i++) {
250
HexagonCPU *cpu = HEXAGON_CPU(object_new(ms->cpu_type));
251
qemu_register_reset(do_cpu_reset, cpu);
@@ -269,8 +261,6 @@ static void virt_init(MachineState *ms)
261
}
262
qdev_prop_set_uint32(DEVICE(cpu), "htid", i);
263
qdev_prop_set_bit(DEVICE(cpu), "start-powered-off", (i != 0));
272
- object_property_set_link(OBJECT(cpu), "tlb",
273
- OBJECT(tlb_dev), &error_fatal);
264
hex_subsys_realize_cpu(&vms->parent_obj, DEVICE(cpu));
265
}
266
include/hw/hexagon/hexagon.h
+1
@@ -158,6 +158,7 @@ struct HexagonCommonMachineState {
158
MemoryRegion cfgtable_rom;
159
MemoryRegion vtcm;
160
DeviceState *glob_regs;
161
+ DeviceState *tlb;
162
};
163
164
#endif