From: Caleb Schlossin <calebs@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, npiggin@gmail.com, adityag@linux.ibm.com,
milesg@linux.ibm.com, alistair@alistair23.me,
kowal@linux.ibm.com, chalapathi.v@linux.ibm.com,
calebs@linux.ibm.com, angeloj@linux.ibm.com
Subject: [PATCH v2 7/7] hw/ppc: Add VMSTATE information to PnvPsi
Date: Mon, 15 Dec 2025 11:18:13 -0600 [thread overview]
Message-ID: <20251215171813.1670241-8-calebs@linux.ibm.com> (raw)
In-Reply-To: <20251215171813.1670241-1-calebs@linux.ibm.com>
PnvPsi needs to be able to save/load snapshots. Add VMSTATE information
to the device class and a post_load() method to restore dynamic data items and
memory region mappings.
Signed-off-by: Michael Kowal <kowal@linux.ibm.com>
Signed-off-by: Caleb Schlossin <calebs@linux.ibm.com>
---
hw/ppc/pnv_psi.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/hw/ppc/pnv_psi.c b/hw/ppc/pnv_psi.c
index 5d947d8b52..88d5f1d45d 100644
--- a/hw/ppc/pnv_psi.c
+++ b/hw/ppc/pnv_psi.c
@@ -25,6 +25,7 @@
#include "qemu/module.h"
#include "system/reset.h"
#include "qapi/error.h"
+#include "migration/vmstate.h"
#include "hw/ppc/fdt.h"
@@ -35,6 +36,8 @@
#include <libfdt.h>
+#undef PSI_DEBUG
+
#define PSIHB_XSCOM_FIR_RW 0x00
#define PSIHB_XSCOM_FIR_AND 0x01
#define PSIHB_XSCOM_FIR_OR 0x02
@@ -130,12 +133,11 @@ static void pnv_psi_set_bar(PnvPsi *psi, uint64_t bar)
{
PnvPsiClass *ppc = PNV_PSI_GET_CLASS(psi);
MemoryRegion *sysmem = get_system_memory();
- uint64_t old = psi->regs[PSIHB_XSCOM_BAR];
psi->regs[PSIHB_XSCOM_BAR] = bar & (ppc->bar_mask | PSIHB_BAR_EN);
/* Update MR, always remove it first */
- if (old & PSIHB_BAR_EN) {
+ if (memory_region_is_mapped(&psi->regs_mr)) {
memory_region_del_subregion(sysmem, &psi->regs_mr);
}
@@ -975,6 +977,40 @@ static void pnv_psi_register_types(void)
type_init(pnv_psi_register_types);
+#ifdef PSI_DEBUG
+static void psi_regs_pic_print_info(uint64_t *regs, uint32_t nr_regs,
+ GString *buf) {
+ uint i, prev_idx = -1;
+ uint64_t reg1, prev_reg1 = -1;
+ uint64_t reg2, prev_reg2 = -1;
+ uint64_t reg3, prev_reg3 = -1;
+ uint64_t reg4, prev_reg4 = -1;
+ for (i = 0; i < nr_regs; i = i + 4) {
+ /* Don't print if values do not change, but print last*/
+ reg1 = regs[i];
+ reg2 = regs[i + 1];
+ reg3 = regs[i + 2];
+ reg4 = regs[i + 3];
+ if (reg1 == prev_reg1 && reg2 == prev_reg2 &&
+ reg3 == prev_reg3 && reg4 == prev_reg4 &&
+ i < (nr_regs - 4)) {
+ if (i == (prev_idx + 4)) {
+ g_string_append_printf(buf, " . . .\n");
+ }
+ continue;
+ }
+
+ g_string_append_printf(buf, " [%03X] 0x%016lX %016lX %016lX %016lX\n",
+ i, reg1, reg2, reg3, reg4);
+ prev_idx = i;
+ prev_reg1 = reg1;
+ prev_reg2 = reg2;
+ prev_reg3 = reg3;
+ prev_reg4 = reg4;
+ }
+}
+#endif
+
void pnv_psi_pic_print_info(Pnv9Psi *psi9, GString *buf)
{
PnvPsi *psi = PNV_PSI(psi9);
@@ -985,4 +1021,10 @@ void pnv_psi_pic_print_info(Pnv9Psi *psi9, GString *buf)
g_string_append_printf(buf, "PSIHB Source %08x .. %08x\n",
offset, offset + psi9->source.nr_irqs - 1);
xive_source_pic_print_info(&psi9->source, offset, buf);
+#ifdef PSI_DEBUG
+ /* Print PSI registers */
+ g_string_append_printf(buf, "\nPSI Regs[0x0..%X]\n",
+ PSIHB_XSCOM_MAX);
+ psi_regs_pic_print_info(psi->regs, PSIHB_XSCOM_MAX, buf);
+#endif
}
--
2.47.3
next prev parent reply other threads:[~2025-12-15 17:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 17:18 [PATCH v2 0/7] hw/ppc: Snapshot support for several ppc devices Caleb Schlossin
2025-12-15 17:18 ` [PATCH v2 1/7] hw/ppc: Add VMSTATE information for LPC model Caleb Schlossin
2025-12-15 17:18 ` [PATCH v2 2/7] hw/ppc: Add pnv_spi vmstate support Caleb Schlossin
2025-12-15 17:18 ` [PATCH v2 3/7] hw/ppc: Add pnv_i2c " Caleb Schlossin
2025-12-15 17:18 ` [PATCH v2 4/7] hw/ppc: pnv_adu.c added " Caleb Schlossin
2025-12-15 17:18 ` [PATCH v2 5/7] hw/ppc: pnv_core.c add " Caleb Schlossin
2025-12-15 17:18 ` [PATCH v2 6/7] hw/ppc: pnv_chiptod.c " Caleb Schlossin
2025-12-15 17:18 ` Caleb Schlossin [this message]
2025-12-16 12:58 ` [PATCH v2 7/7] hw/ppc: Add VMSTATE information to PnvPsi Aditya Gupta
2025-12-16 13:35 ` Caleb Schlossin
2025-12-16 14:36 ` Aditya Gupta
2025-12-16 14:56 ` Caleb Schlossin
2025-12-16 13:02 ` [PATCH v2 0/7] hw/ppc: Snapshot support for several ppc devices Aditya Gupta
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=20251215171813.1670241-8-calebs@linux.ibm.com \
--to=calebs@linux.ibm.com \
--cc=adityag@linux.ibm.com \
--cc=alistair@alistair23.me \
--cc=angeloj@linux.ibm.com \
--cc=chalapathi.v@linux.ibm.com \
--cc=kowal@linux.ibm.com \
--cc=milesg@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@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.