Skip to contentSkip to conversation

Various xive fixes

PATCH Applied Frederic Barrat 3 participants 9 messages Jun 1, 2023

lore
Share & tools
lore
#0 lore raw

v2 cover Various xive fixes

A set of small fixes for the interrupt controller (xive2) on P10.

Change log:
v2:
split last patch to do a bit of cleanup first
add Cedric's reviewed-by on the first 3 patches

Frederic Barrat (5):
pnv/xive2: Add definition for TCTXT Config register pnv/xive2: Add definition for the ESB cache configuration register pnv/xive2: Allow writes to the Physical Thread Enable registers pnv/xive2: Introduce macros to manipulate TIMA addresses pnv/xive2: Handle TIMA access through all ports

 hw/intc/pnv_xive2.c        | 20 +++++++++++++++++++-
 hw/intc/pnv_xive2_regs.h   |  8 ++++++++
 hw/intc/xive.c             | 16 ++++++++--------
 include/hw/ppc/xive_regs.h | 16 ++++++++++++++++
 4 files changed, 51 insertions(+), 9 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH v2 1/5 pnv/xive2: Add definition for TCTXT Config register

Add basic read/write support for the TCTXT Config register on P10. qemu doesn't do anything with it yet, but it avoids logging a guest error when skiboot configures the fused-core state:

qemu-system-ppc64 -machine powernv10 ... -d guest_errors
...
[ 0.131670000,5] XIVE: [ IC 00 ] Initializing XIVE block ID 0...
XIVE[0] - TCTXT: invalid read @140
XIVE[0] - TCTXT: invalid write @140

---
 hw/intc/pnv_xive2.c      | 8 +++++++-
 hw/intc/pnv_xive2_regs.h | 4 ++++
 2 files changed, 11 insertions(+), 1 deletion(-)
hw/intc/pnv_xive2.c +7 -1
index e688381536..f0817a124f 100644
@@ -1269,6 +1269,9 @@ static uint64_t pnv_xive2_ic_tctxt_read(void *opaque, hwaddr offset,
     case TCTXT_EN1_RESET:
         val = xive->tctxt_regs[TCTXT_EN1 >> 3];
         break;
+    case TCTXT_CFG:
+        val = xive->tctxt_regs[reg];
+        break;
     default:
         xive2_error(xive, "TCTXT: invalid read @%"HWADDR_PRIx, offset);
     }
@@ -1280,6 +1283,7 @@ static void pnv_xive2_ic_tctxt_write(void *opaque, hwaddr offset,
                                      uint64_t val, unsigned size)
 {
     PnvXive2 *xive = PNV_XIVE2(opaque);
+    uint32_t reg = offset >> 3;
 
     switch (offset) {
     /*
@@ -1301,7 +1305,9 @@ static void pnv_xive2_ic_tctxt_write(void *opaque, hwaddr offset,
     case TCTXT_EN1_RESET:
         xive->tctxt_regs[TCTXT_EN1 >> 3] &= ~val;
         break;
-
+    case TCTXT_CFG:
+        xive->tctxt_regs[reg] = val;
+        break;
     default:
         xive2_error(xive, "TCTXT: invalid write @%"HWADDR_PRIx, offset);
         return;
hw/intc/pnv_xive2_regs.h +4 -0
index 0c096e4adb..8f1e0a1fde 100644
@@ -405,6 +405,10 @@
 #define X_TCTXT_EN1_RESET                       0x307
 #define TCTXT_EN1_RESET                         0x038
 
+/* TCTXT Config register */
+#define X_TCTXT_CFG                             0x328
+#define TCTXT_CFG                               0x140
+
 /*
  * VSD Tables
  */
Signature · 1 line
2.40.1
#2 lore raw

PATCH v2 2/5 pnv/xive2: Add definition for the ESB cache configuration register

In reply to Frederic Barrat

Add basic read/write support for the ESB cache configuration register on P10. We don't model the ESB cache in qemu so reading/writing the register won't do anything, but it avoids logging a guest error when skiboot configures it:

qemu-system-ppc64 -machine powernv10 ... -d guest_errors

      ...

XIVE[0] - VC: invalid read @240
XIVE[0] - VC: invalid write @240

---
 hw/intc/pnv_xive2.c      | 7 +++++++
 hw/intc/pnv_xive2_regs.h | 4 ++++
 2 files changed, 11 insertions(+)
hw/intc/pnv_xive2.c +7 -0
index f0817a124f..9778c102ff 100644
@@ -959,6 +959,10 @@ static uint64_t pnv_xive2_ic_vc_read(void *opaque, hwaddr offset,
         val = xive->vc_regs[reg];
         break;
 
+    case VC_ESBC_CFG:
+        val = xive->vc_regs[reg];
+        break;
+
     /*
      * EAS cache updates (not modeled)
      */
@@ -1050,6 +1054,9 @@ static void pnv_xive2_ic_vc_write(void *opaque, hwaddr offset,
         /* ESB update */
         break;
 
+    case VC_ESBC_CFG:
+        break;
+
     /*
      * EAS cache updates (not modeled)
      */
hw/intc/pnv_xive2_regs.h +4 -0
index 8f1e0a1fde..7165dc8704 100644
@@ -232,6 +232,10 @@
 #define  VC_ESBC_FLUSH_POLL_BLOCK_ID_MASK       PPC_BITMASK(32, 35)
 #define  VC_ESBC_FLUSH_POLL_OFFSET_MASK         PPC_BITMASK(36, 63) /* 28-bit */
 
+/* ESBC configuration */
+#define X_VC_ESBC_CFG                           0x148
+#define VC_ESBC_CFG                             0x240
+
 /* EASC flush control register */
 #define X_VC_EASC_FLUSH_CTRL                    0x160
 #define VC_EASC_FLUSH_CTRL                      0x300
Signature · 1 line
2.40.1
#3 lore raw

PATCH v2 3/5 pnv/xive2: Allow writes to the Physical Thread Enable registers

In reply to Frederic Barrat

Fix what was probably a silly mistake and allow to write the Physical Thread enable registers 0 and 1. Skiboot prefers to use the ENx_SET variant so it went unnoticed, but there's no reason to discard a write to the full register, it is Read-Write.

Fixes da71b7e3ed45 ("ppc/pnv: Add a XIVE2 controller to the POWER10 chip")
---
 hw/intc/pnv_xive2.c | 1 +
 1 file changed, 1 insertion(+)
hw/intc/pnv_xive2.c +1 -0
index 9778c102ff..5fc4240216 100644
@@ -1298,6 +1298,7 @@ static void pnv_xive2_ic_tctxt_write(void *opaque, hwaddr offset,
      */
     case TCTXT_EN0: /* Physical Thread Enable */
     case TCTXT_EN1: /* Physical Thread Enable (fused core) */
+        xive->tctxt_regs[reg] = val;
         break;
 
     case TCTXT_EN0_SET:
Signature · 1 line
2.40.1
#4 lore raw

PATCH v2 4/5 pnv/xive2: Introduce macros to manipulate TIMA addresses

In reply to Frederic Barrat

TIMA addresses are somewhat special and are split in several bit fields with different meanings. This patch describes it and introduce macros to more easily access the various fields.

---
 hw/intc/xive.c             | 14 +++++++-------
 include/hw/ppc/xive_regs.h | 16 ++++++++++++++++
 2 files changed, 23 insertions(+), 7 deletions(-)
hw/intc/xive.c +7 -7
index a986b96843..ebe399bc09 100644
@@ -249,7 +249,7 @@ static const uint8_t *xive_tm_views[] = {
 static uint64_t xive_tm_mask(hwaddr offset, unsigned size, bool write)
 {
     uint8_t page_offset = (offset >> TM_SHIFT) & 0x3;
-    uint8_t reg_offset = offset & 0x3F;
+    uint8_t reg_offset = offset & TM_REG_OFFSET;
     uint8_t reg_mask = write ? 0x1 : 0x2;
     uint64_t mask = 0x0;
     int i;
@@ -266,8 +266,8 @@ static uint64_t xive_tm_mask(hwaddr offset, unsigned size, bool write)
 static void xive_tm_raw_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,
                               unsigned size)
 {
-    uint8_t ring_offset = offset & 0x30;
-    uint8_t reg_offset = offset & 0x3F;
+    uint8_t ring_offset = offset & TM_RING_OFFSET;
+    uint8_t reg_offset = offset & TM_REG_OFFSET;
     uint64_t mask = xive_tm_mask(offset, size, true);
     int i;
 
@@ -296,8 +296,8 @@ static void xive_tm_raw_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,
 
 static uint64_t xive_tm_raw_read(XiveTCTX *tctx, hwaddr offset, unsigned size)
 {
-    uint8_t ring_offset = offset & 0x30;
-    uint8_t reg_offset = offset & 0x3F;
+    uint8_t ring_offset = offset & TM_RING_OFFSET;
+    uint8_t reg_offset = offset & TM_REG_OFFSET;
     uint64_t mask = xive_tm_mask(offset, size, false);
     uint64_t ret;
     int i;
@@ -534,7 +534,7 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,
     /*
      * First, check for special operations in the 2K region
      */
-    if (offset & 0x800) {
+    if (offset & TM_SPECIAL_OP) {
         xto = xive_tm_find_op(offset, size, true);
         if (!xto) {
             qemu_log_mask(LOG_GUEST_ERROR, "XIVE: invalid write access at TIMA "
@@ -573,7 +573,7 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,
     /*
      * First, check for special operations in the 2K region
      */
-    if (offset & 0x800) {
+    if (offset & TM_SPECIAL_OP) {
         xto = xive_tm_find_op(offset, size, false);
         if (!xto) {
             qemu_log_mask(LOG_GUEST_ERROR, "XIVE: invalid read access to TIMA"
include/hw/ppc/xive_regs.h +16 -0
index b7fde2354e..4a3c9badd3 100644
@@ -48,6 +48,22 @@
 
 #define TM_SHIFT                16
 
+/*
+ * TIMA addresses are 12-bits (4k page).
+ * The MSB indicates a special op with side effect, which can be
+ * refined with bit 10 (see below).
+ * The registers, logically grouped in 4 rings (a quad-word each), are
+ * defined on the 6 LSBs (offset below 0x40)
+ * In between, we can add a cache line index from 0...3 (ie, 0, 0x80,
+ * 0x100, 0x180) to select a specific snooper. Those 'snoop port
+ * address' bits should be dropped when processing the operations as
+ * they are all equivalent.
+ */
+#define TM_ADDRESS_MASK         0xC3F
+#define TM_SPECIAL_OP           0x800
+#define TM_RING_OFFSET          0x30
+#define TM_REG_OFFSET           0x3F
+
 /* TM register offsets */
 #define TM_QW0_USER             0x000 /* All rings */
 #define TM_QW1_OS               0x010 /* Ring 0..2 */
Signature · 1 line
2.40.1
Reviewed-by on v2 4/5
#5 lore raw

Re: [PATCH v2 4/5] pnv/xive2: Introduce macros to manipulate TIMA addresses

Quoted 5 lines · Frederic Barrat

TIMA addresses are somewhat special and are split in several bit fields with different meanings. This patch describes it and introduce macros to more easily access the various fields.

Thanks,

C.

Quoted 85 lines
---
  hw/intc/xive.c             | 14 +++++++-------
  include/hw/ppc/xive_regs.h | 16 ++++++++++++++++
  2 files changed, 23 insertions(+), 7 deletions(-)
hw/intc/xive.c +7 -7
index a986b96843..ebe399bc09 100644
@@ -249,7 +249,7 @@ static const uint8_t *xive_tm_views[] = {
  static uint64_t xive_tm_mask(hwaddr offset, unsigned size, bool write)
  {
      uint8_t page_offset = (offset >> TM_SHIFT) & 0x3;
-    uint8_t reg_offset = offset & 0x3F;
+    uint8_t reg_offset = offset & TM_REG_OFFSET;
      uint8_t reg_mask = write ? 0x1 : 0x2;
      uint64_t mask = 0x0;
      int i;
@@ -266,8 +266,8 @@ static uint64_t xive_tm_mask(hwaddr offset, unsigned size, bool write)
  static void xive_tm_raw_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,
                                unsigned size)
  {
-    uint8_t ring_offset = offset & 0x30;
-    uint8_t reg_offset = offset & 0x3F;
+    uint8_t ring_offset = offset & TM_RING_OFFSET;
+    uint8_t reg_offset = offset & TM_REG_OFFSET;
      uint64_t mask = xive_tm_mask(offset, size, true);
      int i;
 
@@ -296,8 +296,8 @@ static void xive_tm_raw_write(XiveTCTX *tctx, hwaddr offset, uint64_t value,
 
  static uint64_t xive_tm_raw_read(XiveTCTX *tctx, hwaddr offset, unsigned size)
  {
-    uint8_t ring_offset = offset & 0x30;
-    uint8_t reg_offset = offset & 0x3F;
+    uint8_t ring_offset = offset & TM_RING_OFFSET;
+    uint8_t reg_offset = offset & TM_REG_OFFSET;
      uint64_t mask = xive_tm_mask(offset, size, false);
      uint64_t ret;
      int i;
@@ -534,7 +534,7 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,
      /*
       * First, check for special operations in the 2K region
       */
-    if (offset & 0x800) {
+    if (offset & TM_SPECIAL_OP) {
          xto = xive_tm_find_op(offset, size, true);
          if (!xto) {
              qemu_log_mask(LOG_GUEST_ERROR, "XIVE: invalid write access at TIMA "
@@ -573,7 +573,7 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCTX *tctx, hwaddr offset,
      /*
       * First, check for special operations in the 2K region
       */
-    if (offset & 0x800) {
+    if (offset & TM_SPECIAL_OP) {
          xto = xive_tm_find_op(offset, size, false);
          if (!xto) {
              qemu_log_mask(LOG_GUEST_ERROR, "XIVE: invalid read access to TIMA"
include/hw/ppc/xive_regs.h +16 -0
index b7fde2354e..4a3c9badd3 100644
@@ -48,6 +48,22 @@
 
  #define TM_SHIFT                16
 
+/*
+ * TIMA addresses are 12-bits (4k page).
+ * The MSB indicates a special op with side effect, which can be
+ * refined with bit 10 (see below).
+ * The registers, logically grouped in 4 rings (a quad-word each), are
+ * defined on the 6 LSBs (offset below 0x40)
+ * In between, we can add a cache line index from 0...3 (ie, 0, 0x80,
+ * 0x100, 0x180) to select a specific snooper. Those 'snoop port
+ * address' bits should be dropped when processing the operations as
+ * they are all equivalent.
+ */
+#define TM_ADDRESS_MASK         0xC3F
+#define TM_SPECIAL_OP           0x800
+#define TM_RING_OFFSET          0x30
+#define TM_REG_OFFSET           0x3F
+
  /* TM register offsets */
  #define TM_QW0_USER             0x000 /* All rings */
  #define TM_QW1_OS               0x010 /* Ring 0..2 */
#6 lore raw

PATCH v2 5/5 pnv/xive2: Handle TIMA access through all ports

In reply to Frederic Barrat

The Thread Interrupt Management Area (TIMA) can be accessed through 4 ports, targeted by the address. The base address of a TIMA is using port 0 and the other ports are 0x80 apart. Using one port or another can be useful to balance the load on the snoop buses. With skiboot and linux, we currently use port 0, but as it tends to be busy, another hypervisor is using port 1 for TIMA access.

The port address bits fall in between the special op indication bits (the 2 MSBs) and the register offset bits (the 6 LSBs). They are "don't care" for the hardware when processing a TIMA operation. This patch filters out those port address bits so that a TIMA operation can be triggered using any port.

It is also true for indirect access (through the IC BAR) and it's actually nothing new, it was already the case on P9. Which helps here, as the TIMA handling code is common between P9 (xive) and P10 (xive2).

---
 hw/intc/pnv_xive2.c | 4 ++++
 hw/intc/xive.c      | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
hw/intc/pnv_xive2.c +4 -0
index 5fc4240216..ec1edeb385 100644
@@ -1666,6 +1666,8 @@ static void pnv_xive2_tm_write(void *opaque, hwaddr offset,
     bool gen1_tima_os =
         xive->cq_regs[CQ_XIVE_CFG >> 3] & CQ_XIVE_CFG_GEN1_TIMA_OS;
 
+    offset &= TM_ADDRESS_MASK;
+
     /* TODO: should we switch the TM ops table instead ? */
     if (!gen1_tima_os && offset == HV_PUSH_OS_CTX_OFFSET) {
         xive2_tm_push_os_ctx(xptr, tctx, offset, value, size);
@@ -1685,6 +1687,8 @@ static uint64_t pnv_xive2_tm_read(void *opaque, hwaddr offset, unsigned size)
     bool gen1_tima_os =
         xive->cq_regs[CQ_XIVE_CFG >> 3] & CQ_XIVE_CFG_GEN1_TIMA_OS;
 
+    offset &= TM_ADDRESS_MASK;
+
     /* TODO: should we switch the TM ops table instead ? */
     if (!gen1_tima_os && offset == HV_PULL_OS_CTX_OFFSET) {
         return xive2_tm_pull_os_ctx(xptr, tctx, offset, size);
hw/intc/xive.c +1 -1
index ebe399bc09..5204c14b87 100644
@@ -500,7 +500,7 @@ static const XiveTmOp xive_tm_operations[] = {
 static const XiveTmOp *xive_tm_find_op(hwaddr offset, unsigned size, bool write)
 {
     uint8_t page_offset = (offset >> TM_SHIFT) & 0x3;
-    uint32_t op_offset = offset & 0xFFF;
+    uint32_t op_offset = offset & TM_ADDRESS_MASK;
     int i;
 
     for (i = 0; i < ARRAY_SIZE(xive_tm_operations); i++) {
Signature · 1 line
2.40.1
Reviewed-by on v2 5/5
#7 lore raw

Re: [PATCH v2 5/5] pnv/xive2: Handle TIMA access through all ports

Quoted 13 lines · Frederic Barrat

The Thread Interrupt Management Area (TIMA) can be accessed through 4 ports, targeted by the address. The base address of a TIMA is using port 0 and the other ports are 0x80 apart. Using one port or another can be useful to balance the load on the snoop buses. With skiboot and linux, we currently use port 0, but as it tends to be busy, another hypervisor is using port 1 for TIMA access.

The port address bits fall in between the special op indication bits (the 2 MSBs) and the register offset bits (the 6 LSBs). They are "don't care" for the hardware when processing a TIMA operation. This patch filters out those port address bits so that a TIMA operation can be triggered using any port.

Quoted 5 lines

It is also true for indirect access (through the IC BAR) and it's actually nothing new, it was already the case on P9. Which helps here, as the TIMA handling code is common between P9 (xive) and P10 (xive2).

Thanks,

C.

Quoted 40 lines
---
  hw/intc/pnv_xive2.c | 4 ++++
  hw/intc/xive.c      | 2 +-
  2 files changed, 5 insertions(+), 1 deletion(-)
hw/intc/pnv_xive2.c +4 -0
index 5fc4240216..ec1edeb385 100644
@@ -1666,6 +1666,8 @@ static void pnv_xive2_tm_write(void *opaque, hwaddr offset,
      bool gen1_tima_os =
          xive->cq_regs[CQ_XIVE_CFG >> 3] & CQ_XIVE_CFG_GEN1_TIMA_OS;
 
+    offset &= TM_ADDRESS_MASK;
+
      /* TODO: should we switch the TM ops table instead ? */
      if (!gen1_tima_os && offset == HV_PUSH_OS_CTX_OFFSET) {
          xive2_tm_push_os_ctx(xptr, tctx, offset, value, size);
@@ -1685,6 +1687,8 @@ static uint64_t pnv_xive2_tm_read(void *opaque, hwaddr offset, unsigned size)
      bool gen1_tima_os =
          xive->cq_regs[CQ_XIVE_CFG >> 3] & CQ_XIVE_CFG_GEN1_TIMA_OS;
 
+    offset &= TM_ADDRESS_MASK;
+
      /* TODO: should we switch the TM ops table instead ? */
      if (!gen1_tima_os && offset == HV_PULL_OS_CTX_OFFSET) {
          return xive2_tm_pull_os_ctx(xptr, tctx, offset, size);
hw/intc/xive.c +1 -1
index ebe399bc09..5204c14b87 100644
@@ -500,7 +500,7 @@ static const XiveTmOp xive_tm_operations[] = {
  static const XiveTmOp *xive_tm_find_op(hwaddr offset, unsigned size, bool write)
  {
      uint8_t page_offset = (offset >> TM_SHIFT) & 0x3;
-    uint32_t op_offset = offset & 0xFFF;
+    uint32_t op_offset = offset & TM_ADDRESS_MASK;
      int i;
 
      for (i = 0; i < ARRAY_SIZE(xive_tm_operations); i++) {
#8 lore raw
In reply to Frederic Barrat

Queued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,

Daniel

Quoted 20 lines · Frederic Barrat

A set of small fixes for the interrupt controller (xive2) on P10.

Change log:
v2:
split last patch to do a bit of cleanup first add Cedric's reviewed-by on the first 3 patches

Frederic Barrat (5):
pnv/xive2: Add definition for TCTXT Config register pnv/xive2: Add definition for the ESB cache configuration register pnv/xive2: Allow writes to the Physical Thread Enable registers pnv/xive2: Introduce macros to manipulate TIMA addresses pnv/xive2: Handle TIMA access through all ports

  hw/intc/pnv_xive2.c        | 20 +++++++++++++++++++-
  hw/intc/pnv_xive2_regs.h   |  8 ++++++++
  hw/intc/xive.c             | 16 ++++++++--------
  include/hw/ppc/xive_regs.h | 16 ++++++++++++++++
  4 files changed, 51 insertions(+), 9 deletions(-)