From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 01/11] ppc/pnv: generate dtb after machine initialization is complete
Date: Tue, 31 Mar 2026 15:15:03 +0200 [thread overview]
Message-ID: <20260331131514.21152-2-philmd@linaro.org> (raw)
In-Reply-To: <20260331131514.21152-1-philmd@linaro.org>
From: Shivang Upadhyay <shivangu@linux.ibm.com>
Currently, the machine dtb is generated in pnv_init(), before all devices
are fully initialized. This can result in an incomplete dtb for the system,
as seen in bug [1].
Fix this by deferring dtb generation until machine initialization is complete,
using the machine_init_done_notifier hook.
[1] https://lore.kernel.org/all/20260323231612.GA2637687@ax162/
Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
Cc: BALATON Zoltan <balaton@eik.bme.hu>
Cc: qemu-stable@nongnu.org
Reported-by: Nathan Chancellor <nathan@kernel.org>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: a16d4c2f162a86d ("ppc/pnv: fix dumpdtb option")
Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Aditya Gupta <adityag@linux.ibm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20260327124136.983955-1-shivangu@linux.ibm.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/ppc/pnv.h | 2 ++
hw/ppc/pnv.c | 58 +++++++++++++++++++++++++-------------------
2 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index 24f8843a409..90028f974da 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -111,6 +111,8 @@ struct PnvMachineState {
bool big_core;
bool lpar_per_core;
+
+ Notifier machine_init_done;
};
PnvChip *pnv_get_chip(PnvMachineState *pnv, uint32_t chip_id);
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 7e54b6bc604..524563dcfc2 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -748,31 +748,10 @@ static void pnv_powerdown_notify(Notifier *n, void *opaque)
static void pnv_reset(MachineState *machine, ResetType type)
{
- PnvMachineState *pnv = PNV_MACHINE(machine);
- IPMIBmc *bmc;
void *fdt;
qemu_devices_reset(type);
- /*
- * The machine should provide by default an internal BMC simulator.
- * If not, try to use the BMC device that was provided on the command
- * line.
- */
- bmc = pnv_bmc_find(&error_fatal);
- if (!pnv->bmc) {
- if (!bmc) {
- if (!qtest_enabled()) {
- warn_report("machine has no BMC device. Use '-device "
- "ipmi-bmc-sim,id=bmc0 -device isa-ipmi-bt,bmc=bmc0,irq=10' "
- "to define one");
- }
- } else {
- pnv_bmc_set_pnor(bmc, pnv->pnor);
- pnv->bmc = bmc;
- }
- }
-
fdt = machine->fdt;
cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));
}
@@ -984,6 +963,37 @@ static uint64_t pnv_chip_get_ram_size(PnvMachineState *pnv, int chip_id)
return chip_id == 0 ? 1 * GiB : QEMU_ALIGN_DOWN(ram_per_chip, 1 * MiB);
}
+static void pnv_machine_init_done(Notifier *notifier, void *data)
+{
+ PnvMachineState *pnv = container_of(notifier, PnvMachineState, machine_init_done);
+ MachineState *machine = MACHINE(pnv);
+ IPMIBmc *bmc;
+
+ /*
+ * The machine should provide by default an internal BMC simulator.
+ * If not, try to use the BMC device that was provided on the command
+ * line.
+ */
+ bmc = pnv_bmc_find(&error_fatal);
+ if (!pnv->bmc) {
+ if (!bmc) {
+ if (!qtest_enabled()) {
+ warn_report("machine has no BMC device. Use '-device "
+ "ipmi-bmc-sim,id=bmc0 -device isa-ipmi-bt,bmc=bmc0,irq=10' "
+ "to define one");
+ }
+ } else {
+ pnv_bmc_set_pnor(bmc, pnv->pnor);
+ pnv->bmc = bmc;
+ }
+ }
+
+ if (!machine->fdt) {
+ machine->fdt = pnv_dt_create(machine);
+ _FDT((fdt_pack(machine->fdt)));
+ }
+}
+
static void pnv_init(MachineState *machine)
{
const char *bios_name = machine->firmware ?: FW_FILE_NAME;
@@ -1244,10 +1254,8 @@ static void pnv_init(MachineState *machine)
pmc->i2c_init(pnv);
}
- if (!machine->fdt) {
- machine->fdt = pnv_dt_create(machine);
- _FDT((fdt_pack(machine->fdt)));
- }
+ pnv->machine_init_done.notify = pnv_machine_init_done;
+ qemu_add_machine_init_done_notifier(&pnv->machine_init_done);
}
/*
--
2.53.0
next prev parent reply other threads:[~2026-03-31 13:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 13:15 [PULL 00/11] Misc HW patches for 2026-03-31 Philippe Mathieu-Daudé
2026-03-31 13:15 ` Philippe Mathieu-Daudé [this message]
2026-03-31 13:15 ` [PULL 02/11] MAINTAINERS: Separate QDev section from QOM one Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 03/11] target/mips: save CP0 timer in vmstate Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 04/11] backends/igvm: switch to PRIx64 Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 05/11] target/i386/cpu.c: Correct minor grammar error in warning Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 06/11] target/i386: Treat qtest like TCG for supported-features Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 07/11] ati-vga: Silence warning about operator precedence Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 08/11] ati-vga: Add upper limit to x-linear-aper-size property Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 09/11] hw/pci-host/astro: Update copyright and documentation link Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 10/11] hw/hppa: Disable Artist graphics card on 64-bit machines Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 11/11] MAINTAINERS: fix OSUOSL typo Philippe Mathieu-Daudé
2026-03-31 16:34 ` [PULL 00/11] Misc HW patches for 2026-03-31 Peter Maydell
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=20260331131514.21152-2-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.