Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3146883iog; Mon, 27 Jun 2022 10:05:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vbO6hrq62EeYh+LWa6gZZMKgKDqPa1K4rmD7fWF3N0uxWrzxugnKvPm99ZUPraKxREde/O X-Received: by 2002:a17:902:b597:b0:168:d8ce:4a63 with SMTP id a23-20020a170902b59700b00168d8ce4a63mr15847931pls.57.1656349515391; Mon, 27 Jun 2022 10:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656349515; cv=none; d=google.com; s=arc-20160816; b=Oe0goR/MciBIteoK1qHIVKYNVVac5zoQkhOxWta7Xpd48qTveBAxeJ7cmB3OllTea7 Ad+aXZcr5s5NZuohcZp+hTrXbp7pxquyiOND2wNkfxhpGS+aKZPPuKla7HwIkiv9VIl9 nsOK4neTAL2xxp+fAoLq2oGUGPP+9u0YThiNFZu0poxFyf/5c3bnY+MW43ox0EgNKTBg zwBDXTe3UM6qFcKA+j8YZijScjCQKUeKlXMA3DQz72HFLKKqUWGywDkVPZWXbDeBjbNL pe6ye9q5fRKZy4zx0BxOwSvlh6ZEOWKekj8Lwo0+C4aALpZHWgBDEn6NFakB7jzr5y+H eJXw== 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=FBgmAXFg6UdfM55VttiZLJSnriZen+47tQtgCLmPuB8=; b=MV2LXaz7nvwnrJXDBHpQOAjjanBI5dlTRKXbUGTJhRoBQFZce3Rg8+hST6F3Vv/x5s YOkb49qdb2eEUBn+/4A3Hfo8WU0aHNUXUep2yYAns87yt5sD6EQmwNILtX77pxjfSMp3 OaJf94ASeY3ARXG25APzziOIX4cvgVdo0LfvuXLsqDOACqqthG2qh0c90/o654QppwWI itfamtVWu915LqczjR78Vynqrn8s4K4F6w0Epx7woVoqaYHNLmohFWi8bSixMQeQ5rg+ th1NXe/Ojl4ebZP7GmWajYXelOHkaYrI8tcMMwEzEPeEUb/9sgBRk6Ujc2iBGiIIQRgH tB/w== 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 d8-20020a170903230800b0016a75602af0si12306226plh.601.2022.06.27.10.05.02; Mon, 27 Jun 2022 10:05:15 -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 S239575AbiF0QwO (ORCPT + 99 others); Mon, 27 Jun 2022 12:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239580AbiF0Qvf (ORCPT ); Mon, 27 Jun 2022 12:51:35 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6632113F69 for ; Mon, 27 Jun 2022 09:51:33 -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 60F93175A; Mon, 27 Jun 2022 09:51:33 -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 7E4423F792; Mon, 27 Jun 2022 09:51:31 -0700 (PDT) From: Sudeep Holla To: linux-kernel@vger.kernel.org Cc: Sudeep Holla , Greg Kroah-Hartman , Atish Patra , Atish Patra , 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 v5 18/19] arch_topology: Add support for parsing sockets in /cpu-map Date: Mon, 27 Jun 2022 17:50:46 +0100 Message-Id: <20220627165047.336669-19-sudeep.holla@arm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627165047.336669-1-sudeep.holla@arm.com> References: <20220627165047.336669-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. Link: https://lore.kernel.org/r/20220621192034.3332546-20-sudeep.holla@arm.com 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 80184c91c919..7cbe21b1b295 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.36.1