Skip to contentSkip to conversation

perf: ARM CoreSight PMU support

PATCH Applied Besar Wicaksono 2 participants 5 messages Nov 11, 2022 – Nov 15, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v7 cover perf: ARM CoreSight PMU support

Add driver support for ARM CoreSight PMU device and event attributes for NVIDIA implementation. The code is based on ARM Coresight PMU architecture and ACPI ARM Performance Monitoring Unit table (APMT) specification below:
* ARM Coresight PMU:
https://developer.arm.com/documentation/ihi0091/latest
* APMT: https://developer.arm.com/documentation/den0117/latest

The patchset applies on top of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git v6.1-rc4

For APMT support, please see patchset: https://lkml.org/lkml/2022/4/19/1395

Changes from v6:
* Rebase to 6.1-rc4.
* Fix copyright lines on the new files.
* Separate the patch for defconfig change.
v6: https://lore.kernel.org/linux-arm-kernel/[email protected]/

Changes from v5:
* Default get_event/format_attrs callback now returns copy of default array.
Thanks to [email protected] for the review comments.
v5: https://lore.kernel.org/linux-arm-kernel/[email protected]/

Changes from v4:
* Fix code formatting
* Add timeout to read register function with high-low-high sequence
* Add NO_INTERRUPT capability on PMU that does not have IRQ
* Fix the name of NVIDIA PMUs
* Drop filter attribute for NVLink-C2C PMUs
* Added Reviewed/Acked-by from Suzuki
Thanks to [email protected] and [email protected] for the review comments.
v4: https://lore.kernel.org/linux-arm-kernel/[email protected]/

Changes from v3:
* Driver is now probing "arm-cs-arch-pmu" device.
* The driver files, directory, functions are renamed with "arm_cspmu" prefix.
* Use Kconfig ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU.
* Add kernel doc for NVIDIA Uncore PMU.
* Use GENMASK and FIELD_GET macros everywhere.
Thanks to [email protected] and [email protected] for the review comments.
v3: https://lore.kernel.org/linux-arm-kernel/[email protected]/

Changes from v2:
* Driver is now probing "arm-system-pmu" device.
* Change default PMU naming to "arm_<APMT node type>_pmu".
* Add implementor ops to generate custom name.
Thanks to [email protected] for the review comments.
v2: https://lore.kernel.org/linux-arm-kernel/[email protected]/

Changes from v1:
* Remove CPU arch dependency.
* Remove 32-bit read/write helper function and just use read/writel.
* Add .is_visible into event attribute to filter out cycle counter event.
* Update pmiidr matching.
* Remove read-modify-write on PMCR since the driver only writes to PMCR.E.
* Assign default cycle event outside the 32-bit PMEVTYPER range.
* Rework the active event and used counter tracking.
Thanks to [email protected] for the review comments.
v1: https://lore.kernel.org/linux-arm-kernel/[email protected]/

Besar Wicaksono (3):
perf: arm_cspmu: Add support for ARM CoreSight PMU driver
perf: arm_cspmu: Add support for NVIDIA SCF and MCF attribute
arm64: defconfig: enable ARM CoreSight PMU driver

 Documentation/admin-guide/perf/index.rst      |    1 +
 Documentation/admin-guide/perf/nvidia-pmu.rst |  299 ++++
 arch/arm64/configs/defconfig                  |    1 +
 drivers/perf/Kconfig                          |    2 +
 drivers/perf/Makefile                         |    1 +
 drivers/perf/arm_cspmu/Kconfig                |   13 +
 drivers/perf/arm_cspmu/Makefile               |    7 +
 drivers/perf/arm_cspmu/arm_cspmu.c            | 1301 +++++++++++++++++
 drivers/perf/arm_cspmu/arm_cspmu.h            |  151 ++
 drivers/perf/arm_cspmu/nvidia_cspmu.c         |  398 +++++
 drivers/perf/arm_cspmu/nvidia_cspmu.h         |   17 +
 11 files changed, 2191 insertions(+)
 create mode 100644 Documentation/admin-guide/perf/nvidia-pmu.rst
 create mode 100644 drivers/perf/arm_cspmu/Kconfig
 create mode 100644 drivers/perf/arm_cspmu/Makefile
 create mode 100644 drivers/perf/arm_cspmu/arm_cspmu.c
 create mode 100644 drivers/perf/arm_cspmu/arm_cspmu.h
 create mode 100644 drivers/perf/arm_cspmu/nvidia_cspmu.c
 create mode 100644 drivers/perf/arm_cspmu/nvidia_cspmu.h

base-commit: f0c4d9fc9cc9462659728d168387191387e903cc

Signature · 1 line
2.17.1
#1 lore raw

PATCH v7 1/3 perf: arm_cspmu: Add support for ARM CoreSight PMU driver

Add support for ARM CoreSight PMU driver framework and interfaces. The driver provides generic implementation to operate uncore PMU based on ARM CoreSight PMU architecture. The driver also provides interface to get vendor/implementation specific information, for example event attributes and formating.

The specification used in this implementation can be found below:
* ACPI Arm Performance Monitoring Unit table:
https://developer.arm.com/documentation/den0117/latest
* ARM Coresight PMU architecture:
https://developer.arm.com/documentation/ihi0091/latest

---
 drivers/perf/Kconfig               |    2 +
 drivers/perf/Makefile              |    1 +
 drivers/perf/arm_cspmu/Kconfig     |   13 +
 drivers/perf/arm_cspmu/Makefile    |    6 +
 drivers/perf/arm_cspmu/arm_cspmu.c | 1292 ++++++++++++++++++++++++++++
 drivers/perf/arm_cspmu/arm_cspmu.h |  151 ++++
 6 files changed, 1465 insertions(+)
 create mode 100644 drivers/perf/arm_cspmu/Kconfig
 create mode 100644 drivers/perf/arm_cspmu/Makefile
 create mode 100644 drivers/perf/arm_cspmu/arm_cspmu.c
 create mode 100644 drivers/perf/arm_cspmu/arm_cspmu.h
drivers/perf/Kconfig +2 -0
index 341010f20b77..fa87dedf8c92 100644
@@ -199,4 +199,6 @@ config MARVELL_CN10K_DDR_PMU
 	  Enable perf support for Marvell DDR Performance monitoring
 	  event on CN10K platform.
 
+source "drivers/perf/arm_cspmu/Kconfig"
+
 endmenu
drivers/perf/Makefile +1 -0
index 050d04ee19dd..35bb0d979a70 100644
@@ -21,3 +21,4 @@ obj-$(CONFIG_MARVELL_CN10K_TAD_PMU) += marvell_cn10k_tad_pmu.o
 obj-$(CONFIG_MARVELL_CN10K_DDR_PMU) += marvell_cn10k_ddr_pmu.o
 obj-$(CONFIG_APPLE_M1_CPU_PMU) += apple_m1_cpu_pmu.o
 obj-$(CONFIG_ALIBABA_UNCORE_DRW_PMU) += alibaba_uncore_drw_pmu.o
+obj-$(CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU) += arm_cspmu/
drivers/perf/arm_cspmu/Kconfig new file +13 -0
new file mode 100644
index 000000000000..058223bef661
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+
+config ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU
+	tristate "ARM Coresight Architecture PMU"
+	depends on ACPI
+	depends on ACPI_APMT || COMPILE_TEST
+	help
+	  Provides support for performance monitoring unit (PMU) devices
+	  based on ARM CoreSight PMU architecture. Note that this PMU
+	  architecture does not have relationship with the ARM CoreSight
+	  Self-Hosted Tracing.
drivers/perf/arm_cspmu/Makefile new file +6 -0
new file mode 100644
index 000000000000..9bc76de4002d
@@ -0,0 +1,6 @@
+# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU) += \
+	arm_cspmu.o
drivers/perf/arm_cspmu/arm_cspmu.c new file +1292 -0

1,292 lines not on this page · raw message

drivers/perf/arm_cspmu/arm_cspmu.h new file +151 -0

151 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH v7 2/3 perf: arm_cspmu: Add support for NVIDIA SCF and MCF attribute

In reply to Besar Wicaksono

Add support for NVIDIA System Cache Fabric (SCF) and Memory Control Fabric (MCF) PMU attributes for CoreSight PMU implementation in NVIDIA devices.

---
 Documentation/admin-guide/perf/index.rst      |   1 +
 Documentation/admin-guide/perf/nvidia-pmu.rst | 299 +++++++++++++
 drivers/perf/arm_cspmu/Makefile               |   3 +-
 drivers/perf/arm_cspmu/arm_cspmu.c            |   9 +
 drivers/perf/arm_cspmu/nvidia_cspmu.c         | 398 ++++++++++++++++++
 drivers/perf/arm_cspmu/nvidia_cspmu.h         |  17 +
 6 files changed, 726 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/admin-guide/perf/nvidia-pmu.rst
 create mode 100644 drivers/perf/arm_cspmu/nvidia_cspmu.c
 create mode 100644 drivers/perf/arm_cspmu/nvidia_cspmu.h
Documentation/admin-guide/perf/index.rst +1 -0
index 793e1970bc05..7ed239408138 100644
@@ -19,3 +19,4 @@ Performance monitor support
    arm_dsu_pmu
    thunderx2-pmu
    alibaba_pmu
+   nvidia-pmu
Documentation/admin-guide/perf/nvidia-pmu.rst new file +299 -0

299 lines not on this page · raw message

drivers/perf/arm_cspmu/Makefile +2 -1
index 9bc76de4002d..641db85c018b 100644
@@ -3,4 +3,5 @@
 # SPDX-License-Identifier: GPL-2.0
 
 obj-$(CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU) += \
-	arm_cspmu.o
+	arm_cspmu.o \
+	nvidia_cspmu.o
drivers/perf/arm_cspmu/arm_cspmu.c +9 -0
index e8f57aa9f047..e851eeb33f4a 100644
@@ -31,6 +31,7 @@
 #include <acpi/processor.h>
 
 #include "arm_cspmu.h"
+#include "nvidia_cspmu.h"
 
 #define PMUNAME "arm_cspmu"
 #define DRVNAME "arm-cs-arch-pmu"
@@ -116,6 +117,9 @@
  */
 #define HILOHI_MAX_POLL	1000
 
+/* JEDEC-assigned JEP106 identification code */
+#define ARM_CSPMU_IMPL_ID_NVIDIA		0x36B
+
 static unsigned long arm_cspmu_cpuhp_state;
 
 /*
@@ -382,6 +386,11 @@ struct impl_match {
 };
 
 static const struct impl_match impl_match[] = {
+	{
+	  .pmiidr = ARM_CSPMU_IMPL_ID_NVIDIA,
+	  .mask = ARM_CSPMU_PMIIDR_IMPLEMENTER,
+	  .impl_init_ops = nv_cspmu_init_ops
+	},
 	{}
 };
 
drivers/perf/arm_cspmu/nvidia_cspmu.c new file +398 -0

398 lines not on this page · raw message

drivers/perf/arm_cspmu/nvidia_cspmu.h new file +17 -0
new file mode 100644
index 000000000000..71e18f0dc50b
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ *
+ */
+
+/* Support for NVIDIA specific attributes. */
+
+#ifndef __NVIDIA_CSPMU_H__
+#define __NVIDIA_CSPMU_H__
+
+#include "arm_cspmu.h"
+
+/* Allocate NVIDIA descriptor. */
+int nv_cspmu_init_ops(struct arm_cspmu *cspmu);
+
+#endif /* __NVIDIA_CSPMU_H__ */
Signature · 1 line
2.17.1
#3 lore raw

PATCH v7 3/3 arm64: defconfig: enable ARM CoreSight PMU driver

In reply to Besar Wicaksono

Enable driver for Coresight PMU arch device.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 0b6af3348e79..8f3f7593dc5f 100644
@@ -1262,6 +1262,7 @@ CONFIG_ARM_DSU_PMU=m
 CONFIG_FSL_IMX8_DDR_PMU=m
 CONFIG_ARM_SPE_PMU=m
 CONFIG_ARM_DMC620_PMU=m
+CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU=y
 CONFIG_QCOM_L2_PMU=y
 CONFIG_QCOM_L3_PMU=y
 CONFIG_HISI_PMU=y
Signature · 1 line
2.17.1
maintainer Applied
#4 lore raw
In reply to Besar Wicaksono
Quoted 8 lines · Besar Wicaksono

Add driver support for ARM CoreSight PMU device and event attributes for NVIDIA implementation. The code is based on ARM Coresight PMU architecture and ACPI ARM Performance Monitoring Unit table (APMT) specification below:
* ARM Coresight PMU:
https://developer.arm.com/documentation/ihi0091/latest
* APMT: https://developer.arm.com/documentation/den0117/latest

[...]

Applied to will (for-next/perf), thanks!

[1/3] perf: arm_cspmu: Add support for ARM CoreSight PMU driver

      https://git.kernel.org/will/c/e37dfd65731d
[2/3] perf: arm_cspmu: Add support for NVIDIA SCF and MCF attribute
      https://git.kernel.org/will/c/84481be7167e

Note that I had to add some MODULE_LICENSE() macros to the files so that modpost doesn't fail with an allmodconfig build. Please shout if that needs adjusting at all.

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev