qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, Zhao Liu <zhao1.liu@intel.com>
Subject: Re: [PULL 04/49] hw: Add QOM parentship relation with CPUs
Date: Mon, 13 Jan 2025 13:28:32 +0100	[thread overview]
Message-ID: <20250113132832.049f651a@imammedo.users.ipa.redhat.com> (raw)
In-Reply-To: <20250112221726.30206-5-philmd@linaro.org>

On Sun, 12 Jan 2025 23:16:40 +0100
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> QDev objects created with object_new() need to manually add
> their parent relationship with object_property_add_child().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> Message-Id: <20240216110313.17039-22-philmd@linaro.org>
> ---
>  hw/i386/x86-common.c                     | 1 +
>  hw/microblaze/petalogix_ml605_mmu.c      | 1 +
>  hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 +
>  hw/mips/cps.c                            | 1 +
>  hw/ppc/e500.c                            | 1 +
>  hw/ppc/spapr.c                           | 1 +
>  6 files changed, 6 insertions(+)
> 
> diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c
> index 97b4f7d4a0d..9c9ffb3484a 100644
> --- a/hw/i386/x86-common.c
> +++ b/hw/i386/x86-common.c
> @@ -60,6 +60,7 @@ static void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, Error **errp)
>      if (!object_property_set_uint(cpu, "apic-id", apic_id, errp)) {
>          goto out;
>      }
> +    object_property_add_child(OBJECT(x86ms), "cpu[*]", OBJECT(cpu));

I might  be missing something but why it needs to be done manually?

device_set_realized() will place any parent-less device under (1) /machine/unattached
while devices created with device_add() are be placed under /machine/peripheral[-anon]

The commit message unfortunately doesn't explain why [1] shall be replaced
by direct cpu[*] array property directly under machine.
 
Granted, those paths aren't any kind of ABI and wrt x86 cpus
nothing should break (or I'd say it shouldn't break our promises) 
But I'd rather not do this without a good reason/explanation.

>      qdev_realize(DEVICE(cpu), NULL, errp);
>  
>  out:
> diff --git a/hw/microblaze/petalogix_ml605_mmu.c b/hw/microblaze/petalogix_ml605_mmu.c
> index 8b44be75a22..b6be40915ac 100644
> --- a/hw/microblaze/petalogix_ml605_mmu.c
> +++ b/hw/microblaze/petalogix_ml605_mmu.c
> @@ -83,6 +83,7 @@ petalogix_ml605_init(MachineState *machine)
>  
>      /* init CPUs */
>      cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
> +    object_property_add_child(OBJECT(machine), "cpu", OBJECT(cpu));
>      object_property_set_str(OBJECT(cpu), "version", "8.10.a", &error_abort);
>      /* Use FPU but don't use floating point conversion and square
>       * root instructions
> diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c b/hw/microblaze/petalogix_s3adsp1800_mmu.c
> index 2c0d8c34cd2..29629310ba2 100644
> --- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
> +++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
> @@ -73,6 +73,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
>      MemoryRegion *sysmem = get_system_memory();
>  
>      cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
> +    object_property_add_child(OBJECT(machine), "cpu", OBJECT(cpu));
>      object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort);
>      object_property_set_bool(OBJECT(cpu), "little-endian",
>                               !TARGET_BIG_ENDIAN, &error_abort);
> diff --git a/hw/mips/cps.c b/hw/mips/cps.c
> index 0d8cbdc8924..293b405b965 100644
> --- a/hw/mips/cps.c
> +++ b/hw/mips/cps.c
> @@ -87,6 +87,7 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
>          /* All cores use the same clock tree */
>          qdev_connect_clock_in(DEVICE(cpu), "clk-in", s->clock);
>  
> +        object_property_add_child(OBJECT(dev), "cpu[*]", OBJECT(cpu));
>          if (!qdev_realize_and_unref(DEVICE(cpu), NULL, errp)) {
>              return;
>          }
> diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
> index 4551157c011..17d63ced907 100644
> --- a/hw/ppc/e500.c
> +++ b/hw/ppc/e500.c
> @@ -955,6 +955,7 @@ void ppce500_init(MachineState *machine)
>           */
>          object_property_set_bool(OBJECT(cs), "start-powered-off", i != 0,
>                                   &error_abort);
> +        object_property_add_child(OBJECT(machine), "cpu[*]", OBJECT(cpu));
>          qdev_realize_and_unref(DEVICE(cs), NULL, &error_fatal);
>  
>          if (!firstenv) {
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 623842f8064..125be6d29fd 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2705,6 +2705,7 @@ static void spapr_init_cpus(SpaprMachineState *spapr)
>                                      &error_fatal);
>              object_property_set_int(core, CPU_CORE_PROP_CORE_ID, core_id,
>                                      &error_fatal);
> +            object_property_add_child(OBJECT(spapr), "cpu[*]", OBJECT(core));
>              qdev_realize(DEVICE(core), NULL, &error_fatal);
>  
>              object_unref(core);



  reply	other threads:[~2025-01-13 12:29 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-12 22:16 [PULL 00/49] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 01/49] pc-bios/meson.build: Silent unuseful DTC warnings Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 02/49] target: Replace DEVICE(object_new) -> qdev_new() Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 03/49] hw: " Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 04/49] hw: Add QOM parentship relation with CPUs Philippe Mathieu-Daudé
2025-01-13 12:28   ` Igor Mammedov [this message]
2025-01-13 16:00     ` Philippe Mathieu-Daudé
2025-01-14 10:18       ` Igor Mammedov
2025-01-14 12:38         ` Markus Armbruster
2025-01-15 10:19           ` Igor Mammedov
2025-01-15 17:44             ` Peter Xu
2025-02-25 11:50               ` Igor Mammedov
2025-01-14 14:38         ` Zhao Liu
2025-01-15 13:13           ` Igor Mammedov
2025-01-15 14:07             ` Zhao Liu
2025-01-12 22:16 ` [PULL 05/49] hw/usb: Inline usb_try_new() Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 06/49] hw/usb: Inline usb_new() Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 07/49] hw/microblaze: Restrict MemoryRegionOps are implemented as 32-bit Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 08/49] hw/net/xilinx_ethlite: Map MDIO registers (as unimplemented) Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 09/49] hw/net/xilinx_ethlite: Introduce txbuf_ptr() helper Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 10/49] hw/net/xilinx_ethlite: Introduce rxbuf_ptr() helper Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 11/49] hw/net/xilinx_ethlite: Access TX_GIE register for each port Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 12/49] hw/net/xilinx_ethlite: Access TX_LEN " Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 13/49] hw/net/xilinx_ethlite: Access TX_CTRL " Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 14/49] hw/net/xilinx_ethlite: Map RX_CTRL as MMIO Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 15/49] hw/net/xilinx_ethlite: Map TX_LEN " Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 16/49] hw/net/xilinx_ethlite: Map TX_GIE " Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 17/49] hw/net/xilinx_ethlite: Map TX_CTRL " Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 18/49] hw/net/xilinx_ethlite: Map the RAM buffer as RAM memory region Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 19/49] hw/net/xilinx_ethlite: Rename 'mmio' MR as 'container' Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 20/49] hw/net/xilinx_ethlite: Map RESERVED I/O as unimplemented Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 21/49] docs/nitro-enclave: Clarify Enclave and Firecracker relationship Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 22/49] hw/misc/vmcoreinfo: Rename VMCOREINFO_DEVICE -> TYPE_VMCOREINFO Philippe Mathieu-Daudé
2025-01-12 22:16 ` [PULL 23/49] hw/misc/vmcoreinfo: Convert to three-phase reset interface Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 24/49] hw/pci: Rename has_power to enabled Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 25/49] hw/ufs: Adjust value to match CPU's endian format Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 26/49] hw/sd/sdhci: Set SDHC_NIS_DMA bit when appropriate Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 27/49] hw/sd/sdhci: Factor sdhci_sdma_transfer() out Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 28/49] hw/char/stm32f2xx_usart: replace print with trace Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 29/49] hw/timer/imx_gpt: Remove unused define Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 30/49] tests/qtest/libqos: Reuse TYPE_IMX_I2C define Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 31/49] hw/misc/imx6_src: Convert DPRINTF() to trace events Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 32/49] hw/char/imx_serial: Turn some DPRINTF() statements into " Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 33/49] hw/i2c/imx_i2c: Convert DPRINTF() to " Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 34/49] hw/gpio/imx_gpio: Turn DPRINTF() into " Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 35/49] tests/qtest/boot-serial-test: Correct HPPA machine name Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 36/49] tests: Add functional tests for HPPA machines Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 37/49] target/hppa: Convert hppa_cpu_init() to ResetHold handler Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 38/49] hw/hppa: Reset vCPUs calling resettable_reset() Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 39/49] target/hppa: Only set PSW 'M' bit on reset Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 40/49] target/hppa: Set PC on vCPU reset Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 41/49] target/hppa: Speed up hppa_is_pa20() Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 42/49] hw/loongarch/virt: Checkpatch cleanup Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 43/49] backends/cryptodev-vhost-user: Fix local_error leaks Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 44/49] hw/usb/hcd-xhci-pci: Use event ring 0 if mapping unsupported Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 45/49] hw/tricore/triboard: Remove unnecessary use of &first_cpu Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 46/49] MAINTAINERS: remove myself from sbsa-ref Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 47/49] MAINTAINERS: Add me as the maintainer for ivshmem-flat Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 48/49] MAINTAINERS: Update path to coreaudio.m Philippe Mathieu-Daudé
2025-01-12 22:17 ` [PULL 49/49] Add a b4 configuration file Philippe Mathieu-Daudé
2025-01-13 15:40 ` [PULL 00/49] Misc HW patches for 2025-01-12 Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250113132832.049f651a@imammedo.users.ipa.redhat.com \
    --to=imammedo@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).