From: Nathan Chancellor <nathan@kernel.org>
To: Shivang Upadhyay <shivangu@linux.ibm.com>
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, npiggin@gmail.com,
milesg@linux.ibm.com, Aditya Gupta <adityag@linux.ibm.com>,
Harsh Prateek Bora <harshpb@linux.ibm.com>,
BALATON Zoltan <balaton@eik.bme.hu>,
qemu-stable@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH] ppc/pnv: generate dtb after machine initialization is complete
Date: Tue, 24 Mar 2026 12:22:43 -0700 [thread overview]
Message-ID: <20260324192243.GA1270341@ax162> (raw)
In-Reply-To: <20260324135026.247418-1-shivangu@linux.ibm.com>
On Tue, Mar 24, 2026 at 07:20:26PM +0530, Shivang Upadhyay wrote:
> 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>
> ---
> hw/ppc/pnv.c | 17 +++++++++++++----
> include/hw/ppc/pnv.h | 2 ++
> 2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index 7e54b6bc60..f13b2e3db8 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -984,6 +984,17 @@ 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);
> +
> + 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 +1255,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);
> }
>
> /*
> diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
> index 24f8843a40..90028f974d 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);
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-03-24 19:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-24 13:50 [PATCH] ppc/pnv: generate dtb after machine initialization is complete Shivang Upadhyay
2026-03-24 13:54 ` Peter Maydell
2026-03-24 19:22 ` Nathan Chancellor [this message]
2026-03-26 11:16 ` Aditya Gupta
2026-03-26 11:25 ` Peter Maydell
2026-03-26 11:55 ` Aditya Gupta
2026-03-27 10:20 ` Shivang Upadhyay
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=20260324192243.GA1270341@ax162 \
--to=nathan@kernel.org \
--cc=adityag@linux.ibm.com \
--cc=balaton@eik.bme.hu \
--cc=harshpb@linux.ibm.com \
--cc=milesg@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=shivangu@linux.ibm.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 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.