diff mbox series

[2/3] hw/phb4: Add a helper to dump the PELT-V

Message ID 20180726021838.20999-2-oohall@gmail.com
State Accepted
Headers show
Series [1/3] hw/phb4: Print the PEs in the EEH dump in hex | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Oliver O'Halloran July 26, 2018, 2:18 a.m. UTC
The "Partitionable Endpoint Lookup Table (Vector)" is used by the PHB
when processing EEH events. The PELT-V defines which PEs should be
additionally frozen in the event of an error being flagged on a
given PE. Knowing the state of the PELT-V is sometimes useful for
debugging PHB issues so this patch adds a helper to dump it.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hw/phb4.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
diff mbox series

Patch

diff --git a/hw/phb4.c b/hw/phb4.c
index ff0f3f5ad5b2..965f3b5af8af 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -1942,6 +1942,46 @@  static void phb4_read_phb_status(struct phb4 *p,
 	 }
 }
 
+static void __unused phb4_dump_peltv(struct phb4 *p)
+{
+	int stride = p->max_num_pes / 64;
+	uint64_t *tbl = (void *) p->tbl_peltv;
+	unsigned int pe;
+
+	PHBERR(p, "PELT-V: base addr: %p size: %llx (%d PEs, stride = %d)\n",
+			tbl, p->tbl_peltv_size, p->max_num_pes, stride);
+
+	for (pe = 0; pe < p->max_num_pes; pe++) {
+		unsigned int i, j;
+		uint64_t sum = 0;
+
+		i = pe * stride;
+
+		/*
+		 * Only print an entry if there's bits set in the PE's
+		 * PELT-V entry. There's a few hundred possible PEs and
+		 * generally only a handful will be in use.
+		 */
+
+		for (j = 0; j < stride; j++)
+			sum |= tbl[i + j];
+		if (!sum)
+			continue; /* unused PE, skip it */
+
+		if (p->max_num_pes == 512) {
+			PHBERR(p, "PELT-V[%03x] = "
+				"%016llx %016llx %016llx %016llx"
+				"%016llx %016llx %016llx %016llx\n", pe,
+				tbl[i + 0], tbl[i + 1], tbl[i + 2], tbl[i + 3],
+				tbl[i + 4], tbl[i + 5], tbl[i + 6], tbl[i + 7]);
+		} else if (p->max_num_pes == 256) {
+			PHBERR(p, "PELT-V[%03x] = "
+				"%016llx %016llx %016llx %016llx\n", pe,
+				tbl[i + 0], tbl[i + 1], tbl[i + 2], tbl[i + 3]);
+		}
+	}
+}
+
 static void phb4_eeh_dump_regs(struct phb4 *p)
 {
 	struct OpalIoPhb4ErrorData *s;