Trivial cleanup
cover Trivial cleanup
This series contains some low-hanging fruit fixes I came up with when investigating Rust for QEMU, especially QOM object lifecycle vs. the Drop trait.
I noticed that no finalize methods were called in Rust sysbus devices when QEMU quits, and neither are its C variants. What is probably missing in the first place is a
object_unref(object_get_root());
at the end of qemu_cleanup() in runstate.c (see TODO there). Adding it before this series won't clean up machines since their refcount won't reach zero. With this series applied this additional line will cause various issues when quitting QEMU, allowing the problem to be investigated. Fixing it is beyond the scope of this series (and my time budget).
Testing done:
* make check
* Run imx8mp-evk with a Buildroot image
Bernhard Beschow (5):
hw/arm/fsl-imx8mp: Do not create redundant unimplemented devices hw/arm/fsl-imx8mp: Fix parent of ocram memory region hw/arm/imx8mp-evk: Fix reference count of SoC object system/vl: Fix reference count of machine object Revert "sysbus: add irq_routing_notifier"
include/hw/core/sysbus.h | 1 - hw/arm/fsl-imx8mp.c | 3 ++- hw/arm/imx8mp-evk.c | 4 ++-- hw/core/sysbus.c | 6 ------ system/vl.c | 1 + 5 files changed, 5 insertions(+), 10 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/5 hw/arm/fsl-imx8mp: Do not create redundant unimplemented devices
The GPT devices are implemented. No need to create redundant unimplemented devices.
timers")
--- hw/arm/fsl-imx8mp.c | 1 + 1 file changed, 1 insertion(+)
hw/arm/fsl-imx8mp.c +1 -0
@@ -688,6 +688,7 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error **errp)case FSL_IMX8MP_GIC_DIST :case FSL_IMX8MP_GIC_REDIST : case FSL_IMX8MP_GPIO1 ... FSL_IMX8MP_GPIO5: + case FSL_IMX8MP_GPT1 ... FSL_IMX8MP_GPT6: case FSL_IMX8MP_ECSPI1 ... FSL_IMX8MP_ECSPI3:case FSL_IMX8MP_ENET1 : case FSL_IMX8MP_I2C1 ... FSL_IMX8MP_I2C6:
Signature · 1 line
2.53.0
Re: [PATCH 1/5] hw/arm/fsl-imx8mp: Do not create redundant unimplemented devices
Quoted 9 lines · Bernhard Beschow
The GPT devices are implemented. No need to create redundant unimplemented devices.
Fixes f8b26121762c ("hw/arm/fsl-imx8mp: Implement general purposetimers")
cc Gaurav Sharma <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>---
thanks
-- PMM
PATCH 2/5 hw/arm/fsl-imx8mp: Fix parent of ocram memory region
In reply to Bernhard BeschowRather than having a NULL parent, let the containing SoC object be the parent. This cleans up the QOM composition tree a bit.
--- hw/arm/fsl-imx8mp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/fsl-imx8mp.c +1 -1
@@ -671,7 +671,7 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) fsl_imx8mp_memmap[FSL_IMX8MP_PCIE_PHY1].addr);/* On-Chip RAM */ -if (!memory_region_init_ram (&s->ocram,NULL ,"imx8mp.ocram" , +if (!memory_region_init_ram (&s->ocram,OBJECT (dev),"imx8mp.ocram" , fsl_imx8mp_memmap[FSL_IMX8MP_OCRAM ].size, errp)) {return ;
Signature · 1 line
2.53.0
Re: [PATCH 2/5] hw/arm/fsl-imx8mp: Fix parent of ocram memory region
Quoted 15 lines · Bernhard Beschow
Rather than having a NULL parent, let the containing SoC object be the parent. This cleans up the QOM composition tree a bit.
Fixes 1aaf3478684f ("hw/arm/fsl-imx8mp: Add on-chip RAM")cc Gaurav Sharma <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- hw/arm/fsl-imx8mp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/arm/fsl-imx8mp.c +0
-0
hw/arm/fsl-imx8mp.c static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) · line 677
Quoted 8 lines
hw/arm/fsl-imx8mp.c +1
-1@@ -671,7 +671,7 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) fsl_imx8mp_memmap[FSL_IMX8MP_PCIE_PHY1].addr);/* On-Chip RAM */ -if (!memory_region_init_ram (&s->ocram,NULL ,"imx8mp.ocram" , +if (!memory_region_init_ram (&s->ocram,OBJECT (dev),"imx8mp.ocram" , fsl_imx8mp_memmap[FSL_IMX8MP_OCRAM ].size, errp)) {return ;
This moves /machine/unattached/imx8mp.ocram[0] to
/machine/soc/imx8mp.ocram[0], as expected.
Aside: not sure why [0]. Might just be something memory regions do.
Re: [PATCH 2/5] hw/arm/fsl-imx8mp: Fix parent of ocram memory region
In reply to Bernhard BeschowQuoted 16 lines · Bernhard Beschow
Rather than having a NULL parent, let the containing SoC object be the parent. This cleans up the QOM composition tree a bit.
Fixes ("hw/arm/fsl-imx8mp: Add on-chip RAM")cc Gaurav Sharma <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- hw/arm/fsl-imx8mp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/arm/fsl-imx8mp.c +0
-0
hw/arm/fsl-imx8mp.c static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) · line 677
Quoted 8 lines
hw/arm/fsl-imx8mp.c +1
-1@@ -671,7 +671,7 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) fsl_imx8mp_memmap[FSL_IMX8MP_PCIE_PHY1].addr);/* On-Chip RAM */ -if (!memory_region_init_ram (&s->ocram,NULL ,"imx8mp.ocram" , +if (!memory_region_init_ram (&s->ocram,OBJECT (dev),"imx8mp.ocram" , fsl_imx8mp_memmap[FSL_IMX8MP_OCRAM ].size, errp)) {return ;
This is a migration break, because qemu_ram_set_idstr() includes the qdev path of the owning device when it creates the name of the ramblock for migrating it. But since we haven't released anything with this change in it and this board isn't versioned either, that's not a problem.
-- PMM
Re: [PATCH 2/5] hw/arm/fsl-imx8mp: Fix parent of ocram memory region
Am 10. März 2026 10:00:31 UTC schrieb Peter Maydell <[email protected]>:
Quoted 19 lines · Bernhard Beschow
Quoted 18 lines
Rather than having a NULL parent, let the containing SoC object be the parent. This cleans up the QOM composition tree a bit.
Fixes ("hw/arm/fsl-imx8mp: Add on-chip RAM")cc Gaurav Sharma <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- hw/arm/fsl-imx8mp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/arm/fsl-imx8mp.c +0
-0@@ -671,7 +671,7 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) fsl_imx8mp_memmap[FSL_IMX8MP_PCIE_PHY1].addr);
Quoted 13 lines
hw/arm/fsl-imx8mp.c static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) · line 677
Quoted 6 lines
hw/arm/fsl-imx8mp.c +1
-1/* On-Chip RAM */ -if (!memory_region_init_ram (&s->ocram,NULL ,"imx8mp.ocram" , +if (!memory_region_init_ram (&s->ocram,OBJECT (dev),"imx8mp.ocram" , fsl_imx8mp_memmap[FSL_IMX8MP_OCRAM ].size, errp)) {return ;This is a migration break, because
qemu_ram_set_idstr()includes the qdev path of the owning device when it creates the name of the ramblock for migrating it. But since we haven't released anything with this change in it and this board isn't versioned either, that's not a problem.
Do we still need to catch that? If so, how?
Quoted 2 lines
-- PMM
Re: [PATCH 2/5] hw/arm/fsl-imx8mp: Fix parent of ocram memory region
Quoted 37 lines · Bernhard Beschow
Am 10. März 2026 10:00:31 UTC schrieb Peter Maydell <[email protected]>:
Quoted 19 lines · Bernhard Beschow
Quoted 18 lines
Rather than having a NULL parent, let the containing SoC object be the parent. This cleans up the QOM composition tree a bit.
Fixes ("hw/arm/fsl-imx8mp: Add on-chip RAM")cc Gaurav Sharma <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- hw/arm/fsl-imx8mp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/arm/fsl-imx8mp.c +0
-0@@ -671,7 +671,7 @@ static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) fsl_imx8mp_memmap[FSL_IMX8MP_PCIE_PHY1].addr);Quoted 13 lines
hw/arm/fsl-imx8mp.c static void fsl_imx8mp_realize(DeviceState *dev, Error **errp) · line 677
Quoted 6 lines
hw/arm/fsl-imx8mp.c +1
-1/* On-Chip RAM */ -if (!memory_region_init_ram (&s->ocram,NULL ,"imx8mp.ocram" , +if (!memory_region_init_ram (&s->ocram,OBJECT (dev),"imx8mp.ocram" , fsl_imx8mp_memmap[FSL_IMX8MP_OCRAM ].size, errp)) {return ;This is a migration break, because
qemu_ram_set_idstr()includes the qdev path of the owning device when it creates the name of the ramblock for migrating it. But since we haven't released anything with this change in it and this board isn't versioned either, that's not a problem.
Quoted 1 line
Do we still need to catch that? If so, how?
The code change is fine; we just need to mention in the commit message that it's a migration compat break but that it's OK to do that for this board because it isn't versioned.
-- PMM
PATCH 3/5 hw/arm/imx8mp-evk: Fix reference count of SoC object
In reply to Bernhard Beschowobject_new() leaves a reference count of one, and object_property_add_child() then leaves it at two. This would leak the SoC object if the machine object was destroyed since the machine is the SoC's sole owner. Fix this by converting to object_new_with_props() which gets the parenting and reference count right in one go.
--- hw/arm/imx8mp-evk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/imx8mp-evk.c +2 -2
@@ -74,8 +74,8 @@ static void imx8mp_evk_init(MachineState *machine) .modify_dtb = imx8mp_evk_modify_dtb, }; - s =FSL_IMX8MP (object_new (TYPE_FSL_IMX8MP )); -object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s)); + s =FSL_IMX8MP (object_new_with_props (TYPE_FSL_IMX8MP ,OBJECT (machine), +"soc" , &error_fatal,NULL ));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);
Signature · 1 line
2.53.0
Re: [PATCH 3/5] hw/arm/imx8mp-evk: Fix reference count of SoC object
Quoted 19 lines · Bernhard Beschow
object_new()leaves a reference count of one, andobject_property_add_child()then leaves it at two. This would leak the SoC object if the machine object was destroyed since the machine is the SoC's sole owner. Fix this by converting toobject_new_with_props()which gets the parenting and reference count right in one go.Fixes a4eefc69b237 ("hw/arm: Add i.MX 8M Plus EVK board")cc Gaurav Sharma <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- hw/arm/imx8mp-evk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/arm/imx8mp-evk.c +0
-0
hw/arm/imx8mp-evk.c static void imx8mp_evk_init(MachineState *machine) · line 80
Quoted 9 lines
hw/arm/imx8mp-evk.c +2
-2@@ -74,8 +74,8 @@ static void imx8mp_evk_init(MachineState *machine) .modify_dtb = imx8mp_evk_modify_dtb, }; - s =FSL_IMX8MP (object_new (TYPE_FSL_IMX8MP )); -object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s)); + s =FSL_IMX8MP (object_new_with_props (TYPE_FSL_IMX8MP ,OBJECT (machine), +"soc" , &error_fatal,NULL ));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);
There are more boards doing this as object_new / add_child / unref than with object_new_with_props(), but doing it in one call seems better than three.
thanks
-- PMM
Re: [PATCH 3/5] hw/arm/imx8mp-evk: Fix reference count of SoC object
In reply to Bernhard BeschowQuoted 19 lines · Bernhard Beschow
object_new()leaves a reference count of one, andobject_property_add_child()then leaves it at two. This would leak the SoC object if the machine object was destroyed since the machine is the SoC's sole owner. Fix this by converting toobject_new_with_props()which gets the parenting and reference count right in one go.Fixes a4eefc69b237 ("hw/arm: Add i.MX 8M Plus EVK board")cc Gaurav Sharma <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- hw/arm/imx8mp-evk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/arm/imx8mp-evk.c +0
-0
hw/arm/imx8mp-evk.c static void imx8mp_evk_init(MachineState *machine) · line 80
Quoted 9 lines
hw/arm/imx8mp-evk.c +2
-2@@ -74,8 +74,8 @@ static void imx8mp_evk_init(MachineState *machine) .modify_dtb = imx8mp_evk_modify_dtb, }; - s =FSL_IMX8MP (object_new (TYPE_FSL_IMX8MP )); -object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s)); + s =FSL_IMX8MP (object_new_with_props (TYPE_FSL_IMX8MP ,OBJECT (machine), +"soc" , &error_fatal,NULL ));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);
Looking again at this, is this really right? object_property_add_child(...) creates the object (refcount 1), adds it as a child of the specified parent (refcount 2), then does object_unref() (refcount 1). Then in this code we call sysbus_realize_and_unref(), which calls qdev_realize_and_unref(). That function:
* (indirectly) calls bus_add_child(), which takes a reference and hands it to the link property on the parent (refcount 2)
* calls object_unref(), as its name suggests (refcount 1)
So now we have the object with refcount 1, so it doesn't just vanish, but on the other hand both the QOM tree parent and the qbus tree parent think they own a reference to the object, so our refcount is wrong.
I think the existing code here was correct: we get a reference because we call object_new(), and then we drop it by calling the realize_and_unref function.
I'm going to drop this patch from target-arm.next.
-- PMM
Re: [PATCH 3/5] hw/arm/imx8mp-evk: Fix reference count of SoC object
Am 30. April 2026 15:39:48 UTC schrieb Peter Maydell <[email protected]>:
Quoted 45 lines · Bernhard Beschow
Quoted 19 lines
object_new()leaves a reference count of one, andobject_property_add_child()then leaves it at two. This would leak the SoC object if the machine object was destroyed since the machine is the SoC's sole owner. Fix this by converting toobject_new_with_props()which gets the parenting and reference count right in one go.Fixes a4eefc69b237 ("hw/arm: Add i.MX 8M Plus EVK board")cc Gaurav Sharma <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- hw/arm/imx8mp-evk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/arm/imx8mp-evk.c +0
-0hw/arm/imx8mp-evk.c static void imx8mp_evk_init(MachineState *machine) · line 80
Quoted 9 lines
hw/arm/imx8mp-evk.c +2
-2@@ -74,8 +74,8 @@ static void imx8mp_evk_init(MachineState *machine) .modify_dtb = imx8mp_evk_modify_dtb, }; - s =FSL_IMX8MP (object_new (TYPE_FSL_IMX8MP )); -object_property_add_child (OBJECT (machine),"soc" ,OBJECT (s)); + s =FSL_IMX8MP (object_new_with_props (TYPE_FSL_IMX8MP ,OBJECT (machine), +"soc" , &error_fatal,NULL ));object_property_set_uint (OBJECT (s),"fec1-phy-num" ,1 , &error_fatal);sysbus_realize_and_unref (SYS_BUS_DEVICE (s), &error_fatal);Looking again at this, is this really right?
object_property_add_child(...)creates the object (refcount 1), adds it as a child of the specified parent (refcount 2), then doesobject_unref()(refcount 1). Then in this code we callsysbus_realize_and_unref(), which callsqdev_realize_and_unref(). That function:
* (indirectly) callsbus_add_child(), which takes a reference and hands it to the link property on the parent (refcount 2)
* callsobject_unref(), as its name suggests (refcount 1)So now we have the object with refcount 1, so it doesn't just vanish, but on the other hand both the QOM tree parent and the qbus tree parent think they own a reference to the object, so our refcount is wrong.
Quoted 5 lines
I think the existing code here was correct: we get a reference because we call
object_new(), and then we drop it by calling therealize_and_unreffunction.I'm going to drop this patch from target-arm.next.
Yeah, makes sense. Thanks foe the clarification.
We'll need to fix imx8mm-evk now since it uses the same broken pattern (I cc'd Gurav who incorporated this patch into his series). I'll send a fix.
Best regards,
Bernhard
PATCH 4/5 system/vl: Fix reference count of machine object
In reply to Bernhard Beschowobject_new_with_class() and object_property_add_child() leave a reference count of two while the QOM root is the sole owner. Fix the reference count to be one by calling object_unref() once.
--- system/vl.c | 1 + 1 file changed, 1 insertion(+)
system/vl.c +1 -0
@@ -2197,6 +2197,7 @@ static void qemu_create_machine(QDict *qdict) current_machine =MACHINE (object_new_with_class (OBJECT_CLASS (machine_class)));object_property_add_child (object_get_root (),"machine" ,OBJECT (current_machine)); +object_unref (current_machine);qemu_create_machine_containers (OBJECT (current_machine));object_property_add_child (machine_get_container ("unattached" ),"sysbus" ,OBJECT (sysbus_get_default ()));
Signature · 1 line
2.53.0
PATCH 5/5 Revert "sysbus: add irq_routing_notifier"
In reply to Bernhard BeschowThe callback has been introduced in commit 715ca691daca ("sysbus: add irq_routing_notifier") for use in VFIO platform. Meanwhile, VFIO platform has been removed via commit 762c85543948 ("vfio: Remove 'vfio- platform'") which was its only user. Remove this unused code.
This reverts commit 715ca691daca081108b33306faa6fa102f0df8d8.
--- include/hw/core/sysbus.h | 1 - hw/core/sysbus.c | 6 ------ 2 files changed, 7 deletions(-)
include/hw/core/sysbus.h +0 -1
@@ -50,7 +50,6 @@ struct SysBusDeviceClass {* omitted then. (This is not considered a fatal error.) */ char *(*explicit_ofw_unit_address)(const SysBusDevice *dev); -void (*connect_irq_notifier)(SysBusDevice *dev,qemu_irq irq); };struct SysBusDevice {
hw/core/sysbus.c +0 -6
@@ -104,13 +104,7 @@ qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n)void sysbus_connect_irq (SysBusDevice *dev,int n,qemu_irq irq) { -SysBusDeviceClass *sbd =SYS_BUS_DEVICE_GET_CLASS (dev); -qdev_connect_gpio_out_named (DEVICE (dev),SYSBUS_DEVICE_GPIO_IRQ , n, irq); - -if (sbd->connect_irq_notifier) { - sbd->connect_irq_notifier (dev, irq); - } }/* Check whether an MMIO region exists */
Signature · 1 line
2.53.0
Re: [PATCH 5/5] Revert "sysbus: add irq_routing_notifier"
Quoted 34 lines · Bernhard Beschow
The callback has been introduced in commit
715ca691daca("sysbus: addirq_routing_notifier") for use in VFIO platform. Meanwhile, VFIO platform has been removed via commit762c85543948("vfio: Remove 'vfio- platform'") which was its only user. Remove this unused code.This reverts commit
715ca691daca081108b33306faa6fa102f0df8d8.cc Cédric Le Goater <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- include/hw/core/sysbus.h | 1 - hw/core/sysbus.c | 6 ------ 2 files changed, 7 deletions(-)include/hw/core/sysbus.h +0
-1@@ -50,7 +50,6 @@ struct SysBusDeviceClass {* omitted then. (This is not considered a fatal error.) */ char *(*explicit_ofw_unit_address)(const SysBusDevice *dev); -void (*connect_irq_notifier)(SysBusDevice *dev,qemu_irq irq); };struct SysBusDevice {hw/core/sysbus.c +0
-0@@ -104,13 +104,7 @@ qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n)void sysbus_connect_irq (SysBusDevice *dev,int n,qemu_irq irq) {
hw/core/sysbus.c qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n) · line 110
Quoted 10 lines
hw/core/sysbus.c +0
-6-SysBusDeviceClass *sbd =SYS_BUS_DEVICE_GET_CLASS (dev); -qdev_connect_gpio_out_named (DEVICE (dev),SYSBUS_DEVICE_GPIO_IRQ , n, irq); - -if (sbd->connect_irq_notifier) { - sbd->connect_irq_notifier (dev, irq); - } }/* Check whether an MMIO region exists */
Thanks,
C.
Re: [PATCH 5/5] Revert "sysbus: add irq_routing_notifier"
Am 9. März 2026 09:19:10 UTC schrieb "Cédric Le Goater" <[email protected]>:
Quoted 45 lines · Bernhard Beschow
Quoted 31 lines
The callback has been introduced in commit
715ca691daca("sysbus: addirq_routing_notifier") for use in VFIO platform. Meanwhile, VFIO platform has been removed via commit762c85543948("vfio: Remove 'vfio- platform'") which was its only user. Remove this unused code.This reverts commit
715ca691daca081108b33306faa6fa102f0df8d8.cc Cédric Le Goater <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- include/hw/core/sysbus.h | 1 - hw/core/sysbus.c | 6 ------ 2 files changed, 7 deletions(-)include/hw/core/sysbus.h +0
-1@@ -50,7 +50,6 @@ struct SysBusDeviceClass {* omitted then. (This is not considered a fatal error.) */ char *(*explicit_ofw_unit_address)(const SysBusDevice *dev); -void (*connect_irq_notifier)(SysBusDevice *dev,qemu_irq irq); };struct SysBusDevice {hw/core/sysbus.c +0
-0@@ -104,13 +104,7 @@ qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n)void sysbus_connect_irq (SysBusDevice *dev,int n,qemu_irq irq)hw/core/sysbus.c qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n) · line 108
Quoted 10 lines
hw/core/sysbus.c +0
-6{ -SysBusDeviceClass *sbd =SYS_BUS_DEVICE_GET_CLASS (dev); -qdev_connect_gpio_out_named (DEVICE (dev),SYSBUS_DEVICE_GPIO_IRQ , n, irq); - -if (sbd->connect_irq_notifier) { - sbd->connect_irq_notifier (dev, irq); - } }/* Check whether an MMIO region exists */ Reviewed-by Cédric Le Goater <[email protected]>
Quoted 3 lines
Thanks,
C.
Who will pick up this patch?
Best regards,
Bernhard
Re: [PATCH 5/5] Revert "sysbus: add irq_routing_notifier"
Quoted 48 lines · Bernhard Beschow
Am 9. März 2026 09:19:10 UTC schrieb "Cédric Le Goater" <[email protected]>:
Quoted 45 lines · Bernhard Beschow
Quoted 31 lines
The callback has been introduced in commit
715ca691daca("sysbus: addirq_routing_notifier") for use in VFIO platform. Meanwhile, VFIO platform has been removed via commit762c85543948("vfio: Remove 'vfio- platform'") which was its only user. Remove this unused code.This reverts commit
715ca691daca081108b33306faa6fa102f0df8d8.cc Cédric Le Goater <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- include/hw/core/sysbus.h | 1 - hw/core/sysbus.c | 6 ------ 2 files changed, 7 deletions(-)include/hw/core/sysbus.h +0
-1@@ -50,7 +50,6 @@ struct SysBusDeviceClass {* omitted then. (This is not considered a fatal error.) */ char *(*explicit_ofw_unit_address)(const SysBusDevice *dev); -void (*connect_irq_notifier)(SysBusDevice *dev,qemu_irq irq); };struct SysBusDevice {hw/core/sysbus.c +0
-0@@ -104,13 +104,7 @@ qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n)void sysbus_connect_irq (SysBusDevice *dev,int n,qemu_irq irq)hw/core/sysbus.c qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n) · line 108
Quoted 10 lines
hw/core/sysbus.c +0
-6{ -SysBusDeviceClass *sbd =SYS_BUS_DEVICE_GET_CLASS (dev); -qdev_connect_gpio_out_named (DEVICE (dev),SYSBUS_DEVICE_GPIO_IRQ , n, irq); - -if (sbd->connect_irq_notifier) { - sbd->connect_irq_notifier (dev, irq); - } }/* Check whether an MMIO region exists */ Reviewed-by Cédric Le Goater <[email protected]>
Quoted 5 lines
Quoted 3 lines
Thanks,
C.
Who will pick up this patch?
I would say this is a qdev related matter, so Paolo ?
Thanks,
C.
Re: [PATCH 5/5] Revert "sysbus: add irq_routing_notifier"
Am 4. Mai 2026 09:51:05 UTC schrieb "Cédric Le Goater" <[email protected]>:
Quoted 49 lines · Bernhard Beschow
Quoted 48 lines
Am 9. März 2026 09:19:10 UTC schrieb "Cédric Le Goater" <[email protected]>:
Quoted 45 lines · Bernhard Beschow
Quoted 31 lines
The callback has been introduced in commit
715ca691daca("sysbus: addirq_routing_notifier") for use in VFIO platform. Meanwhile, VFIO platform has been removed via commit762c85543948("vfio: Remove 'vfio- platform'") which was its only user. Remove this unused code.This reverts commit
715ca691daca081108b33306faa6fa102f0df8d8.cc Cédric Le Goater <[email protected]>Signed-off-by Bernhard Beschow <[email protected]>--- include/hw/core/sysbus.h | 1 - hw/core/sysbus.c | 6 ------ 2 files changed, 7 deletions(-)include/hw/core/sysbus.h +0
-1@@ -50,7 +50,6 @@ struct SysBusDeviceClass {* omitted then. (This is not considered a fatal error.) */ char *(*explicit_ofw_unit_address)(const SysBusDevice *dev); -void (*connect_irq_notifier)(SysBusDevice *dev,qemu_irq irq); };struct SysBusDevice {hw/core/sysbus.c +0
-0@@ -104,13 +104,7 @@ qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n)void sysbus_connect_irq (SysBusDevice *dev,int n,qemu_irq irq)hw/core/sysbus.c qemu_irq sysbus_get_connected_irq(const SysBusDevice *dev, int n) · line 108
Quoted 10 lines
hw/core/sysbus.c +0
-6{ -SysBusDeviceClass *sbd =SYS_BUS_DEVICE_GET_CLASS (dev); -qdev_connect_gpio_out_named (DEVICE (dev),SYSBUS_DEVICE_GPIO_IRQ , n, irq); - -if (sbd->connect_irq_notifier) { - sbd->connect_irq_notifier (dev, irq); - } }/* Check whether an MMIO region exists */ Reviewed-by Cédric Le Goater <[email protected]>
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Thanks,
C.
Who will pick up this patch?
I would say this is a qdev related matter, so Paolo ?
Meanwhile, Peter took already care of it by applying the patch to target-arm.next and issuing a pull request -- thanks, Peter!
Best regards,
Bernhard
Quoted 5 lines
Thanks,
C.
Am 8. März 2026 20:35:11 UTC schrieb Bernhard Beschow <[email protected]>:
+Markus
Quoted 33 lines
This series contains some low-hanging fruit fixes I came up with when investigating Rust for QEMU, especially QOM object lifecycle vs. the Drop trait.
I noticed that no finalize methods were called in Rust sysbus devices when QEMU quits, and neither are its C variants. What is probably missing in the first place is a
object_unref(object_get_root());
at the end of
qemu_cleanup()inrunstate.c(see TODO there). Adding it before this series won't clean up machines since their refcount won't reach zero. With this series applied this additional line will cause various issues when quitting QEMU, allowing the problem to be investigated. Fixing it is beyond the scope of this series (and my time budget).Testing done:
*make check
* Run imx8mp-evk with a Buildroot imageBernhard Beschow (5):
hw/arm/fsl-imx8mp: Do not create redundant unimplemented devices hw/arm/fsl-imx8mp: Fix parent of ocram memory region hw/arm/imx8mp-evk: Fix reference count of SoC object system/vl: Fix reference count of machine object Revert "sysbus: addirq_routing_notifier"include/hw/core/sysbus.h | 1 - hw/arm/fsl-imx8mp.c | 3 ++- hw/arm/imx8mp-evk.c | 4 ++-- hw/core/sysbus.c | 6 ------ system/vl.c | 1 + 5 files changed, 5 insertions(+), 10 deletions(-)
Quoted 20 lines · Bernhard Beschow
This series contains some low-hanging fruit fixes I came up with when investigating Rust for QEMU, especially QOM object lifecycle vs. the Drop trait.
I noticed that no finalize methods were called in Rust sysbus devices when QEMU quits, and neither are its C variants. What is probably missing in the first place is a
object_unref(object_get_root());at the end of
qemu_cleanup()inrunstate.c(see TODO there). Adding it before this series won't clean up machines since their refcount won't reach zero. With this series applied this additional line will cause various issues when quitting QEMU, allowing the problem to be investigated. Fixing it is beyond the scope of this series (and my time budget).Testing done:
*make check
* Run imx8mp-evk with a Buildroot image
Quoted 6 lines
Bernhard Beschow (5):
hw/arm/fsl-imx8mp: Do not create redundant unimplemented devices hw/arm/fsl-imx8mp: Fix parent of ocram memory region hw/arm/imx8mp-evk: Fix reference count of SoC object system/vl: Fix reference count of machine object Revert "sysbus: addirq_routing_notifier"
Hi; I've applied patches 1, 2, 3 and 5 to target-arm.next, since they're all either arm-specific or the obviously-OK patch that deletes the unused connect_irq_notifier method.
Patch 4 (the system/vl one) I am not applying, because it hasn't been reviewed and I don't know enough to know if it's correct or not. (My guess is that it is correct.) You might want to repost it as a standalone patch to try to get it a bit more attention.
thanks
-- PMM