From patchwork Thu Aug 1 03:46:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 170307 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4837907ile; Wed, 31 Jul 2019 20:46:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwusYDvQTbKrZoMSAfuPjhqG8R9W1R+0YvrkAgYx6h1MrrnCVPfSKbxvjiEuSU7XRlQHdIp X-Received: by 2002:a63:fb43:: with SMTP id w3mr17997472pgj.403.1564631204782; Wed, 31 Jul 2019 20:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564631204; cv=none; d=google.com; s=arc-20160816; b=GtFz/IC6JiHeArclNlxDPXQ6VI+hHzQLnZbznaUngvvHMGeL5Pw7qMwwU3/ooqes/W O2f8ccQJlod6UoQ2ZCGKWV5mC3OwThTpJzcOa5a3JJ7y8yQtKHNrtQ+r8Fw2v+F/aOTI ilGbqZixIC0bKtgf7BP3KbuP91McRGyPisZjkM4EcpuVAKrLO60Jw1YDGJ+JgoYE8DZ5 Kr3sPxWycpTHV24KFb5dneKERjcfhyV/7G0q/tG+NNZAhXVvfvphxuzT5Ns42UlEQd6m Sct5yKgBuYHIBmXwd2ZwrMfwq4JKZCnj6aVa9GJ/GHhpR9k9Umdvkr4t2UMXXd/L25mG Cdiw== 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=twYoy3D3yOtlhpmKhF+TAPwVBsHRZ7M3/Ya2CfZ4Spo=; b=rgRlkF1HIP7QDdCVTFfGw/deQH/JIRGyKCXp6FVxRBNmxxQpIG9+eunidJLcLNSik7 HTQNP/23dgggHe7ehf1dm19kIoZ9eN1ntTeTOiTljRuLqEWIvivlJqv7q0rNpXzwYyFN uttIvb9TVsSOhSvMFLBRFQBrHHlFVPbnv1vmypG5gXeitr95BbAsvEXioq6/XYal2vyi ZrrziLfAnaZ7cOv5Jn3uQRsHbCNATXnqCpqGoD598UB2TknJrQ3AlCfmG+5bFtoUAl60 5ELetBT/dkDRXaitaB6oCl0EC4qEcgBFL3ip4di5yKtRkiks715QRQu0E5Q+Yfqv1L22 TKcQ== 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 u12si3000140pgb.595.2019.07.31.20.46.44; Wed, 31 Jul 2019 20:46:44 -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 S1728843AbfHADqo (ORCPT + 8 others); Wed, 31 Jul 2019 23:46:44 -0400 Received: from foss.arm.com ([217.140.110.172]:57784 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbfHADqn (ORCPT ); Wed, 31 Jul 2019 23:46:43 -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 001491570; Wed, 31 Jul 2019 20:46:43 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.30.64]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E346E3F575; Wed, 31 Jul 2019 20:46:42 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, rjw@rjwysocki.net, lenb@kernel.org, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Jeremy Linton Subject: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Wed, 31 Jul 2019 22:46:33 -0500 Message-Id: <20190801034634.26913-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801034634.26913-1-jeremy.linton@arm.com> References: <20190801034634.26913-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 | 54 +++++++++++++++++++++++++++++++++++++++++++- include/linux/acpi.h | 5 ++++ 2 files changed, 58 insertions(+), 1 deletion(-) -- 2.21.0 Reviewed-by: Sudeep Holla diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 1e7ac0bd0d3a..84718f6cb741 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -540,6 +540,44 @@ 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. + * 1, any passed flag set + * 0, flag unset + */ +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) != 0; + + 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 @@ -604,6 +642,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 @@ -664,7 +717,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 9426b9aaed86..9d0e20a2ac83 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1302,11 +1302,16 @@ 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_topology_hetero_id(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 Aug 1 03:46:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 170308 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4837924ile; Wed, 31 Jul 2019 20:46:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqziMG1i4luDlOV8XMCHE1FeLBCZDSJE2MU3oWYYydkdKi9bfg9V8y2g4hAu+KbN5A1MlkmC X-Received: by 2002:aa7:8b10:: with SMTP id f16mr51630537pfd.44.1564631205664; Wed, 31 Jul 2019 20:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564631205; cv=none; d=google.com; s=arc-20160816; b=SmyGAq+oOZ0oJYgbUolmDmfjoO9OWsp+R2y44+0/4yX6hz6/WzF+jure1luzzPft0g tZqaDTo7FG/idNQaiFMPoGf5GU9a7d/ztwkrWBidviwzJEkNsBVY7xv7jsebn0vK4jms BcGFWpChUrJfPjOklQjUafXibOE6zG5S0ofp7VsEXwosUGu5S1jGQ8PuhcEe7KS6okyb 8AR42+W+7+cjcu+Uo28cNZiKH2Xq0lhDRBq5nHTT6pJz/vu4kQlnPKIH9QnuqggrZwBa AHKKCnZ13GyQ0QmxaKKBJ08RZg3CWeATpMVZMFG3I3B3kzMwA6lpYPzcj4iTOlmkhALX PhHg== 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=BP8+M7lvehMkMcTcdpuHOSheTfyP0wHhgMQs9/wULWgRzjCrm5z/5cEqNrzMiObBL8 PaW2L6EVpF+SXgJAZmAyOptxjPFEn9rJlrz6Mqr2tyFSw4ZGWspX6pFpZ6SIzKYtcKZS GtqdPZtvOuEa73ZdY1Unv7gJO/Gj4CrWcgwgCroVE9R+7GLOUKRW0xKxfudeV4x+uaAY D5kdyHI6sd39AH6T+seNofrM62xhuTuElhTGUgDDtRxzIU+xL+TnDhPVOmcJTME7nX/W b3kGlIiKu7vNpzYbkIsi/iWS8vc2GI6VRfVgrCZckPWp6c7dx74aFQRwm0KF/2IdF4T6 lpLA== 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 u12si3000140pgb.595.2019.07.31.20.46.45; Wed, 31 Jul 2019 20:46:45 -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 S1729053AbfHADqp (ORCPT + 8 others); Wed, 31 Jul 2019 23:46:45 -0400 Received: from foss.arm.com ([217.140.110.172]:57796 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727948AbfHADqo (ORCPT ); Wed, 31 Jul 2019 23:46:44 -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 30EE41596; Wed, 31 Jul 2019 20:46:44 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.30.64]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 209333F575; Wed, 31 Jul 2019 20:46:44 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, rjw@rjwysocki.net, lenb@kernel.org, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, Jeremy Linton Subject: [PATCH v4 2/2] arm64: topology: Use PPTT to determine if PE is a thread Date: Wed, 31 Jul 2019 22:46:34 -0500 Message-Id: <20190801034634.26913-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190801034634.26913-1-jeremy.linton@arm.com> References: <20190801034634.26913-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 Reviewed-by: Sudeep Holla 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);