diff mbox series

[RFC,4/4] pdbg: Add timer facility TOD error injections.

Message ID 158918650638.16822.2953054547382650577.stgit@jupiter
State New
Headers show
Series [RFC,1/4] pdbg: Add support for error injection framework. | expand

Checks

Context Check Description
snowpatch_ozlabs/build-multiarch fail Test build-multiarch on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (6c10b68bf774a9fe21affd5ef0b40084cd49800d)

Commit Message

Mahesh J Salgaonkar May 11, 2020, 8:41 a.m. UTC
Add TOD error injections.

# ./pdbg -p0  inject tod pp0_reg_parity
p0: 0x40031 = 0x1000000000000000
#

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
---
 src/timefac_error.c |   81 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
diff mbox series

Patch

diff --git a/src/timefac_error.c b/src/timefac_error.c
index cb6c9ac..92ccfc2 100644
--- a/src/timefac_error.c
+++ b/src/timefac_error.c
@@ -33,6 +33,9 @@ 
 /* SPR_MODE scom address */
 #define P9_SCOM_SPR_MODE	0x20010A84
 
+/* TOD Error inject register scom address */
+#define TOD_ERROR_INJECT	0x40031
+
 /* TB Errors */
 #define TB_ERROR_MASK		PPC_BITMASK(10, 15)
 /* Core level TB errors */
@@ -44,6 +47,21 @@ 
 #define TB_ERROR_SPURR_PARITY	0x5
 #define TB_ERROR_DEC_PARITY	0x6
 
+/* TOD Errors */
+#define TOD_ERR_MPATH_CREG_PARITY     PPC_BIT(0)
+#define TOD_ERR_PPORT0_CREG_PARITY    PPC_BIT(3)
+#define TOD_ERR_PPORT1_CREG_PARITY    PPC_BIT(4)
+#define TOD_ERR_SPORT0_CREG_PARITY    PPC_BIT(5)
+#define TOD_ERR_SPORT1_CREG_PARITY    PPC_BIT(6)
+#define TOD_ERR_SPATH_CREG_PARITY     PPC_BIT(7)
+#define TOD_ERR_IPATH_CREG_PARITY     PPC_BIT(8)
+#define TOD_ERR_PSMS_CREG_PARITY      PPC_BIT(9)
+#define TOD_ERR_PSS_HAMMING_DISTANCE  PPC_BIT(18)
+#define TOD_ERR_DELAY_COMPL_PARITY    PPC_BIT(22)
+#define TOD_ERR_CTCR_PARITY           PPC_BIT(32)
+#define TOD_ERR_TOD_SYNC_CHECK        PPC_BIT(33)
+#define TOD_ERR_TOD_FSM_PARITY        PPC_BIT(34)
+
 typedef struct error_type {
 	char *name;
 	char *desc;
@@ -59,6 +77,45 @@  static error_type_t tb_error_type[] = {
 	{ "dec_parity", "DEC parity error", TB_ERROR_DEC_PARITY },
 };
 
+static error_type_t tod_error_type[] = {
+	{ "mp_reg_parity",
+	  "Master path control register (0x00): data parity error",
+	  TOD_ERR_MPATH_CREG_PARITY },
+	{ "pp0_reg_parity",
+	  "port-0 primary configuration register (0x01): data parity error",
+	  TOD_ERR_PPORT0_CREG_PARITY },
+	{ "pp1_reg_parity",
+	  "port-1 primary configuration register (0x02): data parity error",
+	  TOD_ERR_PPORT1_CREG_PARITY },
+	{ "sp0_reg_parity",
+	  "port-0 secondary configuration register (0x03): data parity error",
+	  TOD_ERR_SPORT0_CREG_PARITY },
+	{ "sp1_reg_parity",
+	  "port-1 secondary configuration register (0x04): data parity error",
+	  TOD_ERR_SPORT1_CREG_PARITY },
+	{ "sp_reg_parity",
+	  "slave path control register (0x05): data parity error",
+	  TOD_ERR_SPATH_CREG_PARITY },
+	{ "ip_reg_parity",
+	  "internal path control register (0x06): data parity error",
+	  TOD_ERR_IPATH_CREG_PARITY },
+	{ "psms_reg_parity",
+	  "primary/secondary master/slave control register (0x07): data parity error",
+	  TOD_ERR_PSMS_CREG_PARITY },
+	{ "pss_hum_dist", "PSS Hamming Distance",
+	  TOD_ERR_PSS_HAMMING_DISTANCE },
+	{ "delay_parity",
+	  "internal path: delay, STEP check components: parity error",
+	  TOD_ERR_DELAY_COMPL_PARITY },
+	{ "ch_reg_parity",
+	  "chip control register (0x10): data parity error",
+	  TOD_ERR_CTCR_PARITY },
+	{ "sync_check", "internal path: SYNC check error",
+	  TOD_ERR_TOD_SYNC_CHECK },
+	{ "fsm_st_parity", "internal path: FSM state parity error",
+	  TOD_ERR_TOD_FSM_PARITY },
+};
+
 static int timefac_inject_tb_error(struct pdbg_target *target, void *data)
 {
 	int target_type = 0;
@@ -101,6 +158,23 @@  static int timefac_inject_tb_error(struct pdbg_target *target, void *data)
 	return rc;
 }
 
+static int timefac_inject_tod_error(struct pdbg_target *target, void *data)
+{
+	uint64_t err_val;
+	int rc;
+
+	err_val = *((uint64_t *)data);
+
+	if (TARGET_TYPE_PROC != get_target_type(target))
+		return -EINVAL;
+
+	rc = target_inject_error(target, TOD_ERROR_INJECT, err_val);
+	if (rc) {
+		printf("Failed to inject\n");
+	}
+	return rc;
+}
+
 void timefac_err_init(void)
 {
 	int i;
@@ -111,4 +185,11 @@  void timefac_err_init(void)
 				tb_error_type[i].desc, timefac_inject_tb_error,
 				&tb_error_type[i].error);
 
+	/* Register TOD error injects */
+	for (i = 0; i < ARRAY_SIZE(tod_error_type); i++)
+		register_error_inject("tod", tod_error_type[i].name,
+				tod_error_type[i].desc,
+				timefac_inject_tod_error,
+				&tod_error_type[i].error);
+
 }