Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp688imw; Mon, 4 Jul 2022 04:11:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t332DOj2+SK/KTll8nxZksfbHh7OrejAEYgdjlK4PbD2IEfFbXSne6iR3fqISxs9gr9P4b X-Received: by 2002:a17:902:fe81:b0:16b:c67f:68ad with SMTP id x1-20020a170902fe8100b0016bc67f68admr14992829plm.10.1656933107122; Mon, 04 Jul 2022 04:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656933107; cv=none; d=google.com; s=arc-20160816; b=UT40TZ7UamQk7ToYVVCe+9pUweKjproz2vkds4AtpbvNrstK7jkOs4tSGw+Ay970C4 GLX2nbsdxLzd9HyzES2uPV3SRCZt2JmxQwgAv4UadKWY4mwdJ8KLMI8v8GQ6p9cf4vfk LnJqLsDnUt/bberGPnuqZLDzQ+4ng2zkN9D4+w0NeYqfWzNmQWpfRf5xd9x+3MFhDp2o 7QvBaYM/0pPvS9GIbyw6hZ2gnlcCI9/UsSD7gsY6c7J3TNzwqneD8PgCXTSvUYnApO7b hDASH6o2YR9DBoCmJLulpYtlbcU3C0NRNEESNA2qZ+UWNFjcJS9GeQHD5eUrddT+Wn7o ep8A== 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; bh=lS3YjBUIkvH6FGuVAEiH/osaffiOQOuugPEfdIaDMkY=; b=NlPi2G46MtMPR2053oJTk1kkJTODrrbR0aBxw50FPkSqJlJY18B+CgasFLlDheJ0rf ff/FdO43d3idQ8LsaeYHtmIwoDU1Txnd563Fjijt+/l1aInBDPECvWZzIBRrIGYH6sIs HB8gNmni1pmSJzaO4PIi798Mdbkv5pjAC2iKOnkCjWi8+NYh8/ek32nqAoZNh89RYqET Mli60P+YpJoXq0Z5M1P6hAI1CXj7aRk52qh+vO131zx2fN1qMUruXM780sHDSt8hMWG5 gUVBKST2VN75i6J2drDNNeZQ2R+bz1+p7bDmivJwe4e24q4qznJXgEenuXYSkJ8SaO6e QUTA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020a635057000000b003fdb58f085dsi23175574pgl.374.2022.07.04.04.11.34; Mon, 04 Jul 2022 04:11:47 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234460AbiGDKSQ (ORCPT + 99 others); Mon, 4 Jul 2022 06:18:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234277AbiGDKQz (ORCPT ); Mon, 4 Jul 2022 06:16:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EFFBDDFF6 for ; Mon, 4 Jul 2022 03:16:54 -0700 (PDT) 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 175111480; Mon, 4 Jul 2022 03:16:55 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 052023F792; Mon, 4 Jul 2022 03:16:52 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org, Greg Kroah-Hartman Cc: Sudeep Holla , conor.dooley@microchip.com, valentina.fernandezalanis@microchip.com, Vincent Guittot , Dietmar Eggemann , Qing Wang , Rob Herring , "Rafael J . Wysocki" , Ionela Voinescu , Pierre Gondois , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org Subject: [PATCH v6 19/21] arch_topology: Add support for parsing sockets in /cpu-map Date: Mon, 4 Jul 2022 11:16:03 +0100 Message-Id: <20220704101605.1318280-20-sudeep.holla@arm.com> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220704101605.1318280-1-sudeep.holla@arm.com> References: <20220704101605.1318280-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Finally let us add support for socket nodes in /cpu-map in the device tree. Since this may not be present in all the old platforms and even most of the existing platforms, we need to assume absence of the socket node indicates that it is a single socket system and handle appropriately. Also it is likely that most single socket systems skip to as the node since it is optional. Tested-by: Ionela Voinescu Reviewed-by: Ionela Voinescu Signed-off-by: Sudeep Holla --- drivers/base/arch_topology.c | 37 +++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 217a91fc1f59..8719c4458df9 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -545,8 +545,8 @@ static int __init parse_core(struct device_node *core, int package_id, return 0; } -static int __init -parse_cluster(struct device_node *cluster, int cluster_id, int depth) +static int __init parse_cluster(struct device_node *cluster, int package_id, + int cluster_id, int depth) { char name[20]; bool leaf = true; @@ -566,7 +566,7 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth) c = of_get_child_by_name(cluster, name); if (c) { leaf = false; - ret = parse_cluster(c, i, depth + 1); + ret = parse_cluster(c, package_id, i, depth + 1); of_node_put(c); if (ret != 0) return ret; @@ -590,7 +590,8 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth) } if (leaf) { - ret = parse_core(c, 0, cluster_id, core_id++); + ret = parse_core(c, package_id, cluster_id, + core_id++); } else { pr_err("%pOF: Non-leaf cluster with core %s\n", cluster, name); @@ -610,6 +611,32 @@ parse_cluster(struct device_node *cluster, int cluster_id, int depth) return 0; } +static int __init parse_socket(struct device_node *socket) +{ + char name[20]; + struct device_node *c; + bool has_socket = false; + int package_id = 0, ret; + + do { + snprintf(name, sizeof(name), "socket%d", package_id); + c = of_get_child_by_name(socket, name); + if (c) { + has_socket = true; + ret = parse_cluster(c, package_id, -1, 0); + of_node_put(c); + if (ret != 0) + return ret; + } + package_id++; + } while (c); + + if (!has_socket) + ret = parse_cluster(socket, 0, -1, 0); + + return ret; +} + static int __init parse_dt_topology(void) { struct device_node *cn, *map; @@ -630,7 +657,7 @@ static int __init parse_dt_topology(void) if (!map) goto out; - ret = parse_cluster(map, -1, 0); + ret = parse_socket(map); if (ret != 0) goto out_map; -- 2.37.0