From patchwork Wed Apr 25 23:31:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 134387 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp1532759lji; Wed, 25 Apr 2018 17:26:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx49M0VVNp/Agrxtzn29JeLvwYFpeG6jSd/lL8854m+eqwaofqSWZ47RWbNo6QS7X97An0hoJ X-Received: by 2002:a17:902:3281:: with SMTP id z1-v6mr30841219plb.226.1524702389960; Wed, 25 Apr 2018 17:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524702389; cv=none; d=google.com; s=arc-20160816; b=lU3vse/+0CUJ0SE23LBv9TkPmdrujgBvJ+GsOofseou4HAOF/DjfpkSA3F7D646TaA M8/QOQOpLAPh5+2zHrZfH7iPswEFrvmKGMuF54+4wZiA/+cTK3UOCoqptoNF4t7BYodQ d0cFBEx7Al4nAbXC+bRkpVyXmMGF/oX2OcAhMq9FKIHq5YnhoB4UXobQDxvh2tavMSho t93VaBFzKeOv28qZeb0oitIuBnHuHCn3OJE7o8t/ywBF74CwSlxvl2OSZQUqcYTnVMcL Ja1eCDV+lhH6f+LaOFAr1gQ1YqtkPKyO7NWBYamqeYb5flC9AECcPi+VJcassjdINEyn hlCw== 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=we+DCSIkVL77lYGBkGOHtvjuADfLSoWVmu8RepQwgzc=; b=jz+/nB0Jc/AW/cZ7LkYzUT5yW6I6lvcplPTJIrDFCbAsREhODLrJwRKDJdStkm7ncf E12kqZPcL3TAGwgOHemQ+LDD7DMSgM0HlDsvT+qFNqwc8bPaGjbHD1J7mWrhVb5Qu4ny URDUHBU1RLtx3Z23MKn7IkYWW36G4LRb15qp8aC8TYnpths/5Np3mkVuKu9ydxk0YYoT J9FweLG3eGbLbFekMzP1R5EjhdIC5K4ceIaWOgAY8ZdVZB8n9eSByWjMYkbGlfwzh6tE WX8fyPQ7e0jHPPNPjTc65aZloBdAc5c1TDOQF0BUh/eWb8VBycbYzBS36Wh4eIFUqcdA a0eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-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 l4si13233937pgn.54.2018.04.25.17.26.29; Wed, 25 Apr 2018 17:26:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-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-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbeDZA02 (ORCPT + 8 others); Wed, 25 Apr 2018 20:26:28 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45836 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752079AbeDZA0Y (ORCPT ); Wed, 25 Apr 2018 20:26:24 -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 757F880D; Wed, 25 Apr 2018 17:26:24 -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 624D63F590; Wed, 25 Apr 2018 17:26:23 -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@qti.qualcomm.com, timur@qti.qualcomm.com, ard.biesheuvel@linaro.org, Jeremy Linton Subject: [PATCH v8 11/13] arm64: topology: enable ACPI/PPTT based CPU topology Date: Wed, 25 Apr 2018 18:31:19 -0500 Message-Id: <20180425233121.13270-12-jeremy.linton@arm.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180425233121.13270-1-jeremy.linton@arm.com> References: <20180425233121.13270-1-jeremy.linton@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@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 --- arch/arm64/kernel/topology.c | 45 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Morten Rasmussen 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(); }