hw/arm: fsl-imx6: Don't call qdev_get_machine in soc init
Calling qdev_get_machine() in the soc_init function would result in the following assert ../hw/core/qdev.c:858: qdev_get_machine: Assertion `dev' failed. when trying to run ./qemu-system-aarch64 -S -display none -M virt -device fsl-imx6,help as the machine wasn't created yet. We call qdev_get_machine() to obtain the number of CPUs in the machine. So instead of initialising the CPUs in the SoC init let's instead do it in the realise where the machine will exist. Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Tested-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20260312043158.4191378-7-alistair.francis@wdc.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Alistair Francis committed
Mar 12, 2026 at 14:31 UTC
148dec44869e5b18a122f13e6f0bb2a4833d34ed
1 file changed
+7
-7
hw/arm/fsl-imx6.c
+7
-7
@@ -38,17 +38,10 @@
38
39
static void fsl_imx6_init(Object *obj)
40
{
41
- MachineState *ms = MACHINE(qdev_get_machine());
41
FslIMX6State *s = FSL_IMX6(obj);
42
char name[NAME_SIZE];
43
int i;
44
46
- for (i = 0; i < MIN(ms->smp.cpus, FSL_IMX6_NUM_CPUS); i++) {
47
- snprintf(name, NAME_SIZE, "cpu%d", i);
48
- object_initialize_child(obj, name, &s->cpu[i],
49
- ARM_CPU_TYPE_NAME("cortex-a9"));
50
- }
51
-
45
object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV);
46
47
object_initialize_child(obj, "ccm", &s->ccm, TYPE_IMX6_CCM);
@@ -119,6 +112,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
112
unsigned int smp_cpus = ms->smp.cpus;
113
DeviceState *mpcore = DEVICE(&s->a9mpcore);
114
DeviceState *gic;
115
+ char name[NAME_SIZE];
116
117
if (smp_cpus > FSL_IMX6_NUM_CPUS) {
118
error_setg(errp, "%s: Only %d CPUs are supported (%d requested)",
@@ -126,6 +120,12 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
120
return;
121
}
122
123
+ for (i = 0; i < smp_cpus; i++) {
124
+ snprintf(name, NAME_SIZE, "cpu%d", i);
125
+ object_initialize_child(OBJECT(dev), name, &s->cpu[i],
126
+ ARM_CPU_TYPE_NAME("cortex-a9"));
127
+ }
128
+
129
for (i = 0; i < smp_cpus; i++) {
130
131
/* On uniprocessor, the CBAR is set to 0 */