From patchwork Wed Jul 29 02:56:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 1338111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BGdVk4tdlz9sSd for ; Wed, 29 Jul 2020 12:57:02 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BGdVk3wzXzDqxg for ; Wed, 29 Jul 2020 12:57:02 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=mahesh@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 4BGdVY4F2TzDqrT for ; Wed, 29 Jul 2020 12:56:52 +1000 (AEST) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06T2VseC187022 for ; Tue, 28 Jul 2020 22:56:50 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32j7sy2wfw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Jul 2020 22:56:50 -0400 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06T2uh1N067656 for ; Tue, 28 Jul 2020 22:56:50 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 32j7sy2wfh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jul 2020 22:56:50 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06T2tIAb024064; Wed, 29 Jul 2020 02:56:48 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 32gcy4mg94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2020 02:56:48 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06T2ujEO21037462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jul 2020 02:56:45 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C293C11C04A; Wed, 29 Jul 2020 02:56:45 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2BE7611C054; Wed, 29 Jul 2020 02:56:45 +0000 (GMT) Received: from [192.168.122.1] (unknown [9.85.72.15]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 29 Jul 2020 02:56:44 +0000 (GMT) From: Mahesh Salgaonkar To: skiboot list Date: Wed, 29 Jul 2020 08:26:43 +0530 Message-ID: <159599140359.66951.8000579209303137333.stgit@jupiter> In-Reply-To: <159599130727.66951.17066036151753895792.stgit@jupiter> References: <159599130727.66951.17066036151753895792.stgit@jupiter> User-Agent: StGit/0.21 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-29_01:2020-07-28, 2020-07-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 phishscore=0 malwarescore=0 impostorscore=0 adultscore=0 bulkscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007290013 Subject: [Skiboot] [PATCH 1/5] opal/errorlog: Allow generation of Serviceable attention events X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasant Hegde Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Mahesh Salgaonkar Add support to mark error log event as Serviceable/Customer attention events. Signed-off-by: Mahesh Salgaonkar --- core/errorlog.c | 5 +++++ core/pel.c | 3 +++ include/errorlog.h | 2 ++ include/pel.h | 1 + 4 files changed, 11 insertions(+) diff --git a/core/errorlog.c b/core/errorlog.c index f64ac3f23..2f7bcce19 100644 --- a/core/errorlog.c +++ b/core/errorlog.c @@ -73,6 +73,11 @@ struct errorlog *opal_elog_create(struct opal_err_info *e_info, uint32_t tag) return buf; } +void log_mark_serviceable(struct errorlog *buf) +{ + buf->service_req = true; +} + /* Add a new user data section to an existing error log */ void log_add_section(struct errorlog *buf, uint32_t tag) { diff --git a/core/pel.c b/core/pel.c index ec13e5590..4b2656346 100644 --- a/core/pel.c +++ b/core/pel.c @@ -160,6 +160,9 @@ static void create_user_header_section(struct errorlog *elog_data, else usrhdr->action_flags = cpu_to_be16(ERRL_ACTION_NONE); + if (elog_data->service_req) + usrhdr->action_flags |= ERRL_ACTION_SERVICE; + *pel_offset += USER_HEADER_SECTION_SIZE; } diff --git a/include/errorlog.h b/include/errorlog.h index a443d3681..74fe8b1fd 100644 --- a/include/errorlog.h +++ b/include/errorlog.h @@ -124,6 +124,7 @@ struct errorlog { uint32_t plid; uint32_t log_size; uint64_t elog_timeout; + bool service_req; char user_data_dump[OPAL_LOG_MAX_DUMP]; struct list_node link; @@ -350,6 +351,7 @@ void log_append_data(struct errorlog *buf, unsigned char *data, uint16_t size); void log_append_msg(struct errorlog *buf, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); void log_commit(struct errorlog *elog); +void log_mark_serviceable(struct errorlog *buf); /* Called by the backend after an error has been logged by the * backend. If the error could not be logged successfully success is diff --git a/include/pel.h b/include/pel.h index a0df7cc3c..252d27e2e 100644 --- a/include/pel.h +++ b/include/pel.h @@ -38,6 +38,7 @@ /* Error log reporting action */ #define ERRL_ACTION_REPORT 0x2000 +#define ERRL_ACTION_SERVICE 0x8000 #define ERRL_ACTION_NONE 0x0000 enum elogSectionId { From patchwork Wed Jul 29 02:56:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 1338113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BGdWZ3jHZz9sTR for ; Wed, 29 Jul 2020 12:57:46 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BGdWZ1JvXzDqxk for ; Wed, 29 Jul 2020 12:57:46 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com 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 4BGdVj0vTnzDqrT for ; Wed, 29 Jul 2020 12:57:00 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06T2W7YS066628 for ; Tue, 28 Jul 2020 22:56:58 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32jp1m9rt9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Jul 2020 22:56:58 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06T2d5aJ089564 for ; Tue, 28 Jul 2020 22:56:57 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 32jp1m9rsw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jul 2020 22:56:57 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06T2ut8l022450; Wed, 29 Jul 2020 02:56:55 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 32gcqgmfyj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2020 02:56:55 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06T2uqvV30343242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jul 2020 02:56:52 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 82857AE045; Wed, 29 Jul 2020 02:56:52 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3837AE053; Wed, 29 Jul 2020 02:56:51 +0000 (GMT) Received: from [192.168.122.1] (unknown [9.85.72.15]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 29 Jul 2020 02:56:51 +0000 (GMT) From: Mahesh Salgaonkar To: skiboot list Date: Wed, 29 Jul 2020 08:26:51 +0530 Message-ID: <159599141097.66951.1780330798994549187.stgit@jupiter> In-Reply-To: <159599130727.66951.17066036151753895792.stgit@jupiter> References: <159599130727.66951.17066036151753895792.stgit@jupiter> User-Agent: StGit/0.21 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-29_01:2020-07-28, 2020-07-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 priorityscore=1501 phishscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007290013 Subject: [Skiboot] [PATCH 2/5] opal/errorlog: Add support to include callout section in error log. X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasant Hegde Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Mahesh Salgaonkar Allow inclusion of HW callout to eSEL being generated. This will help OPAL to generate errorlog with fru callout section that includes location code, part number and serial number of a faulty hardware that may need replacement. Signed-off-by: Mahesh Salgaonkar --- core/errorlog.c | 41 ++++++++++++++ core/pel.c | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/errorlog.h | 17 ++++++ include/pel.h | 69 ++++++++++++++++++++++++ 4 files changed, 273 insertions(+), 2 deletions(-) diff --git a/core/errorlog.c b/core/errorlog.c index 2f7bcce19..bd2679531 100644 --- a/core/errorlog.c +++ b/core/errorlog.c @@ -105,6 +105,47 @@ void log_add_section(struct errorlog *buf, uint32_t tag) buf->user_section_count++; } +void log_add_callout_section(struct errorlog *buf, const char *loc_code, + const char *part_no, const char *serial_no) +{ + int index = buf->num_fru_callout; + struct elog_fru_callout *fru = &buf->fru_callout[index]; + + if (!buf) { + prerror("ELOG: Cannot add callout section. " + "Buffer is invalid\n"); + return; + } + + if (buf->num_fru_callout >= OPAL_MAX_FRU_CALL_OUTS) { + prerror("ELOG: Cannot add callout section. " + "Maximum limit reached\n"); + return; + } + + /* Location codes -- at most 80 chars with null termination */ + if (strlen(loc_code) >= LOC_CODE_SIZE) { + prerror("ELOG: Invalid Size of location code.\n"); + return; + } + + buf->num_fru_callout++; + memset(fru->loc_code, 0, LOC_CODE_SIZE); + strcpy(fru->loc_code, loc_code); + + /* + * Part number contains a null-terminated ASCII character string. + * 7 ASCII character part number + */ + if (part_no) { + memcpy(fru->part_no, part_no, OPAL_FRU_PART_LEN); + fru->part_no[7] = '\0'; + } + + if (serial_no) + memcpy(fru->serial_no, serial_no, OPAL_FRU_SERIAL_LEN); +} + void opal_elog_complete(struct errorlog *buf, bool success) { if (!success) diff --git a/core/pel.c b/core/pel.c index 4b2656346..4c0b9db2d 100644 --- a/core/pel.c +++ b/core/pel.c @@ -107,10 +107,108 @@ static void setrefcode(struct opal_src_section *src, uint16_t src_refcode) memcpy(src->srcstring+4, refcode, 4); } +static int create_fru_identity(struct elog_fru_callout *elog_fru, + char *pel_buffer, int pel_offset) +{ + int data_len = 0; + struct opal_fru_identity *identity; + + identity = (struct opal_fru_identity *)(pel_buffer + pel_offset); + + if (!strlen(elog_fru->part_no) && !strlen(elog_fru->serial_no)) + return 0; + + identity->id = OPAL_FRU_IDENT_ID; + identity->flags = OPAL_FRU_IDENT_FLAG_NORMAL; + + if (strlen(elog_fru->part_no)) { + identity->flags |= OPAL_FRU_IDENT_FLAG_PART; + memset(identity->fru_data, 0, OPAL_FRU_PART_LEN); + memcpy(identity->fru_data, elog_fru->part_no, + OPAL_FRU_PART_LEN); + data_len = OPAL_FRU_PART_LEN; + } + + if (strlen(elog_fru->serial_no)) { + identity->flags |= OPAL_FRU_IDENT_FLAG_SERIAL; + memset(identity->fru_data + data_len, 0, OPAL_FRU_SERIAL_LEN); + memcpy(identity->fru_data + data_len, elog_fru->serial_no, + OPAL_FRU_SERIAL_LEN); + data_len += OPAL_FRU_SERIAL_LEN; + } + identity->length = FRU_IDENTITY_HEADER_SIZE + data_len; + + return identity->length; +} + +/* + * The FRU Call-out section is added as additional/optional sub section. + * Each additional sub section starts with sub section header followed by + * data. The sub section header contains section id, flags and size of the + * sub section including header size. A variable number of FRU Call-outs are + * possible up to the maximum of 10. Each FRU Callout structure starts on a + * word boundary. + */ +static int create_fru_callout_section(struct errorlog *elog_data, + char *pel_buffer, int pel_offset) +{ + int len; + struct opal_fru_callout_section *fru; + struct opal_fru_callout *fru_callout; + int i, fru_count; + + fru = (struct opal_fru_callout_section *)(pel_buffer + pel_offset); + fru->header.id = OPAL_SRC_SUB_SECTION_ID; + fru->header.flags = 0; + /* + * Initialize SRC sub section size with sub section header size. + * SRC sub section size is expressed in # of words (4 byte fields) + * SRC sub section size will be updated for each FRU call out. + */ + fru->header.length += SRC_SUBSECTION_HEADER_SIZE / 4; + pel_offset += SRC_SUBSECTION_HEADER_SIZE; + fru_callout = (struct opal_fru_callout *)(pel_buffer + pel_offset); + + /* Add FRU Call-outs */ + fru_count = MIN(OPAL_MAX_FRU_CALL_OUTS, elog_data->num_fru_callout); + for (i = 0; i < fru_count; i++) { + struct elog_fru_callout *elog_fru = &elog_data->fru_callout[i]; + + fru_callout->type = OPAL_FRU_TYPE_NORMAL; + fru_callout->priority = OPAL_FRU_PRIO_MEDIUM; + /* Size of loc-code including NULL terminator. */ + len = strlen(elog_fru->loc_code) + 1; + + /* Length of Location Code field - must be a multiple of 4. */ + len = ALIGN_UP(len, 4); + memcpy(fru_callout->loc_code, elog_fru->loc_code, len); + fru_callout->loc_code_len = len; + fru_callout->length = FRU_CALLOUT_SECTION_SIZE + + fru_callout->loc_code_len; + + pel_offset += fru_callout->length; + len = create_fru_identity(elog_fru, pel_buffer, pel_offset); + if (len) + fru_callout->flags = OPAL_FRU_FLAG_IDENTITY_INCLUDED; + fru_callout->length += len; + pel_offset += len; + + /* + * SRC sub section size is expressed in # of words + * (4 byte fields) + */ + fru->header.length += fru_callout->length / 4; + fru_callout = + (struct opal_fru_callout *)(pel_buffer + pel_offset); + } + return fru->header.length * 4; +} + /* Create SRC section of OPAL log */ static void create_src_section(struct errorlog *elog_data, char *pel_buffer, int *pel_offset) { + int len; struct opal_src_section *src = (struct opal_src_section *) (pel_buffer + *pel_offset); @@ -134,6 +232,16 @@ static void create_src_section(struct errorlog *elog_data, src->hexwords[6] = cpu_to_be32(elog_data->additional_info[2]); src->hexwords[7] = cpu_to_be32(elog_data->additional_info[3]); *pel_offset += SRC_SECTION_SIZE; + + if (!elog_data->num_fru_callout) + return; + + /* Fill up src sub section header */ + len = create_fru_callout_section(elog_data, pel_buffer, *pel_offset); + src->srclength += len; + src->v6header.length += len; + src->flags |= OPAL_SRC_FLAG_SUB_SECTION_PRESENT; + *pel_offset += len; } /* Create user header section */ @@ -252,9 +360,47 @@ static size_t pel_user_section_size(struct errorlog *elog_data) return total; } +static size_t pel_fru_callout_section_size(struct errorlog *elog_data) +{ + int i, fru_count; + size_t total = 0; + + if (!elog_data->num_fru_callout) + return 0; + + total += SRC_SUBSECTION_HEADER_SIZE; + fru_count = MIN(OPAL_MAX_FRU_CALL_OUTS, elog_data->num_fru_callout); + for (i = 0; i < fru_count; i++) { + size_t len; + + total += FRU_CALLOUT_SECTION_SIZE; + /* Size of loc-code including NULL terminator. */ + len = strlen(elog_data->fru_callout[i].loc_code) + 1; + len = ALIGN_UP(len, 4); + total += len; + + /* Calculate size for FRU identity if present */ + if (!strlen(elog_data->fru_callout[i].part_no) + && !strlen(elog_data->fru_callout[i].serial_no)) + continue; + + if (strlen(elog_data->fru_callout[i].part_no)) + total += OPAL_FRU_PART_LEN; + + if (strlen(elog_data->fru_callout[i].serial_no)) + total += OPAL_FRU_SERIAL_LEN; + + total += FRU_IDENTITY_HEADER_SIZE; + } + return total; +} + size_t pel_size(struct errorlog *elog_data) { - return PEL_MIN_SIZE + pel_user_section_size(elog_data); + size_t len; + + len = PEL_MIN_SIZE + pel_user_section_size(elog_data); + return len + pel_fru_callout_section_size(elog_data); } /* Converts an OPAL errorlog into a PEL formatted log */ diff --git a/include/errorlog.h b/include/errorlog.h index 74fe8b1fd..24d12c4d8 100644 --- a/include/errorlog.h +++ b/include/errorlog.h @@ -89,6 +89,12 @@ /* Max user dump size is 14K */ #define OPAL_LOG_MAX_DUMP 14336 +#define OPAL_FRU_PART_LEN 8 +#define OPAL_FRU_SERIAL_LEN 12 + +/* Maximum possible FRU Call-outs */ +#define OPAL_MAX_FRU_CALL_OUTS 10 + /* Origin of error, elog_origin */ #define ORG_SAPPHIRE 1 #define ORG_POWERNV 2 @@ -101,6 +107,13 @@ struct elog_user_data_section { char data_dump[1]; } __packed; + +struct elog_fru_callout { + char loc_code[LOC_CODE_SIZE]; + char part_no[OPAL_FRU_PART_LEN]; + char serial_no[OPAL_FRU_SERIAL_LEN]; +}; + /* * All the information regarding an error/event to be reported * needs to populate this structure using pre-defined interfaces @@ -125,6 +138,8 @@ struct errorlog { uint32_t log_size; uint64_t elog_timeout; bool service_req; + uint16_t num_fru_callout; + struct elog_fru_callout fru_callout[OPAL_MAX_FRU_CALL_OUTS]; char user_data_dump[OPAL_LOG_MAX_DUMP]; struct list_node link; @@ -347,6 +362,8 @@ uint32_t log_simple_error(struct opal_err_info *e_info, struct errorlog *opal_elog_create(struct opal_err_info *e_info, uint32_t tag) __warn_unused_result; void log_add_section(struct errorlog *buf, uint32_t tag); +void log_add_callout_section(struct errorlog *buf, const char *loc_code, + const char *part_no, const char *serial_no); void log_append_data(struct errorlog *buf, unsigned char *data, uint16_t size); void log_append_msg(struct errorlog *buf, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); diff --git a/include/pel.h b/include/pel.h index 252d27e2e..e2e816036 100644 --- a/include/pel.h +++ b/include/pel.h @@ -12,12 +12,14 @@ #define PRIVATE_HEADER_SECTION_SIZE 48 #define USER_HEADER_SECTION_SIZE 24 #define SRC_SECTION_SIZE 80 -#define SRC_SUBSECTION_SIZE 4 +#define SRC_SUBSECTION_HEADER_SIZE 4 #define SRC_LENGTH 72 #define OPAL_MAX_SRC_BYTES 32 #define EXTENDED_HEADER_SECTION_SIZE 76 #define MTMS_SECTION_SIZE 28 #define IO_EVENT_SECTION_SIZE 16 +#define FRU_CALLOUT_SECTION_SIZE 4 +#define FRU_IDENTITY_HEADER_SIZE 4 #define OPAL_ELOG_VERSION 1 #define OPAL_ELOG_SST 0 @@ -36,6 +38,8 @@ #define OPAL_SRC_SEC_VER 0x02 #define OPAL_EXT_HRD_VER 0x01 +#define OPAL_SRC_FLAG_SUB_SECTION_PRESENT 0x01 + /* Error log reporting action */ #define ERRL_ACTION_REPORT 0x2000 #define ERRL_ACTION_SERVICE 0x8000 @@ -71,6 +75,37 @@ struct opal_v6_header { /* opal_srctype */ #define OPAL_SRC_TYPE_ERROR 0xBB +/* opal SRC subsection id */ +#define OPAL_SRC_SUB_SECTION_ID 0xC0 + +/* FRU callout Type */ +#define OPAL_FRU_TYPE_NORMAL 0x2 +/* FRU callout flags */ +#define OPAL_FRU_FLAG_IDENTITY_INCLUDED 0x8 +#define OPAL_FRU_FLAG_MRU_INCLUDED 0x4 +/* FRU callout priority */ +#define OPAL_FRU_PRIO_HIGH 'H' +#define OPAL_FRU_PRIO_MEDIUM 'M' +#define OPAL_FRU_PRIO_MEDIUM_GROUP_A 'A' +#define OPAL_FRU_PRIO_MEDIUM_GROUP_B 'B' +#define OPAL_FRU_PRIO_MEDIUM_GROUP_C 'C' +#define OPAL_FRU_PRIO_LOW 'L' + +/* FRU identity srtucture id */ +#define OPAL_FRU_IDENT_ID 0x4944 /* ID */ +/* FRU identity flags bits 0-3 */ +#define OPAL_FRU_IDENT_FLAG_NORMAL 0x10 /* "normal" hardware FRU */ +#define OPAL_FRU_IDENT_FLAG_CODE 0x20 /* code FRU */ +#define OPAL_FRU_IDENT_FLAG_CONFIG 0x30 /* configuration error */ +#define OPAL_FRU_IDENT_FLAG_MAINT 0x40 /* Maintenance Procedure req */ +#define OPAL_FRU_IDENT_FLAG_EXT 0x90 /* External FRU */ +#define OPAL_FRU_IDENT_FLAG_EXT_CODE 0xa0 /* External code FRU */ +#define OPAL_FRU_IDENT_FLAG_TOOL 0xb0 /* Tool FRU */ +#define OPAL_FRU_IDENT_FLAG_SYMBOL 0xc0 /* Symbolic FRU */ +/* FRU identity flags bits 4-7 */ +#define OPAL_FRU_IDENT_FLAG_PART 0x08 /* FRU Part Number supplied */ +#define OPAL_FRU_IDENT_FLAG_CCIN 0x04 /* CCIN supplied */ +#define OPAL_FRU_IDENT_FLAG_SERIAL 0x01 /* FRU serial number supplied */ #define OPAL_CID_SAPPHIRE 'K' /* creator ID for sapphire log */ #define OPAL_CID_POWERNV 'P' /* creator ID for powernv log */ @@ -129,6 +164,38 @@ struct opal_src_section { char srcstring[OPAL_MAX_SRC_BYTES]; } __packed; +struct opal_src_sub_section { + uint8_t id; /* SRC sub section id */ + uint8_t flags; + uint16_t length; /* in # of words (4 byte fields) */ +}; + +struct opal_fru_callout_section { + struct opal_src_sub_section header; +}; + +struct opal_fru_callout { + uint8_t length; /* in bytes */ + uint8_t type:4; + uint8_t flags:4; + uint8_t priority; + uint8_t loc_code_len; + char loc_code[0]; +}; + +struct opal_fru_identity { + uint16_t id; + uint8_t length; + uint8_t flags; + /* + * Depending on flags[4-7] bits fru_data will contain: + * part number 8 bytes (7 ASCII character + 1 null-terminator) + * CCIN number 4 bytes (not a null-terminated string) + * FRU serial number 12 bytes (not a null-terminated string) + */ + char fru_data[0]; +}; + struct opal_extended_header_section { struct opal_v6_header v6header; char model[OPAL_SYS_MODEL_LEN]; From patchwork Wed Jul 29 02:56:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 1338114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BGdWy2NB3z9sSd for ; Wed, 29 Jul 2020 12:58:06 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BGdWy15VDzDqxk for ; Wed, 29 Jul 2020 12:58:06 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com 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 4BGdVq1rsCzDqxf for ; Wed, 29 Jul 2020 12:57:07 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06T2X656008155 for ; Tue, 28 Jul 2020 22:57:04 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32jy8v9uhr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Jul 2020 22:57:04 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06T2v4uX074546 for ; Tue, 28 Jul 2020 22:57:04 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 32jy8v9uhc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jul 2020 22:57:04 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06T2uoep022439; Wed, 29 Jul 2020 02:57:02 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 32gcqgmfyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2020 02:57:02 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06T2uxQ122544824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jul 2020 02:56:59 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 32B88A405C; Wed, 29 Jul 2020 02:56:59 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8CBCDA4054; Wed, 29 Jul 2020 02:56:58 +0000 (GMT) Received: from [192.168.122.1] (unknown [9.85.72.15]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 29 Jul 2020 02:56:58 +0000 (GMT) From: Mahesh Salgaonkar To: skiboot list Date: Wed, 29 Jul 2020 08:26:57 +0530 Message-ID: <159599141769.66951.13565453115820608084.stgit@jupiter> In-Reply-To: <159599130727.66951.17066036151753895792.stgit@jupiter> References: <159599130727.66951.17066036151753895792.stgit@jupiter> User-Agent: StGit/0.21 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-29_01:2020-07-28, 2020-07-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007290018 Subject: [Skiboot] [PATCH 3/5] opal: Get chip part-number and serial-number. X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasant Hegde Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Mahesh Salgaonkar Get chip part-number and serial-number and store it under proc_chip for quick reference while sending error log that needs proc chip FRU details. Signed-off-by: Mahesh Salgaonkar --- core/chip.c | 13 +++++++++++++ include/chip.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/core/chip.c b/core/chip.c index 191432d29..8e97a7bcd 100644 --- a/core/chip.c +++ b/core/chip.c @@ -63,6 +63,8 @@ static void init_chip(struct dt_node *dn) struct proc_chip *chip; uint32_t id; const char *lc = NULL; + const char *part_no = NULL; + const char *serial_no = NULL; id = dt_get_chip_id(dn); assert(id < MAX_CHIPS); @@ -93,6 +95,17 @@ static void init_chip(struct dt_node *dn) if (lc) chip->loc_code = strdup(lc); + /* Update part number and serial number for this chip */ + if (dt_has_node_property(dn, "part-number", NULL)) + part_no = dt_prop_get(dn, "part-number"); + if (part_no) + chip->part_no = strdup(part_no); + + if (dt_has_node_property(dn, "serial-number", NULL)) + serial_no = dt_prop_get(dn, "serial-number"); + if (serial_no) + chip->serial_no = strdup(serial_no); + prlog(PR_INFO, "CHIP: Initialised chip %d from %s\n", id, dn->name); chips[id] = chip; } diff --git a/include/chip.h b/include/chip.h index b79b63ecf..e63f17a18 100644 --- a/include/chip.h +++ b/include/chip.h @@ -187,6 +187,10 @@ struct proc_chip { /* location code of this chip */ const uint8_t *loc_code; + /* part-number and serial number for this chip */ + const uint8_t *part_no; + const uint8_t *serial_no; + /* Used by hw/sbe-p9.c */ struct p9_sbe *sbe; @@ -233,5 +237,29 @@ static inline const char *chip_loc_code(uint32_t chip_id) return chip->loc_code; } +/* helper to get part number of a chip */ +static inline const char *chip_part_number(uint32_t chip_id) +{ + struct proc_chip *chip; + + chip = get_chip(chip_id); + if (!chip) + return NULL; + + return chip->part_no; +} + +/* helper to get serial number of a chip */ +static inline const char *chip_serial_number(uint32_t chip_id) +{ + struct proc_chip *chip; + + chip = get_chip(chip_id); + if (!chip) + return NULL; + + return chip->serial_no; +} + #endif /* __CHIP_H */ From patchwork Wed Jul 29 02:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh J Salgaonkar X-Patchwork-Id: 1338115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BGdXF01lQz9sSd for ; Wed, 29 Jul 2020 12:58:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linux.ibm.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4BGdXD6MzqzDqyf for ; Wed, 29 Jul 2020 12:58:20 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=mahesh@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com 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 4BGdVx3n7KzDqxf for ; Wed, 29 Jul 2020 12:57:13 +1000 (AEST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06T2XC80093819 for ; Tue, 28 Jul 2020 22:57:11 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 32jw2jvqp4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 28 Jul 2020 22:57:11 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 06T2Xo1s099441 for ; Tue, 28 Jul 2020 22:57:11 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 32jw2jvqnn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 Jul 2020 22:57:10 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06T2tBfT023884; Wed, 29 Jul 2020 02:57:08 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 32gcy4mg9s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2020 02:57:08 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06T2v5Md28705260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jul 2020 02:57:06 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD455AE056; Wed, 29 Jul 2020 02:57:05 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44154AE053; Wed, 29 Jul 2020 02:57:05 +0000 (GMT) Received: from [192.168.122.1] (unknown [9.85.72.15]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 29 Jul 2020 02:57:05 +0000 (GMT) From: Mahesh Salgaonkar To: skiboot list Date: Wed, 29 Jul 2020 08:27:04 +0530 Message-ID: <159599142438.66951.13022863099415328839.stgit@jupiter> In-Reply-To: <159599130727.66951.17066036151753895792.stgit@jupiter> References: <159599130727.66951.17066036151753895792.stgit@jupiter> User-Agent: StGit/0.21 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-29_01:2020-07-28, 2020-07-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 impostorscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 clxscore=1015 lowpriorityscore=0 phishscore=0 spamscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007290018 Subject: [Skiboot] [PATCH 4/5] opal/eeh: Send an error callout on EEH error. X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasant Hegde Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" On EEH error send out an error log (eSEL) with hardware callout. To avoid generating multiple events for same error, use a bit flag in generic PHB structure. Use two bits i.e SEND and SENT bit. Whenever an EEH freeze/fence is detected, a SEND error log bit is set. Once the error log is queued, a SENT error log bit is set. These bits are sticky and gets reset when PHB is reinitialized to clear the EEH error. The error log includes FRU details and PHB diag data Signed-off-by: Mahesh Salgaonkar --- core/pci-opal.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/phb3.c | 6 ++++++ hw/phb4.c | 6 ++++++ include/errorlog.h | 1 + include/pci.h | 5 +++++ 5 files changed, 67 insertions(+) diff --git a/core/pci-opal.c b/core/pci-opal.c index aa375c6aa..47503d5d2 100644 --- a/core/pci-opal.c +++ b/core/pci-opal.c @@ -13,6 +13,12 @@ #include #include #include +#include +#include + +DEFINE_LOG_ENTRY(OPAL_RC_PCI_RESET_PHB, OPAL_INPUT_OUTPUT_ERR_EVT, + OPAL_PCI, OPAL_IO_DEVICES, OPAL_UNRECOVERABLE_ERR_GENERAL, + OPAL_NA); #define OPAL_PCICFG_ACCESS_READ(op, cb, type) \ static int64_t opal_pci_config_##op(uint64_t phb_id, \ @@ -984,6 +990,45 @@ static int64_t opal_pci_set_power_state(uint64_t async_token, } opal_call(OPAL_PCI_SET_POWER_STATE, opal_pci_set_power_state, 3); +static void send_eeh_serviceable_event(struct phb *phb, void *diag_buffer) +{ + struct errorlog *buf; + const char *loc, *part, *serial; + uint32_t chip_id, len; + struct OpalIoPhbErrorCommon *common; + + /* Generate and send an error log/eSEL */ + buf = opal_elog_create(&e_info(OPAL_RC_PCI_RESET_PHB), 0); + if (!buf) { + prerror("Unable to send EEH error log (eSEL)\n"); + return; + } + + log_append_msg(buf, "PHB#%x Freeze/Fence detected!\n", phb->opal_id); + log_mark_serviceable(buf); + + /* Add PHB base location code */ + loc = phb->base_loc_code; + log_add_callout_section(buf, loc, NULL, NULL); + + /* Add FRU callout of associated chip id */ + chip_id = dt_get_chip_id(phb->dt_node); + loc = chip_loc_code(chip_id); + part = chip_part_number(chip_id); + serial = chip_serial_number(chip_id); + log_add_callout_section(buf, loc, part, serial); + + /* Insert the phb diag data. */ + common = (struct OpalIoPhbErrorCommon *)diag_buffer; + len = be32_to_cpu(common->len); + + log_add_section(buf, OPAL_ELOG_SEC_DIAG); + log_append_data(buf, diag_buffer, len); + log_commit(buf); + + phb->flags |= PCI_EEH_ERR_LOG_SENT; +} + static int64_t opal_pci_get_phb_diag_data2(uint64_t phb_id, void *diag_buffer, uint64_t diag_buffer_len) @@ -1000,6 +1045,10 @@ static int64_t opal_pci_get_phb_diag_data2(uint64_t phb_id, return OPAL_UNSUPPORTED; phb_lock(phb); rc = phb->ops->get_diag_data2(phb, diag_buffer, diag_buffer_len); + + /* Send an error log if required */ + if ((phb->flags & PCI_EEH_ERR_LOG_MASK) == PCI_EEH_ERR_LOG_SEND) + send_eeh_serviceable_event(phb, diag_buffer); phb_unlock(phb); return rc; diff --git a/hw/phb3.c b/hw/phb3.c index 8af6b6164..0d7370f52 100644 --- a/hw/phb3.c +++ b/hw/phb3.c @@ -68,6 +68,9 @@ static bool phb3_fenced(struct phb3 *p) if (nfir & PPC_BIT(16)) { p->flags |= PHB3_AIB_FENCED; + /* Mark flag to send an error log */ + p->phb.flags |= PCI_EEH_ERR_LOG_SEND; + phb3_eeh_dump_regs(p, NULL); return true; } @@ -2758,6 +2761,9 @@ static int64_t phb3_creset(struct pci_slot *slot) */ p->flags &= ~PHB3_AIB_FENCED; p->flags &= ~PHB3_CAPP_RECOVERY; + + /* Reset the error logging related flag */ + p->phb.flags &= ~PCI_EEH_ERR_LOG_MASK; phb3_init_hw(p, false); if (p->flags & PHB3_CAPP_DISABLING) { diff --git a/hw/phb4.c b/hw/phb4.c index 3f22a2c4d..8e59cdba4 100644 --- a/hw/phb4.c +++ b/hw/phb4.c @@ -2550,6 +2550,9 @@ static bool phb4_fenced(struct phb4 *p) /* Mark ourselves fenced */ p->flags |= PHB4_AIB_FENCED; + /* Mark flag to send an error log */ + p->phb.flags |= PCI_EEH_ERR_LOG_SEND; + PHBERR(p, "PHB Freeze/Fence detected !\n"); phb4_dump_pec_err_regs(p); @@ -3444,6 +3447,9 @@ static int64_t phb4_creset(struct pci_slot *slot) p->flags &= ~PHB4_AIB_FENCED; p->flags &= ~PHB4_CAPP_RECOVERY; p->flags &= ~PHB4_CFG_USE_ASB; + + /* Reset the error logging related flag */ + p->phb.flags &= ~PCI_EEH_ERR_LOG_MASK; phb4_init_hw(p); pci_slot_set_state(slot, PHB4_SLOT_CRESET_FRESET); diff --git a/include/errorlog.h b/include/errorlog.h index 24d12c4d8..9490e4ec4 100644 --- a/include/errorlog.h +++ b/include/errorlog.h @@ -341,6 +341,7 @@ enum opal_reasoncode { }; #define OPAL_ELOG_SEC_DESC 0x44455343 +#define OPAL_ELOG_SEC_DIAG 0x44494147 /* For EEH diag data */ #define DEFINE_LOG_ENTRY(reason, type, id, subsys, \ severity, subtype) static struct opal_err_info err_##reason = \ diff --git a/include/pci.h b/include/pci.h index eb23a6d9b..feadbf21d 100644 --- a/include/pci.h +++ b/include/pci.h @@ -382,6 +382,11 @@ struct phb { /* Additional data the platform might need to attach */ void *platform_data; + + uint32_t flags; +#define PCI_EEH_ERR_LOG_SEND 0x1 +#define PCI_EEH_ERR_LOG_SENT 0x2 +#define PCI_EEH_ERR_LOG_MASK 0x3 }; static inline void phb_lock(struct phb *phb)