Message ID | 1437680989-12126-2-git-send-email-vipin@linux.vnet.ibm.com |
---|---|
State | Superseded |
Headers | show |
Vipin K Parashar <vipin@linux.vnet.ibm.com> writes: > This patch adds a new OPAL call OPAL_TRIGGER_XSTOP which will > be used to invoke xstop. This call invokes xstop by writing to a > XSCOM register. XSCOM address and FIR bit details are obtained > via device-tree property 'ibm,sw-checkstop-fir', which contains > two cells. First cell contains XSCOM address while second cell > contains FIR bit number. No input parameter is required. Machine > enters xstop state upon completion of this call. > > Signed-off-by: Vipin K Parashar <vipin@linux.vnet.ibm.com> (after discussing with benh and jk, came up with the following) Really what we're semantically doing here from a host kernel perspective is "we cannot possibly continue right now, something has gone terribly wrong, please collect some debug data and reboot". So, I was thinking of a call along the lines of: OPAL_CEC_REBOOT2(enum reboot_type, char *diag, int len) where reboot_type would be: 0 = normal, equavalent to current OPAL_CEC_REBOOT 1 = unrecoverable platform error - typically triggers platform checkstop and we can leave the other reboot types open for future expansion, for example, maybe we want to do something with core or unit checkstops in the future. For reboot_type != 0, the (null terminated, all up to diag+len recorded) diag string is stored/forwarded to any attached BMC that is capable of recording it along with any other debug information that firmware can trigger saving. Perhaps we should have reboot_type = 2 for unrecoverable host error (e.g. hook it up to panic() and BUG_ON() ) ?
diff --git a/hw/xscom.c b/hw/xscom.c index 9d3523c..b875ca9 100644 --- a/hw/xscom.c +++ b/hw/xscom.c @@ -53,6 +53,12 @@ DEFINE_LOG_ENTRY(OPAL_RC_XSCOM_RESET, OPAL_PLATFORM_ERR_EVT, OPAL_XSCOM, OPAL_CEC_HARDWARE, OPAL_PREDICTIVE_ERR_GENERAL, OPAL_NA, NULL); +/* xscom details to trigger xstop */ +static struct { + uint64_t addr; + uint64_t fir_bit; +} xstop_xscom; + /* * Locking notes: * @@ -483,9 +489,26 @@ static void xscom_init_chip_info(struct proc_chip *chip) chip->ec_level |= (val >> 8) & 0xf; } +/* +* This function triggers xstop by writing to XSCOM. +* Machine would enter xstop state post completion of this. +*/ +static int64_t opal_trigger_xstop(void) +{ + int rc = OPAL_UNSUPPORTED; + + if (xstop_xscom.addr) + rc = xscom_writeme(xstop_xscom.addr, + PPC_BIT(xstop_xscom.fir_bit)); + + return rc; +} +opal_call(OPAL_TRIGGER_XSTOP, opal_trigger_xstop, 0); + void xscom_init(void) { struct dt_node *xn; + const struct dt_property *p; dt_for_each_compatible(dt_root, xn, "ibm,xscom") { uint32_t gcid = dt_get_chip_id(xn); @@ -521,6 +544,16 @@ void xscom_init(void) chip->ec_level >> 4, chip->ec_level & 0xf); } + + /* Collect details to trigger xstop via XSCOM write */ + p = dt_find_property(dt_root, "ibm,sw-checkstop-fir"); + if (p) { + xstop_xscom.addr = dt_property_get_cell(p, 0); + xstop_xscom.fir_bit = dt_property_get_cell(p, 1); + prlog(PR_INFO, "XSTOP: XSCOM addr = 0x%llx, FIR bit = %lld\n", + xstop_xscom.addr, xstop_xscom.fir_bit); + } else + prlog(PR_INFO, "XSTOP: ibm,sw-checkstop-fir prop not found\n"); } void xscom_used_by_console(void) diff --git a/include/opal-api.h b/include/opal-api.h index bfad589..1b56270 100644 --- a/include/opal-api.h +++ b/include/opal-api.h @@ -161,7 +161,8 @@ #define OPAL_PRD_MSG 113 #define OPAL_LEDS_GET_INDICATOR 114 #define OPAL_LEDS_SET_INDICATOR 115 -#define OPAL_LAST 115 +#define OPAL_TRIGGER_XSTOP 116 +#define OPAL_LAST 116 /* Device tree flags */
This patch adds a new OPAL call OPAL_TRIGGER_XSTOP which will be used to invoke xstop. This call invokes xstop by writing to a XSCOM register. XSCOM address and FIR bit details are obtained via device-tree property 'ibm,sw-checkstop-fir', which contains two cells. First cell contains XSCOM address while second cell contains FIR bit number. No input parameter is required. Machine enters xstop state upon completion of this call. Signed-off-by: Vipin K Parashar <vipin@linux.vnet.ibm.com> --- hw/xscom.c | 33 +++++++++++++++++++++++++++++++++ include/opal-api.h | 3 ++- 2 files changed, 35 insertions(+), 1 deletion(-)