blob: 2b8880e953a294f4dc4abf7fbe7ae04580dd82ce [file] [log] [blame]
Vineet Gupta9c575642013-01-18 15:12:24 +05301/*
Mischa Jonker0dd450f2013-11-07 14:55:11 +01002 * Linux performance counter support for ARC
3 *
4 * Copyright (C) 2011-2013 Synopsys, Inc. (www.synopsys.com)
Vineet Gupta9c575642013-01-18 15:12:24 +05305 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#ifndef __ASM_PERF_EVENT_H
13#define __ASM_PERF_EVENT_H
14
Mischa Jonker0dd450f2013-11-07 14:55:11 +010015/* real maximum varies per CPU, this is the maximum supported by the driver */
16#define ARC_PMU_MAX_HWEVENTS 64
17
18#define ARC_REG_CC_BUILD 0xF6
19#define ARC_REG_CC_INDEX 0x240
20#define ARC_REG_CC_NAME0 0x241
21#define ARC_REG_CC_NAME1 0x242
22
23#define ARC_REG_PCT_BUILD 0xF5
24#define ARC_REG_PCT_COUNTL 0x250
25#define ARC_REG_PCT_COUNTH 0x251
26#define ARC_REG_PCT_SNAPL 0x252
27#define ARC_REG_PCT_SNAPH 0x253
28#define ARC_REG_PCT_CONFIG 0x254
29#define ARC_REG_PCT_CONTROL 0x255
30#define ARC_REG_PCT_INDEX 0x256
31
32#define ARC_REG_PCT_CONTROL_CC (1 << 16) /* clear counts */
33#define ARC_REG_PCT_CONTROL_SN (1 << 17) /* snapshot */
34
35struct arc_reg_pct_build {
36#ifdef CONFIG_CPU_BIG_ENDIAN
37 unsigned int m:8, c:8, r:6, s:2, v:8;
38#else
39 unsigned int v:8, s:2, r:6, c:8, m:8;
40#endif
41};
42
43struct arc_reg_cc_build {
44#ifdef CONFIG_CPU_BIG_ENDIAN
45 unsigned int c:16, r:8, v:8;
46#else
47 unsigned int v:8, r:8, c:16;
48#endif
49};
50
51#define PERF_COUNT_ARC_DCLM (PERF_COUNT_HW_MAX + 0)
52#define PERF_COUNT_ARC_DCSM (PERF_COUNT_HW_MAX + 1)
53#define PERF_COUNT_ARC_ICM (PERF_COUNT_HW_MAX + 2)
54#define PERF_COUNT_ARC_BPOK (PERF_COUNT_HW_MAX + 3)
55#define PERF_COUNT_ARC_EDTLB (PERF_COUNT_HW_MAX + 4)
56#define PERF_COUNT_ARC_EITLB (PERF_COUNT_HW_MAX + 5)
Vineet Gupta0a8a4762015-01-07 13:14:07 +053057#define PERF_COUNT_ARC_LDC (PERF_COUNT_HW_MAX + 6)
58#define PERF_COUNT_ARC_STC (PERF_COUNT_HW_MAX + 7)
59
60#define PERF_COUNT_ARC_HW_MAX (PERF_COUNT_HW_MAX + 8)
Mischa Jonker0dd450f2013-11-07 14:55:11 +010061
62/*
Vineet Guptabde80c22015-04-15 19:44:07 +053063 * Some ARC pct quirks:
Mischa Jonker0dd450f2013-11-07 14:55:11 +010064 *
65 * PERF_COUNT_HW_STALLED_CYCLES_BACKEND
66 * PERF_COUNT_HW_STALLED_CYCLES_FRONTEND
67 * The ARC 700 can either measure stalls per pipeline stage, or all stalls
68 * combined; for now we assign all stalls to STALLED_CYCLES_BACKEND
69 * and all pipeline flushes (e.g. caused by mispredicts, etc.) to
70 * STALLED_CYCLES_FRONTEND.
71 *
72 * We could start multiple performance counters and combine everything
73 * afterwards, but that makes it complicated.
74 *
75 * Note that I$ cache misses aren't counted by either of the two!
76 */
77
Vineet Guptabde80c22015-04-15 19:44:07 +053078/*
79 * ARC PCT has hardware conditions with fixed "names" but variable "indexes"
80 * (based on a specific RTL build)
81 * Below is the static map between perf generic/arc specific event_id and
82 * h/w condition names.
83 * At the time of probe, we loop thru each index and find it's name to
84 * complete the mapping of perf event_id to h/w index as latter is needed
85 * to program the counter really
86 */
Mischa Jonker0dd450f2013-11-07 14:55:11 +010087static const char * const arc_pmu_ev_hw_map[] = {
Vineet Guptabde80c22015-04-15 19:44:07 +053088 /* count cycles */
Mischa Jonker0dd450f2013-11-07 14:55:11 +010089 [PERF_COUNT_HW_CPU_CYCLES] = "crun",
90 [PERF_COUNT_HW_REF_CPU_CYCLES] = "crun",
91 [PERF_COUNT_HW_BUS_CYCLES] = "crun",
Vineet Guptabde80c22015-04-15 19:44:07 +053092
Mischa Jonker0dd450f2013-11-07 14:55:11 +010093 [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = "bflush",
94 [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = "bstall",
Vineet Guptabde80c22015-04-15 19:44:07 +053095
96 /* counts condition */
97 [PERF_COUNT_HW_INSTRUCTIONS] = "iall",
98 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = "ijmp",
99 [PERF_COUNT_ARC_BPOK] = "bpok", /* NP-NT, PT-T, PNT-NT */
100 [PERF_COUNT_HW_BRANCH_MISSES] = "bpfail", /* NP-T, PT-NT, PNT-T */
101
Vineet Gupta0a8a4762015-01-07 13:14:07 +0530102 [PERF_COUNT_ARC_LDC] = "imemrdc", /* Instr: mem read cached */
103 [PERF_COUNT_ARC_STC] = "imemwrc", /* Instr: mem write cached */
104
Vineet Guptabde80c22015-04-15 19:44:07 +0530105 [PERF_COUNT_ARC_DCLM] = "dclm", /* D-cache Load Miss */
106 [PERF_COUNT_ARC_DCSM] = "dcsm", /* D-cache Store Miss */
107 [PERF_COUNT_ARC_ICM] = "icm", /* I-cache Miss */
108 [PERF_COUNT_ARC_EDTLB] = "edtlb", /* D-TLB Miss */
109 [PERF_COUNT_ARC_EITLB] = "eitlb", /* I-TLB Miss */
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100110};
111
112#define C(_x) PERF_COUNT_HW_CACHE_##_x
113#define CACHE_OP_UNSUPPORTED 0xffff
114
115static const unsigned arc_pmu_cache_map[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
116 [C(L1D)] = {
117 [C(OP_READ)] = {
Vineet Gupta0a8a4762015-01-07 13:14:07 +0530118 [C(RESULT_ACCESS)] = PERF_COUNT_ARC_LDC,
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100119 [C(RESULT_MISS)] = PERF_COUNT_ARC_DCLM,
120 },
121 [C(OP_WRITE)] = {
Vineet Gupta0a8a4762015-01-07 13:14:07 +0530122 [C(RESULT_ACCESS)] = PERF_COUNT_ARC_STC,
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100123 [C(RESULT_MISS)] = PERF_COUNT_ARC_DCSM,
124 },
125 [C(OP_PREFETCH)] = {
126 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
127 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
128 },
129 },
130 [C(L1I)] = {
131 [C(OP_READ)] = {
Vineet Gupta0a8a4762015-01-07 13:14:07 +0530132 [C(RESULT_ACCESS)] = PERF_COUNT_HW_INSTRUCTIONS,
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100133 [C(RESULT_MISS)] = PERF_COUNT_ARC_ICM,
134 },
135 [C(OP_WRITE)] = {
136 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
137 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
138 },
139 [C(OP_PREFETCH)] = {
140 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
141 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
142 },
143 },
144 [C(LL)] = {
145 [C(OP_READ)] = {
146 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
147 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
148 },
149 [C(OP_WRITE)] = {
150 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
151 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
152 },
153 [C(OP_PREFETCH)] = {
154 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
155 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
156 },
157 },
158 [C(DTLB)] = {
159 [C(OP_READ)] = {
Vineet Gupta0a8a4762015-01-07 13:14:07 +0530160 [C(RESULT_ACCESS)] = PERF_COUNT_ARC_LDC,
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100161 [C(RESULT_MISS)] = PERF_COUNT_ARC_EDTLB,
162 },
Vineet Gupta0a8a4762015-01-07 13:14:07 +0530163 /* DTLB LD/ST Miss not segregated by h/w*/
Mischa Jonker0dd450f2013-11-07 14:55:11 +0100164 [C(OP_WRITE)] = {
165 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
166 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
167 },
168 [C(OP_PREFETCH)] = {
169 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
170 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
171 },
172 },
173 [C(ITLB)] = {
174 [C(OP_READ)] = {
175 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
176 [C(RESULT_MISS)] = PERF_COUNT_ARC_EITLB,
177 },
178 [C(OP_WRITE)] = {
179 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
180 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
181 },
182 [C(OP_PREFETCH)] = {
183 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
184 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
185 },
186 },
187 [C(BPU)] = {
188 [C(OP_READ)] = {
189 [C(RESULT_ACCESS)] = PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
190 [C(RESULT_MISS)] = PERF_COUNT_HW_BRANCH_MISSES,
191 },
192 [C(OP_WRITE)] = {
193 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
194 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
195 },
196 [C(OP_PREFETCH)] = {
197 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
198 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
199 },
200 },
201 [C(NODE)] = {
202 [C(OP_READ)] = {
203 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
204 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
205 },
206 [C(OP_WRITE)] = {
207 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
208 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
209 },
210 [C(OP_PREFETCH)] = {
211 [C(RESULT_ACCESS)] = CACHE_OP_UNSUPPORTED,
212 [C(RESULT_MISS)] = CACHE_OP_UNSUPPORTED,
213 },
214 },
215};
216
Vineet Gupta9c575642013-01-18 15:12:24 +0530217#endif /* __ASM_PERF_EVENT_H */