From patchwork Fri Jun 14 22:31:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 166932 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp34218ilk; Fri, 14 Jun 2019 15:32:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVom0vyrTLF36c7UBfIApmmlsyp0PylDYOCEg7Bx3fdVCk5lfDyB9a+gEErkfSle5CPu2g X-Received: by 2002:a62:2d3:: with SMTP id 202mr26923457pfc.131.1560551533690; Fri, 14 Jun 2019 15:32:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560551533; cv=none; d=google.com; s=arc-20160816; b=oENH/uvnxpthx/a6SSkUrbAlre3MdDJ1ZCQ67ihd3NPPPItGQe+JOHFuEBkqps+ZI1 a0sscp6vegChftX7hIbrSkak/wlKLL3qEJfq2S96PgOCmjxNGyE4T+R3uyJOxBKf+hah tM3Y1HWW1aSV4j0bgk2k0TEbWogTxjLfvloZbQnp+y6WnK4CFmyyWzLA8P1eM48qzvNq oYFViGz4EMochBB5DOqTxDwsQCyofnarHHIYRyaztFK9h8MajdMsl21li7yMTDI/9T37 P4nIev3YkecWIMz4MZtEwU+z5SfTjpmxiHci3+rb4dV1F9T+SDXJBYMG9KS9nkWE3oi+ 6pyw== 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=ujluJB87zHDpAhG7OaZjBb5ppCsg2sLvfhhkvxCFn7M=; b=ofPoKo3yCOd3JEDU6gaRZH26OGq6vh7xjcbgXcpsycgR5LYZKE20s9yoi7eZ1Ie3tP KDQHqO+YRclprsE5OnFx81PL0JXQW+Ha1dTCdjhf48+W/An35VtiA0oJrf1knYz1lMQO AN8yLc1Va4TueQ3UcmoAy+Tl7ALiP5CDvG9FV8tZpdNa+TWDhXXKTv+5U6JsSnlnsYbo uekotuFL9sgi9mWGHuCLFSWukH/PuqqOMYuAQthdPBZCWxMUWS3psDRNI4+DDP7D9kKu A/wkkxvAlBxFSfo23KJqDJnj7hTjXKLceCr+Wr6cum+kpYQE10mjVEuouGTrLFnHFING ukLA== 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 o20si3202634pjp.48.2019.06.14.15.32.13; Fri, 14 Jun 2019 15:32:13 -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 S1726349AbfFNWcN (ORCPT + 8 others); Fri, 14 Jun 2019 18:32:13 -0400 Received: from foss.arm.com ([217.140.110.172]:43060 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725812AbfFNWcM (ORCPT ); Fri, 14 Jun 2019 18:32:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 96928344; Fri, 14 Jun 2019 15:32:11 -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 8593C3F694; Fri, 14 Jun 2019 15:32:11 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, sudeep.holla@arm.com, lenb@kernel.org, Jeremy Linton Subject: [PATCH v2 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Fri, 14 Jun 2019 17:31:57 -0500 Message-Id: <20190614223158.49575-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190614223158.49575-1-jeremy.linton@arm.com> References: <20190614223158.49575-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..6f45f8c07b46 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 = -ENOENT; + + 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 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 d315d86844e4..3e339375e213 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1301,10 +1301,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 Fri Jun 14 22:31:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 166933 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp34227ilk; Fri, 14 Jun 2019 15:32:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtJPi+vWo6goERsaFfAQ3xmlEo2rFkTkVFf4m+Puily9lQqXeKGtkv73xNY4dQmqUCOoPQ X-Received: by 2002:a63:dd53:: with SMTP id g19mr27904668pgj.3.1560551534122; Fri, 14 Jun 2019 15:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560551534; cv=none; d=google.com; s=arc-20160816; b=p6Qm73XGwNX99RipRx4qKBUXArP2bmxIGmZYXbKxyQtxCq9mHUtsyqHdxdrSYPBc0o NJcSs500PRwsu9lG+1+qJY9ZO4zpmbQYHPb1yDGTBgpH8nLmkMuUwQ3L71xp++zE+IAI 1Scl1bkzHHSVT29+n8zxF01Bhwnat9dXEFuXfP6DDO05QuSw0Xcg40Dz5/0fLV1xw9GJ GDtPaVKSiEYoWFRj6c7neKJTZpGkenrgllKm05bgUpd3uvr840Cu33TUS1rDjp2JJUX9 zBi0Lgi2w5hhvZoariWwrru2GRi/jm027f2AHTVYIgdeXZKOlTFRjWr/3hS4sQsYVWVQ W9CQ== 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=SBG0tYuTi04IGz6GIXALsaa2gGpHXzXhoCwxtleKxllQZG2Sq/J5FNKoZwOZSeoos5 R0XtxdZ7yU+aNL6FMAU3dL3W76FNROBx6PQrtJKL+CDJedSdWRN0mDUEqptLWWSbJ+iI V+tbQ/6IhvLqyZyRZepms1ovSjLZ/RoGAosdbWsTymu/W/LS0rOZr3rCC6W036CjFOaE x6yi+tnSQptFdTMyyFtV+2DK4jN5jUzbBNFaGqK8zDLuu84T1VhpUieUoESpLyXjmbrh UZNlmKC3DfNGLriaxmq5QWo2/H9nhZ80GopY/NMqF8sr4gMenIgk/72NOgEJIYye8PdK q/sw== 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 o20si3202634pjp.48.2019.06.14.15.32.13; Fri, 14 Jun 2019 15:32:14 -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 S1726369AbfFNWcN (ORCPT + 8 others); Fri, 14 Jun 2019 18:32:13 -0400 Received: from foss.arm.com ([217.140.110.172]:43074 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726346AbfFNWcM (ORCPT ); Fri, 14 Jun 2019 18:32:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3B845346; Fri, 14 Jun 2019 15:32:12 -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 2BA2C3F694; Fri, 14 Jun 2019 15:32:12 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, sudeep.holla@arm.com, lenb@kernel.org, Jeremy Linton Subject: [PATCH v2 2/2] arm64: topology: Use PPTT to determine if PE is a thread Date: Fri, 14 Jun 2019 17:31:58 -0500 Message-Id: <20190614223158.49575-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190614223158.49575-1-jeremy.linton@arm.com> References: <20190614223158.49575-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);