hw/arm: Use ARM_CPU_TYPE_NAME() and object_initialize_child()
Subsystems (5)
v2 cover hw/arm: Use ARM_CPU_TYPE_NAME() and object_initialize_child()
First we use ARM_CPU_TYPE_NAME() when we should.
Then is follow up of [1]:
This series looks at Eduardo suggestions from [2] and Thomas commit aff39be0ed97 to replace various object_initialize + qdev_set_parent_bus calls by sysbus_init_child_obj().
Finally, some devices are declared orphean while they have a parent, let them be together again.
Since v1 [3]:
- addressed Peter Maydell review comments
[1] https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg01492.html
[2] https://patchwork.ozlabs.org/patch/943333/#1953608
[3] https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg00135.html
Philippe Mathieu-Daudé (6):
hw/arm: Use ARM_CPU_TYPE_NAME() macro when appropriate hw/arm: Use object_initialize_child for correct reference counting hw/arm: Use sysbus_init_child_obj for correct reference counting hw/arm/fsl-imx: Add the cpu as child of the SoC object hw/dma/xilinx_axi: Use object_initialize_child for correct ref.
counting
hw/net/xilinx_axi: Use object_initialize_child for correct ref.
counting
hw/arm/allwinner-a10.c | 3 ++- hw/arm/cubieboard.c | 3 ++- hw/arm/digic.c | 3 ++- hw/arm/exynos4_boards.c | 4 ++-- hw/arm/fsl-imx25.c | 4 +++- hw/arm/fsl-imx31.c | 4 +++- hw/arm/fsl-imx6.c | 3 ++- hw/arm/fsl-imx6ul.c | 2 +- hw/arm/mcimx7d-sabre.c | 9 ++++----- hw/arm/mps2-tz.c | 15 +++++++-------- hw/arm/musca.c | 9 +++++---- hw/arm/xlnx-zynqmp.c | 8 ++++---- hw/dma/xilinx_axidma.c | 16 ++++++++-------- hw/net/xilinx_axienet.c | 17 ++++++++--------- 14 files changed, 53 insertions(+), 47 deletions(-)
Signature · 1 line
2.20.1
PATCH v2 1/6 hw/arm: Use ARM_CPU_TYPE_NAME() macro when appropriate
Commit ba1ba5cca introduce the ARM_CPU_TYPE_NAME() macro. Unify the code base by use it in all places.
---
v2: rebased, use in imx25/31 (pm215)
--- hw/arm/allwinner-a10.c | 3 ++- hw/arm/cubieboard.c | 3 ++- hw/arm/digic.c | 3 ++- hw/arm/fsl-imx25.c | 2 +- hw/arm/fsl-imx31.c | 2 +- hw/arm/fsl-imx6.c | 3 ++- hw/arm/fsl-imx6ul.c | 2 +- hw/arm/xlnx-zynqmp.c | 8 ++++---- 8 files changed, 15 insertions(+), 11 deletions(-)
hw/arm/allwinner-a10.c +2 -1
@@ -30,7 +30,8 @@ static void aw_a10_init(Object *obj)AwA10State *s =AW_A10 (obj);object_initialize_child (obj,"cpu" , &s->cpu,sizeof (s->cpu), -"cortex-a8-" TYPE_ARM_CPU , &error_abort,NULL ); +ARM_CPU_TYPE_NAME ("cortex-a8" ), + &error_abort,NULL );sysbus_init_child_obj (obj,"intc" , &s->intc,sizeof (s->intc),TYPE_AW_A10_PIC );
hw/arm/cubieboard.c +2 -1
@@ -81,7 +81,8 @@ static void cubieboard_init(MachineState *machine)static void cubieboard_machine_init (MachineClass *mc) { - mc->desc ="cubietech cubieboard" ; + mc->desc ="cubietech cubieboard (Cortex-A9)" ; + mc->default_cpu_type =ARM_CPU_TYPE_NAME ("cortex-a9" ); mc->init = cubieboard_init; mc->block_default_type =IF_IDE ; mc->units_per_default_bus =1 ;
hw/arm/digic.c +2 -1
@@ -37,7 +37,8 @@ static void digic_init(Object *obj)int i;object_initialize_child (obj,"cpu" , &s->cpu,sizeof (s->cpu), -"arm946-" TYPE_ARM_CPU , &error_abort,NULL ); +ARM_CPU_TYPE_NAME ("arm946" ), + &error_abort,NULL );for (i =0 ; i <DIGIC4_NB_TIMERS ; i++) {#define DIGIC_TIMER_NAME_MLEN 11
hw/arm/fsl-imx25.c +1 -1
@@ -36,7 +36,7 @@ static void fsl_imx25_init(Object *obj)FslIMX25State *s =FSL_IMX25 (obj);int i; -object_initialize (&s->cpu,sizeof (s->cpu),"arm926-" TYPE_ARM_CPU ); +object_initialize (&s->cpu,sizeof (s->cpu),ARM_CPU_TYPE_NAME ("arm926" ));sysbus_init_child_obj (obj,"avic" , &s->avic,sizeof (s->avic),TYPE_IMX_AVIC );
hw/arm/fsl-imx31.c +1 -1
@@ -33,7 +33,7 @@ static void fsl_imx31_init(Object *obj)FslIMX31State *s =FSL_IMX31 (obj);int i; -object_initialize (&s->cpu,sizeof (s->cpu),"arm1136-" TYPE_ARM_CPU ); +object_initialize (&s->cpu,sizeof (s->cpu),ARM_CPU_TYPE_NAME ("arm1136" ));sysbus_init_child_obj (obj,"avic" , &s->avic,sizeof (s->avic),TYPE_IMX_AVIC );
hw/arm/fsl-imx6.c +2 -1
@@ -43,7 +43,8 @@ static void fsl_imx6_init(Object *obj)for (i =0 ; i <MIN (ms->smp.cpus,FSL_IMX6_NUM_CPUS ); i++) {snprintf (name,NAME_SIZE ,"cpu%d" , i);object_initialize_child (obj, name, &s->cpu[i],sizeof (s->cpu[i]), -"cortex-a9-" TYPE_ARM_CPU , &error_abort,NULL ); +ARM_CPU_TYPE_NAME ("cortex-a9" ), + &error_abort,NULL ); } sysbus_init_child_obj(obj, "a9mpcore", &s->a9mpcore, sizeof(s->a9mpcore),
hw/arm/fsl-imx6ul.c +1 -1
@@ -34,7 +34,7 @@ static void fsl_imx6ul_init(Object *obj)int i;object_initialize_child (obj,"cpu0" , &s->cpu,sizeof (s->cpu), -"cortex-a7-" TYPE_ARM_CPU , &error_abort,NULL ); +ARM_CPU_TYPE_NAME ("cortex-a7" ), &error_abort,NULL );/* * A7MPCORE
hw/arm/xlnx-zynqmp.c +4 -4
@@ -196,8 +196,8 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,object_initialize_child (OBJECT (&s->rpu_cluster),"rpu-cpu[*]" , &s->rpu_cpu[i],sizeof (s->rpu_cpu[i]), -"cortex-r5f-" TYPE_ARM_CPU , &error_abort, -NULL ); +ARM_CPU_TYPE_NAME ("cortex-r5f" ), + &error_abort,NULL ); name =object_get_canonical_path_component (OBJECT (&s->rpu_cpu[i]));if (strcmp (name, boot_cpu)) {
@@ -237,8 +237,8 @@ static void xlnx_zynqmp_init(Object *obj)for (i =0 ; i < num_apus; i++) {object_initialize_child (OBJECT (&s->apu_cluster),"apu-cpu[*]" , &s->apu_cpu[i],sizeof (s->apu_cpu[i]), -"cortex-a53-" TYPE_ARM_CPU , &error_abort, -NULL ); +ARM_CPU_TYPE_NAME ("cortex-a53" ), + &error_abort,NULL ); } sysbus_init_child_obj(obj, "gic", &s->gic, sizeof(s->gic),
Signature · 1 line
2.20.1
Re: [Qemu-arm] [Qemu-devel] [PATCH v2 1/6] hw/arm: Use ARM_CPU_TYPE_NAME() macro when appropriate
Quoted 7 lines · Philippe Mathieu-Daudé
Commit
ba1ba5ccaintroduce theARM_CPU_TYPE_NAME()macro. Unify the code base by use it in all places.Reviewed-by Alistair Francis <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v2: rebased, use in imx25/31 (pm215)
Quoted 10 lines
--- hw/arm/allwinner-a10.c | 3 ++- hw/arm/cubieboard.c | 3 ++- hw/arm/digic.c | 3 ++- hw/arm/fsl-imx25.c | 2 +- hw/arm/fsl-imx31.c | 2 +- hw/arm/fsl-imx6.c | 3 ++- hw/arm/fsl-imx6ul.c | 2 +- hw/arm/xlnx-zynqmp.c | 8 ++++---- 8 files changed, 15 insertions(+), 11 deletions(-)
r~
PATCH v2 2/6 hw/arm: Use object_initialize_child for correct reference counting
In reply to Philippe Mathieu-DaudéAs explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child() increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the reference counting here right.
--- hw/arm/mcimx7d-sabre.c | 9 ++++----- hw/arm/mps2-tz.c | 15 +++++++-------- hw/arm/musca.c | 9 +++++---- 3 files changed, 16 insertions(+), 17 deletions(-)
hw/arm/mcimx7d-sabre.c +4 -5
@@ -30,7 +30,6 @@ static void mcimx7d_sabre_init(MachineState *machine) {static struct arm_boot_info boot_info;MCIMX7Sabre *s =g_new0 (MCIMX7Sabre,1 ); -Object *soc;int i;if (machine->ram_size >FSL_IMX7_MMDC_SIZE ) {
@@ -49,10 +48,10 @@ static void mcimx7d_sabre_init(MachineState *machine) .nb_cpus = machine->smp.cpus, }; -object_initialize (&s->soc,sizeof (s->soc),TYPE_FSL_IMX7 ); - soc =OBJECT (&s->soc); -object_property_add_child (OBJECT (machine),"soc" , soc, &error_fatal); -object_property_set_bool (soc, true,"realized" , &error_fatal); +object_initialize_child (OBJECT (machine),"soc" , + &s->soc,sizeof (s->soc), +TYPE_FSL_IMX7 , &error_fatal,NULL ); +object_property_set_bool (OBJECT (&s->soc), true,"realized" , &error_fatal);memory_region_allocate_system_memory (&s->ram,NULL ,"mcimx7d-sabre.ram" , machine->ram_size);
hw/arm/mps2-tz.c +7 -8
@@ -427,10 +427,10 @@ static void mps2tz_common_init(MachineState *machine)/* The sec_resp_cfg output from the IoTKit must be split into multiple * lines, one for each of the PPCs we create here, plus one per MSC. */ -object_initialize (&mms->sec_resp_splitter,sizeof (mms->sec_resp_splitter), -TYPE_SPLIT_IRQ ); -object_property_add_child (OBJECT (machine),"sec-resp-splitter" , -OBJECT (&mms->sec_resp_splitter), &error_abort); +object_initialize_child (OBJECT (machine),"sec-resp-splitter" , + &mms->sec_resp_splitter, +sizeof (mms->sec_resp_splitter), +TYPE_SPLIT_IRQ , &error_abort,NULL );object_property_set_int (OBJECT (&mms->sec_resp_splitter),ARRAY_SIZE (mms->ppc) +ARRAY_SIZE (mms->msc),"num-lines" , &error_fatal);
@@ -465,10 +465,9 @@ static void mps2tz_common_init(MachineState *machine)* Tx, Rx and "combined" IRQs are sent to the NVIC separately. * Create the OR gate for this. */ -object_initialize (&mms->uart_irq_orgate,sizeof (mms->uart_irq_orgate), -TYPE_OR_IRQ ); -object_property_add_child (OBJECT (mms),"uart-irq-orgate" , -OBJECT (&mms->uart_irq_orgate), &error_abort); +object_initialize_child (OBJECT (mms),"uart-irq-orgate" , + &mms->uart_irq_orgate,sizeof (mms->uart_irq_orgate), +TYPE_OR_IRQ , &error_abort,NULL );object_property_set_int (OBJECT (&mms->uart_irq_orgate),10 ,"num-lines" , &error_fatal); object_property_set_bool(OBJECT(&mms->uart_irq_orgate), true,
hw/arm/musca.c +5 -4
@@ -424,10 +424,11 @@ static void musca_init(MachineState *machine)* The sec_resp_cfg output from the SSE-200 must be split into multiple * lines, one for each of the PPCs we create here. */ -object_initialize (&mms->sec_resp_splitter,sizeof (mms->sec_resp_splitter), -TYPE_SPLIT_IRQ ); -object_property_add_child (OBJECT (machine),"sec-resp-splitter" , -OBJECT (&mms->sec_resp_splitter), &error_fatal); +object_initialize_child (OBJECT (machine),"sec-resp-splitter" , + &mms->sec_resp_splitter, +sizeof (mms->sec_resp_splitter), +TYPE_SPLIT_IRQ , &error_fatal,NULL ); +object_property_set_int (OBJECT (&mms->sec_resp_splitter),ARRAY_SIZE (mms->ppc),"num-lines" , &error_fatal); object_property_set_bool(OBJECT(&mms->sec_resp_splitter), true,
Signature · 1 line
2.20.1
Re: [Qemu-arm] [PATCH v2 2/6] hw/arm: Use object_initialize_child for correct reference counting
Quoted 31 lines · Philippe Mathieu-Daudé
As explained in commit
aff39be0ed97:Both functions,
object_initialize()andobject_property_add_child()increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use nowobject_initialize_child()instead to get the reference counting here right.Reviewed-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/mcimx7d-sabre.c | 9 ++++----- hw/arm/mps2-tz.c | 15 +++++++-------- hw/arm/musca.c | 9 +++++---- 3 files changed, 16 insertions(+), 17 deletions(-)hw/arm/mcimx7d-sabre.c +0
-1@@ -30,7 +30,6 @@ static void mcimx7d_sabre_init(MachineState *machine) {static struct arm_boot_info boot_info;MCIMX7Sabre *s =g_new0 (MCIMX7Sabre,1 ); -Object *soc;int i;if (machine->ram_size >FSL_IMX7_MMDC_SIZE ) {
hw/arm/mcimx7d-sabre.c static void mcimx7d_sabre_init(MachineState *machine) · line 53
Quoted 10 lines
hw/arm/mcimx7d-sabre.c +3
-4@@ -49,10 +48,10 @@ static void mcimx7d_sabre_init(MachineState *machine) .nb_cpus = machine->smp.cpus, }; -object_initialize (&s->soc,sizeof (s->soc),TYPE_FSL_IMX7 ); - soc =OBJECT (&s->soc); -object_property_add_child (OBJECT (machine),"soc" , soc, &error_fatal); -object_property_set_bool (soc, true,"realized" , &error_fatal); +object_initialize_child (OBJECT (machine),"soc" , + &s->soc,sizeof (s->soc), +TYPE_FSL_IMX7 , &error_fatal,NULL );
You could fit that into two instead of three lines.
But it's just a cosmetic nit, so:
Re: [Qemu-arm] [Qemu-devel] [PATCH v2 2/6] hw/arm: Use object_initialize_child for correct reference counting
In reply to Philippe Mathieu-DaudéQuoted 10 lines · Philippe Mathieu-Daudé
As explained in commit
aff39be0ed97:Both functions,
object_initialize()andobject_property_add_child()increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use nowobject_initialize_child()instead to get the reference counting here right.
Quoted 7 lines
Reviewed-by Peter Maydell <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/arm/mcimx7d-sabre.c | 9 ++++----- hw/arm/mps2-tz.c | 15 +++++++-------- hw/arm/musca.c | 9 +++++---- 3 files changed, 16 insertions(+), 17 deletions(-)
r~
PATCH v2 3/6 hw/arm: Use sysbus_init_child_obj for correct reference counting
In reply to Philippe Mathieu-DaudéAs explained in commit aff39be0ed97:
Both functions, object_initialize() and qdev_set_parent_bus() increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use now sysbus_init_child_obj() instead to get the reference counting here right.
---
v2: Corrected commit description (pm215)
--- hw/arm/exynos4_boards.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/exynos4_boards.c +2 -2
@@ -131,8 +131,8 @@ exynos4_boards_init_common(MachineState *machine,exynos4_boards_init_ram (s,get_system_memory (), exynos4_board_ram_size[board_type]); -object_initialize (&s->soc,sizeof (s->soc),TYPE_EXYNOS4210_SOC ); -qdev_set_parent_bus (DEVICE (&s->soc),sysbus_get_default ()); +sysbus_init_child_obj (OBJECT (machine),"soc" , + &s->soc,sizeof (s->soc),TYPE_EXYNOS4210_SOC );object_property_set_bool (OBJECT (&s->soc), true,"realized" , &error_fatal);
Signature · 1 line
2.20.1
Re: [Qemu-arm] [PATCH v2 3/6] hw/arm: Use sysbus_init_child_obj for correct reference counting
Quoted 3 lines · Philippe Mathieu-Daudé
As explained in commit
aff39be0ed97:Both functions,
object_initialize()andqdev_set_parent_bus()
Commit aff39be0ed97 was not about qdev_set_parent_bus(), so the first sentence sounds somewhat misleading here. Maybe rephrase the commit message without that reference to aff39be0ed97 ?
Quoted 4 lines
increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Well, the parent here (the machine) currently never gets destroyed ... so unless you've got a patch in your pipe to fix that, too, you should maybe also rephrase this part of the commit message.
Thomas
Re: [Qemu-arm] [PATCH v2 3/6] hw/arm: Use sysbus_init_child_obj for correct reference counting
Quoted 10 lines · Thomas Huth
Quoted 3 lines · Philippe Mathieu-Daudé
As explained in commit
aff39be0ed97:Both functions,
object_initialize()andqdev_set_parent_bus()Commit
aff39be0ed97was not aboutqdev_set_parent_bus(), so the first sentence sounds somewhat misleading here. Maybe rephrase the commit message without that reference toaff39be0ed97?
Quoted 8 lines
Quoted 4 lines
increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Well, the parent here (the machine) currently never gets destroyed ... so unless you've got a patch in your pipe to fix that, too, you should maybe also rephrase this part of the commit message.
How about just making the commit message:
Both object_initialize() and qdev_set_parent_bus() increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. In machine model code this refcount leak is not particularly problematic because (unlike devices) machines will never be created on demand via QMP, and they are never destroyed. But in any case let's use the new sysbus_init_child_obj() instead to get the reference counting here right.
?
thanks
-- PMM
Re: [Qemu-arm] [Qemu-devel] [PATCH v2 3/6] hw/arm: Use sysbus_init_child_obj for correct reference counting
In reply to Philippe Mathieu-DaudéQuoted 5 lines · Philippe Mathieu-Daudé
hw/arm/exynos4_boards.c +0
-0
hw/arm/exynos4_boards.c exynos4_boards_init_common(MachineState *machine, · line 137
Quoted 9 lines
hw/arm/exynos4_boards.c +2
-2@@ -131,8 +131,8 @@ exynos4_boards_init_common(MachineState *machine,exynos4_boards_init_ram (s,get_system_memory (), exynos4_board_ram_size[board_type]); -object_initialize (&s->soc,sizeof (s->soc),TYPE_EXYNOS4210_SOC ); -qdev_set_parent_bus (DEVICE (&s->soc),sysbus_get_default ()); +sysbus_init_child_obj (OBJECT (machine),"soc" , + &s->soc,sizeof (s->soc),TYPE_EXYNOS4210_SOC );object_property_set_bool (OBJECT (&s->soc), true,"realized" , &error_fatal);
Thomas' comments re the commit message notwithstanding, the patch itself is correct.
r~
PATCH v2 4/6 hw/arm/fsl-imx: Add the cpu as child of the SoC object
In reply to Philippe Mathieu-DaudéChild properties form the composition tree. All objects need to be a child of another object. Objects can only be a child of one object.
Respect this with the i.MX SoC, to get a cleaner composition tree.
---
v2: reworded commit description with Markus suggestions
--- hw/arm/fsl-imx25.c | 4 +++- hw/arm/fsl-imx31.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
hw/arm/fsl-imx25.c +3 -1
@@ -36,7 +36,9 @@ static void fsl_imx25_init(Object *obj)FslIMX25State *s =FSL_IMX25 (obj);int i; -object_initialize (&s->cpu,sizeof (s->cpu),ARM_CPU_TYPE_NAME ("arm926" )); +object_initialize_child (obj,"cpu" , &s->cpu,sizeof (s->cpu), +ARM_CPU_TYPE_NAME ("arm926" ), + &error_abort,NULL );sysbus_init_child_obj (obj,"avic" , &s->avic,sizeof (s->avic),TYPE_IMX_AVIC );
hw/arm/fsl-imx31.c +3 -1
@@ -33,7 +33,9 @@ static void fsl_imx31_init(Object *obj)FslIMX31State *s =FSL_IMX31 (obj);int i; -object_initialize (&s->cpu,sizeof (s->cpu),ARM_CPU_TYPE_NAME ("arm1136" )); +object_initialize_child (obj,"cpu" , &s->cpu,sizeof (s->cpu), +ARM_CPU_TYPE_NAME ("arm1136" ), + &error_abort,NULL );sysbus_init_child_obj (obj,"avic" , &s->avic,sizeof (s->avic),TYPE_IMX_AVIC );
Signature · 1 line
2.20.1
Re: [Qemu-arm] [Qemu-devel] [PATCH v2 4/6] hw/arm/fsl-imx: Add the cpu as child of the SoC object
Quoted 5 lines · Philippe Mathieu-Daudé
Child properties form the composition tree. All objects need to be a child of another object. Objects can only be a child of one object.
Respect this with the i.MX SoC, to get a cleaner composition tree.
Quoted 7 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v2: reworded commit description with Markus suggestions--- hw/arm/fsl-imx25.c | 4 +++- hw/arm/fsl-imx31.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)
r~
PATCH v2 5/6 hw/dma/xilinx_axi: Use object_initialize_child for correct ref. counting
In reply to Philippe Mathieu-DaudéAs explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child() increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the reference counting here right.
---
v2: fix typo ENET -> DMA in TYPE macro name
--- hw/dma/xilinx_axidma.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
hw/dma/xilinx_axidma.c +8 -8
@@ -566,14 +566,14 @@ static void xilinx_axidma_init(Object *obj)XilinxAXIDMA *s =XILINX_AXI_DMA (obj);SysBusDevice *sbd =SYS_BUS_DEVICE (obj); -object_initialize (&s->rx_data_dev,sizeof (s->rx_data_dev), -TYPE_XILINX_AXI_DMA_DATA_STREAM ); -object_initialize (&s->rx_control_dev,sizeof (s->rx_control_dev), -TYPE_XILINX_AXI_DMA_CONTROL_STREAM ); -object_property_add_child (OBJECT (s),"axistream-connected-target" , - (Object *)&s->rx_data_dev, &error_abort); -object_property_add_child (OBJECT (s),"axistream-control-connected-target" , - (Object *)&s->rx_control_dev, &error_abort); +object_initialize_child (OBJECT (s),"axistream-connected-target" , + &s->rx_data_dev,sizeof (s->rx_data_dev), +TYPE_XILINX_AXI_DMA_DATA_STREAM , &error_abort, +NULL ); +object_initialize_child (OBJECT (s),"axistream-control-connected-target" , + &s->rx_control_dev,sizeof (s->rx_control_dev), +TYPE_XILINX_AXI_DMA_CONTROL_STREAM , &error_abort, +NULL );sysbus_init_irq (sbd, &s->streams[0 ].irq);sysbus_init_irq (sbd, &s->streams[1 ].irq);
Signature · 1 line
2.20.1
Re: [Qemu-arm] [Qemu-devel] [PATCH v2 5/6] hw/dma/xilinx_axi: Use object_initialize_child for correct ref. counting
Quoted 10 lines · Philippe Mathieu-Daudé
As explained in commit
aff39be0ed97:Both functions,
object_initialize()andobject_property_add_child()increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use nowobject_initialize_child()instead to get the reference counting here right.
Quoted 7 lines
Reviewed-by Alistair Francis <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v2: fix typo ENET -> DMA in TYPE macro name--- hw/dma/xilinx_axidma.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
r~
Re: [Qemu-arm] [PATCH v2 5/6] hw/dma/xilinx_axi: Use object_initialize_child for correct ref. counting
In reply to Philippe Mathieu-DaudéQuoted 36 lines · Philippe Mathieu-Daudé
As explained in commit
aff39be0ed97:Both functions,
object_initialize()andobject_property_add_child()increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use nowobject_initialize_child()instead to get the reference counting here right.Reviewed-by Alistair Francis <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
v2: fix typo ENET -> DMA in TYPE macro name--- hw/dma/xilinx_axidma.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)hw/dma/xilinx_axidma.c +1
-8@@ -566,14 +566,14 @@ static void xilinx_axidma_init(Object *obj)XilinxAXIDMA *s =XILINX_AXI_DMA (obj);SysBusDevice *sbd =SYS_BUS_DEVICE (obj); -object_initialize (&s->rx_data_dev,sizeof (s->rx_data_dev), -TYPE_XILINX_AXI_DMA_DATA_STREAM ); -object_initialize (&s->rx_control_dev,sizeof (s->rx_control_dev), -TYPE_XILINX_AXI_DMA_CONTROL_STREAM ); -object_property_add_child (OBJECT (s),"axistream-connected-target" , - (Object *)&s->rx_data_dev, &error_abort); -object_property_add_child (OBJECT (s),"axistream-control-connected-target" , - (Object *)&s->rx_control_dev, &error_abort); + object_initialize_child(OBJECT(s), "axistream-connected-target",
hw/dma/xilinx_axidma.c static void xilinx_axidma_init(Object *obj) · line 579
Quoted 10 lines
hw/dma/xilinx_axidma.c +7
-0+ &s->rx_data_dev,sizeof (s->rx_data_dev), +TYPE_XILINX_AXI_DMA_DATA_STREAM , &error_abort, + NULL); +object_initialize_child (OBJECT (s),"axistream-control-connected-target" , + &s->rx_control_dev,sizeof (s->rx_control_dev), +TYPE_XILINX_AXI_DMA_CONTROL_STREAM , &error_abort, +NULL );sysbus_init_irq (sbd, &s->streams[0 ].irq);sysbus_init_irq (sbd, &s->streams[1 ].irq);
PATCH v2 6/6 hw/net/xilinx_axi: Use object_initialize_child for correct ref. counting
In reply to Philippe Mathieu-DaudéAs explained in commit aff39be0ed97:
Both functions, object_initialize() and object_property_add_child() increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use now object_initialize_child() instead to get the reference counting here right.
--- hw/net/xilinx_axienet.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
hw/net/xilinx_axienet.c +8 -9
@@ -994,15 +994,14 @@ static void xilinx_enet_init(Object *obj)XilinxAXIEnet *s =XILINX_AXI_ENET (obj);SysBusDevice *sbd =SYS_BUS_DEVICE (obj); -object_initialize (&s->rx_data_dev,sizeof (s->rx_data_dev), -TYPE_XILINX_AXI_ENET_DATA_STREAM ); -object_initialize (&s->rx_control_dev,sizeof (s->rx_control_dev), -TYPE_XILINX_AXI_ENET_CONTROL_STREAM ); -object_property_add_child (OBJECT (s),"axistream-connected-target" , - (Object *)&s->rx_data_dev, &error_abort); -object_property_add_child (OBJECT (s),"axistream-control-connected-target" , - (Object *)&s->rx_control_dev, &error_abort); - +object_initialize_child (OBJECT (s),"axistream-connected-target" , + &s->rx_data_dev,sizeof (s->rx_data_dev), +TYPE_XILINX_AXI_ENET_DATA_STREAM , &error_abort, +NULL ); +object_initialize_child (OBJECT (s),"axistream-control-connected-target" , + &s->rx_control_dev,sizeof (s->rx_control_dev), +TYPE_XILINX_AXI_ENET_CONTROL_STREAM , &error_abort, +NULL );sysbus_init_irq (sbd, &s->irq);memory_region_init_io (&s->iomem,OBJECT (s), &enet_ops, s,"enet" ,0x40000 );
Signature · 1 line
2.20.1
Re: [Qemu-arm] [Qemu-devel] [PATCH v2 6/6] hw/net/xilinx_axi: Use object_initialize_child for correct ref. counting
Quoted 10 lines · Philippe Mathieu-Daudé
As explained in commit
aff39be0ed97:Both functions,
object_initialize()andobject_property_add_child()increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use nowobject_initialize_child()instead to get the reference counting here right.
Quoted 5 lines
Reviewed-by Alistair Francis <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/net/xilinx_axienet.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
r~
Re: [Qemu-arm] [PATCH v2 6/6] hw/net/xilinx_axi: Use object_initialize_child for correct ref. counting
In reply to Philippe Mathieu-DaudéQuoted 35 lines · Philippe Mathieu-Daudé
As explained in commit
aff39be0ed97:Both functions,
object_initialize()andobject_property_add_child()increase the reference counter of the new object, so one of the references has to be dropped afterwards to get the reference counting right. Otherwise the child object will not be properly cleaned up when the parent gets destroyed.
Thus let's use nowobject_initialize_child()instead to get the reference counting here right.Reviewed-by Alistair Francis <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/net/xilinx_axienet.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)hw/net/xilinx_axienet.c +1
-9@@ -994,15 +994,14 @@ static void xilinx_enet_init(Object *obj)XilinxAXIEnet *s =XILINX_AXI_ENET (obj);SysBusDevice *sbd =SYS_BUS_DEVICE (obj); -object_initialize (&s->rx_data_dev,sizeof (s->rx_data_dev), -TYPE_XILINX_AXI_ENET_DATA_STREAM ); -object_initialize (&s->rx_control_dev,sizeof (s->rx_control_dev), -TYPE_XILINX_AXI_ENET_CONTROL_STREAM ); -object_property_add_child (OBJECT (s),"axistream-connected-target" , - (Object *)&s->rx_data_dev, &error_abort); -object_property_add_child (OBJECT (s),"axistream-control-connected-target" , - (Object *)&s->rx_control_dev, &error_abort); - + object_initialize_child(OBJECT(s), "axistream-connected-target",
hw/net/xilinx_axienet.c static void xilinx_enet_init(Object *obj) · line 1007
Quoted 10 lines
hw/net/xilinx_axienet.c +7
-0+ &s->rx_data_dev,sizeof (s->rx_data_dev), +TYPE_XILINX_AXI_ENET_DATA_STREAM , &error_abort, + NULL); +object_initialize_child (OBJECT (s),"axistream-control-connected-target" , + &s->rx_control_dev,sizeof (s->rx_control_dev), +TYPE_XILINX_AXI_ENET_CONTROL_STREAM , &error_abort, +NULL );sysbus_init_irq (sbd, &s->irq);memory_region_init_io (&s->iomem,OBJECT (s), &enet_ops, s,"enet" ,0x40000 );
Quoted 20 lines · Philippe Mathieu-Daudé
First we use
ARM_CPU_TYPE_NAME()when we should.Then is follow up of [1]:
This series looks at Eduardo suggestions from [2] and Thomas commit
aff39be0ed97to replace variousobject_initialize+qdev_set_parent_buscalls bysysbus_init_child_obj().Finally, some devices are declared orphean while they have a parent, let them be together again.
Since v1 [3]:
- addressed Peter Maydell review comments[1] https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg01492.html
[2] https://patchwork.ozlabs.org/patch/943333/#1953608
[3] https://lists.gnu.org/archive/html/qemu-devel/2019-07/msg00135.html
Quoted 9 lines
Philippe Mathieu-Daudé (6):
hw/arm: UseARM_CPU_TYPE_NAME()macro when appropriate hw/arm: Useobject_initialize_childfor correct reference counting hw/arm: Usesysbus_init_child_objfor correct reference counting hw/arm/fsl-imx: Add the cpu as child of the SoC object hw/dma/xilinx_axi: Useobject_initialize_childfor correct ref.
counting
hw/net/xilinx_axi: Useobject_initialize_childfor correct ref.
counting
This series is now in master (but I forgot to mention that I'd applied it to target-arm.next when I did that).
thanks
-- PMM