From patchwork Thu Oct 10 13:29:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 175784 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2298537ill; Thu, 10 Oct 2019 06:33:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9gsEhRmZYs1osy68dx4DSMfdACbtBJW+FZd94Yy4Ss0wKFtbKpBsJZbaEGOdA+j1TLDLS X-Received: by 2002:a17:906:670c:: with SMTP id a12mr1125322ejp.273.1570714412775; Thu, 10 Oct 2019 06:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570714412; cv=none; d=google.com; s=arc-20160816; b=SGIIs5fl9rQM8hcirUERy71rxqwDDNuYW/3AK+2kO6bL5/7QYH39/LMrEgUdth4+4E AQWlDQEhA+B6E4RTw668pwht6n1JfUeWleOqwWC7xBbzn7FhHt5ULUKuWMOI959JyFXa 3JuFIXIf8ylkZ/gu2fPf2wEIdJAyO4TdYNVFhaoNdk8rxIHZLt1/PDzp4Sg8SFy4ev78 eFwCA4ZOP4eUsTx8b/x5r6LOfw1noSJBKPyYUnmZQ9zZjsJQuXrLIOEwMExz2JBr2eOk 9oSBWUNQGmmUUJ1DDlbhZpNTaZkj/uGxZJMjzYPmI9hybPM+45TZdLtslxtclwSMl/Wx uxPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=FtAp2VrFICGd+jCYnNVjeT3BVzwK706gjcU83wBrMF4=; b=chpTj6KbIbQjk/rVQmQJGkoKDvkbiqh21/xCcTrE7id5kt1JmG5TK5beZxhC/e9arD RQBgDDxDO54clds0RVSHoPtQEG7qASL7PFECEm2vciZsNmUQQ3zqgMHQ59cYf2vnk7ib +rM2S1uhaW7HsahD/ZtK2+DZwvjiFuJ0NVmqcl/Nu+lzw2h3bBbsyTc2BHlFNnVNsU+m AYFIZ0b0jCWNO0Aayo5EvCQMScZTQITtYVsq2Wmqdca/QYH1oTMxk8fsxUcOhOcaZb0N RV0gfLrQdRiM6AKoR6JHRlpUSmfwCsKwyrbbPhUgU2DeCpvW9/6pqff6vjmds+5OPLmG n1hA== 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 f35si3629794eda.415.2019.10.10.06.33.32; Thu, 10 Oct 2019 06:33:32 -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 S2388020AbfJJNdc (ORCPT + 7 others); Thu, 10 Oct 2019 09:33:32 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3688 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387897AbfJJNdb (ORCPT ); Thu, 10 Oct 2019 09:33:31 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3C8C49C029AD8555264E; Thu, 10 Oct 2019 21:33:26 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Thu, 10 Oct 2019 21:33:19 +0800 From: John Garry To: , , , , , , , , CC: , , , , , , , John Garry Subject: [RFC PATCH 2/3] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Thu, 10 Oct 2019 21:29:51 +0800 Message-ID: <1570714192-236724-3-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1570714192-236724-1-git-send-email-john.garry@huawei.com> References: <1570714192-236724-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Jeremy Linton Commit bbd1b70639f785a970d998f35155c713f975e3ac upstream. 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 Reviewed-by: Robert Richter Acked-by: Rafael J. Wysocki Signed-off-by: Will Deacon [jpg: backport for 4.19, replace acpi_pptt_warn_missing()] Signed-off-by: John Garry --- drivers/acpi/pptt.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 5 +++++ 2 files changed, 57 insertions(+) -- 2.17.1 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index da031b1df6f5..9dbf86a0c827 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -509,6 +509,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)) { + pr_warn_once("No PPTT table found, cpu topology may be inaccurate\n"); + 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 @@ -573,6 +611,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 diff --git a/include/linux/acpi.h b/include/linux/acpi.h index b4d23b3a2ef2..59a416dfcaaa 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1291,10 +1291,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;