From patchwork Wed Oct 16 21:51:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 176530 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp50082ill; Wed, 16 Oct 2019 15:08:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdmx4wxCFqL76/rM/zdO3ZNerDlrwjzCYJa5gthi+umRW5Ad02fV9DQ76JWtQ+F/JmujK5 X-Received: by 2002:a17:906:85c5:: with SMTP id i5mr553347ejy.222.1571263707082; Wed, 16 Oct 2019 15:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571263707; cv=none; d=google.com; s=arc-20160816; b=eOOtexrF7Mwj+MV7WGSLRBjTkI8a6iAZ6mYT2O94GmYspnytxoHs2mprnch0eGwpV2 Xf9kQA6+Jop1CH8V7ewIYXDB2eZCRolCdWFMT9mZtVHuqpVk/7MeS21FzfY73FfotqvC XZQybkrRpQAmlOTqzuf8mvxobxXGp+VlKqwV8tJGCcXcVsfAWp275qiTG3gXA4ho3ao7 picE1jTNAkEynRlXg/TCXu1tf4SOr04Wpeuoyy9XZdhOfQsvKl2rQ6mJhaSHMzK1xTa7 bK7wMym8qyXMH94SCDtQQhMjqb0yHDvuAmKVowMkkHC+OmS+8ls1zzZybMtM0dr6Gylu gbrg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/fOsADwDD1GQpM3h0qUFtWJw2jNXs0GIvv/iHQ5TJLQ=; b=tonq1fT1ilPh4kqDM/uaN5uhTInJUfFe/z3xtZwnzW8nmaVEhFg0MCfhZ94OCaWHsC mtsSH/dvKUYkzsSHp/mFXbCg2tApJJB/0H8NFrOGsuhxPndPVtjmmoLC50D4VH7WlOys AtuvTwl2xl8aV2c53jqmlscxgCviAi9lvKaLgiyNg3x3hAR08K/rhiXia0RZIpeP5JuR ij3zWx8i2HYRsn1kq9c11wT5J+l/BGv47Hnr/xbd4/bxYz/xYgivQFAQ2xy7uvjGB3vr NW/2c4sj5reOwYmcsb2kJK93TMH1HqbgRSk8ZYLw1Y6pZYqhmA8VtcQR1Z+9SKiab1+U h03Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zMDIxj9i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 e23si216164ejt.379.2019.10.16.15.08.26; Wed, 16 Oct 2019 15:08:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zMDIxj9i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438070AbfJPWIV (ORCPT + 26 others); Wed, 16 Oct 2019 18:08:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:50784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391233AbfJPV5u (ORCPT ); Wed, 16 Oct 2019 17:57:50 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 37F4E21D7D; Wed, 16 Oct 2019 21:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263069; bh=qbbtywL0VKu2zBaJP9W9WFBm4xk1t57/2QfOShygBEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zMDIxj9iiQ6VCr+Fd4GauMOTJW+mD2Xyz7vKQu83rk6ZRbwukVAv0XwuyD3hSTjaT HAkbp5SAhBe+TEaH/xFMMsn7KVFd5eidGRSjlvro36tCrI1TK7M3/WPh0wRvGgrbSA TOVfOLdbCcnmm7CeJQwSYxeaw/MqKU9GBkrUeMCQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeremy Linton , Sudeep Holla , Robert Richter , "Rafael J. Wysocki" , Will Deacon , John Garry , Sasha Levin Subject: [PATCH 4.19 69/81] ACPI/PPTT: Add support for ACPI 6.3 thread flag Date: Wed, 16 Oct 2019 14:51:20 -0700 Message-Id: <20191016214846.213102586@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214805.727399379@linuxfoundation.org> References: <20191016214805.727399379@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Signed-off-by: Sasha Levin --- drivers/acpi/pptt.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 5 +++++ 2 files changed, 57 insertions(+) -- 2.20.1 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index da031b1df6f5c..9dbf86a0c8277 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 b4d23b3a2ef2d..59a416dfcaaa2 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;