[PATCH 0/4][Eoan] perf: Add ACPI support for the ARMv8.3 Statistical Profiling Extension

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/4][Eoan] perf: Add ACPI support for the ARMv8.3 Statistical Profiling Extension

dann frazier-4
BugLink: https://bugs.launchpad.net/bugs/1841490

All clean cherry-picks from upstream. This series is for Eoan. Disco requires
a couple additional patches - I'll submit a Disco series In-Reply-To this
cover letter as well.

Jeremy Linton (4):
  ACPI/PPTT: Modify node flag detection to find last IDENTICAL
  ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens
  arm_pmu: acpi: spe: Add initial MADT/SPE probing
  perf: arm_spe: Enable ACPI/Platform automatic module loading

 arch/arm64/include/asm/acpi.h |  3 ++
 drivers/acpi/pptt.c           | 61 ++++++++++++++++++++++++++---
 drivers/perf/arm_pmu_acpi.c   | 72 +++++++++++++++++++++++++++++++++++
 drivers/perf/arm_spe_pmu.c    | 12 +++++-
 include/linux/acpi.h          |  5 +++
 include/linux/perf/arm_pmu.h  |  2 +
 6 files changed, 147 insertions(+), 8 deletions(-)

--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/4][Eoan] ACPI/PPTT: Modify node flag detection to find last IDENTICAL

dann frazier-4
From: Jeremy Linton <[hidden email]>

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 <[hidden email]>
Tested-by: Hanjun Guo <[hidden email]>
Reviewed-by: Sudeep Holla <[hidden email]>
Signed-off-by: Jeremy Linton <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit ed2b664fcc8073c09394393756df3fc86977bbac)
Signed-off-by: dann frazier <[hidden email]>
---
 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.
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/4][Eoan] ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens

dann frazier-4
In reply to this post by dann frazier-4
From: Jeremy Linton <[hidden email]>

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 <[hidden email]>
Tested-by: Hanjun Guo <[hidden email]>
Reviewed-by: Sudeep Holla <[hidden email]>
Signed-off-by: Jeremy Linton <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit 56855a99f3d0d1e9f1f4e24f5851f9bf14c83296)
Signed-off-by: dann frazier <[hidden email]>
---
 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;
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/4][Eoan] arm_pmu: acpi: spe: Add initial MADT/SPE probing

dann frazier-4
In reply to this post by dann frazier-4
From: Jeremy Linton <[hidden email]>

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 <[hidden email]>
Reviewed-by: Sudeep Holla <[hidden email]>
Reviewed-by: Lorenzo Pieralisi <[hidden email]>
Signed-off-by: Jeremy Linton <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit d24a0c7099b32b6981d7f126c45348e381718350)
Signed-off-by: dann frazier <[hidden email]>
---
 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__ */
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 4/4][Eoan] perf: arm_spe: Enable ACPI/Platform automatic module loading

dann frazier-4
In reply to this post by dann frazier-4
From: Jeremy Linton <[hidden email]>

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 <[hidden email]>
Reviewed-by: Sudeep Holla <[hidden email]>
Signed-off-by: Jeremy Linton <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit d482e575fbf0f7ec9319bded951f21bbc84312bf)
Signed-off-by: dann frazier <[hidden email]>
---
 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 <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/perf_event.h>
+#include <linux/perf/arm_pmu.h>
 #include <linux/platform_device.h>
 #include <linux/printk.h>
 #include <linux/slab.h>
@@ -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,
 };
 
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/6][SRU Disco] perf: Add ACPI support for the ARMv8.3 Statistical Profiling Extension

dann frazier-4
In reply to this post by dann frazier-4
BugLink: https://bugs.launchpad.net/bugs/1841490

All clean cherry-picks from upstream. This series is for Disco.

Erik Schmauss (2):
  ACPICA: ACPI 6.3: MADT: add support for statistical profiling in GICC
  ACPICA: ACPI 6.3: PPTT add additional fields in Processor Structure
    Flags

Jeremy Linton (4):
  ACPI/PPTT: Modify node flag detection to find last IDENTICAL
  ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens
  arm_pmu: acpi: spe: Add initial MADT/SPE probing
  perf: arm_spe: Enable ACPI/Platform automatic module loading

 arch/arm64/include/asm/acpi.h |  3 ++
 drivers/acpi/pptt.c           | 61 ++++++++++++++++++++++++++---
 drivers/perf/arm_pmu_acpi.c   | 72 +++++++++++++++++++++++++++++++++++
 drivers/perf/arm_spe_pmu.c    | 12 +++++-
 include/acpi/actbl2.h         | 12 ++++--
 include/linux/acpi.h          |  5 +++
 include/linux/perf/arm_pmu.h  |  2 +
 7 files changed, 155 insertions(+), 12 deletions(-)

--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/6][SRU Disco] ACPICA: ACPI 6.3: MADT: add support for statistical profiling in GICC

dann frazier-4
From: Erik Schmauss <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1841490

ACPICA commit 31b184052a986dc8d80c878edeca574d4ffa1cf5

Link: https://github.com/acpica/acpica/commit/31b18405
Signed-off-by: Erik Schmauss <[hidden email]>
Signed-off-by: Bob Moore <[hidden email]>
Signed-off-by: Rafael J. Wysocki <[hidden email]>
(cherry picked from commit e646e0a50cfadae315f2db05e07a2ec072ce8d9c)
Signed-off-by: dann frazier <[hidden email]>
---
 include/acpi/actbl2.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index c50ef7e6b9425..03d924ec835f9 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -623,7 +623,7 @@ struct acpi_madt_local_x2apic_nmi {
  u8 reserved[3]; /* reserved - must be zero */
 };
 
-/* 11: Generic Interrupt (ACPI 5.0 + ACPI 6.0 changes) */
+/* 11: Generic interrupt - GICC (ACPI 5.0 + ACPI 6.0 + ACPI 6.3 changes) */
 
 struct acpi_madt_generic_interrupt {
  struct acpi_subtable_header header;
@@ -641,7 +641,8 @@ struct acpi_madt_generic_interrupt {
  u64 gicr_base_address;
  u64 arm_mpidr;
  u8 efficiency_class;
- u8 reserved2[3];
+ u8 reserved2[1];
+ u16 spe_interrupt; /* ACPI 6.3 */
 };
 
 /* Masks for Flags field above */
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/6][SRU Disco] ACPICA: ACPI 6.3: PPTT add additional fields in Processor Structure Flags

dann frazier-4
In reply to this post by dann frazier-4
From: Erik Schmauss <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1841490

ACPICA commit c736ea34add19a3a07e0e398711847cd6b95affd

Link: https://github.com/acpica/acpica/commit/c736ea34
Signed-off-by: Erik Schmauss <[hidden email]>
Signed-off-by: Bob Moore <[hidden email]>
Signed-off-by: Rafael J. Wysocki <[hidden email]>
(cherry picked from commit b5eab512e7cffb2bb37c4b342b5594e9e75fd486)
Signed-off-by: dann frazier <[hidden email]>
---
 include/acpi/actbl2.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h
index 03d924ec835f9..6ec86ca859c8f 100644
--- a/include/acpi/actbl2.h
+++ b/include/acpi/actbl2.h
@@ -1473,8 +1473,11 @@ struct acpi_pptt_processor {
 
 /* Flags */
 
-#define ACPI_PPTT_PHYSICAL_PACKAGE          (1) /* Physical package */
-#define ACPI_PPTT_ACPI_PROCESSOR_ID_VALID   (2) /* ACPI Processor ID valid */
+#define ACPI_PPTT_PHYSICAL_PACKAGE          (1)
+#define ACPI_PPTT_ACPI_PROCESSOR_ID_VALID   (1<<1)
+#define ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD  (1<<2) /* ACPI 6.3 */
+#define ACPI_PPTT_ACPI_LEAF_NODE            (1<<3) /* ACPI 6.3 */
+#define ACPI_PPTT_ACPI_IDENTICAL            (1<<4) /* ACPI 6.3 */
 
 /* 1: Cache Type Structure */
 
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/6][SRU Disco] ACPI/PPTT: Modify node flag detection to find last IDENTICAL

dann frazier-4
In reply to this post by dann frazier-4
From: Jeremy Linton <[hidden email]>

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 <[hidden email]>
Tested-by: Hanjun Guo <[hidden email]>
Reviewed-by: Sudeep Holla <[hidden email]>
Signed-off-by: Jeremy Linton <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit ed2b664fcc8073c09394393756df3fc86977bbac)
Signed-off-by: dann frazier <[hidden email]>
---
 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 da031b1df6f5c..068dc5bdc7ab2 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -429,17 +429,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);
@@ -472,8 +495,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.
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 4/6][SRU Disco] ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens

dann frazier-4
In reply to this post by dann frazier-4
From: Jeremy Linton <[hidden email]>

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 <[hidden email]>
Tested-by: Hanjun Guo <[hidden email]>
Reviewed-by: Sudeep Holla <[hidden email]>
Signed-off-by: Jeremy Linton <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit 56855a99f3d0d1e9f1f4e24f5851f9bf14c83296)
Signed-off-by: dann frazier <[hidden email]>
---
 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 068dc5bdc7ab2..08cacb155c08e 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -675,3 +675,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 87715f20b69a0..d4a6b6e2b3edb 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1315,6 +1315,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)
@@ -1325,6 +1326,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;
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 5/6][SRU Disco] arm_pmu: acpi: spe: Add initial MADT/SPE probing

dann frazier-4
In reply to this post by dann frazier-4
From: Jeremy Linton <[hidden email]>

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 <[hidden email]>
Reviewed-by: Sudeep Holla <[hidden email]>
Reviewed-by: Lorenzo Pieralisi <[hidden email]>
Signed-off-by: Jeremy Linton <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit d24a0c7099b32b6981d7f126c45348e381718350)
Signed-off-by: dann frazier <[hidden email]>
---
 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 7628efbe6c125..d10399b9f9981 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 0f197516d7089..864d7ebe45e92 100644
--- a/drivers/perf/arm_pmu_acpi.c
+++ b/drivers/perf/arm_pmu_acpi.c
@@ -74,6 +74,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;
@@ -279,6 +349,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 4641e850b2046..784bc58f165aa 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__ */
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 6/6][SRU Disco] perf: arm_spe: Enable ACPI/Platform automatic module loading

dann frazier-4
In reply to this post by dann frazier-4
From: Jeremy Linton <[hidden email]>

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 <[hidden email]>
Reviewed-by: Sudeep Holla <[hidden email]>
Signed-off-by: Jeremy Linton <[hidden email]>
Signed-off-by: Will Deacon <[hidden email]>
(cherry picked from commit d482e575fbf0f7ec9319bded951f21bbc84312bf)
Signed-off-by: dann frazier <[hidden email]>
---
 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 e120f933412a7..4fb65c61c8eab 100644
--- a/drivers/perf/arm_spe_pmu.c
+++ b/drivers/perf/arm_spe_pmu.c
@@ -38,6 +38,7 @@
 #include <linux/of_address.h>
 #include <linux/of_device.h>
 #include <linux/perf_event.h>
+#include <linux/perf/arm_pmu.h>
 #include <linux/platform_device.h>
 #include <linux/printk.h>
 #include <linux/slab.h>
@@ -1168,7 +1169,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;
@@ -1228,11 +1235,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,
 };
 
--
2.23.0


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK / APPLIED[E]: [PATCH 0/4][Eoan] perf: Add ACPI support for the ARMv8.3 Statistical Profiling Extension

Seth Forshee
In reply to this post by dann frazier-4
On Mon, Aug 26, 2019 at 08:02:15PM -0600, dann frazier wrote:
> BugLink: https://bugs.launchpad.net/bugs/1841490
>
> All clean cherry-picks from upstream. This series is for Eoan. Disco requires
> a couple additional patches - I'll submit a Disco series In-Reply-To this
> cover letter as well.

Upstream cherry picks, scope limited to arm64, positive testing.

Acked-by: Seth Forshee <[hidden email]>

Applied to eoan/master-next, thanks!

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH 0/6][SRU Disco] perf: Add ACPI support for the ARMv8.3 Statistical Profiling Extension

Kleber Souza
In reply to this post by dann frazier-4
On 8/27/19 4:03 AM, dann frazier wrote:

> BugLink: https://bugs.launchpad.net/bugs/1841490
>
> All clean cherry-picks from upstream. This series is for Disco.
>
> Erik Schmauss (2):
>   ACPICA: ACPI 6.3: MADT: add support for statistical profiling in GICC
>   ACPICA: ACPI 6.3: PPTT add additional fields in Processor Structure
>     Flags
>
> Jeremy Linton (4):
>   ACPI/PPTT: Modify node flag detection to find last IDENTICAL
>   ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens
>   arm_pmu: acpi: spe: Add initial MADT/SPE probing
>   perf: arm_spe: Enable ACPI/Platform automatic module loading
>
>  arch/arm64/include/asm/acpi.h |  3 ++
>  drivers/acpi/pptt.c           | 61 ++++++++++++++++++++++++++---
>  drivers/perf/arm_pmu_acpi.c   | 72 +++++++++++++++++++++++++++++++++++
>  drivers/perf/arm_spe_pmu.c    | 12 +++++-
>  include/acpi/actbl2.h         | 12 ++++--
>  include/linux/acpi.h          |  5 +++
>  include/linux/perf/arm_pmu.h  |  2 +
>  7 files changed, 155 insertions(+), 12 deletions(-)
>

Clean cherry-picks, mostly limited to arm code.

Acked-by: Kleber Sacilotto de Souza <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED: [PATCH 0/6][SRU Disco] perf: Add ACPI support for the ARMv8.3 Statistical Profiling Extension

Kleber Souza
In reply to this post by dann frazier-4
On 8/27/19 4:03 AM, dann frazier wrote:

> BugLink: https://bugs.launchpad.net/bugs/1841490
>
> All clean cherry-picks from upstream. This series is for Disco.
>
> Erik Schmauss (2):
>   ACPICA: ACPI 6.3: MADT: add support for statistical profiling in GICC
>   ACPICA: ACPI 6.3: PPTT add additional fields in Processor Structure
>     Flags
>
> Jeremy Linton (4):
>   ACPI/PPTT: Modify node flag detection to find last IDENTICAL
>   ACPI/PPTT: Add function to return ACPI 6.3 Identical tokens
>   arm_pmu: acpi: spe: Add initial MADT/SPE probing
>   perf: arm_spe: Enable ACPI/Platform automatic module loading
>
>  arch/arm64/include/asm/acpi.h |  3 ++
>  drivers/acpi/pptt.c           | 61 ++++++++++++++++++++++++++---
>  drivers/perf/arm_pmu_acpi.c   | 72 +++++++++++++++++++++++++++++++++++
>  drivers/perf/arm_spe_pmu.c    | 12 +++++-
>  include/acpi/actbl2.h         | 12 ++++--
>  include/linux/acpi.h          |  5 +++
>  include/linux/perf/arm_pmu.h  |  2 +
>  7 files changed, 155 insertions(+), 12 deletions(-)
>

Applied to disco/master-next branch.

Thanks,
Kleber


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team