From patchwork Tue Mar 26 22:39:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 161233 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5766161jan; Tue, 26 Mar 2019 15:40:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzgMBM7k0WLoJMFnrcbGOkuILVmX08WwmXOAqQtXTsxMk6yOq2TcBcpJowPSoGS5SEB+O5w X-Received: by 2002:a65:62d6:: with SMTP id m22mr31889770pgv.443.1553640007114; Tue, 26 Mar 2019 15:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553640007; cv=none; d=google.com; s=arc-20160816; b=GeA8d5Ml4cIqmd6LUiMwW8mZOspH3qAeH+9jLiKq2OkFS+L3G1xGPqfXLoPeR3iMea ZoR0biPdx0y4L+39zxF1ZJi/0U9cigHrtZfCLuQW5OvYoftlS/SZpkS7bEV045e2iKzC rSho/CDrIMskTxdpEKLfaYPCtMkixZXcbV1kforUEFsWhT/oK2oU13wi/NVwKF+z5dG2 agcXByQGGFAcXuxCIeZ9o1cM2mA8yJqJz+S6mjKz+1JXNxw6bpCfOvR3j25bP4mokTnV BHPXYdV5P4wCQpZmpxJegYFfrprQacV6fSLHXBcIYzmTeM1Jqpz/IBuaBFD4Lg7QC3wM L4Ow== 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=5bqBHOeQS0gDMFENg7zJG5tqRoVyjsr4QLO+wlepYV0=; b=MFLPMpEVYL8OPgVv18pDbUuJkUWCJYZozu5sd0iYL03/JcM33cprqEfgoEsPOo+Zwt eU+q0KzftRlqTVNkNN/VgIgCRZCcNNx+HoiyFDXtc5i4AZXZ3jv9DIsuWPjt0Kvi07IJ fVOLiO1yZGeFwea0hPbk8Xq0jUQuRS1Bw2qwsCSLi1VOEJo+pGkYZy3U3GQMp9Jz5ezY f0zBV8rz4NCe8mx4qb9/V2q/tUlI85kJSfPeKbmoFJp08MdeLDj5ooMgz9UIcuvC6uk9 KHJa1vBbKG55gbIeyvT0s0TXeeuzLuHbOFsmxixm7irewEo/E5/s18tcW7/UVKEzHETE 68fA== ARC-Authentication-Results: i=1; mx.google.com; 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 b9si16243084pfd.228.2019.03.26.15.40.06; Tue, 26 Mar 2019 15:40:07 -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; 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 S1731868AbfCZWj4 (ORCPT + 31 others); Tue, 26 Mar 2019 18:39:56 -0400 Received: from foss.arm.com ([217.140.101.70]:44482 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726782AbfCZWjy (ORCPT ); Tue, 26 Mar 2019 18:39:54 -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 852C71596; Tue, 26 Mar 2019 15:39:54 -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 E6DC03F614; Tue, 26 Mar 2019 15:39:53 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, sudeep.holla@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, linuxarm@huawei.com, Jeremy Linton Subject: [PATCH 1/4] ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens Date: Tue, 26 Mar 2019 17:39:35 -0500 Message-Id: <20190326223938.5365-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190326223938.5365-1-jeremy.linton@arm.com> References: <20190326223938.5365-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.20.1 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 065c4fc245d1..472c95ec816b 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() - Determine a unique implementation + * @cpu: Kernel logical cpu number + * + * Determine a unique heterogeneous ID for the given CPU. CPUs with the same + * implementation should have matching IDs. Since this is a tree we can only + * detect implementations where the heterogeneous flag is the parent to all + * matching cores. AKA if a two socket machine has two different core types + * in each socket this will end up being represented as four unique core types + * rather than two. + * + * The returned ID 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. + * + * 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 Tue Mar 26 22:39:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 161236 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5766215jan; Tue, 26 Mar 2019 15:40:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPhpDvZvToKyUvSm19mMMVxDziyLVyI4XGuWZUsezr5+KU1VdNlmWOdmLwt+h+/C7GjT2Z X-Received: by 2002:a63:5ec2:: with SMTP id s185mr30889970pgb.27.1553640011976; Tue, 26 Mar 2019 15:40:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553640011; cv=none; d=google.com; s=arc-20160816; b=EQ/2Bo/lITVihuxjRB2lohTyK6GKnk2r7hs1DoN+gZrLzVhHQFz1VgzMDzHkDPS8Ut taALgoFe5jnntSDEaSUG+wHfrm/FQQ2TZH1+P7Y59rB6TVUcSoFzYEdH9ejAT5DeQ8wR 0KPE+xt/2wSU/LVmc16tmgApNsLcfshhqpn89Hqv2yITjyS3ZmB/L37Hbo6aIHkddxgZ vDmfx3YmcwsugJ5ghAoV82FKgDSEI8vaXVIVbJjtSbCnRYEaqZm49e6Iymc3dijAQwgl Osm+sEkwgkSJos1RWN8SdRd08xB98aiBSuuqQUuwlDUPqAQEmK6EQe2j2nhGyKSi8UsR hJVQ== 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=7m9CA3axMMtROXpVsOpihCVHu6VNokCXPEI/paARcnE=; b=ANVkiFAV7A0putEEC7Rv/fSx0UuqOaY4jlkVilrl95Ub7430022MwPggdV3GCV8NO7 Rqif2pUJX+xkS2GQsDECgEFkmZMpanDoW144eyAa7QeqqMad0BPjGk7RMc7uTx9xVepi IuJg76el25CJUNoYmD19P9Qh3YUOqAmfG0BVbFxweVsU/DmzhA/GlJbeg77+WBdK3XFu IWTMPy72APBkMhWbaOnswszKDct/KJiGL9cxatRujV8eUuvLB8dXXSUpqTv8UEyg2JIY j5JYoQs0d+Y0/kiLTQqU45M7DR0DCwsVSkK84WOU1wMiZT3Bc/EbfOUyefS2h+7yS2yC zPJg== ARC-Authentication-Results: i=1; mx.google.com; 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 j188si17466365pfb.75.2019.03.26.15.40.11; Tue, 26 Mar 2019 15:40:11 -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; 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 S1732407AbfCZWkK (ORCPT + 31 others); Tue, 26 Mar 2019 18:40:10 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44494 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731707AbfCZWj4 (ORCPT ); Tue, 26 Mar 2019 18:39:56 -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 BEC33165C; Tue, 26 Mar 2019 15:39:55 -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 2A8F43F614; Tue, 26 Mar 2019 15:39:55 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, sudeep.holla@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, linuxarm@huawei.com, Jeremy Linton Subject: [PATCH 2/4] ACPI/PPTT: Modify node flag detection to find last IDENTICAL Date: Tue, 26 Mar 2019 17:39:36 -0500 Message-Id: <20190326223938.5365-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190326223938.5365-1-jeremy.linton@arm.com> References: <20190326223938.5365-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. To achieve this with the existing code we need to pass a function through the tree traversal logic so we can check the next node to assure that IDENTICAL isn't set before returning a node with IDENTICAL set. Signed-off-by: Jeremy Linton --- drivers/acpi/pptt.c | 62 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 14 deletions(-) -- 2.20.1 diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 472c95ec816b..db18510346f9 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -432,17 +432,51 @@ static void cache_setup_acpi_cpu(struct acpi_table_header *table, } } + +typedef bool (*node_check)(struct acpi_table_header *table_hdr, + struct acpi_pptt_processor *cpu); +static bool flag_package(struct acpi_table_header *table_hdr, + struct acpi_pptt_processor *cpu) +{ + return cpu->flags & ACPI_PPTT_PHYSICAL_PACKAGE; +} + +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; +} + +static bool flag_none(struct acpi_table_header *table_hdr, + struct acpi_pptt_processor *cpu) +{ + 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, - struct acpi_pptt_processor *cpu, - int level, int flag) +static struct acpi_pptt_processor *acpi_find_processor_tag_id(struct acpi_table_header *table_hdr, + struct acpi_pptt_processor *cpu, + int level, node_check chk) { struct acpi_pptt_processor *prev_node; while (cpu && level) { - if (cpu->flags & flag) + if (chk(table_hdr, cpu)) break; pr_debug("level %d\n", level); prev_node = fetch_pptt_node(table_hdr, cpu->parent); @@ -473,15 +507,15 @@ static void acpi_pptt_warn_missing(void) * 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) + unsigned int cpu, int level, node_check chk) { struct acpi_pptt_processor *cpu_node; u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); cpu_node = acpi_find_processor_node(table, acpi_cpu_id); if (cpu_node) { - cpu_node = acpi_find_processor_package_id(table, cpu_node, - level, flag); + cpu_node = acpi_find_processor_tag_id(table, cpu_node, + level, chk); /* * As per specification if the processor structure represents * an actual processor, then ACPI processor ID must be valid. @@ -498,7 +532,7 @@ static int topology_get_acpi_cpu_tag(struct acpi_table_header *table, return -ENOENT; } -static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) +static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, node_check chk) { struct acpi_table_header *table; acpi_status status; @@ -509,7 +543,7 @@ static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int flag) acpi_pptt_warn_missing(); return -ENOENT; } - retval = topology_get_acpi_cpu_tag(table, cpu, level, flag); + retval = topology_get_acpi_cpu_tag(table, cpu, level, chk); pr_debug("Topology Setup ACPI cpu %d, level %d ret = %d\n", cpu, level, retval); acpi_put_table(table); @@ -601,7 +635,7 @@ int cache_setup_acpi(unsigned int cpu) */ int find_acpi_cpu_topology(unsigned int cpu, int level) { - return find_acpi_cpu_topology_tag(cpu, level, 0); + return find_acpi_cpu_topology_tag(cpu, level, flag_none); } /** @@ -658,7 +692,7 @@ int find_acpi_cpu_cache_topology(unsigned int cpu, int level) int find_acpi_cpu_topology_package(unsigned int cpu) { return find_acpi_cpu_topology_tag(cpu, PPTT_ABORT_PACKAGE, - ACPI_PPTT_PHYSICAL_PACKAGE); + flag_package); } /** @@ -674,8 +708,8 @@ int find_acpi_cpu_topology_package(unsigned int cpu) * * The returned ID 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. + * The search terminates when a level is found without the identical + * implementation flag set following a node with it set, or we reach the root. * * 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 @@ -684,5 +718,5 @@ int find_acpi_cpu_topology_package(unsigned int 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); + flag_identical); } From patchwork Tue Mar 26 22:39:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 161235 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5766169jan; Tue, 26 Mar 2019 15:40:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzriplHNs8s+lwDDmsKvOmW4AdS/rM6cF4sk70W1sqOGR7hBJ1aQaz5tPNgO+BKaBFarByX X-Received: by 2002:a17:902:b58f:: with SMTP id a15mr19537028pls.36.1553640007478; Tue, 26 Mar 2019 15:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553640007; cv=none; d=google.com; s=arc-20160816; b=gBiJBM+/rKo/vGVCHG91FYNA9wr3N8QoO9PpegPP8Am9kjiTJFrtJLgp5+deqfupBH VqCfs+zS7/LhTggoXwoqYkgDzQFn7tNLtLaZiYMG/NXCceMD1BSWyxOoeo6SimMUFWfL ou96fwb0jeq8pDSwGVuXJz9xTB3q0jIJcTbNvkV+d8Jp2Iibnw1FXAGiaVS+KJSRItCG ohUqboZsam1QN0bIm87aWxIaiiJfUBGH2EN9mXVVxnFcZfQC5Fs7HEFBAMCWY60NmHVK eGw7Tl1qlvEVkF86cmXTFTSPRQGNTHk+UsQybF1K6LuPSkQQnEp24Oys4uOZCKuF2Mv+ +FGQ== 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=lZQhCPtni8aaOP+OEH9YfW3qq14wlIvFUy66wuPXgJw=; b=Yb8y4PCaQLtut46e8pRsL4P8UJrPOWjYgbX2NU3X80iYoRIXCg4YdnGB+og7uTtBw7 Z3mj3gIZmiK7g1hJwX3LgRmPdF7zS1Uj0JfM/pJbL8WnN5btivGB3KdwaN9uvefyHdxm 1Zi4QheD4KIsPRysNvz0rbikflkTwYpmnyp8NE8fJRukXP5OoxD2TcBqQlJpLhMpdxrL i1Nfqo1F+tSuGUtKgJIX5G84KOeQDnO1jOVcEP2+C+V4SRh6Lz9xM9mZks4CjGs0lG76 uOc4R4gd8VvCpGwjMy/NEpKEiIvk3eH0lEx7t8LCFa88MIoCUhrwDnKZW0Dv+Wi45r9U +jTg== ARC-Authentication-Results: i=1; mx.google.com; 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 b9si16243084pfd.228.2019.03.26.15.40.07; Tue, 26 Mar 2019 15:40:07 -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; 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 S1732157AbfCZWj7 (ORCPT + 31 others); Tue, 26 Mar 2019 18:39:59 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44508 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726782AbfCZWj5 (ORCPT ); Tue, 26 Mar 2019 18:39:57 -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 F158A1682; Tue, 26 Mar 2019 15:39:56 -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 5ED093F614; Tue, 26 Mar 2019 15:39:56 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, sudeep.holla@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, linuxarm@huawei.com, Jeremy Linton Subject: [PATCH 3/4] arm_pmu: acpi: spe: Add initial MADT/SPE probing Date: Tue, 26 Mar 2019 17:39:37 -0500 Message-Id: <20190326223938.5365-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190326223938.5365-1-jeremy.linton@arm.com> References: <20190326223938.5365-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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/arm_pmu_acpi.c | 69 +++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) -- 2.20.1 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/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c index 0f197516d708..a2418108eab2 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -74,6 +74,73 @@ static void arm_pmu_acpi_unregister_irq(int cpu) acpi_unregister_gsi(gsi); } +static struct resource spe_resources[] = { + { + /* irq */ + .flags = IORESOURCE_IRQ, + } +}; + +static struct platform_device spe_dev = { + .name = "arm,spe-v1", + .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_parse_irqs(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; +} + static int arm_pmu_acpi_parse_irqs(void) { int irq, cpu, irq_cpu, err; @@ -279,6 +346,8 @@ static int arm_pmu_acpi_init(void) if (acpi_disabled) return 0; + arm_spe_acpi_parse_irqs(); /* failures are expected */ + ret = arm_pmu_acpi_parse_irqs(); if (ret) return ret; From patchwork Tue Mar 26 22:39:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 161234 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp5766172jan; Tue, 26 Mar 2019 15:40:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPstG8yN1p90+q+G3SqaKWjmofTLsbpTkz4HgqaO38aL1sB0eYt5zm/T1POZ7rm+i/BOpB X-Received: by 2002:a62:1881:: with SMTP id 123mr31907228pfy.25.1553640007825; Tue, 26 Mar 2019 15:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553640007; cv=none; d=google.com; s=arc-20160816; b=JaLmvkRANHlbNTp3CQcKfWWp2rsv6Rf7q7JhhdmlCZ8RZsMT3CNHWHvSfG7w9qu89G zJNGW6GLhAt+kuf4GbxcZUtIcWylLFBYy/trmiJbXUo3ChjgcnreKxYqSeXtlEgguEnR Wqe2GEKRTOU0bwcOuvmMIrWUVU5HqkkkHxhRKUy1k/YETEoillyzH+02J4tRIoaikM2Q zUpYuZQGvDwadwOrInRoLucOSEC0eXwr4rhy1CZiTc7dUx6L+6qXkJFSRosQnaf0hGZO f1rmVDjW1xlAi7bpu0Jv7F3X/B43kTPJdBIiT5BUuSDHbDj/ebRaSAsJ0D6Herdjq7sz iYlQ== 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=tJYayjolUeY/f2xvJECwoZvWJY7Jnc6kgT76w6ge4sc=; b=z4z5KPWkdnRdKw6hPMzITfgs34Rc6OyhHxVur32zd7No+PBiUxTjooHloyox9T28j4 o4lhDh+yXfGnUCHIlNLGuVraRuiuSPjPoxMoLqRUkapYo7IFfWX1YF6oPwSXwWGGF28K GxZn7iAXLo77i/5nrwOH7/DvZNPXZxpLmWF0K1KBcJg2jCXJXtCWso8wWqjH7IwfJL8d r54v9XB750gZdnJuTOxz7PJFDjPVuohjLPIuMm7+PTQXYxx/Aa/16F7Ira0k8s0MyuYs MqflY3mfaJwDUzyavdZDOvDIQkZCKhonDKdsf0COKfqlRi7RXr+F9bOAzbQ2oOX9ulTk wMDw== ARC-Authentication-Results: i=1; mx.google.com; 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 b9si16243084pfd.228.2019.03.26.15.40.07; Tue, 26 Mar 2019 15:40:07 -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; 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 S1732316AbfCZWkE (ORCPT + 31 others); Tue, 26 Mar 2019 18:40:04 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44520 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731912AbfCZWj6 (ORCPT ); Tue, 26 Mar 2019 18:39:58 -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 36E68169E; Tue, 26 Mar 2019 15:39:58 -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 8FB903F614; Tue, 26 Mar 2019 15:39:57 -0700 (PDT) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, mark.rutland@arm.com, sudeep.holla@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, linuxarm@huawei.com, Jeremy Linton Subject: [PATCH 4/4] perf: arm_spe: Enable ACPI/Platform automatic module loading Date: Tue, 26 Mar 2019 17:39:38 -0500 Message-Id: <20190326223938.5365-5-jeremy.linton@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190326223938.5365-1-jeremy.linton@arm.com> References: <20190326223938.5365-1-jeremy.linton@arm.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 7cb766dafe85..ffa2c76c08bb 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -1176,7 +1176,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[] = { + { "arm,spe-v1", 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 +1242,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, };