From patchwork Tue Aug 27 02:02:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 1153534 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46HXFR58Dtz9sDQ; Tue, 27 Aug 2019 12:02:35 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1i2QoZ-000518-HJ; Tue, 27 Aug 2019 02:02:31 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1i2QoX-00050g-GN for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2019 02:02:29 +0000 Received: from mail-io1-f69.google.com ([209.85.166.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1i2QoX-00036C-21 for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2019 02:02:29 +0000 Received: by mail-io1-f69.google.com with SMTP id q5so25161717iof.19 for ; Mon, 26 Aug 2019 19:02:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vXn8rB8Hlt2VUQpUKTzay+0lz94auiHtBwHD0plB5BI=; b=Wphqu+euhYO1xYo2OqG5ROTGmPeH7g3k+GvGdJApuzNDhVgb1P0MSJswuIkr7GodE+ uA7MSRxkNxcU/ao2svm15FggnC/ynmEHNpKlM2uSqDXxlL4+VNbeUoXOKY9NNFQzhAy2 vXQcnfPXQgTjhXOObRgqwjyWIMWgzubzWQnYqMcftkx7GwgOiQ8Lnpkmetnge8rxSUBK ioAzoL2V2zelXYT+kSRYwajQTCu11khd7byuyNfADSY7PHNKHFMBDK81XBUnKMt3Zci8 ETal4vqhOLcsTBqHA8hDVFucPXXhy1k1VU5eprv3Md7F1goGdAZucGE9bzsHuSESwRWx spkw== X-Gm-Message-State: APjAAAWpB1DNgQq4jWESciYB0qO031Sqiy1wF5Dv5CTsJIUb4H2O5/74 QcBlT/I7u5sP5YbyhfvNfm+IXmhHveYw69whcnbrlF+tOzejsW/IrpRJfkCfW6CPVLatDF+hUlA j/zZH8hbJrtXFXukqY7woN92GrCoY/B84vLm88/oAVg== X-Received: by 2002:a02:4047:: with SMTP id n68mr21591178jaa.10.1566871347905; Mon, 26 Aug 2019 19:02:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0dlZQ/8gccHg6Em4x4zhwkN4GNxdtMjqBootKGQIKAYTy07OpxTzLJyHHrl/WtFFzG4cFzQ== X-Received: by 2002:a02:4047:: with SMTP id n68mr21591165jaa.10.1566871347623; Mon, 26 Aug 2019 19:02:27 -0700 (PDT) Received: from xps13.canonical.com (c-71-56-235-36.hsd1.co.comcast.net. [71.56.235.36]) by smtp.gmail.com with ESMTPSA id j18sm5741931ioo.14.2019.08.26.19.02.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 19:02:27 -0700 (PDT) From: dann frazier To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/4][Eoan] ACPI/PPTT: Modify node flag detection to find last IDENTICAL Date: Mon, 26 Aug 2019 20:02:16 -0600 Message-Id: <20190827020219.15242-2-dann.frazier@canonical.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827020219.15242-1-dann.frazier@canonical.com> References: <20190827020219.15242-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jeremy Linton BugLink: https://bugs.launchpad.net/bugs/1841490 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. Acked-by: Rafael J. Wysocki Tested-by: Hanjun Guo Reviewed-by: Sudeep Holla Signed-off-by: Jeremy Linton Signed-off-by: Will Deacon (cherry picked from commit ed2b664fcc8073c09394393756df3fc86977bbac) Signed-off-by: dann frazier --- drivers/acpi/pptt.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index b72e6afaa8fb9..05344413f1997 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -432,17 +432,40 @@ 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, - struct acpi_pptt_processor *cpu, - int level, int flag) +static struct acpi_pptt_processor *acpi_find_processor_tag(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) + /* special case the identical flag to find last identical */ + 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,8 +503,8 @@ 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, - level, flag); + cpu_node = acpi_find_processor_tag(table, cpu_node, + level, flag); /* * As per specification if the processor structure represents * an actual processor, then ACPI processor ID must be valid. From patchwork Tue Aug 27 02:02:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 1153536 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46HXFS5RHPz9sMr; Tue, 27 Aug 2019 12:02:36 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1i2Qoa-00051j-OZ; Tue, 27 Aug 2019 02:02:32 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1i2QoY-000511-Q9 for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2019 02:02:30 +0000 Received: from mail-io1-f71.google.com ([209.85.166.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1i2QoY-00036F-Cc for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2019 02:02:30 +0000 Received: by mail-io1-f71.google.com with SMTP id q26so25185634ioi.10 for ; Mon, 26 Aug 2019 19:02:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GyXjsHqwLA70RhRfWh4AOD+N8LWysKIva9LBoyRTr5I=; b=Ryc5hHm8fv1JgS9hHVWHdyuTD1TRKEZ0U92b19zdmxmlFwKLxIP3q5xTMEJPE/e09A FiCrVsl72rqKP+/dtw6oEtxSZQpsz2OobGV4UPKZtbQBm8RAwu0+DSgdYxorXu+3rjmL c979Oy5YD+GN3neElQ12/0LY98W696zhnw870gslAbhI+YVp+IVp5DSVFQsg5TM+dQrg Vx/Zz/83VkydtIBlqnxtPdodUquncR+1e5glfrzOBnfV83khxXZiivXPnh2jXtwa2iJQ 7EAGQScftjufi8YdH5Myw47b4fYh9sGbP5rflPlbom684+OTraBzMgZaex/NKkZWWTzo 102A== X-Gm-Message-State: APjAAAXpkXPkJUwv3hmsQEveLiu8eT4jw4af09Zm/c3Z1WgG+pWLHGvD vxYjs9o3oCRnPACWQeyBN+Fp1MnWSsJKYTmQV4c8aiHj+2Zlie7O1JnElLtzy0V1BxouDHlXcjO xtT5fJMEk/d7OC9VkJkxggK0E5jtCjE84W8RuNRSMTQ== X-Received: by 2002:a6b:6812:: with SMTP id d18mr2937062ioc.239.1566871349249; Mon, 26 Aug 2019 19:02:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZp7/H/HOqkvn/bYfMO0QY6qgmwzBppS1zg8wYnoXVq2lB6pbXaTf4JpMYzcvslbwYQD2S4w== X-Received: by 2002:a6b:6812:: with SMTP id d18mr2937042ioc.239.1566871348993; Mon, 26 Aug 2019 19:02:28 -0700 (PDT) Received: from xps13.canonical.com (c-71-56-235-36.hsd1.co.comcast.net. [71.56.235.36]) by smtp.gmail.com with ESMTPSA id p3sm10895047iom.7.2019.08.26.19.02.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 19:02:28 -0700 (PDT) From: dann frazier To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/4][Eoan] ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens Date: Mon, 26 Aug 2019 20:02:17 -0600 Message-Id: <20190827020219.15242-3-dann.frazier@canonical.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827020219.15242-1-dann.frazier@canonical.com> References: <20190827020219.15242-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jeremy Linton BugLink: https://bugs.launchpad.net/bugs/1841490 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. Acked-by: Rafael J. Wysocki Tested-by: Hanjun Guo Reviewed-by: Sudeep Holla Signed-off-by: Jeremy Linton Signed-off-by: Will Deacon (cherry picked from commit 56855a99f3d0d1e9f1f4e24f5851f9bf14c83296) Signed-off-by: dann frazier --- drivers/acpi/pptt.c | 26 ++++++++++++++++++++++++++ include/linux/acpi.h | 5 +++++ 2 files changed, 31 insertions(+) diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 05344413f1997..1e7ac0bd0d3a0 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -683,3 +683,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 872ab208c8ad8..b2c8d6f21d68f 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1306,6 +1306,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) @@ -1316,6 +1317,10 @@ static inline int find_acpi_cpu_topology_package(unsigned int cpu) { return -EINVAL; } +static inline 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 Aug 27 02:02:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 1153537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46HXFW0lWCz9sBF; Tue, 27 Aug 2019 12:02:38 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1i2Qod-00053R-Ah; Tue, 27 Aug 2019 02:02:35 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1i2Qoa-00051b-Nk for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2019 02:02:32 +0000 Received: from mail-io1-f69.google.com ([209.85.166.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1i2QoZ-00036R-Tb for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2019 02:02:32 +0000 Received: by mail-io1-f69.google.com with SMTP id h7so19990738ioj.5 for ; Mon, 26 Aug 2019 19:02:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oBsCm+fz61SoPCsZ75w7LIoI4DxN6JhGmz4tWDwH6oM=; b=hzsFAN9XQn9RHH6KNuHtrWWS3Mu/rfuL7EZnUekwP5tGEqT63Cf0Rk3z8q9mRfOopS gRrv1FacliYWkdwFNymLR9GLpYwBwyo2+6eIfdAT1VGA9UAUvfQMeq7fkvk6MgTZoVTx vD4jhIw8fuO/y23JuCDNEUPsZDi0J8UGFiqJJDHJo0cNqiPDun0IPidF1Z6ENOADoaCy rGG/zYlvY3fSQLB+PfN63AnfW618q106Xr76dRX7nfIKE6GQ3OX4fvEj9JFdb48hehRs YTq3IYfeG9NynTF7+EyILcmI6ak33Fle/Xu9ZY7IV6xkYts6sFLR8zC2gSUilJlZl25g /gmg== X-Gm-Message-State: APjAAAXpR8GLp/rByUaPp4GgVcvO6LsEFpVfs+IZnljUvpgZbJ8M2d4Q eZsmij/n/+RsfntSHfqlHfxOFQ+eeYsDNToSBtT15g3NNTsDPvN2dvaS4RgRck1oDjNhSM75jTy b8gUMb35Isw1DkWe5Owtv2/tMP57NvjEWmxpPaxFdzQ== X-Received: by 2002:a02:caa8:: with SMTP id e8mr20392204jap.67.1566871350621; Mon, 26 Aug 2019 19:02:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqySFibkVFIgRXwduFqK4EoLzx/2L1f5WpYPgpSxndWtTK+FItwQuspZ8oCEPOp2kagWXZyuVQ== X-Received: by 2002:a02:caa8:: with SMTP id e8mr20392190jap.67.1566871350284; Mon, 26 Aug 2019 19:02:30 -0700 (PDT) Received: from xps13.canonical.com (c-71-56-235-36.hsd1.co.comcast.net. [71.56.235.36]) by smtp.gmail.com with ESMTPSA id q8sm11221120ion.82.2019.08.26.19.02.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 19:02:29 -0700 (PDT) From: dann frazier To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/4][Eoan] arm_pmu: acpi: spe: Add initial MADT/SPE probing Date: Mon, 26 Aug 2019 20:02:18 -0600 Message-Id: <20190827020219.15242-4-dann.frazier@canonical.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827020219.15242-1-dann.frazier@canonical.com> References: <20190827020219.15242-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jeremy Linton BugLink: https://bugs.launchpad.net/bugs/1841490 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. Tested-by: Hanjun Guo Reviewed-by: Sudeep Holla Reviewed-by: Lorenzo Pieralisi Signed-off-by: Jeremy Linton Signed-off-by: Will Deacon (cherry picked from commit d24a0c7099b32b6981d7f126c45348e381718350) Signed-off-by: dann frazier --- arch/arm64/include/asm/acpi.h | 3 ++ drivers/perf/arm_pmu_acpi.c | 72 +++++++++++++++++++++++++++++++++++ include/linux/perf/arm_pmu.h | 2 + 3 files changed, 77 insertions(+) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index ada0bc480a1b2..b263e239cb599 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -38,6 +38,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 d2c2978409d24..acce8781c456c 100644 --- a/drivers/perf/arm_pmu_acpi.c +++ b/drivers/perf/arm_pmu_acpi.c @@ -71,6 +71,76 @@ static void arm_pmu_acpi_unregister_irq(int cpu) acpi_unregister_gsi(gsi); } +#if IS_ENABLED(CONFIG_ARM_SPE_PMU) +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 void arm_spe_acpi_register_device(void) +{ + int cpu, hetid, irq, ret; + bool first = true; + u16 gsi = 0; + + /* + * 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) { + struct acpi_madt_generic_interrupt *gicc; + + gicc = acpi_cpu_get_madt_gicc(cpu); + if (gicc->header.length < ACPI_MADT_GICC_SPE) + return; + + if (first) { + gsi = gicc->spe_interrupt; + if (!gsi) + return; + 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; + } + } + + 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; + } + + 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); + } +} +#else +static inline void arm_spe_acpi_register_device(void) +{ +} +#endif /* CONFIG_ARM_SPE_PMU */ + static int arm_pmu_acpi_parse_irqs(void) { int irq, cpu, irq_cpu, err; @@ -276,6 +346,8 @@ static int arm_pmu_acpi_init(void) if (acpi_disabled) return 0; + arm_spe_acpi_register_device(); + 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 a9b0ee408fbd4..71f525a35ac2b 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -171,4 +171,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 Tue Aug 27 02:02:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 1153538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46HXFY120nz9sDB; Tue, 27 Aug 2019 12:02:41 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1i2Qoe-00054N-RY; Tue, 27 Aug 2019 02:02:36 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1i2Qoc-00052s-4u for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2019 02:02:34 +0000 Received: from mail-io1-f69.google.com ([209.85.166.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1i2Qob-00036b-ID for kernel-team@lists.ubuntu.com; Tue, 27 Aug 2019 02:02:33 +0000 Received: by mail-io1-f69.google.com with SMTP id k13so25121455ioh.16 for ; Mon, 26 Aug 2019 19:02:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R1bN6k0AlWaXvXX9B0S3pOYqult4vwG6HmJD07juTsM=; b=cuUnl/40ixhjSPLrtgKXPI/dxw8/0uOnlPwe7H3d44PKN+brkTfKtE80PSDa4VSIjO nrJ+hECKrEK+dyYrVHl3gdF7Ah7DaoZGQ/LUOFsyVT5t5oe99igYwKnCEWyi/WijnZUm r2lXHcfqTLomOdiooNYCXfZtVox+lE4QPMc3Vzm85/CZmeWVl8azW2sTitxv97Igsp27 aPzoEIuBBSELEhnJ/Bi5wkUHpNsudisSqyva73F4ah6FIkgw8fNGdNq05jhv92f6hYS6 nHpqQF3imi5IgGxBcWnmyKfoTLK+3FWo7ps9vMNRrjJvuuLoZA4dBnDzvNXRuvRCEarr ovWg== X-Gm-Message-State: APjAAAUaJuvNy5seYSLCUJi/wXRfLJSTpLbJFARf2dUbRZyYMQSSy8a0 bGmZY1UupcDHYNHkCKV5HkUo+xKq1yLr6Xkz/WOLVk2IdYVbRX9dC0VNQfQYaC5FM6eJe6odb3w 4RDyQ8Ynwuf9iHIsPJUSU2uNrY6hR8BjIAEv1EK3uFg== X-Received: by 2002:a6b:6010:: with SMTP id r16mr16512362iog.124.1566871352379; Mon, 26 Aug 2019 19:02:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCl6c07NWZPDzx4I690IvClYU8Ixsk4W99SvQiN8Qmnllvhb7WigDTgdApJaL9xivxI2mY8w== X-Received: by 2002:a6b:6010:: with SMTP id r16mr16512343iog.124.1566871352102; Mon, 26 Aug 2019 19:02:32 -0700 (PDT) Received: from xps13.canonical.com (c-71-56-235-36.hsd1.co.comcast.net. [71.56.235.36]) by smtp.gmail.com with ESMTPSA id z9sm19262203ior.79.2019.08.26.19.02.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 19:02:31 -0700 (PDT) From: dann frazier To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/4][Eoan] perf: arm_spe: Enable ACPI/Platform automatic module loading Date: Mon, 26 Aug 2019 20:02:19 -0600 Message-Id: <20190827020219.15242-5-dann.frazier@canonical.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827020219.15242-1-dann.frazier@canonical.com> References: <20190827020219.15242-1-dann.frazier@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Jeremy Linton BugLink: https://bugs.launchpad.net/bugs/1841490 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. Tested-by: Hanjun Guo Reviewed-by: Sudeep Holla Signed-off-by: Jeremy Linton Signed-off-by: Will Deacon (cherry picked from commit d482e575fbf0f7ec9319bded951f21bbc84312bf) Signed-off-by: dann frazier --- drivers/perf/arm_spe_pmu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index 49b4909252555..4e4984a55cd1b 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -1157,7 +1158,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; @@ -1217,11 +1224,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, };