From patchwork Thu Nov 10 18:06:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Dufour X-Patchwork-Id: 18267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp299359wru; Thu, 10 Nov 2022 10:16:38 -0800 (PST) X-Google-Smtp-Source: AMsMyM4dz/rwGnLgGeyr3FLcg3bkU9HzCclXmfFT9A4C/tgRzaHVbdHC/RAi+K2XuPKlBz5q23v6 X-Received: by 2002:aa7:ca41:0:b0:462:3340:757b with SMTP id j1-20020aa7ca41000000b004623340757bmr2930754edt.308.1668104198285; Thu, 10 Nov 2022 10:16:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104198; cv=none; d=google.com; s=arc-20160816; b=PJ4Tgc3lR/IJLTD1vgS3Wtu40aRojEEjL5wXq9zhT+Nxlar1LTizAnRYrCM9HzWDqP V9KlvAQOzaZXs7Ebs7GowdE+TzrLwjPhpqbG5JosSF7KMYAMJGc51k6sdeVIg4/0K4X9 cnftJ9n6hR6imaxJ2gLGhVtkoVPNkeRDby8UcE8T60IySgIj+kibFidBQVvdNwN5O69h IFZlo3F3PfhJB6wd772zg4V0dTVtrzcj2cnHsOb4NJvaYRQL2Ka1lkP4lbPBaXY55usL +GEfTd6sgKXcX8Qdg7sndOBxR+in+LaThTm2Gwp428S3U6RtxaKnJaIshqt4VzUZs+GV PnFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DpmSL5sS3W0zss4QlY53Iu2CLIrD1N3OiphS+anrYJ0=; b=MJ98l8BS2MMVXxA0xw/Z9QhgcPtpblEeP6HAmfLUb16nD1DEU9ismv5AiD3ZPbG5HK 7V/tOHutDvsX5iMWdIPEtRCUWSJxDVR69UsaZPw0tht1CYYP0njD7kvW1k3CRSthYDFu gCbG8OXw8hQfbWHJaj839hXNfG7xa58M6h+iisj8T283bb+CYMf+mdVsxNz54bTwu1Yk yMITQ69DD1sEoqbqcU7T+Fg5VxWFLO+o7SuU48H9aUKAiJ1x1y7WTFn+X1d+s2ZCCAKZ fxMzypQs4r7n4GbXrXkDGxK7rikM0KlJPIeM7F+gr9hbwdhPuepYY7Eso/c8Glm7udQs paTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=iL+IqVov; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs8-20020a1709073e8800b0078ca7bbf616si18722607ejc.746.2022.11.10.10.16.14; Thu, 10 Nov 2022 10:16:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=iL+IqVov; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbiKJSGq (ORCPT + 99 others); Thu, 10 Nov 2022 13:06:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230000AbiKJSGi (ORCPT ); Thu, 10 Nov 2022 13:06:38 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63C10636F for ; Thu, 10 Nov 2022 10:06:37 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2AAHkf4a031310; Thu, 10 Nov 2022 18:06:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=DpmSL5sS3W0zss4QlY53Iu2CLIrD1N3OiphS+anrYJ0=; b=iL+IqVovsJwqo7vtj+O9bYLqc0ebwsq+tUIZOdZuyvc49Ly/owxdKw+WDtaCq012vT3j BjqqlycIw3SiDsMTZR+0Ox5uJgYcPCgeGEIok1gNZSjJ6VbsPNVYofGOvSRelgWN52VY 0O1s2yFDG9DU3BLvbwAL6P80W3jRqi60P8mieZEZOQP52thVkjuTLzvLd45MfyFsM1JL a4qzt8hCydJVbRxINGhdiutXqBSvByX7Ct6pOE5SoOPzYLGB/SSfLH1rz81QwvyN9MZt fBeFWjM3csGggqV9sgxrpyiO6r/CrIIDKxHGZfzVaL1XprjsVj+IcFJ+Za4Wzsn5nlEE Fw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3ks60frk72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 18:06:26 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AAHrNwx021422; Thu, 10 Nov 2022 18:06:26 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3ks60frk61-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 18:06:26 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AAI5lRw018865; Thu, 10 Nov 2022 18:06:24 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 3kngpgnk07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 18:06:24 +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 2AAI6LqC39125706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Nov 2022 18:06:22 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1ABAAE04D; Thu, 10 Nov 2022 18:06:21 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 985FCAE045; Thu, 10 Nov 2022 18:06:21 +0000 (GMT) Received: from pomme.tlslab.ibm.com (unknown [9.101.4.33]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Nov 2022 18:06:21 +0000 (GMT) From: Laurent Dufour To: mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] powerpc: export the CPU node count Date: Thu, 10 Nov 2022 19:06:18 +0100 Message-Id: <20221110180619.15796-2-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221110180619.15796-1-ldufour@linux.ibm.com> References: <20221110180619.15796-1-ldufour@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: lzqmg08Fi39zbCdtzGdQbZE8J7o24bL- X-Proofpoint-ORIG-GUID: AbXjTEfTdajvO8aZ2mQQ9xwgJFU2Ousx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-10_12,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 phishscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211100126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749134027694298844?= X-GMAIL-MSGID: =?utf-8?q?1749134027694298844?= At boot time, the FDT is parsed to compute the number of CPUs. In addition count the number of CPU nodes and export it. This is useful when building the FDT for a kexeced kernel since we need to take in account the CPU node added since the boot time during CPU hotplug operations. Signed-off-by: Laurent Dufour --- arch/powerpc/include/asm/prom.h | 1 + arch/powerpc/kernel/prom.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h index 2e82820fbd64..c0107d8ddd8c 100644 --- a/arch/powerpc/include/asm/prom.h +++ b/arch/powerpc/include/asm/prom.h @@ -85,6 +85,7 @@ struct of_drc_info { extern int of_read_drc_info_cell(struct property **prop, const __be32 **curval, struct of_drc_info *data); +extern unsigned int boot_cpu_node_count; /* * There are two methods for telling firmware what our capabilities are. diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 1eed87d954ba..645f4450dfc3 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -72,6 +72,7 @@ int __initdata iommu_is_off; int __initdata iommu_force_on; unsigned long tce_alloc_start, tce_alloc_end; u64 ppc64_rma_size; +unsigned int boot_cpu_node_count __ro_after_init; #endif static phys_addr_t first_memblock_size; static int __initdata boot_cpu_count; @@ -335,6 +336,8 @@ static int __init early_init_dt_scan_cpus(unsigned long node, if (type == NULL || strcmp(type, "cpu") != 0) return 0; + boot_cpu_node_count++; + /* Get physical cpuid */ intserv = of_get_flat_dt_prop(node, "ibm,ppc-interrupt-server#s", &len); if (!intserv) From patchwork Thu Nov 10 18:06:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Dufour X-Patchwork-Id: 18268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp300452wru; Thu, 10 Nov 2022 10:18:29 -0800 (PST) X-Google-Smtp-Source: AMsMyM6P/1AlQXugqK/UhvhA+EAchUyom4nwaPNZZJM3eQbb3UmC+ZTjG7ovQTnReYXzHb0DMQmC X-Received: by 2002:a17:906:7008:b0:78e:ebb:cbb7 with SMTP id n8-20020a170906700800b0078e0ebbcbb7mr3483763ejj.38.1668104309504; Thu, 10 Nov 2022 10:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668104309; cv=none; d=google.com; s=arc-20160816; b=UtaVt8/ewBhagv3i1UGqP7pQZZKgxPXpg8gi3nZ+AquDtrEO8Yl2rNWY4O9Zikr2HU MUHJyer6KMg67PSdRaMO6P7JnfopEl8gf0dO08YmzclzbxQhrsqPVoUZrWtQQBzY4Ax7 cdp5bjSAZWaISzvU8xKWafifVBm5U///dbo5ZILnUF5QoqBoOZ/Bes7ryszi8+xq9T66 479C/6S1SjtSU+wMN7X+5GUVVfZ7+TcBRg9GafuirgiN8PWo15K22bWzd3INvCC53NeC zfyEUPkMQI5KWGLX+9/iBy7X4nzNdazaWyz6kBqNL9T86EDi1ojFFDNj/s9V8FCiWRXz SrLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6yrW636fqCp62zNO6e7icAOgbXhM+JFZKFb7pIKsSuo=; b=TPULe/BQale6Fa+WrNfHlXjecqyZEWQET9FhR1sUmwp7zkp6fLdAM+x0CUynN+lW7J WLjLkFrRleN69u6MhG8Txph6AM81B/k/6oaMi9WZMyfYP6/+qdIusReNNx5/PzxQ3NTm SpW//Z85KixxTffxC4g59cd1/Z017MlijD4xEAykZ/51jxe06av4Od6zO07YdACFw2Sd KKIB+ImEgcMAHX83vZuhPDgoryGfFQ+zgFInewnfCkZF1PEwknyKG9CBexokocu2c32L cQNHfLnBlEQQUVnzo7GY6JMMN9IvpNau/+F8Cx4jWKgcQbFjE1+6X5XkChAYUyZ//k0A l1ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=iT30AsLo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a1709064fc500b007aacd494fe9si17861841ejw.311.2022.11.10.10.18.05; Thu, 10 Nov 2022 10:18:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=iT30AsLo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230492AbiKJSGu (ORCPT + 99 others); Thu, 10 Nov 2022 13:06:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbiKJSGi (ORCPT ); Thu, 10 Nov 2022 13:06:38 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6480B63B3 for ; Thu, 10 Nov 2022 10:06:37 -0800 (PST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2AAHqOLw028088; Thu, 10 Nov 2022 18:06:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=6yrW636fqCp62zNO6e7icAOgbXhM+JFZKFb7pIKsSuo=; b=iT30AsLoEJb7+YFbxBU1jonNUwkumazsHkC1Li4N2nCSUkRMECQgUflyCCYvQYgR2jDG p3HGAizlCzoh2NAWv3VKTNJwHs1Ol04lWH1AMnpCSnSx/Des1BAW1E/2f3ytaJ6p+ZlU +EauujAZPyi54j9c0+/rSvvumiLzVJZ0rZE1zfXPV5X3xIiFNm0FMUTo+GZlJe1/r+Tz 3i2c/YMTC1EI1e/CSlgIFj1o82LzYkzouMAihtg3YnkVawjgJkSikGTF4apbSYnKraFz qd93p+xPS7O77twRhcvlaYC7OOBU8ifJ2xMNJlGQuFHA7jeVWte/U/hpRHYMO/Ge31th 8Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ks635ren4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 18:06:26 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AAHr131029255; Thu, 10 Nov 2022 18:06:26 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3ks635rem4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 18:06:26 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AAHoYZN015561; Thu, 10 Nov 2022 18:06:24 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04fra.de.ibm.com with ESMTP id 3kngmqnhdh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Nov 2022 18:06:24 +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 2AAI6MDH57672058 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Nov 2022 18:06:22 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50A2CAE051; Thu, 10 Nov 2022 18:06:22 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F19F4AE045; Thu, 10 Nov 2022 18:06:21 +0000 (GMT) Received: from pomme.tlslab.ibm.com (unknown [9.101.4.33]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Nov 2022 18:06:21 +0000 (GMT) From: Laurent Dufour To: mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] powerpc: Take in account addition CPU node when building kexec FDT Date: Thu, 10 Nov 2022 19:06:19 +0100 Message-Id: <20221110180619.15796-3-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221110180619.15796-1-ldufour@linux.ibm.com> References: <20221110180619.15796-1-ldufour@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sw4pmto-tG0SojxlH4a3ZrKvAo6-WjVf X-Proofpoint-ORIG-GUID: crMpBqeFaocd5gAKAcUPc_NX1uDxQ3Gt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-10_12,2022-11-09_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211100126 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749134144369850457?= X-GMAIL-MSGID: =?utf-8?q?1749134144369850457?= On a system with a large number of CPUs, the creation of the FDT for a kexec kernel may fail because the allocated FDT is not large enough. When this happens, such a message is displayed on the console: Unable to add ibm,processor-vadd-size property: FDT_ERR_NOSPACE The property's name may change depending when the buffer overwrite is detected. Obviously the created FDT is missing information, and it is expected that system dump or kexec kernel failed to run properly. When the FDT is allocated, the size of the FDT the kernel received at boot time is used and an extra size can be applied. Currently, only memory added after boot time is taken in account, not the CPU nodes. The extra size should take in account these additional CPU nodes and compute the required extra space. To achieve that, the size of a CPU node, including its subnode is computed once and multiplied by the number of additional CPU nodes. The assumption is that the size of the CPU node is _same_ for all the node, the only variable part should be the name "PowerPC,POWERxx@##" where "##" may vary a bit. Signed-off-by: Laurent Dufour --- arch/powerpc/kexec/file_load_64.c | 60 ++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index 349a781cea0b..6865cd7dc3ca 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -26,6 +26,7 @@ #include #include #include +#include struct umem_info { u64 *buf; /* data buffer for usable-memory property */ @@ -928,6 +929,46 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code, return ret; } +/** + * get_cpu_node_size - Compute the size of a CPU node in the FDT. + * This should be done only once and the value is stored in + * a static variable. + * Returns the max size of a CPU node in the FDT. + */ +static unsigned int cpu_node_size(void) +{ + static unsigned int cpu_node_size; + struct device_node *dn; + struct property *pp; + + /* + * Don't compute it twice, we are assuming that the per CPU node size + * doesn't change during the system's life. + */ + if (cpu_node_size) + return cpu_node_size; + + dn = of_find_node_by_type(NULL, "cpu"); + if (!dn) { + /* Unlikely to happen */ + WARN_ON_ONCE(1); + return 0; + } + + /* + * We compute the sub node size for a CPU node, assuming it + * will be the same for all. + */ + cpu_node_size += strlen(dn->name) + 5; + for_each_property_of_node(dn, pp) { + cpu_node_size += strlen(pp->name); + cpu_node_size += pp->length; + } + + of_node_put(dn); + return cpu_node_size; +} + /** * kexec_extra_fdt_size_ppc64 - Return the estimated additional size needed to * setup FDT for kexec/kdump kernel. @@ -937,7 +978,10 @@ int setup_purgatory_ppc64(struct kimage *image, const void *slave_code, */ unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image) { + struct device_node *dn; u64 usm_entries; + unsigned int cpu_nodes = 0; + unsigned int extra_size; if (image->type != KEXEC_TYPE_CRASH) return 0; @@ -949,7 +993,21 @@ unsigned int kexec_extra_fdt_size_ppc64(struct kimage *image) */ usm_entries = ((memblock_end_of_DRAM() / drmem_lmb_size()) + (2 * (resource_size(&crashk_res) / drmem_lmb_size()))); - return (unsigned int)(usm_entries * sizeof(u64)); + + extra_size = (unsigned int)(usm_entries * sizeof(u64)); + + /* + * Get the number of CPU nodes in the current DT. This allows to + * reserve places for CPU nodes added since the boot time. + */ + for_each_node_by_type(dn, "cpu") { + cpu_nodes++; + } + + if (cpu_nodes > boot_cpu_node_count) + extra_size += (cpu_nodes - boot_cpu_node_count) * cpu_node_size(); + + return extra_size; } /**