From patchwork Wed Feb 28 22:06:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 130072 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp270184lja; Wed, 28 Feb 2018 14:07:38 -0800 (PST) X-Google-Smtp-Source: AG47ELspqT6yCOYJfC0EFYo5AjAqablfJ4DV/kH/6uiuTycDybZsyaO5Tr89kHQGv3nHma+vw8JP X-Received: by 10.101.75.18 with SMTP id r18mr9318851pgq.36.1519855657988; Wed, 28 Feb 2018 14:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855657; cv=none; d=google.com; s=arc-20160816; b=Lz9Fy6Sf7D/irtGEq9eTig6uflwhF2jtjRAllWSXMt78+7fSF5a0dJBJuXvf04XAtD 5grA0KjZjT0ASBzHIVkcQc4Y4ImG/hg+kUFsKpOv163ZlBAYQoBpsTQsP3Aw1LRELf1v I27Hr2PhPi+LpG9t9zWWG+/xrqptVCb/kEaqsEKPVvVW5eY6/OvZkQorR/hf5q0oWlhI 3UFUz6Stv2/fiH9YggkLhNbYgTwaOJ4fw5+OAmmadiOk6YErqSrNFrtoViQ5O4FaRNEX emAZCaW77z6waEKI5wBiIAc3fy6w61TccIfrlnkHdY6b7kjYZ1q60OW6ivLpJinrg3s2 rgsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=67hBQw3N45mpT2AFRrevGfvDZ7Szd+8j6rHJTDYfm7A=; b=IVFOaZLypixU3hSo45ntHY6nC4hDnOTiDMz4DSJaKM+bCe8R626D3pFdMq7qK8/USD UaHqPxld5m6Z+IW/CqsJPacPDge9kslfa0PEU4L7xsW136BMzdZg61XnmolxlazeV09g SZPo5kpyVmPkHZZnJNDhVzSzjTeZ96jSieh688Q9ugsz2uiZYkU5EjYBoTV4LjZhpF50 mVkumRJjoN+uIdstGN/MbDVNtmOTANnRrEBNiNDuN2JSdXd/e+XOT55FbkA3ca/YCblO Dq6lsGlhBi3Apv+1d06OBeU2Vp6I74s9D9pSEIbhdRn6VePLGFH7eqH93xzTRumcsoTJ PfIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9-v6si1953161plt.293.2018.02.28.14.07.37; Wed, 28 Feb 2018 14:07:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935390AbeB1WHd (ORCPT + 28 others); Wed, 28 Feb 2018 17:07:33 -0500 Received: from foss.arm.com ([217.140.101.70]:58166 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935365AbeB1WHb (ORCPT ); Wed, 28 Feb 2018 17:07:31 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2644169F; Wed, 28 Feb 2018 14:07:30 -0800 (PST) Received: from beelzebub.austin.arm.com (beelzebub.austin.arm.com [10.118.12.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DA1113F246; Wed, 28 Feb 2018 14:07:29 -0800 (PST) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, sudeep.holla@arm.com, lorenzo.pieralisi@arm.com, hanjun.guo@linaro.org, rjw@rjwysocki.net, will.deacon@arm.com, catalin.marinas@arm.com, gregkh@linuxfoundation.org, mark.rutland@arm.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, wangxiongfeng2@huawei.com, vkilari@codeaurora.org, ahs3@redhat.com, dietmar.eggemann@arm.com, morten.rasmussen@arm.com, palmer@sifive.com, lenb@kernel.org, john.garry@huawei.com, austinwc@codeaurora.org, tnowicki@caviumnetworks.com, Jeremy Linton Subject: [PATCH v7 11/13] arm64: topology: enable ACPI/PPTT based CPU topology Date: Wed, 28 Feb 2018 16:06:17 -0600 Message-Id: <20180228220619.6992-12-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180228220619.6992-1-jeremy.linton@arm.com> References: <20180228220619.6992-1-jeremy.linton@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Propagate the topology information from the PPTT tree to the cpu_topology array. We can get the thread id, core_id and cluster_id by assuming certain levels of the PPTT tree correspond to those concepts. The package_id is flagged in the tree and can be found by calling find_acpi_cpu_topology_package() which terminates its search when it finds an ACPI node flagged as the physical package. If the tree doesn't contain enough levels to represent all of the requested levels then the root node will be returned for all subsequent levels. Signed-off-by: Jeremy Linton --- arch/arm64/kernel/topology.c | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) -- 2.13.6 diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index dc18b1e53194..bd1aae438a31 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -11,6 +11,7 @@ * for more details. */ +#include #include #include #include @@ -22,6 +23,7 @@ #include #include #include +#include #include #include @@ -296,6 +298,45 @@ static void __init reset_cpu_topology(void) } } +#ifdef CONFIG_ACPI +/* + * Propagate the topology information of the processor_topology_node tree to the + * cpu_topology array. + */ +static int __init parse_acpi_topology(void) +{ + bool is_threaded; + int cpu, topology_id; + + is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; + + for_each_possible_cpu(cpu) { + topology_id = find_acpi_cpu_topology(cpu, 0); + if (topology_id < 0) + return topology_id; + + if (is_threaded) { + cpu_topology[cpu].thread_id = topology_id; + topology_id = find_acpi_cpu_topology(cpu, 1); + cpu_topology[cpu].core_id = topology_id; + } else { + cpu_topology[cpu].thread_id = -1; + cpu_topology[cpu].core_id = topology_id; + } + topology_id = find_acpi_cpu_topology_package(cpu); + cpu_topology[cpu].package_id = topology_id; + } + + return 0; +} + +#else +static inline int __init parse_acpi_topology(void) +{ + return -EINVAL; +} +#endif + void __init init_cpu_topology(void) { reset_cpu_topology(); @@ -304,6 +345,8 @@ void __init init_cpu_topology(void) * Discard anything that was parsed if we hit an error so we * don't use partial information. */ - if (of_have_populated_dt() && parse_dt_topology()) + if ((!acpi_disabled) && parse_acpi_topology()) + reset_cpu_topology(); + else if (of_have_populated_dt() && parse_dt_topology()) reset_cpu_topology(); }