From patchwork Thu Aug 8 20:40:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 170840 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp9073321ile; Thu, 8 Aug 2019 13:41:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwregAc38Qg2i3Yt+XnTCf91olF6ZWIV9is0FewA2wQlBJibZyz0t1RBjTiFUMnvve91Hvy X-Received: by 2002:a17:90b:95:: with SMTP id bb21mr6015712pjb.8.1565296906382; Thu, 08 Aug 2019 13:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565296906; cv=none; d=google.com; s=arc-20160816; b=psMwnxtKtrHKrQToyRnoA5no8/B5MlD+dlgIgJOC7Fc0qGEGpiFfHYT9EKttA5nFnD EE+pJPiJrCns3DAIXZlu/rusHZeZMvlbWXhkx/gtDCONh0WI9WT4P+S9biQUqc8aidWB BIP4oOY6nPr+gfFgtz+y37NRNCa2L5Lr+i3MyFdk0/66a8iu+yC5uEkemsgO0B22UVBr CPFw7xh1H/bQ/Ig7L7C4DjzR7iLqdUqXftG3jHLBxwne23l/UTlTav05EbVEB0fvqVND /bL9YxLZjbFdjbHlfU669cl0cZm+NkgLVHtcKxL9D53tMVl3+ZCt+uswZRCoDrwn0k8o FEkA== 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=TMap+BSCvqnAFvdgW0/3qOHNWTDG/JBKNNj5mxOoJds=; b=R60SYI9WA6kcWbY6VDxXJgdIHfTqz6lt7Slunh7Fo4263cWfcohfL8N/eEEIxaJrBH Vo8XKpOtDtzHNfP/1qb8Lrm4obp4OdJw4jvUVKhCTuDB2g74C9V2V4gPEGxV536DMBdD Jcg9d2w2/GzPt+bMxJtQnpi3LtStt2P/fo2xSSA0v9vlNInIBM9RoqiwgU4E7hwWB/3B yTYjTgxoL/AN7QdESO5aY4HByw8IQcnQ6de3zRiwIXAg1pH/2P7R0rr7F2muRivjD8IJ JMhvXbetSLINo39w6ZwSJmRL0OvLu0ghnzIsTB7BnggHKTzHPpmZwnrz8miZMD1rUTWm OKWA== 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 y16si55793905pgj.169.2019.08.08.13.41.46; Thu, 08 Aug 2019 13:41:46 -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 S2390326AbfHHUlp (ORCPT + 7 others); Thu, 8 Aug 2019 16:41:45 -0400 Received: from foss.arm.com ([217.140.110.172]:38430 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390148AbfHHUlp (ORCPT ); Thu, 8 Aug 2019 16:41:45 -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 33B771684; Thu, 8 Aug 2019 13:41:45 -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 22BC93F694; Thu, 8 Aug 2019 13:41:45 -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, rric@kernel.org, Jeremy Linton Subject: [PATCH v4 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Thu, 8 Aug 2019 15:40:06 -0500 Message-Id: <20190808204007.30110-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190808204007.30110-1-jeremy.linton@arm.com> References: <20190808204007.30110-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 Reviewed-by: Sudeep Holla --- drivers/acpi/pptt.c | 53 +++++++++++++++++++++++++++++++++++++++++++- include/linux/acpi.h | 5 +++++ 2 files changed, 57 insertions(+), 1 deletion(-) -- 2.21.0 Reviewed-by: Robert Richter Acked-by: Rafael J. Wysocki diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 1e7ac0bd0d3a..f31544d3656e 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 minimum 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,20 @@ 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 +716,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;