Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp311646iob; Wed, 18 May 2022 02:45:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnewMW2sI93n0qjlMdRMZ2Cl9fXKEJNzrMWNjH36Z4dpy0DGmpbwRykJtoi3gYxECi3+/y X-Received: by 2002:a17:90b:795:b0:1df:10a3:84e3 with SMTP id l21-20020a17090b079500b001df10a384e3mr23164969pjz.197.1652867128641; Wed, 18 May 2022 02:45:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652867128; cv=none; d=google.com; s=arc-20160816; b=gA2W7jo6t4U1R0TgEZ1lEzNag9nET0KSWMXd7/EpDFSdLdNvADOD4RL0fhjp/QCuuB SymOuV41KuC4WaBTsG9KBx+aNcuqwV150KrlIECO5XFCYZ8lTrqpfzzbC23W8adcZ2Ym Q+KBBSsnIHmfYNMJ1waXSVUEFPqiNqiJm3fXiVkzR9nmPQAUiCgjdMcNTKhaz3sGS3ht VxdTMjvHN3oV1IgnLM95tT6NLLfq5jF5N1m42RZerldORCnYC133eGPa9fApQyGOHw5V dRGqNXb0J6N/MtXt6E1uokGXhfpXo3ckO78XJtYQ5aku/bJcbUWS0OdMs5eHZ1cXcYam jQEA== 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=mRoclNG9S6DsS9RwHWPVaTT4JX93PYOQTvn3I2VBqvM=; b=MuLD9IfwaTUQxhjDec055HY2a9TpTqBbA3T/KI8tQ/sc/CZ0/zZLSNyJ0B9PWRjSjU ScGW31suwn5TG4i18bgh9Ip9V68wf1UY3dsh0CUfiFFHbrCGIC1/MomlFBWA/NhHykyt 45NlOz9uBRMylFyte+W6boJwxnEystz4E6/zShB13TNc7KtxJkENRtwIxgY8M1a8+PJv 8FKkKpTmtf1SGmTGmrGyA1byFNaWEqJ2ijAW8WFNphM2SWxkyFjwkd1EWa5iCoU3sl1f 7wrwmuIfk7FlAt62HMTMji3wXX4105so5JLEavSDbHfkka1Xw48uc/CU27etakzbaVFE l56g== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b11-20020a170902d50b00b001619fbc05desi2335275plg.598.2022.05.18.02.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 02:45:28 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DF4BA75237; Wed, 18 May 2022 02:34:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234378AbiERJeQ (ORCPT + 99 others); Wed, 18 May 2022 05:34:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234339AbiERJeC (ORCPT ); Wed, 18 May 2022 05:34:02 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2441EAFAF4 for ; Wed, 18 May 2022 02:34:00 -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 08C5615A1; Wed, 18 May 2022 02:34:00 -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 77A9F3F66F; Wed, 18 May 2022 02:33:58 -0700 (PDT) From: Sudeep Holla To: Atish Patra , linux-kernel@vger.kernel.org Cc: Sudeep Holla , Atish Patra , Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Qing Wang , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, Rob Herring Subject: [PATCH v2 4/8] arch_topology: Add support for parsing sockets in /cpu-map Date: Wed, 18 May 2022 10:33:21 +0100 Message-Id: <20220518093325.2070336-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220518093325.2070336-1-sudeep.holla@arm.com> References: <20220518093325.2070336-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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. 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 bdb6f2a17df0..77aab5fea46b 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -539,8 +539,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; @@ -560,7 +560,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; @@ -584,7 +584,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); @@ -604,6 +605,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; @@ -624,7 +651,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.36.1