From patchwork Tue Jul 3 06:17:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 938390 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KYt70wdqz9s2R for ; Tue, 3 Jul 2018 16:21:35 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41KYt66DXJzF1Nb for ; Tue, 3 Jul 2018 16:21:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.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 41KYpC4zXGzF1LQ for ; Tue, 3 Jul 2018 16:18:11 +1000 (AEST) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w636EMEu136501 for ; Tue, 3 Jul 2018 02:18:10 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k00m561u3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 03 Jul 2018 02:18:09 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 3 Jul 2018 07:18:07 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 3 Jul 2018 07:18:04 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w636I3BO40632536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 3 Jul 2018 06:18:03 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC72C4203F; Tue, 3 Jul 2018 09:18:28 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0AD542041; Tue, 3 Jul 2018 09:18:27 +0100 (BST) Received: from hegdevasant.in.ibm.com (unknown [9.199.176.102]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 3 Jul 2018 09:18:27 +0100 (BST) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Tue, 3 Jul 2018 11:47:21 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180703061727.8789-1-hegdevasant@linux.vnet.ibm.com> References: <20180703061727.8789-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070306-0028-0000-0000-000002D79301 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070306-0029-0000-0000-0000238F121E Message-Id: <20180703061727.8789-13-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-03_03:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807030072 Subject: [Skiboot] [PATCH v4 12/18] fadump: Add fw-source-table to ibm, dump node X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stewart@linux.vnet.ibm.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Add 'fw-source-table' property to ibm,dump node. Payload will make use of this property to create ELF notes. This patch also adjusts MDST and MDDT entry for OPAL dump. Now OPAL dump size reflects runtime size of OPAL. Finally add reserve node for opal dump destination memory. If dump is available then reserve node size is max of current dump destination size and memory reserved for next dump. Signed-off-by: Vasant Hegde --- core/Makefile.inc | 2 +- core/init.c | 4 ++ core/opal-mpipl.c | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/opal-dump.h | 3 + 4 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 core/opal-mpipl.c diff --git a/core/Makefile.inc b/core/Makefile.inc index d36350590..5b7009ea8 100644 --- a/core/Makefile.inc +++ b/core/Makefile.inc @@ -9,7 +9,7 @@ CORE_OBJS += vpd.o hostservices.o platform.o nvram.o nvram-format.o hmi.o CORE_OBJS += console-log.o ipmi.o time-utils.o pel.o pool.o errorlog.o CORE_OBJS += timer.o i2c.o rtc.o flash.o sensor.o ipmi-opal.o CORE_OBJS += flash-subpartition.o bitmap.o buddy.o pci-quirk.o powercap.o psr.o -CORE_OBJS += pci-dt-slot.o direct-controls.o cpufeatures.o +CORE_OBJS += pci-dt-slot.o direct-controls.o cpufeatures.o opal-mpipl.o ifeq ($(SKIBOOT_GCOV),1) CORE_OBJS += gcov-profiling.o diff --git a/core/init.c b/core/init.c index b660af2d7..1c61343f6 100644 --- a/core/init.c +++ b/core/init.c @@ -54,6 +54,7 @@ #include #include #include +#include enum proc_gen proc_gen; unsigned int pcie_max_link_speed; @@ -1039,6 +1040,9 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) */ p9_sbe_init(); + /* init opal dump */ + opal_fadump_init(); + /* Initialize i2c */ p8_i2c_init(); diff --git a/core/opal-mpipl.c b/core/opal-mpipl.c new file mode 100644 index 000000000..9e95cdbae --- /dev/null +++ b/core/opal-mpipl.c @@ -0,0 +1,172 @@ +/* Copyright 2018 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define pr_fmt(fmt) "FADUMP: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "hdata/spira.h" + +/* Actual address of MDST and MDDT table */ +#define MDST_TABLE_BASE (SKIBOOT_BASE + MDST_TABLE_OFF) +#define MDDT_TABLE_BASE (SKIBOOT_BASE + MDDT_TABLE_OFF) + +static struct spira_ntuple *ntuple_mdst; +static struct spira_ntuple *ntuple_mddt; +static struct spira_ntuple *ntuple_mdrt; + + +/* Reserve OPAL dump destination memory */ +static void add_fadump_reserve_node(struct dt_node *dump_node) +{ + int i; + u64 cur_size = 0, new_size = 0; + /* Use relocated memory address */ + struct mddt_table *mddt = (void *)(MDDT_TABLE_BASE); + struct mdrt_table *mdrt = (void *)(MDRT_TABLE_BASE); + + /* If dump exists, get current opal dump size */ + if (dt_find_property(dump_node, "result-table")) { + for (i = 0; i < ntuple_mdrt->act_cnt; i++) { + if (mdrt->data_region >= DUMP_REGION_OPAL_START && + mdrt->data_region < DUMP_REGION_OPAL_END) + cur_size += be32_to_cpu(mdrt->size); + + mdrt++; + } + } + + /* Get new OPAL dump reservation size */ + for (i = 0; i < ntuple_mddt->act_cnt; i++) { + if (mddt->data_region >= DUMP_REGION_OPAL_START && + mddt->data_region < DUMP_REGION_OPAL_END) + new_size += be32_to_cpu(mddt->size); + + mddt++; + } + + mem_reserve_fw("ibm,firmware-dump", (u64)FADUMP_DEST_CON_LOG, + new_size > cur_size ? new_size : cur_size); +} + +/* Pass OPAL dump reservation details to payload via device tree. */ +static void dt_add_fadump_source_table(struct dt_node *dump_node, + struct mdst_table *mdst, + struct mddt_table *mddt) +{ + size_t prop_size; + struct fadump *source_table; + + if (mdst->data_region != DUMP_REGION_OPAL_MEMORY || + mddt->data_region != DUMP_REGION_OPAL_MEMORY) { + prlog(PR_DEBUG, + "OPAL memory entry is missing in MDST/MDDT table\n"); + return; + } + + prop_size = sizeof(struct fadump) + sizeof(struct fadump_section); + source_table = zalloc(prop_size); + if (!source_table) { + prlog(PR_ERR, "Failed to allocate memory\n"); + return; + } + + source_table->fadump_section_size = sizeof(struct fadump_section); + source_table->section_count = 1; + source_table->section[0].source_type = mdst->data_region; + source_table->section[0].source_addr = mdst->addr & ~(HRMOR_BIT); + source_table->section[0].source_size = mdst->size; + source_table->section[0].dest_addr = mddt->addr & ~(HRMOR_BIT); + source_table->section[0].dest_size = mddt->size; + + dt_add_property(dump_node, "fw-source-table", source_table, prop_size); + free(source_table); +} + +/* + * OPAL adjusts runtime OPAL size based on number of CPUs and PIR value. + * Hardcoded dump entry in MDST and MDDT table contains maximum size required + * to capture OPAL dump (so that we can capture early OPAL dump). Adjust + * OPAL dump entry in MDST and MDDT to reflect OPAL runtime size. + */ +static void adjust_opal_dump_size(struct dt_node *dump_node) +{ + int i; + u64 opal_size; + /* Use relocated memory address */ + struct mdst_table *mdst = (void *)(MDST_TABLE_BASE); + struct mddt_table *mddt = (void *)(MDDT_TABLE_BASE); + + /* Get OPAL runtime size */ + if (!dt_find_property(opal_node, "opal-runtime-size")) + return; + opal_size = dt_prop_get_u64(opal_node, "opal-runtime-size"); + + /* Safe to assume MDST, MDDT table contains entry for OPAL dump + * (see hdata/spira.c) + */ + for (i = 0; i < ntuple_mdst->act_cnt; i++) { + if (mdst->data_region != DUMP_REGION_OPAL_MEMORY) { + mdst++; + continue; + } + mdst->size = opal_size; + break; + } + + for (i = 0; i < ntuple_mddt->act_cnt; i++) { + if (mddt->data_region != DUMP_REGION_OPAL_MEMORY) { + mddt++; + continue; + } + mddt->size = opal_size; + break; + } + + /* Add OPAL dump reservation details to DT */ + dt_add_fadump_source_table(dump_node, mdst, mddt); + /* Make sure OPAL dump destination memory is reserved */ + add_fadump_reserve_node(dump_node); +} + +void opal_fadump_init(void) +{ + struct dt_node *dump_node; + + if (proc_gen < proc_gen_p9) + return; + + /* fadump needs HDAT support */ + dump_node = dt_find_by_path(dt_root, "ibm,dump"); + if (!dump_node) + return; + + /* Get MDST and MDDT ntuple from SPIRAH */ + ntuple_mdst = &(spirah.ntuples.mdump_src); + ntuple_mddt = &(spirah.ntuples.mdump_dst); + ntuple_mdrt = &(spirah.ntuples.mdump_res); + + adjust_opal_dump_size(dump_node); +} diff --git a/include/opal-dump.h b/include/opal-dump.h index 3619057c1..d0d016eb0 100644 --- a/include/opal-dump.h +++ b/include/opal-dump.h @@ -82,4 +82,7 @@ struct mdrt_table { __be64 padding; } __packed; +/* init opal dump */ +extern void opal_fadump_init(void); + #endif /* __OPAL_DUMP_H */