From patchwork Fri Oct 28 16:00:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Dufour X-Patchwork-Id: 12440 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp916059wru; Fri, 28 Oct 2022 09:10:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM53WI9CkbSiP3qozsweZm0IiiVYDatgqWUMUCTyCjxdS+9twjAweAdz0YVUcOeIpK6vWp6D X-Received: by 2002:a17:902:7d87:b0:17f:9cd0:2e03 with SMTP id a7-20020a1709027d8700b0017f9cd02e03mr80251plm.164.1666973421072; Fri, 28 Oct 2022 09:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666973421; cv=none; d=google.com; s=arc-20160816; b=pO12DUdiRBiQbtdWXkjqxhpFZNRxfVkZaJNYkPV+nnIT8wqCdV2TgOUerxQ3PHTOP2 ALEs9dwJmEMdSqiOAftzWHe95M7HTO453YOcRlrGvhAcMrGdHFkVS5sbTrZElOoT+rJV ycs4XjIsd+JBJEC/BPSsw4Rt1P8Z6zzjPZs/EgGQRASyfxtSEssGTra4lDAEnlEVkHJE fuEs1zXaesOSumTYgWKlcjr3ArdElYYtdpx3QXO2Fh6Lr7V4hOiUbgrqVLrl58Nz4USY zzQaHRHNzLlOJOa3iD1IvtDdaR7m8TBSYCKYlnLvuZUw6X5414WHaj7gs1UTfAcls/Kg a10w== 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=m5gmoe5nzt1dR38vy96xlF8K5GaVfd5hD1tpJKcT8y0=; b=UL8GCEwrJ4Mj8viEfg6F40wAJTfvT1YkRmNDyzaepu+Ld4WxI+xP8G4bImZpwo73fV LSyeYIXXjGJWTzWXUlJRgjA/rf+HcpMc9SqGtI3vnvnk+Of6lp4XyOQ+PxAXVNnqctSd oGzJDV5oKpNIXqGohCoJ4LKZQcrkAzOK8OnkrrrjOco86PmxI/PraS7aqhQPlnvNYUWc rYZPH58xgrb8XMZiMD2QCKp4BkeZ6NsFdnvM2nwCX7VjWAfJuK5KUdNb/oMO4iI9k32U hsjaYpUrpt0ZmdyBZmw7JS3SbVJMsEgv+4RX2s4sx9pX2wbBV4ILr2Z2ZshnygrP5TDu C00g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=fe9RPeqi; 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 f19-20020a056a00239300b0056bce3dfaacsi6356048pfc.25.2022.10.28.09.10.07; Fri, 28 Oct 2022 09:10:21 -0700 (PDT) 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=fe9RPeqi; 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 S230423AbiJ1QIC (ORCPT + 99 others); Fri, 28 Oct 2022 12:08:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230514AbiJ1QGr (ORCPT ); Fri, 28 Oct 2022 12:06:47 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A08BD1DC800 for ; Fri, 28 Oct 2022 09:05:53 -0700 (PDT) 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 29SFnqZp031911; Fri, 28 Oct 2022 16:05:45 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=m5gmoe5nzt1dR38vy96xlF8K5GaVfd5hD1tpJKcT8y0=; b=fe9RPeqiZw6/Jm6jyYy58khmfLHhqhgbZu9vcgn7n3x0sTbqUlMwaeIq70xrW3CN24FJ SK7xBJTQGdqXuZYXcKltAM9iy4BfxZ30KxKYa8qcBNoGVsik8pyAN39x9JxZLI1nyKIP WcYKsv3kTiieCg+4pvKheBDJo8nGx4htY8y930w8Kbxl5XCwtDni8IfN/7JJHiJeyAbC 3iCbXyR+sJpTCmw/F3CB4FSw54SIRw6Q94d7cdrJn1aFjgMoa9xudS4gcLZbI7GKpnSV vyFVcqecvrCSNBQD3vgJVWAxcacwab7v2s21szJnltz5UaLKaCqvkmuxVFYw6GiFZHEg Gg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kgj2n8he3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 16:05:44 +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 29SFnpYW031812; Fri, 28 Oct 2022 16:05:44 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kgj2n8hcr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 16:05:44 +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 29SFp6YK023375; Fri, 28 Oct 2022 16:00:38 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma02fra.de.ibm.com with ESMTP id 3kfahmjt7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 16:00:38 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29SG1BpG29295026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Oct 2022 16:01:11 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DC4111C04A; Fri, 28 Oct 2022 16:00:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9F1011C050; Fri, 28 Oct 2022 16:00:35 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.94.157]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Oct 2022 16:00:35 +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 1/2] powerpc: export the CPU node count Date: Fri, 28 Oct 2022 18:00:33 +0200 Message-Id: <20221028160034.44400-2-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221028160034.44400-1-ldufour@linux.ibm.com> References: <20221028160034.44400-1-ldufour@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ILStheXaMmokWjvPpmUjqmkfJvUUO0oR X-Proofpoint-GUID: nRy3YEhyd_d89r4ajn7fB5olKmnQ_TwI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-28_07,2022-10-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 bulkscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2210280100 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?1747948322460228073?= X-GMAIL-MSGID: =?utf-8?q?1747948322460228073?= 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/kexec_ranges.h | 2 ++ arch/powerpc/kernel/prom.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/arch/powerpc/include/asm/kexec_ranges.h b/arch/powerpc/include/asm/kexec_ranges.h index f83866a19e87..bf35d00ddd09 100644 --- a/arch/powerpc/include/asm/kexec_ranges.h +++ b/arch/powerpc/include/asm/kexec_ranges.h @@ -22,4 +22,6 @@ int add_rtas_mem_range(struct crash_mem **mem_ranges); int add_opal_mem_range(struct crash_mem **mem_ranges); int add_reserved_mem_ranges(struct crash_mem **mem_ranges); +extern unsigned int boot_cpu_node_count; + #endif /* _ASM_POWERPC_KEXEC_RANGES_H */ diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 1eed87d954ba..d326148fd5a4 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -56,6 +56,7 @@ #include #include #include +#include #include @@ -72,6 +73,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 +337,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 Fri Oct 28 16:00:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Dufour X-Patchwork-Id: 12447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp916944wru; Fri, 28 Oct 2022 09:11:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6SGAJ0U9IZQXvzpXm/zYp27u0Y5B8eweQk1chdSrLNWEgzG1uxYvO2ANxOfSeQZjM15FBq X-Received: by 2002:a17:907:60c8:b0:78d:bc8d:8457 with SMTP id hv8-20020a17090760c800b0078dbc8d8457mr93741ejc.418.1666973516994; Fri, 28 Oct 2022 09:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666973516; cv=none; d=google.com; s=arc-20160816; b=uhO8VVqY4ip4HFvk8SHp1j7udZBK586TdlwW26kyretXBt0GI9cmKgn9ldlLuxjFfn 8NfCSNJNfZ2X8pZoFZQwCLcHwpRENcyKe+SMsJD90JUdqF0WsWafHIrCRB5Mxdib99+y Vk3UFQj0PCgNKl24YkhvG5UXHlbmBnaQSaoFJez/T7Fkn9CVs7e2LQYKBYoMvRZdOIoI X1ESGK1eKK+wooDaiI3ptBNQfMzyk3/GGxslrzKcNmpouO6SXDhak/WZ7kZFhbIW7Cfm WuCIjbjTiH4WzMYZTVViDVDwxIOxWEJxoVx+NsKq6l3vGU+tzWMAAT+sCLPVeLjGwjZS XIIw== 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=Ag61Q8Xg55sUv7jlbJD5dxol/V7IGyeMOcpLHVlRgKg=; b=dDWZ4c/StY2QbD3SBHdK47uul0GPDJV7zLfLldLQDgd5bXNysJ9j0eJieZNI4BghDp kKFy6VaW2JEbiQxvTnaHDZPOTGq/KR0dQo79f5tF3TFy3pEaR7ND3Uo/a2iV59YySXwT uTygiGZBUmZvqgUYk9tWcdhLVNP6bMFsxUqnuLdOhxbh0lHig00RvwMN1CCAzz0R7INc kTUW6ygLKOSnqO9zdUFeKcZjTaFfnT6aNIiRnpbDSyNwFUCfyjvwi90eBVgYHC3LWKZd wMQi7+2ZKxqMP6dwotinMu5fhuGOP1D58ATZhHLRqlbh1XZPz7hKV2mU393wH8TXsZtU vjGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZXCtEZNo; 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 hc14-20020a170907168e00b0078ddd8656d9si1031621ejc.9.2022.10.28.09.11.31; Fri, 28 Oct 2022 09:11:56 -0700 (PDT) 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=ZXCtEZNo; 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 S229871AbiJ1QIQ (ORCPT + 99 others); Fri, 28 Oct 2022 12:08:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230315AbiJ1QGt (ORCPT ); Fri, 28 Oct 2022 12:06:49 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C09C14 for ; Fri, 28 Oct 2022 09:06:00 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29SFi76Q037322; Fri, 28 Oct 2022 16:05:50 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=Ag61Q8Xg55sUv7jlbJD5dxol/V7IGyeMOcpLHVlRgKg=; b=ZXCtEZNoaDkxNsFS8wPL7gpTXbQ6DM9x+hpzZAMVQaSB62KgKQkhciwtTJrQf5d+hTQX 7GIT2rZMaAtQ+HN360Vzeb+bmIidbeBO4BpYekBWw9uL3rtfLhLUiLYwSEMMB6Y0dgTS VIiKhUciRl0t0hR/q1DbYZwKhLapqIADnasUdQjnv03E9wSaU77LEjEnfR+5MdpoXzmV bq921REj5QBQxlXPBfiB/m4CypAGC1lYgkbyOZONcFxXXqNErlaXrvcbyvvz+ERtlDBX kAcJqixo/j8UgofGqbG5ym62LdFxr4mooOJNfyy2h0rm6MtkkY4aZrUv6YEw+gRzsUy3 8Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kghyw8q6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 16:05:49 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 29SFlXf5010291; Fri, 28 Oct 2022 16:05:49 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kghyw8q59-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 16:05:49 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29SFppHt004243; Fri, 28 Oct 2022 16:00:38 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06fra.de.ibm.com with ESMTP id 3kfbg2ar0x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 28 Oct 2022 16:00:38 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29SG1BhP29295030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 28 Oct 2022 16:01:11 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8614711C04A; Fri, 28 Oct 2022 16:00:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D25511C04C; Fri, 28 Oct 2022 16:00:36 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.94.157]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 28 Oct 2022 16:00:36 +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 2/2] powerpc: Take in account addition CPU node when building kexec FDT Date: Fri, 28 Oct 2022 18:00:34 +0200 Message-Id: <20221028160034.44400-3-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221028160034.44400-1-ldufour@linux.ibm.com> References: <20221028160034.44400-1-ldufour@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: JPYw-6l1ZhIYxfCFG3f87yUQjTYgtouA X-Proofpoint-ORIG-GUID: XDD6smsMZ-tfigq6HbcTJXcfw1qNR-gN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-28_07,2022-10-27_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 impostorscore=0 clxscore=1015 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2210280100 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?1747948422789423844?= X-GMAIL-MSGID: =?utf-8?q?1747948422789423844?= 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 | 59 ++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index 349a781cea0b..1476922cd7c5 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -928,6 +928,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 +977,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 +992,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; } /**