From patchwork Fri May 11 23:58:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 135566 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1525673lji; Fri, 11 May 2018 16:59:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp97FkR7DJFqWfS2OKBXYnaKZUfChNvXHYhJZklEmq+vfGbixf19stFFufJRIkW5Rv7xwNx X-Received: by 2002:a65:640e:: with SMTP id a14-v6mr926455pgv.406.1526083160324; Fri, 11 May 2018 16:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526083160; cv=none; d=google.com; s=arc-20160816; b=vrJetVDKtwGprG6rs5Gdxppu+PSwxkhuhzkC7seQ2h34Y+m1aqVVysKrr5rLa7tXRx nWPj9Kd48yHNEfeTgVeWJAHqrZ4Cae31RNce2R/Yhnme6xNwC18oDZz9+7XQE38TxXK8 z0D1YCjQikdGiHKm2plBIB1Jd4LQbyhRLn9hgf9dsl1TiUX9Ft7abwp7o1JtdwbEQ0ij 7msBoBI8EItXO1yEx+3jdTbUcRIx63wsr3reK05FqHaeUCa0ylsugXuAMRGFmPTyNdQz vRYYZEb+MiLq6+O2ap1z2u7hsAOI6A2vMW1aXw1iw+j9tnfbuOv0sY4+VwuLAl73c6gw yzNQ== 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=KyBrSSuu0Yv83DJ7q51FP/GnEa6pLsKmNowo+Gx8QgE=; b=JP9pff5MIMq/PeCnu6y8WIGnYO6y4jLAZTr68MFoH8ucI6q1GwngeG7RkWDfXkcd0j wmxmMdGYhvn0CkixlBmguPGk+r2YikZ9oUkEIrYXBHMYkfMF/Ipfd6q6mODyPOX2HxSP N/OA38BXHoHLODWxYXAaNpOc9SWxZhuzW2HFlwTdMoiitBMNg+KPVF+tAnoSMCneh4Mj rxQFP9e9hbk2gRgFDLETt5gkuQyysRMvYgHN9tuGh5AwQ1YlWsT2a4gFDPivzjZi8fNG g0Q2eXCDI8cY+GQyIf6GtybWAxVLk1BzQxaMuq1OclGGVBLNad1beC6un2/JQNvBNSj6 zrJQ== 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 d17-v6si3351580pgv.188.2018.05.11.16.59.20; Fri, 11 May 2018 16:59:20 -0700 (PDT) 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 S1752047AbeEKX7Q (ORCPT + 29 others); Fri, 11 May 2018 19:59:16 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50414 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027AbeEKX7O (ORCPT ); Fri, 11 May 2018 19:59:14 -0400 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 B4A4B174E; Fri, 11 May 2018 16:59:13 -0700 (PDT) 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 AB93A3F53D; Fri, 11 May 2018 16:59:12 -0700 (PDT) From: Jeremy Linton To: linux-acpi@vger.kernel.org Cc: Sudeep.Holla@arm.com, linux-arm-kernel@lists.infradead.org, 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, jhugo@codeaurora.org, ard.biesheuvel@linaro.org, Jeremy Linton Subject: [PATCH v9 10/12] arm64: topology: enable ACPI/PPTT based CPU topology Date: Fri, 11 May 2018 18:58:05 -0500 Message-Id: <20180511235807.30834-11-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180511235807.30834-1-jeremy.linton@arm.com> References: <20180511235807.30834-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 and core_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 Tested-by: Ard Biesheuvel Tested-by: Vijaya Kumar K Tested-by: Xiongfeng Wang Tested-by: Tomasz Nowicki Acked-by: Sudeep Holla Acked-by: Ard Biesheuvel Acked-by: Morten Rasmussen --- 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..047d98e68502 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(); }