diff options
author | Andrew Donnellan <andrew.donnellan@au1.ibm.com> | 2017-03-01 10:58:16 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-03-16 17:17:32 +1100 |
commit | b2dc494a4950927cdda5f009e1a482aabcb25afa (patch) | |
tree | fe3989f8d566d85be928f95c40ecb7cc9530fc48 /core | |
parent | 4638f6476b0e936d3f8e17d82e4dc69a6d537cee (diff) | |
download | blackbird-skiboot-b2dc494a4950927cdda5f009e1a482aabcb25afa.tar.gz blackbird-skiboot-b2dc494a4950927cdda5f009e1a482aabcb25afa.zip |
hmi: refactor malfunction alert handling
The logic in decode_malfunction() is rather tricky to follow. Refactor the
code to make it easier to follow.
No functional change.
Cc: Russell Currey <ruscur@russell.cc>
Cc: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Cc: Ryan Grimm <grimm@linux.vnet.ibm.com>
Cc: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Cc: Daniel Axtens <dja@axtens.net>
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/hmi.c | 88 |
1 files changed, 42 insertions, 46 deletions
@@ -296,27 +296,6 @@ static int handle_capp_recoverable(int chip_id, int capp_index) return 0; } -static int decode_one_malfunction(int flat_chip_id, struct OpalHMIEvent *hmi_evt) -{ - int capp_index; - struct proc_chip *chip = get_chip(flat_chip_id); - int capp_num = CHIP_IS_NAPLES(chip) ? 2 : 1; - - hmi_evt->severity = OpalHMI_SEV_FATAL; - hmi_evt->type = OpalHMI_ERROR_MALFUNC_ALERT; - - for (capp_index = 0; capp_index < capp_num; capp_index++) - if (is_capp_recoverable(flat_chip_id, capp_index)) - if (handle_capp_recoverable(flat_chip_id, capp_index)) { - hmi_evt->severity = OpalHMI_SEV_NO_ERROR; - hmi_evt->type = OpalHMI_ERROR_CAPP_RECOVERY; - return 1; - } - - /* TODO check other FIRs */ - return 0; -} - static bool decode_core_fir(struct cpu_thread *cpu, struct OpalHMIEvent *hmi_evt) { @@ -368,7 +347,7 @@ static bool decode_core_fir(struct cpu_thread *cpu, } static void find_core_checkstop_reason(struct OpalHMIEvent *hmi_evt, - int *event_generated) + bool *event_generated) { struct cpu_thread *cpu; @@ -401,8 +380,30 @@ static void find_core_checkstop_reason(struct OpalHMIEvent *hmi_evt, } } +static void find_capp_checkstop_reason(int flat_chip_id, + struct OpalHMIEvent *hmi_evt, + bool *event_generated) +{ + int capp_index; + struct proc_chip *chip = get_chip(flat_chip_id); + int capp_num = CHIP_IS_NAPLES(chip) ? 2 : 1; + + for (capp_index = 0; capp_index < capp_num; capp_index++) { + if (is_capp_recoverable(flat_chip_id, capp_index)) { + if (handle_capp_recoverable(flat_chip_id, capp_index)) { + hmi_evt->severity = OpalHMI_SEV_NO_ERROR; + hmi_evt->type = OpalHMI_ERROR_CAPP_RECOVERY; + queue_hmi_event(hmi_evt, 1); + *event_generated = true; + return; + } + } + } +} + static void find_nx_checkstop_reason(int flat_chip_id, - struct OpalHMIEvent *hmi_evt, int *event_generated) + struct OpalHMIEvent *hmi_evt, + bool *event_generated) { uint64_t nx_status; uint64_t nx_dma_fir; @@ -461,12 +462,12 @@ static void find_nx_checkstop_reason(int flat_chip_id, /* Send an HMI event. */ queue_hmi_event(hmi_evt, 0); - *event_generated = 1; + *event_generated = true; } static void find_npu_checkstop_reason(int flat_chip_id, struct OpalHMIEvent *hmi_evt, - int *event_generated) + bool *event_generated) { struct phb *phb; struct npu *p = NULL; @@ -530,43 +531,38 @@ static void find_npu_checkstop_reason(int flat_chip_id, /* The HMI is "recoverable" because it shouldn't crash the system */ queue_hmi_event(hmi_evt, 1); - *event_generated = 1; + *event_generated = true; } static void decode_malfunction(struct OpalHMIEvent *hmi_evt) { int i; - int recover = -1; uint64_t malf_alert; - int event_generated = 0; + bool event_generated = false; xscom_read(this_cpu()->chip_id, 0x2020011, &malf_alert); - for (i = 0; i < 64; i++) + if (!malf_alert) + return; + + for (i = 0; i < 64; i++) { if (malf_alert & PPC_BIT(i)) { - recover = decode_one_malfunction(i, hmi_evt); xscom_write(this_cpu()->chip_id, 0x02020011, ~PPC_BIT(i)); - if (recover) { - queue_hmi_event(hmi_evt, recover); - event_generated = 1; - } + find_capp_checkstop_reason(i, hmi_evt, &event_generated); find_nx_checkstop_reason(i, hmi_evt, &event_generated); find_npu_checkstop_reason(i, hmi_evt, &event_generated); } + } - if (recover != -1) { - find_core_checkstop_reason(hmi_evt, &event_generated); + find_core_checkstop_reason(hmi_evt, &event_generated); - /* - * In case, if we fail to find checkstop reason send an - * unknown HMI event. - */ - if (!event_generated) { - hmi_evt->u.xstop_error.xstop_type = - CHECKSTOP_TYPE_UNKNOWN; - hmi_evt->u.xstop_error.xstop_reason = 0; - queue_hmi_event(hmi_evt, recover); - } + /* + * If we fail to find checkstop reason, send an unknown HMI event. + */ + if (!event_generated) { + hmi_evt->u.xstop_error.xstop_type = CHECKSTOP_TYPE_UNKNOWN; + hmi_evt->u.xstop_error.xstop_reason = 0; + queue_hmi_event(hmi_evt, false); } } |