From patchwork Tue Feb 28 23:58:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Donnellan X-Patchwork-Id: 733950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vXwY804myz9s7r for ; Wed, 1 Mar 2017 10:59:40 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vXwY76RKYzDqGp for ; Wed, 1 Mar 2017 10:59:39 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vXwY26YgczDqGp for ; Wed, 1 Mar 2017 10:59:34 +1100 (AEDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1SNwiEA099519 for ; Tue, 28 Feb 2017 18:59:33 -0500 Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) by mx0a-001b2d01.pphosted.com with ESMTP id 28wkb902a7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 28 Feb 2017 18:59:32 -0500 Received: from localhost by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 Mar 2017 09:59:30 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 1 Mar 2017 09:59:27 +1000 Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 66F322BB0045 for ; Wed, 1 Mar 2017 10:59:27 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1SNxJIC46202956 for ; Wed, 1 Mar 2017 10:59:27 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v1SNwtKv014032 for ; Wed, 1 Mar 2017 10:58:55 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v1SNwsnp013740; Wed, 1 Mar 2017 10:58:54 +1100 Received: from ajd.au.ibm.com (unknown [9.192.166.116]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 1A4C5A01A7; Wed, 1 Mar 2017 10:58:29 +1100 (AEDT) From: Andrew Donnellan To: skiboot@lists.ozlabs.org Date: Wed, 1 Mar 2017 10:58:16 +1100 X-Mailer: git-send-email 2.11.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022823-0052-0000-0000-0000021D1BF4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022823-0053-0000-0000-000007DF8586 Message-Id: <20170228235817.16746-1-andrew.donnellan@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-28_21:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702280204 Subject: [Skiboot] [PATCH 1/2] hmi: refactor malfunction alert handling X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ryan Grimm , Daniel Axtens MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 Cc: Mahesh Salgaonkar Cc: Ryan Grimm Cc: Frederic Barrat Cc: Daniel Axtens Signed-off-by: Andrew Donnellan Reviewed-by: Mahesh Salgaonkar Reviewed-by: Frederic Barrat --- I'd appreciate review here, I hope I haven't introduced any unintended changes, but I also don't think I fully understand the expected behaviour. I've given it some limited testing, it doesn't seem to break my CAPI kexec series which is good. --- core/hmi.c | 88 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/core/hmi.c b/core/hmi.c index 6fe060dc..31a23ec7 100644 --- a/core/hmi.c +++ b/core/hmi.c @@ -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); } }