From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20A9AC43334 for ; Mon, 27 Jun 2022 13:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eBAYm0WA1knM2cGXE2GGCgGFvsIsIU/QaTJSYp1/mrA=; b=SdPl7ThmWmvavg iddNsLqW6z0Xv919djOeRtn4azzaIUaQEFzNOwy7BkRBUh5z4Jpp5By2Kiw0WmsvLR2sINOxwpyxJ gldMR0L9O1VqESNhSfujCQ/Mgf2pVJxPyuDWR8pbvTPtaj5BCxnmDgoZFSMJYjn3WowctQ71tmACw Sawy2rvrOpowFxe1h8h4GP2/B1vm/pKxVSAJdXmPswom0lARH0tl7UYf6wv6GlhnjOot2PfDkHfWu GypPo9PnSw05Mg3Dm8NKzcWjAhjMpxZvZghNTFQ7+lD0ngzwOViG1kU6W3Ez3FMXe08y3lPH9sa7O OF4I0wYjsC9iX10Tg/cQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5p5r-001DyJ-NQ; Mon, 27 Jun 2022 13:47:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5p5o-001DxC-IG; Mon, 27 Jun 2022 13:47:58 +0000 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 C95BE1758; Mon, 27 Jun 2022 06:47:55 -0700 (PDT) Received: from localhost (ionvoi01-desktop.cambridge.arm.com [10.1.196.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3B5263F5A1; Mon, 27 Jun 2022 06:47:55 -0700 (PDT) Date: Mon, 27 Jun 2022 14:47:53 +0100 From: Ionela Voinescu To: Sudeep Holla Cc: linux-kernel@vger.kernel.org, Greg KH , Atish Patra , Atish Patra , Vincent Guittot , Dietmar Eggemann , Qing Wang , Rob Herring , "Rafael J . Wysocki" , Pierre Gondois , linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v4 19/20] arch_topology: Add support for parsing sockets in /cpu-map Message-ID: References: <20220621192034.3332546-1-sudeep.holla@arm.com> <20220621192034.3332546-20-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220621192034.3332546-20-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220627_064756_753107_5F5F1D85 X-CRM114-Status: GOOD ( 24.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tuesday 21 Jun 2022 at 20:20:33 (+0100), Sudeep Holla wrote: > 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 75604f783bfc..ed1cb64a95aa 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; > @@ -629,7 +656,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 > Reviewed-by: Ionela Voinescu Thanks, Ionela. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel