From patchwork Thu May 23 22:40:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 165078 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2806087ili; Thu, 23 May 2019 15:40:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLm63uDzPme3y7r8EWEODG6u4z08zUzl5uUI+rAdg1dxwBt1Wj9zwjzSBE/0YqbKy6OkE4 X-Received: by 2002:aa7:8c12:: with SMTP id c18mr110102404pfd.194.1558651234807; Thu, 23 May 2019 15:40:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558651234; cv=none; d=google.com; s=arc-20160816; b=vWOwCmMoWLhsvg0cdzK1YmPhrfDT1/26Lm3vS4ksf5sArzEUsrOqo56zTLxbKoAf6q TQje/5nJF2fJAAqdNdU3OOvUW7u9EhOVj920dmM2B3EWX7KtS6AgViENPARrfNf4+wGy 0Nz3qG18a6nreGqwKJ997Wsoez81nVMuHuhWEHN7mrxFFLEDKCIcQ++pxRC9uRWhm8kA n3ypxsxKb98p7UKnkOVltx3VH4iJ1goR59JNSWqWNeYwu7UHdScZlyyw9Lfo4G4XIQhd y7mQZZhdx3mg0VmGPv8KT99AVFiYm70eMvgdQzH557jt5OZgCTAX7ROSk/Lk8N4XS6E7 o/1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=q3dECMxcJ5IgJTLsQbFHFKQQjP/IKVWSULY53AWzbwM=; b=PvjlME+WtMgYhzo2Rs7/IH3Qsi5B6EAvK4CplJXvAaB+Pei9TWiKWhXe9IZ3E5dpXn LDg62y7YnTzNzLM0Bxn+WZ1FtEY3Z6fGN5Xh/IyrISx/ULQC43HVkwMLNWh99uCWwh+8 CFsrSmZLTZ/fYfAAO4fizTcGJ7xcll0wXm3A4VwaNkVrkImNEIxUMIMORALeCfWfzdUP ceBAwj0zbxI9wqP8uBLXvtyuvCpOxqQVlkiBmq07UpHf6eXOsaadvo7WZYcCn6h0HkW2 D0RB5A7pGoiw/jvfISCBtii++XtUq/YZdDv7SbF+bTk0cBxiNCqxfoAip+h4C0ixn5E7 KuHg== 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 g2si1414619plt.95.2019.05.23.15.40.34; Thu, 23 May 2019 15:40:34 -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 S2387762AbfEWWke (ORCPT + 9 others); Thu, 23 May 2019 18:40:34 -0400 Received: from foss.arm.com ([217.140.101.70]:57876 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387546AbfEWWke (ORCPT ); Thu, 23 May 2019 18:40:34 -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 7A4BA374; Thu, 23 May 2019 15:40:33 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.30.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14B303F5AF; Thu, 23 May 2019 15:40:33 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, sudeep.holla@arm.com, Jeremy Linton Subject: [PATCH 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Thu, 23 May 2019 17:40:14 -0500 Message-Id: <20190523224015.56270-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523224015.56270-1-jeremy.linton@arm.com> References: <20190523224015.56270-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org ACPI 6.3 adds a flag to the CPU node to indicate whether the given PE is a thread. Add a function to return that information for a given linux logical CPU. Signed-off-by: Jeremy Linton --- drivers/acpi/pptt.c | 53 +++++++++++++++++++++++++++++++++++++++++++- include/linux/acpi.h | 5 +++++ 2 files changed, 57 insertions(+), 1 deletion(-) -- 2.21.0 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index b72e6afaa8fb..6f43a0c05f61 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -517,6 +517,43 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) return retval; } +/** + * check_acpi_cpu_flag() - Determine if CPU node has a flag set + * @cpu: Kernel logical CPU number + * @rev: The PPTT revision defining the flag + * @flag: The flag itself + * + * Check the node representing a CPU for a given flag. + * + * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or + * the table revision isn't new enough. + * Otherwise returns flag value + */ +static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag) +{ + struct acpi_table_header *table; + acpi_status status; + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); + struct acpi_pptt_processor *cpu_node = NULL; + int ret = -ENONET; + + status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); + if (ACPI_FAILURE(status)) { + acpi_pptt_warn_missing(); + return ret; + } + + if (table->revision >= rev) + cpu_node = acpi_find_processor_node(table, acpi_cpu_id); + + if (cpu_node) + ret = cpu_node->flags & flag; + + acpi_put_table(table); + + return ret; +} + /** * acpi_find_last_cache_level() - Determines the number of cache levels for a PE * @cpu: Kernel logical CPU number @@ -581,6 +618,21 @@ int cache_setup_acpi(unsigned int cpu) return status; } +/** + * acpi_pptt_cpu_is_thread() - Determine if logical CPU is a thread + * @cpu: Kernel logical CPU number + * + * + * Return: 1, a thread + * 0, not a thread + * -ENOENT if the PPTT doesn't exist, the CPU cannot be found or + * the table revision isn't new enough. + */ +int acpi_pptt_cpu_is_thread(unsigned int cpu) +{ + return check_acpi_cpu_flag(cpu, 2, ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD); +} + /** * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU * @cpu: Kernel logical CPU number @@ -641,7 +693,6 @@ int find_acpi_cpu_cache_topology(unsigned int cpu, int level) return ret; } - /** * find_acpi_cpu_topology_package() - Determine a unique CPU package value * @cpu: Kernel logical CPU number diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 98440df7fe42..513833233c65 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1314,10 +1314,15 @@ static inline int lpit_read_residency_count_address(u64 *address) #endif #ifdef CONFIG_ACPI_PPTT +int acpi_pptt_cpu_is_thread(unsigned int cpu); int find_acpi_cpu_topology(unsigned int cpu, int level); int find_acpi_cpu_topology_package(unsigned int cpu); int find_acpi_cpu_cache_topology(unsigned int cpu, int level); #else +static inline int acpi_pptt_cpu_is_thread(unsigned int cpu) +{ + return -EINVAL; +} static inline int find_acpi_cpu_topology(unsigned int cpu, int level) { return -EINVAL; From patchwork Thu May 23 22:40:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 165079 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp2806111ili; Thu, 23 May 2019 15:40:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTxCisoEQ7y6TvrMnp0/j7ldfTU4OAJSvjGspz32kzGz9lvaEiWs3jp7XHvFbyMUc5kP0r X-Received: by 2002:a62:87c6:: with SMTP id i189mr109574311pfe.65.1558651235863; Thu, 23 May 2019 15:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558651235; cv=none; d=google.com; s=arc-20160816; b=MJm2wmAAKdRNHCuJySW7d5zvC24fLJV41WrzX6+/mqaDrXzsojWD6sVTjIoJUdldBe sM7y+u77/x0qeonJ1ITXvpznqEBOnqXJiECTPYjbsQsYoM0hJOMDpEoatr9+XZzALgOV PryRzzEwo/6zSAI76Rh4S4OxPhPRrOy3UGmtBFgawhXnAHqGqdQ5pHxmB3KovVfulJs8 4bblUTbliSbpmsIa8bppVegq0P36Of83QcCh4+OhW6Dc7Yf8lBZYP1Cs5a0qxIf5mIuR /pdEDvZ+hGvneMT5+C0VczfoRuHyTzDuqgm3Uir2zMBD1pc6SWbZk3qRzbiljzznP5lW Ui6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=o7YcmtidsCQoep7qv5xOU12ScfxzO8HXPxAmyprhlXw=; b=EiWczbkn7KmzYTbd0UlND1ZrRRpaI5QJMmnAZWJrgtibrBWqnz/qD0a7qvt0GW0Cu9 20rEZnSkz5KYD+7os2PxVtP1OisqDa9YzgIv2eoe4I2AzvRaF0JZzHZR6kcGuGx7WHvW SiJM+pf96Ron6ZrjDteiOIBfjr97fQq9Lm8Z8PBsTiCRjAy754bYaf6dTLQUQPxOw/YY qngcbAp2njgSr2+yTYb7GwcXJUw0rFtPdnXisfuvmkOopWvqQWClyQ1tIgOTgiczcxsy Svfoi+70GnLMVQ1QwKkJ+JkWZuj5MLq+kztyTiVij08I1Rb3QZzRmScKL8zynEOcxVDa YqQg== 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 g2si1414619plt.95.2019.05.23.15.40.35; Thu, 23 May 2019 15:40:35 -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 S2387735AbfEWWkf (ORCPT + 9 others); Thu, 23 May 2019 18:40:35 -0400 Received: from foss.arm.com ([217.140.101.70]:57888 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387546AbfEWWkf (ORCPT ); Thu, 23 May 2019 18:40:35 -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 CD31015A2; Thu, 23 May 2019 15:40:34 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.30.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5F1EA3F5AF; Thu, 23 May 2019 15:40:34 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, sudeep.holla@arm.com, Jeremy Linton Subject: [PATCH 2/2] arm64: topology: Use PPTT to determine if PE is a thread Date: Thu, 23 May 2019 17:40:15 -0500 Message-Id: <20190523224015.56270-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190523224015.56270-1-jeremy.linton@arm.com> References: <20190523224015.56270-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org ACPI 6.3 adds a thread flag to represent if a CPU/PE is actually a thread. Given that the MPIDR_MT bit may not represent this information consistently on homogeneous machines we should prefer the PPTT flag if its available. Signed-off-by: Jeremy Linton --- arch/arm64/kernel/topology.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.21.0 diff --git a/arch/arm64/kernel/topology.c b/arch/arm64/kernel/topology.c index 0825c4a856e3..cbbedb53cf06 100644 --- a/arch/arm64/kernel/topology.c +++ b/arch/arm64/kernel/topology.c @@ -346,11 +346,9 @@ void remove_cpu_topology(unsigned int cpu) */ static int __init parse_acpi_topology(void) { - bool is_threaded; + int is_threaded; int cpu, topology_id; - is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; - for_each_possible_cpu(cpu) { int i, cache_id; @@ -358,6 +356,10 @@ static int __init parse_acpi_topology(void) if (topology_id < 0) return topology_id; + is_threaded = acpi_pptt_cpu_is_thread(cpu); + if (is_threaded < 0) + is_threaded = read_cpuid_mpidr() & MPIDR_MT_BITMASK; + if (is_threaded) { cpu_topology[cpu].thread_id = topology_id; topology_id = find_acpi_cpu_topology(cpu, 1);