Received: by 10.192.165.148 with SMTP id m20csp1353113imm; Wed, 25 Apr 2018 17:28:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx48dGjFSB4si1BK+k3DitLiXsOd6zZrTz4yZwbYgueE4zyIU/e8AgTBptcY2qNIi4JdASBD1 X-Received: by 2002:a17:902:2ac3:: with SMTP id j61-v6mr30635303plb.224.1524702537356; Wed, 25 Apr 2018 17:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524702537; cv=none; d=google.com; s=arc-20160816; b=0BNH4BOTlwDBMecHcvpwA0WM9eTmGsRNJMaRybbfCIn5/qc70eSSXqmTligSaugHaJ rdx3jndjE1/2jXDdIw1r3cPxApAaJGAHvdlISI8AVNTgIaeRrClsw+vwEOntfvui7JON aSV1niC7mNCdQ5W2LShjJk/xB7G/aD3mN/B3h+UFj52tdfFO4EzBiQyqRZEdJuM83UPC X+n6Xg037WxdLXHTbtvGllXgBC34ErYVX4VKZD7bCDydKouD4Qr06efkTQiQshID7Jkt LIBxQwdqjRL6EZY3ckPtN5ZWE8Tbn+kcaF7ANCclpvxjpPidZB6aSGrFHw/qrMusnTX4 ShwA== 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=PhFEXSYnZbMr/gGvLgB/gN1hj8ffNpA+gkOhEgXSZsI=; b=ESu2tGaYi8IPH/WnujSDnne+e7qkjIOYP1CtZzm+mz/Bq7C9UELrn2qCxYKevCIu6d M5uOW9FV3V0+YRZcmXnGjXRJ9Us++HTOzmTw62fnY7OXxlIG3UeHBUN4jabu7e6rhg51 GSjJJlMrrZBj5ghfXtJ4GLGtKbGy1Uqh+TqUkn7fimkwUrI8wPj39ZgErk75K3mr1Qst zgVG5B6gPJSwl9sRY6tkIrAaDb2HQZVVRC5IpRZsmKVyOqx9BOR+G+ChUEuU7vRy2big TXP+jSXf4YYobHKHKE3uCMk7RLO9oxpi2Oiv2JIwTf9nU2vCFzBNE8KH7DxTEnC4HK/F Z2Iw== 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 e6si16429927pff.205.2018.04.25.17.28.43; Wed, 25 Apr 2018 17:28:57 -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 S1752331AbeDZA0b (ORCPT + 99 others); Wed, 25 Apr 2018 20:26:31 -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-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 --- 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