Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1022995iob; Fri, 13 May 2022 20:01:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrSzcgwrK7SOc26NSy8Kn7/q29Oy7j+HiQ5v+JDnNqwnGkJRGl+E42DfOceDJ0wCH7ijEA X-Received: by 2002:a5d:4090:0:b0:20c:8b91:3b17 with SMTP id o16-20020a5d4090000000b0020c8b913b17mr6001340wrp.348.1652497284311; Fri, 13 May 2022 20:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652497284; cv=none; d=google.com; s=arc-20160816; b=RlrVFn/EGBIUNMOxBSNLm+WocyzLx5wiiuKpD1hrwNSkk7cwhC3dNA+aY2NMsgLNlq vDCJXP1rqKPBS0Wptn+YlWGlH1mKZhM7EsSZPtzCc8pFhW+/n3hansNXUXEVlzVRzzMn SlSN/jybeeYVKuXVVRczXlrVnBXURFSk02MqM/yYXd4mC/GeszJij8U3bZNW2SjeP4dM qh9rqvHnyKPX297L2Xu8dqOZkrLYpTKKR0xULaYtzTviJix6bWbqC/2J+jYndhs+1nC2 y0CIpdiEDcv36/eKj0d/7dLXyuw3kQIFJjIJay519pRkhzPlxsBJSXanrRh6RaELQ3ne h1jw== 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=N3STqQyCI7fW4Tehm/pJAYuZkqxv8F7D3eRc6mGi4n8=; b=vDlcfQpJAwsVEeveZ5OcRgH/AIx7cTa0ExDYiJhLmXOtMKgzwcCLj6Pw/QJFGPPIYe za1mADrMhKIR28ediBDjApS7oE3Uc/g5bWLrpcon67pS2BijsoSaXoVsyomsMDUFVsQf oTBLCluYdxjZzNjVMoL7XBY9nfBVd5tDm4lz5MaIhVl9mBD3+1QLsVrU1wT8sed7WEWG ZNNjzmLAERi1ggu9HyPqkvPpg4Zcyx6PnCzt5EhWftk0PakMBvHLvEvF5eaRtdrNJkTW 5oTh7arX5CIcg7V7Mb9jwKukTQRraqaaYocysTSiXbtxc3GEPy6A4ftaOQcxkhxopzky xTWw== 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:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r12-20020adff70c000000b0020c5c717027si3214912wrp.888.2022.05.13.20.01.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:01:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 2CE7E3A32E1; Fri, 13 May 2022 16:44:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379229AbiEMJ4i (ORCPT + 99 others); Fri, 13 May 2022 05:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379247AbiEMJ4S (ORCPT ); Fri, 13 May 2022 05:56:18 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 541DA1BE94 for ; Fri, 13 May 2022 02:56:17 -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 2DD231477; Fri, 13 May 2022 02:56:17 -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 CF6F63F5A1; Fri, 13 May 2022 02:56:15 -0700 (PDT) From: Sudeep Holla To: Atish Patra , Atish Patra , linux-kernel@vger.kernel.org Cc: Sudeep Holla , Atish Patra , Vincent Guittot , Morten Rasmussen , Dietmar Eggemann , Qing Wang Subject: [PATCH 4/4] arch_topology: Add support for parsing sockets in /cpu-map Date: Fri, 13 May 2022 10:55:59 +0100 Message-Id: <20220513095559.1034633-5-sudeep.holla@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220513095559.1034633-1-sudeep.holla@arm.com> References: <20220513095559.1034633-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 46420db5a836..ae61af84c161 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