From patchwork Mon Oct 14 11:56:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 176202 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4411562ill; Mon, 14 Oct 2019 04:59:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3yNpqf52gx2Bn4MrAe4SyUGcfMTkch/YHEhxT7nFtSpqAOam1zI7tDIV+VvhaqmQOV3Z/ X-Received: by 2002:aa7:d888:: with SMTP id u8mr26936632edq.144.1571054355373; Mon, 14 Oct 2019 04:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571054355; cv=none; d=google.com; s=arc-20160816; b=iGqUsVtYonntM7LUt+24oV2wsZJUPoUDKdb7SHaP25xtna6t51tZhipYi/VOCT0v9j wqGERBEihvyeBJhD/64QnW/GlbOPjS0NtbHVD9gEjKg5DLq+2zGb7+tnWOKT8RXrbPKb WbyNPUgUPXDQQiolgdjlf7E0INk1itw95IVlz8mjVVEkCCUsjodQD2Zmh7CVmOxfrAYo peYXl15N6FfKuOtDma9cml1faJn0P3UKqsOGLbkySWw2YhDXJ9jvVBTmnFkN5lJF7XQt iXu94xdG/xRK6SubD/hG3UBnaQ00wHGpOUdSGSN60UQ1uYX2PTy1VmFabQt4cNEaBEVW qEcg== 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=WCaIk3zej6+QWQmyhFVw7xrp+YC7vWrmEXWi+S1tBak=; b=xaYP+1xJV4jMhBV3hdN+nQz17bo3vmON/V+t9Rpp56vdqMiIAqecUVzzuUoiODQyCL tWtmCucQcRUpPG5oEnOfWEYBjc0qeerR0Zlj1P9ZoGwqdGfHySdN4lPMqkIeVwOB81FZ AG8ty/3nYRljTOpHmZt2DdByecp0NJ5Aqe4lCiSrH5C6kiUVuxJ7Gy9NYPQRWh1btDoF hFGNUBbvr/95Q3Sw2kD8NMyTYfKuz3Y6cGUOEZLShF7xeKJTDca4xtN8ZoK0Je4Fiy06 h3jf5G03bPtY05VssdKAuVUHdyTIAJPaYf1/BQxKjGQgL3cX2TzJeNHSa5PQEZll6XUs RNDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 g21si10532934ejk.23.2019.10.14.04.59.15; Mon, 14 Oct 2019 04:59:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731719AbfJNL7O (ORCPT + 13 others); Mon, 14 Oct 2019 07:59:14 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3710 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730810AbfJNL7O (ORCPT ); Mon, 14 Oct 2019 07:59:14 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 7D03C4B0C5916CE21BBA; Mon, 14 Oct 2019 19:59:10 +0800 (CST) Received: from localhost.localdomain (10.67.212.75) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Mon, 14 Oct 2019 19:59:00 +0800 From: John Garry To: CC: , , , , , , , , , , , , , , John Garry Subject: [PATCH for-stable-5.3 1/2] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Mon, 14 Oct 2019 19:56:01 +0800 Message-ID: <1571054162-71090-2-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1571054162-71090-1-git-send-email-john.garry@huawei.com> References: <1571054162-71090-1-git-send-email-john.garry@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.212.75] X-CFilter-Loop: Reflected Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 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 1e7ac0bd0d3a..9497298018a9 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 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;