qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pnv/psi: Add VMSTATE information to PnvPsi
@ 2025-12-11 17:00 Caleb Schlossin
  2025-12-12 17:05 ` Miles Glenn
  0 siblings, 1 reply; 5+ messages in thread
From: Caleb Schlossin @ 2025-12-11 17:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, milesg, adityag, npiggin, kowal, calebs

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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] pnv/psi: Add VMSTATE information to PnvPsi
  2025-12-11 17:00 [PATCH] pnv/psi: Add VMSTATE information to PnvPsi Caleb Schlossin
@ 2025-12-12 17:05 ` Miles Glenn
  2025-12-15 13:07   ` Caleb Schlossin
  2025-12-15 17:21   ` Caleb Schlossin
  0 siblings, 2 replies; 5+ messages in thread
From: Miles Glenn @ 2025-12-12 17:05 UTC (permalink / raw)
  To: Caleb Schlossin, qemu-devel; +Cc: qemu-ppc, adityag, npiggin, kowal

Caleb, why not add this commit to your other submission of patches
titled "Snapshot support for several ppc devices"?

-Glenn

On Thu, 2025-12-11 at 11:00 -0600, Caleb Schlossin wrote:
> 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
>  }



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pnv/psi: Add VMSTATE information to PnvPsi
  2025-12-12 17:05 ` Miles Glenn
@ 2025-12-15 13:07   ` Caleb Schlossin
  2025-12-16 15:33     ` Miles Glenn
  2025-12-15 17:21   ` Caleb Schlossin
  1 sibling, 1 reply; 5+ messages in thread
From: Caleb Schlossin @ 2025-12-15 13:07 UTC (permalink / raw)
  To: milesg, qemu-devel; +Cc: qemu-ppc, adityag, npiggin, kowal

I can do that, if others agree. I see the commit msg should really be "hw/ppc: ...", so it would fit with the others.

- Caleb

On 12/12/25 11:05 AM, Miles Glenn wrote:
> Caleb, why not add this commit to your other submission of patches
> titled "Snapshot support for several ppc devices"?
> 
> -Glenn
> 
> On Thu, 2025-12-11 at 11:00 -0600, Caleb Schlossin wrote:
>> 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
>>  }
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pnv/psi: Add VMSTATE information to PnvPsi
  2025-12-12 17:05 ` Miles Glenn
  2025-12-15 13:07   ` Caleb Schlossin
@ 2025-12-15 17:21   ` Caleb Schlossin
  1 sibling, 0 replies; 5+ messages in thread
From: Caleb Schlossin @ 2025-12-15 17:21 UTC (permalink / raw)
  To: milesg, qemu-devel; +Cc: qemu-ppc, adityag, npiggin, kowal



On 12/12/25 11:05 AM, Miles Glenn wrote:
> Caleb, why not add this commit to your other submission of patches
> titled "Snapshot support for several ppc devices"?
> 
> -Glenn

PSI vmstate support commit now included with the second patch set here: https://lore.kernel.org/qemu-devel/20251215171813.1670241-1-calebs@linux.ibm.com/T/#t

> 
> On Thu, 2025-12-11 at 11:00 -0600, Caleb Schlossin wrote:
>> 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
>>  }
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pnv/psi: Add VMSTATE information to PnvPsi
  2025-12-15 13:07   ` Caleb Schlossin
@ 2025-12-16 15:33     ` Miles Glenn
  0 siblings, 0 replies; 5+ messages in thread
From: Miles Glenn @ 2025-12-16 15:33 UTC (permalink / raw)
  To: Caleb Schlossin, qemu-devel; +Cc: qemu-ppc, adityag, npiggin, kowal

On Mon, 2025-12-15 at 07:07 -0600, Caleb Schlossin wrote:
> I can do that, if others agree. I see the commit msg should really be "hw/ppc: ...", so it would fit with the others.
> 
> - Caleb
> 

Even if that wasn't the case, a commit series is not required to
address a single component (they often don't) and the cover letter
subject doesn't even need to have the "hw/ppc:" prefix in it.

-Glenn

> On 12/12/25 11:05 AM, Miles Glenn wrote:
> > Caleb, why not add this commit to your other submission of patches
> > titled "Snapshot support for several ppc devices"?
> > 
> > -Glenn
> > 
> > On Thu, 2025-12-11 at 11:00 -0600, Caleb Schlossin wrote:
> > > 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
> > >  }



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-16 15:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-11 17:00 [PATCH] pnv/psi: Add VMSTATE information to PnvPsi Caleb Schlossin
2025-12-12 17:05 ` Miles Glenn
2025-12-15 13:07   ` Caleb Schlossin
2025-12-16 15:33     ` Miles Glenn
2025-12-15 17:21   ` Caleb Schlossin

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).