Received: by 10.223.185.116 with SMTP id b49csp6708639wrg; Wed, 28 Feb 2018 14:09:05 -0800 (PST) X-Google-Smtp-Source: AH8x227uxFdpHNho0MxIXGZFThmAqsnPM1THljjOEu9uRe2PuHenxPhXc7mle00YHySIEEefjOeb X-Received: by 10.101.74.208 with SMTP id c16mr15482710pgu.116.1519855745636; Wed, 28 Feb 2018 14:09:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519855745; cv=none; d=google.com; s=arc-20160816; b=VL1dc5Y1zNWY7sVA8ub2JpZgU/7z4Mychs/Q2Q9RAwdLdi0YSpiWXJ6Nx/NrBRbJCW 6i8DlDv3B7Z1wShTVy+eb76nmryo/sbUq644kDGhMdqb8KDfdk8/zs18D1qVSaS/7QPl HwHNahDPXZ65aLaD4/Il8+beY1v31OJnclPaqy46yJGiBzmaeSmVl4sucWWeYElnC0LQ 923MejrkMJCxb1n4snemHn15InIT4uBD2JHvEgTFU2Ad+KgotVN9BF+8X0GVpvr1tvHk XfComGnPxFrH2xBJB21sxo6cLpgIH62TNc7znSvzyWSEYKiFxVtTld+WFg+8vAKUdzIt bVNQ== 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 l18si1541190pgn.339.2018.02.28.14.08.50; Wed, 28 Feb 2018 14:09:05 -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 S935387AbeB1WHc (ORCPT + 99 others); Wed, 28 Feb 2018 17:07:32 -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(-) 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(); } -- 2.13.6