i.MX 8M Plus EVK Fixes
v2 cover i.MX 8M Plus EVK Fixes
As discussed in [1], this series modifies the SoC class be derived from TYPE_SYS_BUS_DEVICE to fix the reset mechanism and to prevent it from being user-creatable. It also removes an unused define.
v2:
* Do not set user_creatable = false; (Zoltan, Peter)
[1] https://lore.kernel.org/qemu-devel/[email protected]/
Bernhard Beschow (2):
hw/arm/fsl-imx8mp: Derive struct FslImx8mpState from
TYPE_SYS_BUS_DEVICE
hw/arm/fsl-imx8mp: Remove unused define
include/hw/arm/fsl-imx8mp.h | 4 ++-- hw/arm/fsl-imx8mp.c | 2 +- hw/arm/imx8mp-evk.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.48.1
PATCH v2 1/2 hw/arm/fsl-imx8mp: Derive struct FslImx8mpState from TYPE_SYS_BUS_DEVICE
Deriving from TYPE_SYS_BUS_DEVICE fixes the SoC object to be reset upon machine reset. It also makes the SoC implementation not user-creatable which can trigger the following crash:
$ ./qemu-system-aarch64 -M virt -device fsl-imx8mp ** ERROR:../../devel/qemu/tcg/tcg.c:1006:tcg_register_thread: assertion failed: (n < tcg_max_ctxs) Bail out! ERROR:../../devel/qemu/tcg/tcg.c:1006:tcg_register_thread: assertion failed: (n < tcg_max_ctxs) Aborted (core dumped)
--- include/hw/arm/fsl-imx8mp.h | 3 ++- hw/arm/fsl-imx8mp.c | 2 +- hw/arm/imx8mp-evk.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
include/hw/arm/fsl-imx8mp.h +2 -1
@@ -26,6 +26,7 @@#include "hw/timer/imx_gpt.h" #include "hw/usb/hcd-dwc3.h" #include "hw/watchdog/wdt_imx2.h" +#include "hw/sysbus.h" #include "qom/object.h" #include "qemu/units.h"
@@ -49,7 +50,7 @@ enum FslImx8mpConfiguration { };struct FslImx8mpState { -DeviceState parent_obj; +SysBusDevice parent_obj;ARMCPU cpu[FSL_IMX8MP_NUM_CPUS ];GICv3State gic;
hw/arm/fsl-imx8mp.c +1 -1
@@ -702,7 +702,7 @@ static void fsl_imx8mp_class_init(ObjectClass *oc, void *data)static const TypeInfo fsl_imx8mp_types[] = { { .name =TYPE_FSL_IMX8MP , - .parent =TYPE_DEVICE , + .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (FslImx8mpState), .instance_init = fsl_imx8mp_init, .class_init = fsl_imx8mp_class_init,
hw/arm/imx8mp-evk.c +1 -1
@@ -37,7 +37,7 @@ static void imx8mp_evk_init(MachineState *machine) s =FSL_IMX8MP (object_new (TYPE_FSL_IMX8MP ));object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal); -qdev_realize (DEVICE (s),NULL , &error_fatal); +sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);memory_region_add_subregion (get_system_memory (),FSL_IMX8MP_RAM_START , machine->ram);
Signature · 1 line
2.48.1
Re: [PATCH v2 1/2] hw/arm/fsl-imx8mp: Derive struct FslImx8mpState from TYPE_SYS_BUS_DEVICE
Quoted 31 lines · Bernhard Beschow
Deriving from
TYPE_SYS_BUS_DEVICEfixes the SoC object to be reset upon machine reset. It also makes the SoC implementation not user-creatable which can trigger the following crash:$ ./qemu-system-aarch64 -M virt -device fsl-imx8mp ** ERROR:../../devel/qemu/tcg/tcg.c:1006:tcg_register_thread: assertion failed: (n < tcg_max_ctxs) Bail out! ERROR:../../devel/qemu/tcg/tcg.c:1006:tcg_register_thread: assertion failed: (n < tcg_max_ctxs) Aborted (core dumped)hw/arm/fsl-imx8mp.c +1
-1@@ -702,7 +702,7 @@ static void fsl_imx8mp_class_init(ObjectClass *oc, void *data)static const TypeInfo fsl_imx8mp_types[] = { { .name =TYPE_FSL_IMX8MP , - .parent =TYPE_DEVICE , + .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (FslImx8mpState), .instance_init = fsl_imx8mp_init, .class_init = fsl_imx8mp_class_init,hw/arm/imx8mp-evk.c +0
-0
hw/arm/imx8mp-evk.c static void imx8mp_evk_init(MachineState *machine) · line 40
Quoted 5 lines
hw/arm/imx8mp-evk.c +1
-1@@ -37,7 +37,7 @@ static void imx8mp_evk_init(MachineState *machine) s =FSL_IMX8MP (object_new (TYPE_FSL_IMX8MP ));object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal); -qdev_realize (DEVICE (s),NULL , &error_fatal); +sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);
You want sysbus_realize() here, not the _and_unref() variant, because the device was created with object_initialize_child().
The pairing is:
* object_initialize_child() + sysbus_realize() / qdev_realize()
* qdev_new() + sysbus_realize_and_unref() / qdev_realize_and_unref()
(See the doc comment in include/hw/qdev-core.h for qdev_realize_and_unref() for more detail.)
Otherwise
thanks
-- PMM
Re: [PATCH v2 1/2] hw/arm/fsl-imx8mp: Derive struct FslImx8mpState from TYPE_SYS_BUS_DEVICE
Quoted 33 lines · Peter Maydell
Quoted 31 lines · Bernhard Beschow
Deriving from
TYPE_SYS_BUS_DEVICEfixes the SoC object to be reset upon machine reset. It also makes the SoC implementation not user-creatable which can trigger the following crash:$ ./qemu-system-aarch64 -M virt -device fsl-imx8mp ** ERROR:../../devel/qemu/tcg/tcg.c:1006:tcg_register_thread: assertion failed: (n < tcg_max_ctxs) Bail out! ERROR:../../devel/qemu/tcg/tcg.c:1006:tcg_register_thread: assertion failed: (n < tcg_max_ctxs) Aborted (core dumped)hw/arm/fsl-imx8mp.c +1
-1@@ -702,7 +702,7 @@ static void fsl_imx8mp_class_init(ObjectClass *oc, void *data)static const TypeInfo fsl_imx8mp_types[] = { { .name =TYPE_FSL_IMX8MP , - .parent =TYPE_DEVICE , + .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (FslImx8mpState), .instance_init = fsl_imx8mp_init, .class_init = fsl_imx8mp_class_init,hw/arm/imx8mp-evk.c +0
-0@@ -37,7 +37,7 @@ static void imx8mp_evk_init(MachineState *machine)
Quoted 8 lines
hw/arm/imx8mp-evk.c static void imx8mp_evk_init(MachineState *machine) · line 40
Quoted 5 lines
hw/arm/imx8mp-evk.c +1
-1s =FSL_IMX8MP (object_new (TYPE_FSL_IMX8MP ));object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal); -qdev_realize (DEVICE (s),NULL , &error_fatal); +sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);You want
sysbus_realize()here, not the_and_unref()variant, because the device was created withobject_initialize_child().
No, that's wrong, we create it with object_new(). So the _and_unref() *is* correct, but this is a separate bug fix from the "should be sysbus, not qdev" bug this patch says it is fixing. Can it be in a separate patch, please?
thanks
-- PMM
Re: [PATCH v2 1/2] hw/arm/fsl-imx8mp: Derive struct FslImx8mpState from TYPE_SYS_BUS_DEVICE
Am 18. März 2025 15:29:17 UTC schrieb Peter Maydell <[email protected]>:
Quoted 43 lines · Peter Maydell
Quoted 33 lines · Bernhard Beschow
Quoted 31 lines
Deriving from
TYPE_SYS_BUS_DEVICEfixes the SoC object to be reset upon machine reset. It also makes the SoC implementation not user-creatable which can trigger the following crash:$ ./qemu-system-aarch64 -M virt -device fsl-imx8mp ** ERROR:../../devel/qemu/tcg/tcg.c:1006:tcg_register_thread: assertion failed: (n < tcg_max_ctxs) Bail out! ERROR:../../devel/qemu/tcg/tcg.c:1006:tcg_register_thread: assertion failed: (n < tcg_max_ctxs) Aborted (core dumped)hw/arm/fsl-imx8mp.c +1
-1@@ -702,7 +702,7 @@ static void fsl_imx8mp_class_init(ObjectClass *oc, void *data)static const TypeInfo fsl_imx8mp_types[] = { { .name =TYPE_FSL_IMX8MP , - .parent =TYPE_DEVICE , + .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (FslImx8mpState), .instance_init = fsl_imx8mp_init, .class_init = fsl_imx8mp_class_init,hw/arm/imx8mp-evk.c +0
-0@@ -37,7 +37,7 @@ static void imx8mp_evk_init(MachineState *machine)Quoted 8 lines
hw/arm/imx8mp-evk.c static void imx8mp_evk_init(MachineState *machine) · line 40
Quoted 5 lines
hw/arm/imx8mp-evk.c +1
-1s =FSL_IMX8MP (object_new (TYPE_FSL_IMX8MP ));object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal); -qdev_realize (DEVICE (s),NULL , &error_fatal); +sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);You want
sysbus_realize()here, not the_and_unref()variant, because the device was created withobject_initialize_child().
Quoted 4 lines
No, that's wrong, we create it with
object_new(). So the_and_unref()*is* correct, but this is a separate bug fix from the "should be sysbus, not qdev" bug this patch says it is fixing. Can it be in a separate patch, please?
Sure, fixed in v3.
Best regards,
Bernhard
Quoted 3 lines
thanks
-- PMM
PATCH v2 2/2 hw/arm/fsl-imx8mp: Remove unused define
In reply to Bernhard BeschowThe SoC has three SPI controllers, not four. Remove the extra define of an SPI IRQ.
--- include/hw/arm/fsl-imx8mp.h | 1 - 1 file changed, 1 deletion(-)
include/hw/arm/fsl-imx8mp.h +0 -1
@@ -238,7 +238,6 @@ enum FslImx8mpIrqs {FSL_IMX8MP_ECSPI1_IRQ =31 ,FSL_IMX8MP_ECSPI2_IRQ =32 ,FSL_IMX8MP_ECSPI3_IRQ =33 , -FSL_IMX8MP_ECSPI4_IRQ =34 ,FSL_IMX8MP_I2C1_IRQ =35 , FSL_IMX8MP_I2C2_IRQ = 36,
Signature · 1 line
2.48.1
Re: [PATCH v2 2/2] hw/arm/fsl-imx8mp: Remove unused define
Quoted 6 lines · Bernhard Beschow
The SoC has three SPI controllers, not four. Remove the extra define of an SPI IRQ.
Fixes 06908a84f036 "hw/arm/fsl-imx8mp: Add SPI controllers"Signed-off-by Bernhard Beschow <[email protected]>
thanks
-- PMM