From patchwork Fri May 3 23:24:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 163333 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1197933ill; Fri, 3 May 2019 16:24:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxp2ntIG0ki9FNFeXPMvTypQ3Mvsy5StddZezir0jYTPp2YWJyoFHRhBxabJpxWfwrXDDp0 X-Received: by 2002:a17:902:9b83:: with SMTP id y3mr14253685plp.165.1556925868984; Fri, 03 May 2019 16:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556925868; cv=none; d=google.com; s=arc-20160816; b=NPu3xeaKVMMeGeTM1mCuf5P8KHz7UXm+MQTdryOf2qdRKHbytyMfJKUNqBiaxIHn7P OMRQED0YTE+ywzuG68x1Vhu5ayKL8Sv6E/a+WutUztugMMWCdOA9F4NHbbF7blH0IKy8 RVaqLsnOYhScKqVLOY8V5Qd/F+BrqXyol8VE8gO2Qiv2H/piN8+3+MOnBo0UhHbWY3wg tQmhx/8B1DWAla4mtzHYgAJQQdyjtuAzoF2UcfBv4/HclG7Tu17MolH7xpoNdvyf6wev 5P9acE5i7fGHBaK3XIuZzdjHLuhh04z/weMRvJUgKETia6XIV2lDYfB6cbsfwhmBfs1X eong== 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=C0oTMGfy26SDKMequapunINPRYAqB9Pian1+9zdX67E=; b=Q8OVnccIkhYSuzayz2kTKupztY9AzTsUY6YPG6YhATK5DMp8crsR/hmUqPB7uAY4pV M4hfuGuO0Lu0t/HGC2ir2MyEwkQQIGh2G9IfAWMYlSmIVshF5PWNtZ11Jvztbn8BPWGe AXt4ln8dqkm63I57M9hJoaBehJ+LnqbQbOHoatDiJWCTn/nb9KBxgVA8V92iZQ6WoW/U Yh6Ketij2DDr7+Q1dnw97h605eBbGbGcSk/Pcibc+OwsUUDh38yApFRS/NzEnwAdtgiu pyM5aC5iIj+zYTXYOnR8psugj6qUF6JOuqxWVQF855GUCxScWUFY54rdKbkbTuZHIhv7 UqDg== 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 x3si4677027plv.33.2019.05.03.16.24.28; Fri, 03 May 2019 16:24:28 -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 S1726320AbfECXY2 (ORCPT + 9 others); Fri, 3 May 2019 19:24:28 -0400 Received: from foss.arm.com ([217.140.101.70]:40194 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726244AbfECXY2 (ORCPT ); Fri, 3 May 2019 19:24:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 56EC015AD; Fri, 3 May 2019 16:24:27 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B85B03F557; Fri, 3 May 2019 16:24:26 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, linuxarm@huawei.com, john.garry@huawei.com, Jeremy Linton , "Rafael J . Wysocki" Subject: [PATCH v3 1/5] ACPI/PPTT: Trivial, change the capitalization of CPU Date: Fri, 3 May 2019 18:24:03 -0500 Message-Id: <20190503232407.37195-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503232407.37195-1-jeremy.linton@arm.com> References: <20190503232407.37195-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 CPU is an acronym and customarily capitalized. Much of the commenting in the PPTT code has been using "cpu" rather than "CPU". Correct that, and other human readable strings. Signed-off-by: Jeremy Linton Acked-by: Rafael J. Wysocki --- drivers/acpi/pptt.c | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) -- 2.21.0 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 065c4fc245d1..83a026765faa 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -164,7 +164,7 @@ static struct acpi_pptt_cache *acpi_find_cache_level(struct acpi_table_header *t } /** - * acpi_count_levels() - Given a PPTT table, and a cpu node, count the caches + * acpi_count_levels() - Given a PPTT table, and a CPU node, count the caches * @table_hdr: Pointer to the head of the PPTT table * @cpu_node: processor node we wish to count caches for * @@ -235,7 +235,7 @@ static int acpi_pptt_leaf_node(struct acpi_table_header *table_hdr, /** * acpi_find_processor_node() - Given a PPTT table find the requested processor * @table_hdr: Pointer to the head of the PPTT table - * @acpi_cpu_id: cpu we are searching for + * @acpi_cpu_id: CPU we are searching for * * Find the subtable entry describing the provided processor. * This is done by iterating the PPTT table looking for processor nodes @@ -456,21 +456,21 @@ static struct acpi_pptt_processor *acpi_find_processor_package_id(struct acpi_ta static void acpi_pptt_warn_missing(void) { - pr_warn_once("No PPTT table found, cpu and cache topology may be inaccurate\n"); + pr_warn_once("No PPTT table found, CPU and cache topology may be inaccurate\n"); } /** * topology_get_acpi_cpu_tag() - Find a unique topology value for a feature * @table: Pointer to the head of the PPTT table - * @cpu: Kernel logical cpu number + * @cpu: Kernel logical CPU number * @level: A level that terminates the search * @flag: A flag which terminates the search * - * Get a unique value given a cpu, and a topology level, that can be - * matched to determine which cpus share common topological features + * Get a unique value given a CPU, and a topology level, that can be + * matched to determine which CPUs share common topological features * at that level. * - * Return: Unique value, or -ENOENT if unable to locate cpu + * Return: Unique value, or -ENOENT if unable to locate CPU */ static int topology_get_acpi_cpu_tag(struct acpi_table_header *table, unsigned int cpu, int level, int flag) @@ -510,7 +510,7 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) return -ENOENT; } retval = topology_get_acpi_cpu_tag(table, cpu, level, flag); - pr_debug("Topology Setup ACPI cpu %d, level %d ret = %d\n", + pr_debug("Topology Setup ACPI CPU %d, level %d ret = %d\n", cpu, level, retval); acpi_put_table(table); @@ -519,9 +519,9 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) /** * acpi_find_last_cache_level() - Determines the number of cache levels for a PE - * @cpu: Kernel logical cpu number + * @cpu: Kernel logical CPU number * - * Given a logical cpu number, returns the number of levels of cache represented + * Given a logical CPU number, returns the number of levels of cache represented * in the PPTT. Errors caused by lack of a PPTT table, or otherwise, return 0 * indicating we didn't find any cache levels. * @@ -534,7 +534,7 @@ int acpi_find_last_cache_level(unsigned int cpu) int number_of_levels = 0; acpi_status status; - pr_debug("Cache Setup find last level cpu=%d\n", cpu); + pr_debug("Cache Setup find last level CPU=%d\n", cpu); acpi_cpu_id = get_acpi_id_for_cpu(cpu); status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); @@ -551,14 +551,14 @@ int acpi_find_last_cache_level(unsigned int cpu) /** * cache_setup_acpi() - Override CPU cache topology with data from the PPTT - * @cpu: Kernel logical cpu number + * @cpu: Kernel logical CPU number * * Updates the global cache info provided by cpu_get_cacheinfo() * when there are valid properties in the acpi_pptt_cache nodes. A * successful parse may not result in any updates if none of the * cache levels have any valid flags set. Futher, a unique value is * associated with each known CPU cache entry. This unique value - * can be used to determine whether caches are shared between cpus. + * can be used to determine whether caches are shared between CPUs. * * Return: -ENOENT on failure to find table, or 0 on success */ @@ -567,7 +567,7 @@ int cache_setup_acpi(unsigned int cpu) struct acpi_table_header *table; acpi_status status; - pr_debug("Cache Setup ACPI cpu %d\n", cpu); + pr_debug("Cache Setup ACPI CPU %d\n", cpu); status = acpi_get_table(ACPI_SIG_PPTT, 0, &table); if (ACPI_FAILURE(status)) { @@ -582,8 +582,8 @@ int cache_setup_acpi(unsigned int cpu) } /** - * find_acpi_cpu_topology() - Determine a unique topology value for a given cpu - * @cpu: Kernel logical cpu number + * find_acpi_cpu_topology() - Determine a unique topology value for a given CPU + * @cpu: Kernel logical CPU number * @level: The topological level for which we would like a unique ID * * Determine a topology unique ID for each thread/core/cluster/mc_grouping @@ -596,7 +596,7 @@ int cache_setup_acpi(unsigned int cpu) * other levels beyond this use a generated value to uniquely identify * a topological feature. * - * Return: -ENOENT if the PPTT doesn't exist, or the cpu cannot be found. + * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found. * Otherwise returns a value which represents a unique topological feature. */ int find_acpi_cpu_topology(unsigned int cpu, int level) @@ -606,12 +606,12 @@ int find_acpi_cpu_topology(unsigned int cpu, int level) /** * find_acpi_cpu_cache_topology() - Determine a unique cache topology value - * @cpu: Kernel logical cpu number + * @cpu: Kernel logical CPU number * @level: The cache level for which we would like a unique ID * * Determine a unique ID for each unified cache in the system * - * Return: -ENOENT if the PPTT doesn't exist, or the cpu cannot be found. + * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found. * Otherwise returns a value which represents a unique topological feature. */ int find_acpi_cpu_cache_topology(unsigned int cpu, int level) @@ -643,17 +643,17 @@ int find_acpi_cpu_cache_topology(unsigned int cpu, int level) /** - * find_acpi_cpu_topology_package() - Determine a unique cpu package value - * @cpu: Kernel logical cpu number + * find_acpi_cpu_topology_package() - Determine a unique CPU package value + * @cpu: Kernel logical CPU number * - * Determine a topology unique package ID for the given cpu. + * Determine a topology unique package ID for the given CPU. * This ID can then be used to group peers, which will have matching ids. * * The search terminates when either a level is found with the PHYSICAL_PACKAGE * flag set or we reach a root node. * - * Return: -ENOENT if the PPTT doesn't exist, or the cpu cannot be found. - * Otherwise returns a value which represents the package for this cpu. + * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found. + * Otherwise returns a value which represents the package for this CPU. */ int find_acpi_cpu_topology_package(unsigned int cpu) { From patchwork Fri May 3 23:24:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 163335 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1197945ill; Fri, 3 May 2019 16:24:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqzocrrgq48TFHM+funEVxd6rxlDvHfw2Fi8PoHd5IWiFxhCH7zoDpEyo7lS4t3baUGuAacz X-Received: by 2002:a17:902:820a:: with SMTP id x10mr14551171pln.316.1556925869635; Fri, 03 May 2019 16:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556925869; cv=none; d=google.com; s=arc-20160816; b=DwDJO4oi0DMpIRCIsDRdsBOydLFmjhlmTns+uqRcFfY28HPT2w4keMdjVE9hB6bRqH hXfMzdgtXjNZ1/t9IRYkl0ma+DL+DUSjSh/gAIbNT0x5LGqnWfb/2w6ZlO4JiGtUjee2 /jPb/ue3tbrxhMnlo3cKK7zkC8prilIWE3Ik4dAwob5G1OFYBDoYBMYFIWPG5V4dSE7x wD/0ZJor1p6BWsx21ra6suHDpdJt2+rjZzNmujYfvGwUaZ8X2EVnZdBhMfoSC33MoIJY T4VBukrkAz/M+m3AVTsxbebEiEwBEqUlNarcUhX04GMfaOeNztW8QM+q+OlFxXWWlizo qenA== 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=SF9SiONcv108u86ar2jpmk3grTd5bZTvlAwE8kxmPrg=; b=bA97/jdcotOyVLLgSaACDAesKqDUGvi8epJsOo1SgMSJcVVKIpzrKYKhnObWrvyi2g 6fct+ghxHhAE1SGOBxwSTRuXgQ5bDiF7bZcfdrTvSsBPVjUZIL0rNVBZQywL8UNzT/wM ghVUEtKQyQ9tO/iA8owVTKeg3oZmcVExoZ7rHPac1IbR4C4ov1ZpnPqRc52+JbO5cF9H TCG/yR5eefEs0b7W+EpgwkyqZEDhz2oLZ2TenlChFsUv3RjgwqYxHP6xf3+up8gss6MY SXY+4bqnttJ+RgpIr4iyifZVpYeMMQi5QSvp3vPwsqDWDYlGSzCYf2NuzXhluOlpnkSK tPAA== 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 x3si4677027plv.33.2019.05.03.16.24.29; Fri, 03 May 2019 16:24:29 -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 S1726244AbfECXY3 (ORCPT + 9 others); Fri, 3 May 2019 19:24:29 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:40208 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbfECXY2 (ORCPT ); Fri, 3 May 2019 19:24:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E85A815BF; Fri, 3 May 2019 16:24:27 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5E8273F557; Fri, 3 May 2019 16:24:27 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, linuxarm@huawei.com, john.garry@huawei.com, Jeremy Linton Subject: [PATCH v3 2/5] ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens Date: Fri, 3 May 2019 18:24:04 -0500 Message-Id: <20190503232407.37195-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503232407.37195-1-jeremy.linton@arm.com> References: <20190503232407.37195-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 indicate that child nodes are all identical cores. This is useful to authoritatively determine if a set of (possibly offline) cores are identical or not. Since the flag doesn't give us a unique id we can generate one and use it to create bitmaps of sibling nodes, or simply in a loop to determine if a subset of cores are identical. Signed-off-by: Jeremy Linton --- drivers/acpi/pptt.c | 26 ++++++++++++++++++++++++++ include/linux/acpi.h | 5 +++++ 2 files changed, 31 insertions(+) -- 2.21.0 Reviewed-by: Sudeep Holla diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 83a026765faa..1865515297ca 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -660,3 +660,29 @@ int find_acpi_cpu_topology_package(unsigned int cpu) return find_acpi_cpu_topology_tag(cpu, PPTT_ABORT_PACKAGE, ACPI_PPTT_PHYSICAL_PACKAGE); } + +/** + * find_acpi_cpu_topology_hetero_id() - Get a core architecture tag + * @cpu: Kernel logical CPU number + * + * Determine a unique heterogeneous tag for the given CPU. CPUs with the same + * implementation should have matching tags. + * + * The returned tag can be used to group peers with identical implementation. + * + * The search terminates when a level is found with the identical implementation + * flag set or we reach a root node. + * + * Due to limitations in the PPTT data structure, there may be rare situations + * where two cores in a heterogeneous machine may be identical, but won't have + * the same tag. + * + * Return: -ENOENT if the PPTT doesn't exist, or the CPU cannot be found. + * Otherwise returns a value which represents a group of identical cores + * similar to this CPU. + */ +int find_acpi_cpu_topology_hetero_id(unsigned int cpu) +{ + return find_acpi_cpu_topology_tag(cpu, PPTT_ABORT_PACKAGE, + ACPI_PPTT_ACPI_IDENTICAL); +} diff --git a/include/linux/acpi.h b/include/linux/acpi.h index d5dcebd7aad3..1444fb042898 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1309,6 +1309,7 @@ static inline int lpit_read_residency_count_address(u64 *address) #ifdef CONFIG_ACPI_PPTT 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 find_acpi_cpu_topology(unsigned int cpu, int level) @@ -1319,6 +1320,10 @@ static inline int find_acpi_cpu_topology_package(unsigned int cpu) { return -EINVAL; } +static int find_acpi_cpu_topology_hetero_id(unsigned int cpu) +{ + return -EINVAL; +} static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level) { return -EINVAL; From patchwork Fri May 3 23:24:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 163336 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1197950ill; Fri, 3 May 2019 16:24:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqzAG5fYnrL610qt9fx4BUeuc8QDkw0VWUGqfhYLctzhSHfAiz3WXbajrn2j53vepT6uT+2c X-Received: by 2002:a17:902:8b83:: with SMTP id ay3mr14128031plb.187.1556925869937; Fri, 03 May 2019 16:24:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556925869; cv=none; d=google.com; s=arc-20160816; b=S/Ojwlg1r3AjjYUsjuN2sXmxVGEr30xVsUkP3LBIiwYj0Ti6f1tfapvJ+k8DqcxGkd F/Q3MeKwaeZz9aJwV2jEINP1e+RRmnKBoT5AuOGPS2BPnoF0yiOYlYjaDFEMEa9s9I0i BkTwh4ozG/3qm471LFn4phcjkyJJT2UZdlKE+mDYhILFzeHMpp1S2LEG+g3K304o2NUr 6gfPZUaxQTsC6rCuyyzbWgp7WexGmNKrPb4TFtqSBJbAKFvKF6Ey1DJqXmrPshiYczJZ +ZAz2Ex0shuRVi+haBSecj7oOUObd1XHXwlQx/ucn5jHQ/a7r2XnEam8HNzWrlWVGPHD 20EQ== 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=RomcoymDCgIywX8ChCYZ0qaza9Bn5HozL/WWX0MxphY=; b=Iq88eMmAulKTsQmHLRb3WoWsFBiPiaJXt99XX5XaOAx29xlyKZVZ9+nmkgLGMfnELD f3hY1/ow4hE/bqOho3Ct8ahZP8gQuIgK5HOikhv0Xhspl/xBzDpRAfotGJ3AauHnKfP2 ZuWVgtEVSJrIJK/El9u4TZr4cix8XTUPbNAAy1ewS06T95hFn2N9W8M313CIod3fgGfd iLvS7kEvGvbkJ22l5dmCjJ4IOVbcAPuJ4QAV9STFtBEvuRLs90PJAmcZkQBt0xkhR/mR IZ90uBiK62D9+iY4c5Fi92RluyjnlWnkLCZ9z60oMCUYgi3HKmiFcBtjG2GpRwKQMuhV FGXg== 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 x3si4677027plv.33.2019.05.03.16.24.29; Fri, 03 May 2019 16:24:29 -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 S1726376AbfECXY3 (ORCPT + 9 others); Fri, 3 May 2019 19:24:29 -0400 Received: from foss.arm.com ([217.140.101.70]:40222 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbfECXY3 (ORCPT ); Fri, 3 May 2019 19:24:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 85522165C; Fri, 3 May 2019 16:24:28 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EFCBC3F557; Fri, 3 May 2019 16:24:27 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, linuxarm@huawei.com, john.garry@huawei.com, Jeremy Linton Subject: [PATCH v3 3/5] ACPI/PPTT: Modify node flag detection to find last IDENTICAL Date: Fri, 3 May 2019 18:24:05 -0500 Message-Id: <20190503232407.37195-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503232407.37195-1-jeremy.linton@arm.com> References: <20190503232407.37195-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 The ACPI specification implies that the IDENTICAL flag should be set on all non leaf nodes where the children are identical. This means that we need to be searching for the last node with the identical flag set rather than the first one. Since this flag is also dependent on the table revision, we need to add a bit of extra code to verify the table revision, and the next node's state in the traversal. Since we want to avoid function pointers here, lets just special case the IDENTICAL flag. Signed-off-by: Jeremy Linton --- drivers/acpi/pptt.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) -- 2.21.0 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 1865515297ca..456e1c0a35ae 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -432,17 +432,39 @@ static void cache_setup_acpi_cpu(struct acpi_table_header *table, } } +static bool flag_identical(struct acpi_table_header *table_hdr, + struct acpi_pptt_processor *cpu) +{ + struct acpi_pptt_processor *next; + + /* heterogeneous machines must use PPTT revision > 1 */ + if (table_hdr->revision < 2) + return false; + + /* Locate the last node in the tree with IDENTICAL set */ + if (cpu->flags & ACPI_PPTT_ACPI_IDENTICAL) { + next = fetch_pptt_node(table_hdr, cpu->parent); + if (!(next && next->flags & ACPI_PPTT_ACPI_IDENTICAL)) + return true; + } + + return false; +} + /* Passing level values greater than this will result in search termination */ #define PPTT_ABORT_PACKAGE 0xFF -static struct acpi_pptt_processor *acpi_find_processor_package_id(struct acpi_table_header *table_hdr, +static struct acpi_pptt_processor *acpi_find_processor_tag_id(struct acpi_table_header *table_hdr, struct acpi_pptt_processor *cpu, int level, int flag) { struct acpi_pptt_processor *prev_node; while (cpu && level) { - if (cpu->flags & flag) + if (flag == ACPI_PPTT_ACPI_IDENTICAL) { + if (flag_identical(table_hdr, cpu)) + break; + } else if (cpu->flags & flag) break; pr_debug("level %d\n", level); prev_node = fetch_pptt_node(table_hdr, cpu->parent); @@ -480,7 +502,7 @@ static int topology_get_acpi_cpu_tag(struct acpi_table_header *table, cpu_node = acpi_find_processor_node(table, acpi_cpu_id); if (cpu_node) { - cpu_node = acpi_find_processor_package_id(table, cpu_node, + cpu_node = acpi_find_processor_tag_id(table, cpu_node, level, flag); /* * As per specification if the processor structure represents From patchwork Fri May 3 23:24: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: 163338 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1197965ill; Fri, 3 May 2019 16:24:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwonSlG7+pr43MnPCCh0rW6vCQD3gZnbfpAk88VbTPqJMC7ZMDj4Q5QW0kPGXeLiyj/02ws X-Received: by 2002:a17:902:20e2:: with SMTP id v31mr10324099plg.138.1556925871879; Fri, 03 May 2019 16:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556925871; cv=none; d=google.com; s=arc-20160816; b=yokboMq4nyRbwTHyn1qNUgM5kD0zfRfvD1/QEGHVGy1/hFGofwWu3zoG9tE5Gp/pKk EmsDNpnS39syHrSELtBeZOxtwAa60KDnzT4gjLqcvJamgzD6HyyR48bj0Pp+VJajIG4t JDBoYc0T2BtzUK7oniANOn3qpzZMDMHckguIy947XUjqM6ezQsfJaj0zgr8BjeKRXld9 CNQUswF+rnedeRgJYnMm7XBPym41L8qaw+TdXPFhohY5J79XkP2q08+kYn30ZAkH7ajw lhAcdU1RrLxj+zr0vOyHZ3A6P94+z94u+OrLblkxExWK91zev/JvbBGG6PkRaPnidDga wBNA== 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=StTsLO6SMOUepI5f+v08l9yaL1SFV6RZQ5mCwZlNpUw=; b=ZC6fOctskagaaIturXxGUzk6mLM+4PtWkqjqJW4nQo8F1p0eU24bWKOW1SjvN8tjDn nLlIlprx1wc+Q06apee/Hn4AsVAH1jeW4tLy6GfDZCkEf99YtJgY4GEZgleBroZnuFVE TsAHOHl4QuD7YvZT8jzS0Vzc/ZoEyffnZpyrIM4R3lTxlDX+fF0PT8Zu6QV2icwQqkHJ Oupj/uSXxFQAAcVBOjh24EClP9f4Wke8lArZ9JIs8h390cF4+FyUpkdEDps2VxeEyItK YNbcgtJq0N5rlZ+JA8sono4ABcBUQ/2X0+37cvpCtlQC6WNps6f3c9B1KrBxX0zzxTcR jMEg== 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 x3si4677027plv.33.2019.05.03.16.24.31; Fri, 03 May 2019 16:24:31 -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 S1726041AbfECXYb (ORCPT + 9 others); Fri, 3 May 2019 19:24:31 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:40208 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726059AbfECXY3 (ORCPT ); Fri, 3 May 2019 19:24:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 229771684; Fri, 3 May 2019 16:24:29 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8D0243F557; Fri, 3 May 2019 16:24:28 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, linuxarm@huawei.com, john.garry@huawei.com, Jeremy Linton Subject: [PATCH v3 4/5] arm_pmu: acpi: spe: Add initial MADT/SPE probing Date: Fri, 3 May 2019 18:24:06 -0500 Message-Id: <20190503232407.37195-5-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503232407.37195-1-jeremy.linton@arm.com> References: <20190503232407.37195-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 additional fields to the MADT GICC structure to describe SPE PPI's. We pick these out of the cached reference to the madt_gicc structure similarly to the core PMU code. We then create a platform device referring to the IRQ and let the user/module loader decide whether to load the SPE driver. Signed-off-by: Jeremy Linton --- arch/arm64/include/asm/acpi.h | 3 ++ drivers/perf/Kconfig | 5 +++ drivers/perf/arm_pmu_acpi.c | 76 +++++++++++++++++++++++++++++++++++ include/linux/perf/arm_pmu.h | 2 + 4 files changed, 86 insertions(+) -- 2.21.0 diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 7628efbe6c12..d10399b9f998 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -41,6 +41,9 @@ (!(entry) || (entry)->header.length < ACPI_MADT_GICC_MIN_LENGTH || \ (unsigned long)(entry) + (entry)->header.length > (end)) +#define ACPI_MADT_GICC_SPE (ACPI_OFFSET(struct acpi_madt_generic_interrupt, \ + spe_interrupt) + sizeof(u16)) + /* Basic configuration for ACPI */ #ifdef CONFIG_ACPI pgprot_t __acpi_get_mem_attribute(phys_addr_t addr); diff --git a/drivers/perf/Kconfig b/drivers/perf/Kconfig index af9bc178495d..bc2647c64c9d 100644 --- a/drivers/perf/Kconfig +++ b/drivers/perf/Kconfig @@ -52,6 +52,11 @@ config ARM_PMU_ACPI depends on ARM_PMU && ACPI def_bool y +config ARM_SPE_ACPI + depends on ARM_PMU_ACPI && ARM_SPE_PMU + def_bool y + + config ARM_DSU_PMU tristate "ARM DynamIQ Shared Unit (DSU) PMU" depends on ARM64 diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c index 0f197516d708..b0244e1e8c91 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -74,6 +74,80 @@ static void arm_pmu_acpi_unregister_irq(int cpu) acpi_unregister_gsi(gsi); } +#ifdef CONFIG_ARM_SPE_ACPI +static struct resource spe_resources[] = { + { + /* irq */ + .flags = IORESOURCE_IRQ, + } +}; + +static struct platform_device spe_dev = { + .name = ARMV8_SPE_PDEV_NAME, + .id = -1, + .resource = spe_resources, + .num_resources = ARRAY_SIZE(spe_resources) +}; + +/* + * For lack of a better place, hook the normal PMU MADT walk + * and create a SPE device if we detect a recent MADT with + * a homogeneous PPI mapping. + */ +static int arm_spe_acpi_register_device(void) +{ + int cpu, ret, irq; + int hetid; + u16 gsi = 0; + bool first = true; + + struct acpi_madt_generic_interrupt *gicc; + + /* + * sanity check all the GICC tables for the same interrupt number + * for now we only support homogeneous ACPI/SPE machines. + */ + for_each_possible_cpu(cpu) { + gicc = acpi_cpu_get_madt_gicc(cpu); + + if (gicc->header.length < ACPI_MADT_GICC_SPE) + return -ENODEV; + if (first) { + gsi = gicc->spe_interrupt; + if (!gsi) + return -ENODEV; + hetid = find_acpi_cpu_topology_hetero_id(cpu); + first = false; + } else if ((gsi != gicc->spe_interrupt) || + (hetid != find_acpi_cpu_topology_hetero_id(cpu))) { + pr_warn("ACPI: SPE must be homogeneous\n"); + return -EINVAL; + } + } + + irq = acpi_register_gsi(NULL, gsi, ACPI_LEVEL_SENSITIVE, + ACPI_ACTIVE_HIGH); + if (irq < 0) { + pr_warn("ACPI: SPE Unable to register interrupt: %d\n", gsi); + return irq; + } + + spe_resources[0].start = irq; + ret = platform_device_register(&spe_dev); + if (ret < 0) { + pr_warn("ACPI: SPE: Unable to register device\n"); + acpi_unregister_gsi(gsi); + } + + return ret; +} +#else +static inline int arm_spe_acpi_register_device(void) +{ + return -ENODEV; +} +#endif /* CONFIG_ARM_SPE_ACPI */ + static int arm_pmu_acpi_parse_irqs(void) { int irq, cpu, irq_cpu, err; @@ -279,6 +353,8 @@ static int arm_pmu_acpi_init(void) if (acpi_disabled) return 0; + arm_spe_acpi_register_device(); /* failures are expected */ + ret = arm_pmu_acpi_parse_irqs(); if (ret) return ret; diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 4641e850b204..784bc58f165a 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -175,4 +175,6 @@ void armpmu_free_irq(int irq, int cpu); #endif /* CONFIG_ARM_PMU */ +#define ARMV8_SPE_PDEV_NAME "arm,spe-v1" + #endif /* __ARM_PMU_H__ */ From patchwork Fri May 3 23:24:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 163337 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp1197962ill; Fri, 3 May 2019 16:24:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvx1hGBqKjVlNdAKm0CTdWNbJB+XWgUqDnssqQNu8Qq3YM97x0mTm3LGiD2+SPksgGfnhe X-Received: by 2002:aa7:8384:: with SMTP id u4mr14560832pfm.214.1556925871623; Fri, 03 May 2019 16:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556925871; cv=none; d=google.com; s=arc-20160816; b=oFHlIGycDls6mgK/NFZ8a9LQXMmHQbAMUNyLzzkLVgmlYWzy1PGGCxpCR12lU5p+Ed bOzaB77jKQMTn4S0lIxMtMt4EwRmYCxSRIvUv9HF+0XrhT0qRSVR0Tz4QuPeNQxLBfmw HKpHpFoNjBdzB2H+Z2jYsYwbE6DPp/CZXQ1Ofy4AqtRbDFbG1iuQ4oqBjQA8pZkMFKWA Ws950ZhCYJuwrtvUVl3sbbrxltAwtRmzqOJ143W8Tum3W8O0yVLRFyfiJscQQJj/DC2w YOlj9HtTj7H9H/AjSGc1jmEl8ebqBVSjX2j8Oy9UfWlhqmKRr+3cTqeO050Mb9WEZUwN dr0A== 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=pP6Zgb3fW90BzPhhrcIxrO4ihO3YiyxTRL95xLNygOM=; b=KUJiyMWCzDm+imbLE4Tzt5QvuB+goEcFMvI2sL056hZthXRm6zfBGGWH3vTZ/ai45n M8LXrNRHKuZUSnEVd0ZTlUUDeuVhOpOrgvWM/SZpsjjwOevFaQ70FItEtN91Qg4mg3a2 rJkHxY4RjHqRNj7KjyyiaYVOv7mgkY4Gx2bkUZdDPhxYS74u6GrXVv1V/3l4+Za0mc3M vA0nZyTyrJTW44cDnXO1UxXOlqPXMnZU8DFbUeTZzuBTiI47fqtbfpAEhTbA97Jw+idk fqBP/o13RECj2RTIlFGXmsxPJ29ZEMLMjSGo+XdfvlGKXWcfE8pgACgvWpW4w6NX+Q5Q liEg== 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 x3si4677027plv.33.2019.05.03.16.24.31; Fri, 03 May 2019 16:24:31 -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 S1726400AbfECXYb (ORCPT + 9 others); Fri, 3 May 2019 19:24:31 -0400 Received: from foss.arm.com ([217.140.101.70]:40222 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbfECXYa (ORCPT ); Fri, 3 May 2019 19:24:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B3E37168F; Fri, 3 May 2019 16:24:29 -0700 (PDT) Received: from mammon-tx2.austin.arm.com (mammon-tx2.austin.arm.com [10.118.29.246]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2A2CF3F557; Fri, 3 May 2019 16:24:29 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, linuxarm@huawei.com, john.garry@huawei.com, Jeremy Linton Subject: [PATCH v3 5/5] perf: arm_spe: Enable ACPI/Platform automatic module loading Date: Fri, 3 May 2019 18:24:07 -0500 Message-Id: <20190503232407.37195-6-jeremy.linton@arm.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190503232407.37195-1-jeremy.linton@arm.com> References: <20190503232407.37195-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 Lets add the MODULE_TABLE and platform id_table entries so that the SPE driver can attach to the ACPI platform device created by the core pmu code. Signed-off-by: Jeremy Linton Reviewed-by: Sudeep Holla --- drivers/perf/arm_spe_pmu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.21.0 diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 7cb766dafe85..a11951b08330 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1176,7 +1177,13 @@ static const struct of_device_id arm_spe_pmu_of_match[] = { }; MODULE_DEVICE_TABLE(of, arm_spe_pmu_of_match); -static int arm_spe_pmu_device_dt_probe(struct platform_device *pdev) +static const struct platform_device_id arm_spe_match[] = { + { ARMV8_SPE_PDEV_NAME, 0}, + { } +}; +MODULE_DEVICE_TABLE(platform, arm_spe_match); + +static int arm_spe_pmu_device_probe(struct platform_device *pdev) { int ret; struct arm_spe_pmu *spe_pmu; @@ -1236,11 +1243,12 @@ static int arm_spe_pmu_device_remove(struct platform_device *pdev) } static struct platform_driver arm_spe_pmu_driver = { + .id_table = arm_spe_match, .driver = { .name = DRVNAME, .of_match_table = of_match_ptr(arm_spe_pmu_of_match), }, - .probe = arm_spe_pmu_device_dt_probe, + .probe = arm_spe_pmu_device_probe, .remove = arm_spe_pmu_device_remove, };