From nobody Thu Nov 6 01:20:32 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1700448946454674.2968728657522; Sun, 19 Nov 2023 18:55:46 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.636371.991825 (Exim 4.92) (envelope-from ) id 1r4uRc-0002px-4a; Mon, 20 Nov 2023 02:55:28 +0000 Received: by outflank-mailman (output) from mailman id 636371.991825; Mon, 20 Nov 2023 02:55:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r4uRc-0002pk-1o; Mon, 20 Nov 2023 02:55:28 +0000 Received: by outflank-mailman (input) for mailman id 636371; Mon, 20 Nov 2023 02:55:27 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r4uRb-0007WE-NI for xen-devel@lists.xenproject.org; Mon, 20 Nov 2023 02:55:27 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 4150dff3-8750-11ee-9b0e-b553b5be7939; Mon, 20 Nov 2023 03:55:26 +0100 (CET) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 77CE51042; Sun, 19 Nov 2023 18:56:11 -0800 (PST) Received: from a015966.shanghai.arm.com (a015966.shanghai.arm.com [10.169.190.5]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D3AA53F6C4; Sun, 19 Nov 2023 18:55:22 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4150dff3-8750-11ee-9b0e-b553b5be7939 From: Henry Wang To: xen-devel@lists.xenproject.org Cc: Wei Chen , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Henry Wang Subject: [PATCH v6 10/17] xen/arm: unified entry to parse all NUMA data from device tree Date: Mon, 20 Nov 2023 10:54:24 +0800 Message-Id: <20231120025431.14845-11-Henry.Wang@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231120025431.14845-1-Henry.Wang@arm.com> References: <20231120025431.14845-1-Henry.Wang@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1700448948226100003 Content-Type: text/plain; charset="utf-8" From: Wei Chen In this function, we scan the whole device tree to parse CPU node id, memory node id and distance-map. Though early_scan_node will invoke a handler to process memory nodes. If we want to parse memory node id in that handler, we have to embed NUMA parse code in that handler. But we still need to scan whole device tree to find CPU NUMA id and distance-map. In this case, we include memory NUMA id parse in this function too. Another benefit is that we have a unique entry for device tree NUMA data parse. Signed-off-by: Wei Chen Signed-off-by: Henry Wang --- v5 -> v6: - Rebase on top of staging without code changes. v1 -> v5: - Fix typos in commit message. - Fix code style and align parameters. - Use strncmp to replace memcmp. --- xen/arch/arm/include/asm/numa.h | 1 + xen/arch/arm/numa-dt.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/xen/arch/arm/include/asm/numa.h b/xen/arch/arm/include/asm/num= a.h index 2987158d16..15308f5a36 100644 --- a/xen/arch/arm/include/asm/numa.h +++ b/xen/arch/arm/include/asm/numa.h @@ -44,6 +44,7 @@ extern bool numa_disabled(void); extern void numa_set_distance(nodeid_t from, nodeid_t to, unsigned int distance); extern void numa_detect_cpu_node(unsigned int cpu); +extern int numa_device_tree_init(const void *fdt); =20 #else =20 diff --git a/xen/arch/arm/numa-dt.c b/xen/arch/arm/numa-dt.c index 2fb6663e08..8198a0da2e 100644 --- a/xen/arch/arm/numa-dt.c +++ b/xen/arch/arm/numa-dt.c @@ -267,3 +267,33 @@ static int __init fdt_parse_numa_distance_map_v1(const= void *fdt, int node) numa_fw_bad(); return -EINVAL; } + +static int __init fdt_scan_numa_nodes(const void *fdt, int node, + const char *uname, int depth, + unsigned int address_cells, + unsigned int size_cells, void *data) +{ + int len, ret =3D 0; + const void *prop; + + prop =3D fdt_getprop(fdt, node, "device_type", &len); + if ( prop ) + { + if ( strncmp(prop, "cpu", len) =3D=3D 0 ) + ret =3D fdt_parse_numa_cpu_node(fdt, node); + else if ( strncmp(prop, "memory", len) =3D=3D 0 ) + ret =3D fdt_parse_numa_memory_node(fdt, node, uname, + address_cells, size_cells); + } + else if ( fdt_node_check_compatible(fdt, node, + "numa-distance-map-v1") =3D=3D 0 ) + ret =3D fdt_parse_numa_distance_map_v1(fdt, node); + + return ret; +} + +/* Initialize NUMA from device tree */ +int __init numa_device_tree_init(const void *fdt) +{ + return device_tree_for_each_node(fdt, 0, fdt_scan_numa_nodes, NULL); +} --=20 2.25.1