hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/arch/powerpc/include/asm/imc-pmu.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 #ifndef __ASM_POWERPC_IMC_PMU_H
23 #define __ASM_POWERPC_IMC_PMU_H
34
....@@ -7,11 +8,6 @@
78 * Copyright (C) 2017 Madhavan Srinivasan, IBM Corporation.
89 * (C) 2017 Anju T Sudhakar, IBM Corporation.
910 * (C) 2017 Hemant K Shaw, IBM Corporation.
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public License
13
- * as published by the Free Software Foundation; either version
14
- * 2 of the License, or later version.
1511 */
1612
1713 #include <linux/perf_event.h>
....@@ -33,6 +29,7 @@
3329 */
3430 #define THREAD_IMC_LDBAR_MASK 0x0003ffffffffe000ULL
3531 #define THREAD_IMC_ENABLE 0x8000000000000000ULL
32
+#define TRACE_IMC_ENABLE 0x4000000000000000ULL
3633
3734 /*
3835 * For debugfs interface for imc-mode and imc-command
....@@ -59,6 +56,34 @@
5956 char *scale;
6057 };
6158
59
+/*
60
+ * Trace IMC hardware updates a 64bytes record on
61
+ * Core Performance Monitoring Counter (CPMC)
62
+ * overflow. Here is the layout for the trace imc record
63
+ *
64
+ * DW 0 : Timebase
65
+ * DW 1 : Program Counter
66
+ * DW 2 : PIDR information
67
+ * DW 3 : CPMC1
68
+ * DW 4 : CPMC2
69
+ * DW 5 : CPMC3
70
+ * Dw 6 : CPMC4
71
+ * DW 7 : Timebase
72
+ * .....
73
+ *
74
+ * The following is the data structure to hold trace imc data.
75
+ */
76
+struct trace_imc_data {
77
+ u64 tb1;
78
+ u64 ip;
79
+ u64 val;
80
+ u64 cpmc1;
81
+ u64 cpmc2;
82
+ u64 cpmc3;
83
+ u64 cpmc4;
84
+ u64 tb2;
85
+};
86
+
6287 /* Event attribute array index */
6388 #define IMC_FORMAT_ATTR 0
6489 #define IMC_EVENT_ATTR 1
....@@ -67,6 +92,18 @@
6792
6893 /* PMU Format attribute macros */
6994 #define IMC_EVENT_OFFSET_MASK 0xffffffffULL
95
+
96
+/*
97
+ * Macro to mask bits 0:21 of first double word(which is the timebase) to
98
+ * compare with 8th double word (timebase) of trace imc record data.
99
+ */
100
+#define IMC_TRACE_RECORD_TB1_MASK 0x3ffffffffffULL
101
+
102
+/*
103
+ * Bit 0:1 in third DW of IMC trace record
104
+ * specifies the MSR[HV PR] values.
105
+ */
106
+#define IMC_TRACE_RECORD_VAL_HVPR(x) ((x) >> 62)
70107
71108 /*
72109 * Device tree parser code detects IMC pmu support and
....@@ -100,7 +137,7 @@
100137 * are inited.
101138 */
102139 struct imc_pmu_ref {
103
- struct mutex lock;
140
+ spinlock_t lock;
104141 unsigned int id;
105142 int refc;
106143 };
....@@ -113,6 +150,7 @@
113150
114151 enum {
115152 IMC_TYPE_THREAD = 0x1,
153
+ IMC_TYPE_TRACE = 0x2,
116154 IMC_TYPE_CORE = 0x4,
117155 IMC_TYPE_CHIP = 0x10,
118156 };
....@@ -123,6 +161,8 @@
123161 #define IMC_DOMAIN_NEST 1
124162 #define IMC_DOMAIN_CORE 2
125163 #define IMC_DOMAIN_THREAD 3
164
+/* For trace-imc the domain is still thread but it operates in trace-mode */
165
+#define IMC_DOMAIN_TRACE 4
126166
127167 extern int init_imc_pmu(struct device_node *parent,
128168 struct imc_pmu *pmu_ptr, int pmu_id);