public inbox for qemu-devel@nongnu.org
 help / color / mirror / Atom feed
From: Shivang Upadhyay <shivangu@linux.ibm.com>
To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Cc: npiggin@gmail.com, milesg@linux.ibm.com,
	Shivang Upadhyay <shivangu@linux.ibm.com>,
	Aditya Gupta <adityag@linux.ibm.com>,
	Harsh Prateek Bora <harshpb@linux.ibm.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	BALATON Zoltan <balaton@eik.bme.hu>,
	qemu-stable@nongnu.org
Subject: [PATCH v2] ppc/pnv: fix dumpdtb option
Date: Wed, 11 Mar 2026 20:05:49 +0530	[thread overview]
Message-ID: <20260311143549.118720-1-shivangu@linux.ibm.com> (raw)

The '-machine dumpdtb' command line option stopped working on
PowerPC/pnv systems after recent design change [1].

Fixing this by generating fdt blob in `pnv_init`.

[1] https://lore.kernel.org/qemu-devel/20250206151214.2947842-1-peter.maydell@linaro.org/

Cc: Aditya Gupta <adityag@linux.ibm.com>
Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: BALATON Zoltan <balaton@eik.bme.hu>
Cc: qemu-stable@nongnu.org
Fixes: 8fd2518ef2f8d34 ("hw: Centralize handling of -machine dumpdtb option")
Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com>

---
Changes

V2:
    * added fdt_pack to newly generated fdt in pnv_init
    * cleared the fdt generation code from pnv_reset

V1:
    * https://lore.kernel.org/all/20260225081037.21990-1-shivangu@linux.ibm.com/
---
 hw/ppc/pnv.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 1513575b8f..7e54b6bc60 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -773,26 +773,8 @@ static void pnv_reset(MachineState *machine, ResetType type)
         }
     }
 
-    if (machine->fdt) {
-        fdt = machine->fdt;
-    } else {
-        fdt = pnv_dt_create(machine);
-        /* Pack resulting tree */
-        _FDT((fdt_pack(fdt)));
-    }
-
+    fdt = machine->fdt;
     cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));
-
-    /* Update machine->fdt with latest fdt */
-    if (machine->fdt != fdt) {
-        /*
-         * Set machine->fdt for 'dumpdtb' QMP/HMP command. Free
-         * the existing machine->fdt to avoid leaking it during
-         * a reset.
-         */
-        g_free(machine->fdt);
-        machine->fdt = fdt;
-    }
 }
 
 static ISABus *pnv_chip_power8_isa_create(PnvChip *chip, Error **errp)
@@ -1261,6 +1243,11 @@ static void pnv_init(MachineState *machine)
     if (pmc->i2c_init) {
         pmc->i2c_init(pnv);
     }
+
+    if (!machine->fdt) {
+        machine->fdt = pnv_dt_create(machine);
+        _FDT((fdt_pack(machine->fdt)));
+    }
 }
 
 /*
-- 
2.53.0



             reply	other threads:[~2026-03-11 14:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 14:35 Shivang Upadhyay [this message]
2026-03-11 14:57 ` [PATCH v2] ppc/pnv: fix dumpdtb option Peter Maydell
2026-03-11 15:04   ` Shivang Upadhyay
2026-03-13  6:15 ` Aditya Gupta
2026-03-13  6:41   ` Aditya Gupta
2026-03-13 11:20 ` Aditya Gupta
2026-03-13 16:33   ` Shivang Upadhyay
2026-03-16  6:09   ` Shivang Upadhyay
2026-03-23 23:16 ` Nathan Chancellor
2026-03-24  6:30   ` Shivang Upadhyay
2026-03-24  8:42   ` Shivang Upadhyay
2026-03-24 10:14     ` Peter Maydell
2026-03-24 10:21       ` Shivang Upadhyay
2026-03-24 10:47         ` 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=20260311143549.118720-1-shivangu@linux.ibm.com \
    --to=shivangu@linux.ibm.com \
    --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 \
    /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