2 * ARMv7 Cortex-A8 and Cortex-A9 Performance Events handling code.
4 * ARMv7 support: Jean Pihet <jpihet@mvista.com>
5 * 2010 (c) MontaVista Software, LLC.
7 * Copied from ARMv6 code, with the low level code inspired
8 * by the ARMv7 Oprofile code.
10 * Cortex-A8 has up to 4 configurable performance counters and
11 * a single cycle counter.
12 * Cortex-A9 has up to 31 configurable performance counters and
13 * a single cycle counter.
15 * All counters can be enabled/disabled and IRQ masked separately. The cycle
16 * counter and all 4 performance counters together can be reset separately.
21 static struct arm_pmu armv7pmu
;
24 * Common ARMv7 event types
26 * Note: An implementation may not be able to count all of these events
27 * but the encodings are considered to be `reserved' in the case that
28 * they are not available.
30 enum armv7_perf_types
{
31 ARMV7_PERFCTR_PMNC_SW_INCR
= 0x00,
32 ARMV7_PERFCTR_IFETCH_MISS
= 0x01,
33 ARMV7_PERFCTR_ITLB_MISS
= 0x02,
34 ARMV7_PERFCTR_DCACHE_REFILL
= 0x03, /* L1 */
35 ARMV7_PERFCTR_DCACHE_ACCESS
= 0x04, /* L1 */
36 ARMV7_PERFCTR_DTLB_REFILL
= 0x05,
37 ARMV7_PERFCTR_DREAD
= 0x06,
38 ARMV7_PERFCTR_DWRITE
= 0x07,
39 ARMV7_PERFCTR_INSTR_EXECUTED
= 0x08,
40 ARMV7_PERFCTR_EXC_TAKEN
= 0x09,
41 ARMV7_PERFCTR_EXC_EXECUTED
= 0x0A,
42 ARMV7_PERFCTR_CID_WRITE
= 0x0B,
43 /* ARMV7_PERFCTR_PC_WRITE is equivalent to HW_BRANCH_INSTRUCTIONS.
45 * - all branch instructions,
46 * - instructions that explicitly write the PC,
47 * - exception generating instructions.
49 ARMV7_PERFCTR_PC_WRITE
= 0x0C,
50 ARMV7_PERFCTR_PC_IMM_BRANCH
= 0x0D,
51 ARMV7_PERFCTR_PC_PROC_RETURN
= 0x0E,
52 ARMV7_PERFCTR_UNALIGNED_ACCESS
= 0x0F,
54 /* These events are defined by the PMUv2 supplement (ARM DDI 0457A). */
55 ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
= 0x10,
56 ARMV7_PERFCTR_CLOCK_CYCLES
= 0x11,
57 ARMV7_PERFCTR_PC_BRANCH_PRED
= 0x12,
58 ARMV7_PERFCTR_MEM_ACCESS
= 0x13,
59 ARMV7_PERFCTR_L1_ICACHE_ACCESS
= 0x14,
60 ARMV7_PERFCTR_L1_DCACHE_WB
= 0x15,
61 ARMV7_PERFCTR_L2_DCACHE_ACCESS
= 0x16,
62 ARMV7_PERFCTR_L2_DCACHE_REFILL
= 0x17,
63 ARMV7_PERFCTR_L2_DCACHE_WB
= 0x18,
64 ARMV7_PERFCTR_BUS_ACCESS
= 0x19,
65 ARMV7_PERFCTR_MEMORY_ERROR
= 0x1A,
66 ARMV7_PERFCTR_INSTR_SPEC
= 0x1B,
67 ARMV7_PERFCTR_TTBR_WRITE
= 0x1C,
68 ARMV7_PERFCTR_BUS_CYCLES
= 0x1D,
70 ARMV7_PERFCTR_CPU_CYCLES
= 0xFF
73 /* ARMv7 Cortex-A8 specific event types */
74 enum armv7_a8_perf_types
{
75 ARMV7_PERFCTR_WRITE_BUFFER_FULL
= 0x40,
76 ARMV7_PERFCTR_L2_STORE_MERGED
= 0x41,
77 ARMV7_PERFCTR_L2_STORE_BUFF
= 0x42,
78 ARMV7_PERFCTR_L2_ACCESS
= 0x43,
79 ARMV7_PERFCTR_L2_CACH_MISS
= 0x44,
80 ARMV7_PERFCTR_AXI_READ_CYCLES
= 0x45,
81 ARMV7_PERFCTR_AXI_WRITE_CYCLES
= 0x46,
82 ARMV7_PERFCTR_MEMORY_REPLAY
= 0x47,
83 ARMV7_PERFCTR_UNALIGNED_ACCESS_REPLAY
= 0x48,
84 ARMV7_PERFCTR_L1_DATA_MISS
= 0x49,
85 ARMV7_PERFCTR_L1_INST_MISS
= 0x4A,
86 ARMV7_PERFCTR_L1_DATA_COLORING
= 0x4B,
87 ARMV7_PERFCTR_L1_NEON_DATA
= 0x4C,
88 ARMV7_PERFCTR_L1_NEON_CACH_DATA
= 0x4D,
89 ARMV7_PERFCTR_L2_NEON
= 0x4E,
90 ARMV7_PERFCTR_L2_NEON_HIT
= 0x4F,
91 ARMV7_PERFCTR_L1_INST
= 0x50,
92 ARMV7_PERFCTR_PC_RETURN_MIS_PRED
= 0x51,
93 ARMV7_PERFCTR_PC_BRANCH_FAILED
= 0x52,
94 ARMV7_PERFCTR_PC_BRANCH_TAKEN
= 0x53,
95 ARMV7_PERFCTR_PC_BRANCH_EXECUTED
= 0x54,
96 ARMV7_PERFCTR_OP_EXECUTED
= 0x55,
97 ARMV7_PERFCTR_CYCLES_INST_STALL
= 0x56,
98 ARMV7_PERFCTR_CYCLES_INST
= 0x57,
99 ARMV7_PERFCTR_CYCLES_NEON_DATA_STALL
= 0x58,
100 ARMV7_PERFCTR_CYCLES_NEON_INST_STALL
= 0x59,
101 ARMV7_PERFCTR_NEON_CYCLES
= 0x5A,
103 ARMV7_PERFCTR_PMU0_EVENTS
= 0x70,
104 ARMV7_PERFCTR_PMU1_EVENTS
= 0x71,
105 ARMV7_PERFCTR_PMU_EVENTS
= 0x72,
108 /* ARMv7 Cortex-A9 specific event types */
109 enum armv7_a9_perf_types
{
110 ARMV7_PERFCTR_JAVA_HW_BYTECODE_EXEC
= 0x40,
111 ARMV7_PERFCTR_JAVA_SW_BYTECODE_EXEC
= 0x41,
112 ARMV7_PERFCTR_JAZELLE_BRANCH_EXEC
= 0x42,
114 ARMV7_PERFCTR_COHERENT_LINE_MISS
= 0x50,
115 ARMV7_PERFCTR_COHERENT_LINE_HIT
= 0x51,
117 ARMV7_PERFCTR_ICACHE_DEP_STALL_CYCLES
= 0x60,
118 ARMV7_PERFCTR_DCACHE_DEP_STALL_CYCLES
= 0x61,
119 ARMV7_PERFCTR_TLB_MISS_DEP_STALL_CYCLES
= 0x62,
120 ARMV7_PERFCTR_STREX_EXECUTED_PASSED
= 0x63,
121 ARMV7_PERFCTR_STREX_EXECUTED_FAILED
= 0x64,
122 ARMV7_PERFCTR_DATA_EVICTION
= 0x65,
123 ARMV7_PERFCTR_ISSUE_STAGE_NO_INST
= 0x66,
124 ARMV7_PERFCTR_ISSUE_STAGE_EMPTY
= 0x67,
125 ARMV7_PERFCTR_INST_OUT_OF_RENAME_STAGE
= 0x68,
127 ARMV7_PERFCTR_PREDICTABLE_FUNCT_RETURNS
= 0x6E,
129 ARMV7_PERFCTR_MAIN_UNIT_EXECUTED_INST
= 0x70,
130 ARMV7_PERFCTR_SECOND_UNIT_EXECUTED_INST
= 0x71,
131 ARMV7_PERFCTR_LD_ST_UNIT_EXECUTED_INST
= 0x72,
132 ARMV7_PERFCTR_FP_EXECUTED_INST
= 0x73,
133 ARMV7_PERFCTR_NEON_EXECUTED_INST
= 0x74,
135 ARMV7_PERFCTR_PLD_FULL_DEP_STALL_CYCLES
= 0x80,
136 ARMV7_PERFCTR_DATA_WR_DEP_STALL_CYCLES
= 0x81,
137 ARMV7_PERFCTR_ITLB_MISS_DEP_STALL_CYCLES
= 0x82,
138 ARMV7_PERFCTR_DTLB_MISS_DEP_STALL_CYCLES
= 0x83,
139 ARMV7_PERFCTR_MICRO_ITLB_MISS_DEP_STALL_CYCLES
= 0x84,
140 ARMV7_PERFCTR_MICRO_DTLB_MISS_DEP_STALL_CYCLES
= 0x85,
141 ARMV7_PERFCTR_DMB_DEP_STALL_CYCLES
= 0x86,
143 ARMV7_PERFCTR_INTGR_CLK_ENABLED_CYCLES
= 0x8A,
144 ARMV7_PERFCTR_DATA_ENGINE_CLK_EN_CYCLES
= 0x8B,
146 ARMV7_PERFCTR_ISB_INST
= 0x90,
147 ARMV7_PERFCTR_DSB_INST
= 0x91,
148 ARMV7_PERFCTR_DMB_INST
= 0x92,
149 ARMV7_PERFCTR_EXT_INTERRUPTS
= 0x93,
151 ARMV7_PERFCTR_PLE_CACHE_LINE_RQST_COMPLETED
= 0xA0,
152 ARMV7_PERFCTR_PLE_CACHE_LINE_RQST_SKIPPED
= 0xA1,
153 ARMV7_PERFCTR_PLE_FIFO_FLUSH
= 0xA2,
154 ARMV7_PERFCTR_PLE_RQST_COMPLETED
= 0xA3,
155 ARMV7_PERFCTR_PLE_FIFO_OVERFLOW
= 0xA4,
156 ARMV7_PERFCTR_PLE_RQST_PROG
= 0xA5
159 /* ARMv7 Cortex-A5 specific event types */
160 enum armv7_a5_perf_types
{
161 ARMV7_PERFCTR_IRQ_TAKEN
= 0x86,
162 ARMV7_PERFCTR_FIQ_TAKEN
= 0x87,
164 ARMV7_PERFCTR_EXT_MEM_RQST
= 0xc0,
165 ARMV7_PERFCTR_NC_EXT_MEM_RQST
= 0xc1,
166 ARMV7_PERFCTR_PREFETCH_LINEFILL
= 0xc2,
167 ARMV7_PERFCTR_PREFETCH_LINEFILL_DROP
= 0xc3,
168 ARMV7_PERFCTR_ENTER_READ_ALLOC
= 0xc4,
169 ARMV7_PERFCTR_READ_ALLOC
= 0xc5,
171 ARMV7_PERFCTR_STALL_SB_FULL
= 0xc9,
174 /* ARMv7 Cortex-A15 specific event types */
175 enum armv7_a15_perf_types
{
176 ARMV7_PERFCTR_L1_DCACHE_READ_ACCESS
= 0x40,
177 ARMV7_PERFCTR_L1_DCACHE_WRITE_ACCESS
= 0x41,
178 ARMV7_PERFCTR_L1_DCACHE_READ_REFILL
= 0x42,
179 ARMV7_PERFCTR_L1_DCACHE_WRITE_REFILL
= 0x43,
181 ARMV7_PERFCTR_L1_DTLB_READ_REFILL
= 0x4C,
182 ARMV7_PERFCTR_L1_DTLB_WRITE_REFILL
= 0x4D,
184 ARMV7_PERFCTR_L2_DCACHE_READ_ACCESS
= 0x50,
185 ARMV7_PERFCTR_L2_DCACHE_WRITE_ACCESS
= 0x51,
186 ARMV7_PERFCTR_L2_DCACHE_READ_REFILL
= 0x52,
187 ARMV7_PERFCTR_L2_DCACHE_WRITE_REFILL
= 0x53,
189 ARMV7_PERFCTR_SPEC_PC_WRITE
= 0x76,
193 * Cortex-A8 HW events mapping
195 * The hardware events that we support. We do support cache operations but
196 * we have harvard caches and no way to combine instruction and data
197 * accesses/misses in hardware.
199 static const unsigned armv7_a8_perf_map
[PERF_COUNT_HW_MAX
] = {
200 [PERF_COUNT_HW_CPU_CYCLES
] = ARMV7_PERFCTR_CPU_CYCLES
,
201 [PERF_COUNT_HW_INSTRUCTIONS
] = ARMV7_PERFCTR_INSTR_EXECUTED
,
202 [PERF_COUNT_HW_CACHE_REFERENCES
] = HW_OP_UNSUPPORTED
,
203 [PERF_COUNT_HW_CACHE_MISSES
] = HW_OP_UNSUPPORTED
,
204 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS
] = ARMV7_PERFCTR_PC_WRITE
,
205 [PERF_COUNT_HW_BRANCH_MISSES
] = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
206 [PERF_COUNT_HW_BUS_CYCLES
] = ARMV7_PERFCTR_CLOCK_CYCLES
,
209 static const unsigned armv7_a8_perf_cache_map
[PERF_COUNT_HW_CACHE_MAX
]
210 [PERF_COUNT_HW_CACHE_OP_MAX
]
211 [PERF_COUNT_HW_CACHE_RESULT_MAX
] = {
214 * The performance counters don't differentiate between read
215 * and write accesses/misses so this isn't strictly correct,
216 * but it's the best we can do. Writes and reads get
220 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_DCACHE_ACCESS
,
221 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DCACHE_REFILL
,
224 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_DCACHE_ACCESS
,
225 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DCACHE_REFILL
,
228 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
229 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
234 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_L1_INST
,
235 [C(RESULT_MISS
)] = ARMV7_PERFCTR_L1_INST_MISS
,
238 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_L1_INST
,
239 [C(RESULT_MISS
)] = ARMV7_PERFCTR_L1_INST_MISS
,
242 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
243 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
248 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_L2_ACCESS
,
249 [C(RESULT_MISS
)] = ARMV7_PERFCTR_L2_CACH_MISS
,
252 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_L2_ACCESS
,
253 [C(RESULT_MISS
)] = ARMV7_PERFCTR_L2_CACH_MISS
,
256 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
257 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
262 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
263 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DTLB_REFILL
,
266 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
267 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DTLB_REFILL
,
270 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
271 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
276 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
277 [C(RESULT_MISS
)] = ARMV7_PERFCTR_ITLB_MISS
,
280 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
281 [C(RESULT_MISS
)] = ARMV7_PERFCTR_ITLB_MISS
,
284 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
285 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
290 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_PC_WRITE
,
292 = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
295 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_PC_WRITE
,
297 = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
300 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
301 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
306 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
307 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
310 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
311 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
314 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
315 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
321 * Cortex-A9 HW events mapping
323 static const unsigned armv7_a9_perf_map
[PERF_COUNT_HW_MAX
] = {
324 [PERF_COUNT_HW_CPU_CYCLES
] = ARMV7_PERFCTR_CPU_CYCLES
,
325 [PERF_COUNT_HW_INSTRUCTIONS
] =
326 ARMV7_PERFCTR_INST_OUT_OF_RENAME_STAGE
,
327 [PERF_COUNT_HW_CACHE_REFERENCES
] = ARMV7_PERFCTR_DCACHE_ACCESS
,
328 [PERF_COUNT_HW_CACHE_MISSES
] = ARMV7_PERFCTR_DCACHE_REFILL
,
329 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS
] = ARMV7_PERFCTR_PC_WRITE
,
330 [PERF_COUNT_HW_BRANCH_MISSES
] = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
331 [PERF_COUNT_HW_BUS_CYCLES
] = ARMV7_PERFCTR_CLOCK_CYCLES
,
334 static const unsigned armv7_a9_perf_cache_map
[PERF_COUNT_HW_CACHE_MAX
]
335 [PERF_COUNT_HW_CACHE_OP_MAX
]
336 [PERF_COUNT_HW_CACHE_RESULT_MAX
] = {
339 * The performance counters don't differentiate between read
340 * and write accesses/misses so this isn't strictly correct,
341 * but it's the best we can do. Writes and reads get
345 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_DCACHE_ACCESS
,
346 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DCACHE_REFILL
,
349 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_DCACHE_ACCESS
,
350 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DCACHE_REFILL
,
353 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
354 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
359 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
360 [C(RESULT_MISS
)] = ARMV7_PERFCTR_IFETCH_MISS
,
363 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
364 [C(RESULT_MISS
)] = ARMV7_PERFCTR_IFETCH_MISS
,
367 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
368 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
373 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
374 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
377 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
378 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
381 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
382 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
387 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
388 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DTLB_REFILL
,
391 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
392 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DTLB_REFILL
,
395 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
396 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
401 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
402 [C(RESULT_MISS
)] = ARMV7_PERFCTR_ITLB_MISS
,
405 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
406 [C(RESULT_MISS
)] = ARMV7_PERFCTR_ITLB_MISS
,
409 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
410 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
415 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_PC_WRITE
,
417 = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
420 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_PC_WRITE
,
422 = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
425 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
426 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
431 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
432 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
435 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
436 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
439 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
440 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
446 * Cortex-A5 HW events mapping
448 static const unsigned armv7_a5_perf_map
[PERF_COUNT_HW_MAX
] = {
449 [PERF_COUNT_HW_CPU_CYCLES
] = ARMV7_PERFCTR_CPU_CYCLES
,
450 [PERF_COUNT_HW_INSTRUCTIONS
] = ARMV7_PERFCTR_INSTR_EXECUTED
,
451 [PERF_COUNT_HW_CACHE_REFERENCES
] = HW_OP_UNSUPPORTED
,
452 [PERF_COUNT_HW_CACHE_MISSES
] = HW_OP_UNSUPPORTED
,
453 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS
] = ARMV7_PERFCTR_PC_WRITE
,
454 [PERF_COUNT_HW_BRANCH_MISSES
] = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
455 [PERF_COUNT_HW_BUS_CYCLES
] = HW_OP_UNSUPPORTED
,
458 static const unsigned armv7_a5_perf_cache_map
[PERF_COUNT_HW_CACHE_MAX
]
459 [PERF_COUNT_HW_CACHE_OP_MAX
]
460 [PERF_COUNT_HW_CACHE_RESULT_MAX
] = {
464 = ARMV7_PERFCTR_DCACHE_ACCESS
,
466 = ARMV7_PERFCTR_DCACHE_REFILL
,
470 = ARMV7_PERFCTR_DCACHE_ACCESS
,
472 = ARMV7_PERFCTR_DCACHE_REFILL
,
476 = ARMV7_PERFCTR_PREFETCH_LINEFILL
,
478 = ARMV7_PERFCTR_PREFETCH_LINEFILL_DROP
,
483 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_L1_ICACHE_ACCESS
,
484 [C(RESULT_MISS
)] = ARMV7_PERFCTR_IFETCH_MISS
,
487 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_L1_ICACHE_ACCESS
,
488 [C(RESULT_MISS
)] = ARMV7_PERFCTR_IFETCH_MISS
,
491 * The prefetch counters don't differentiate between the I
492 * side and the D side.
496 = ARMV7_PERFCTR_PREFETCH_LINEFILL
,
498 = ARMV7_PERFCTR_PREFETCH_LINEFILL_DROP
,
503 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
504 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
507 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
508 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
511 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
512 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
517 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
518 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DTLB_REFILL
,
521 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
522 [C(RESULT_MISS
)] = ARMV7_PERFCTR_DTLB_REFILL
,
525 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
526 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
531 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
532 [C(RESULT_MISS
)] = ARMV7_PERFCTR_ITLB_MISS
,
535 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
536 [C(RESULT_MISS
)] = ARMV7_PERFCTR_ITLB_MISS
,
539 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
540 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
545 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_PC_BRANCH_PRED
,
547 = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
550 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_PC_BRANCH_PRED
,
552 = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
555 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
556 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
562 * Cortex-A15 HW events mapping
564 static const unsigned armv7_a15_perf_map
[PERF_COUNT_HW_MAX
] = {
565 [PERF_COUNT_HW_CPU_CYCLES
] = ARMV7_PERFCTR_CPU_CYCLES
,
566 [PERF_COUNT_HW_INSTRUCTIONS
] = ARMV7_PERFCTR_INSTR_EXECUTED
,
567 [PERF_COUNT_HW_CACHE_REFERENCES
] = HW_OP_UNSUPPORTED
,
568 [PERF_COUNT_HW_CACHE_MISSES
] = HW_OP_UNSUPPORTED
,
569 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS
] = ARMV7_PERFCTR_SPEC_PC_WRITE
,
570 [PERF_COUNT_HW_BRANCH_MISSES
] = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
571 [PERF_COUNT_HW_BUS_CYCLES
] = ARMV7_PERFCTR_BUS_CYCLES
,
574 static const unsigned armv7_a15_perf_cache_map
[PERF_COUNT_HW_CACHE_MAX
]
575 [PERF_COUNT_HW_CACHE_OP_MAX
]
576 [PERF_COUNT_HW_CACHE_RESULT_MAX
] = {
580 = ARMV7_PERFCTR_L1_DCACHE_READ_ACCESS
,
582 = ARMV7_PERFCTR_L1_DCACHE_READ_REFILL
,
586 = ARMV7_PERFCTR_L1_DCACHE_WRITE_ACCESS
,
588 = ARMV7_PERFCTR_L1_DCACHE_WRITE_REFILL
,
591 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
592 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
597 * Not all performance counters differentiate between read
598 * and write accesses/misses so we're not always strictly
599 * correct, but it's the best we can do. Writes and reads get
600 * combined in these cases.
603 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_L1_ICACHE_ACCESS
,
604 [C(RESULT_MISS
)] = ARMV7_PERFCTR_IFETCH_MISS
,
607 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_L1_ICACHE_ACCESS
,
608 [C(RESULT_MISS
)] = ARMV7_PERFCTR_IFETCH_MISS
,
611 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
612 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
618 = ARMV7_PERFCTR_L2_DCACHE_READ_ACCESS
,
620 = ARMV7_PERFCTR_L2_DCACHE_READ_REFILL
,
624 = ARMV7_PERFCTR_L2_DCACHE_WRITE_ACCESS
,
626 = ARMV7_PERFCTR_L2_DCACHE_WRITE_REFILL
,
629 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
630 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
635 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
637 = ARMV7_PERFCTR_L1_DTLB_READ_REFILL
,
640 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
642 = ARMV7_PERFCTR_L1_DTLB_WRITE_REFILL
,
645 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
646 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
651 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
652 [C(RESULT_MISS
)] = ARMV7_PERFCTR_ITLB_MISS
,
655 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
656 [C(RESULT_MISS
)] = ARMV7_PERFCTR_ITLB_MISS
,
659 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
660 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
665 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_PC_BRANCH_PRED
,
667 = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
670 [C(RESULT_ACCESS
)] = ARMV7_PERFCTR_PC_BRANCH_PRED
,
672 = ARMV7_PERFCTR_PC_BRANCH_MIS_PRED
,
675 [C(RESULT_ACCESS
)] = CACHE_OP_UNSUPPORTED
,
676 [C(RESULT_MISS
)] = CACHE_OP_UNSUPPORTED
,
682 * Perf Events' indices
684 #define ARMV7_IDX_CYCLE_COUNTER 0
685 #define ARMV7_IDX_COUNTER0 1
686 #define ARMV7_IDX_COUNTER_LAST (ARMV7_IDX_CYCLE_COUNTER + cpu_pmu->num_events - 1)
688 #define ARMV7_MAX_COUNTERS 32
689 #define ARMV7_COUNTER_MASK (ARMV7_MAX_COUNTERS - 1)
692 * ARMv7 low level PMNC access
696 * Perf Event to low level counters mapping
698 #define ARMV7_IDX_TO_COUNTER(x) \
699 (((x) - ARMV7_IDX_COUNTER0) & ARMV7_COUNTER_MASK)
702 * Per-CPU PMNC: config reg
704 #define ARMV7_PMNC_E (1 << 0) /* Enable all counters */
705 #define ARMV7_PMNC_P (1 << 1) /* Reset all counters */
706 #define ARMV7_PMNC_C (1 << 2) /* Cycle counter reset */
707 #define ARMV7_PMNC_D (1 << 3) /* CCNT counts every 64th cpu cycle */
708 #define ARMV7_PMNC_X (1 << 4) /* Export to ETM */
709 #define ARMV7_PMNC_DP (1 << 5) /* Disable CCNT if non-invasive debug*/
710 #define ARMV7_PMNC_N_SHIFT 11 /* Number of counters supported */
711 #define ARMV7_PMNC_N_MASK 0x1f
712 #define ARMV7_PMNC_MASK 0x3f /* Mask for writable bits */
715 * FLAG: counters overflow flag status reg
717 #define ARMV7_FLAG_MASK 0xffffffff /* Mask for writable bits */
718 #define ARMV7_OVERFLOWED_MASK ARMV7_FLAG_MASK
721 * PMXEVTYPER: Event selection reg
723 #define ARMV7_EVTYPE_MASK 0xc00000ff /* Mask for writable bits */
724 #define ARMV7_EVTYPE_EVENT 0xff /* Mask for EVENT bits */
727 * Event filters for PMUv2
729 #define ARMV7_EXCLUDE_PL1 (1 << 31)
730 #define ARMV7_EXCLUDE_USER (1 << 30)
731 #define ARMV7_INCLUDE_HYP (1 << 27)
733 static inline u32
armv7_pmnc_read(void)
736 asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(val
));
740 static inline void armv7_pmnc_write(u32 val
)
742 val
&= ARMV7_PMNC_MASK
;
744 asm volatile("mcr p15, 0, %0, c9, c12, 0" : : "r"(val
));
747 static inline int armv7_pmnc_has_overflowed(u32 pmnc
)
749 return pmnc
& ARMV7_OVERFLOWED_MASK
;
752 static inline int armv7_pmnc_counter_valid(int idx
)
754 return idx
>= ARMV7_IDX_CYCLE_COUNTER
&& idx
<= ARMV7_IDX_COUNTER_LAST
;
757 static inline int armv7_pmnc_counter_has_overflowed(u32 pmnc
, int idx
)
762 if (!armv7_pmnc_counter_valid(idx
)) {
763 pr_err("CPU%u checking wrong counter %d overflow status\n",
764 smp_processor_id(), idx
);
766 counter
= ARMV7_IDX_TO_COUNTER(idx
);
767 ret
= pmnc
& BIT(counter
);
773 static inline int armv7_pmnc_select_counter(int idx
)
777 if (!armv7_pmnc_counter_valid(idx
)) {
778 pr_err("CPU%u selecting wrong PMNC counter %d\n",
779 smp_processor_id(), idx
);
783 counter
= ARMV7_IDX_TO_COUNTER(idx
);
784 asm volatile("mcr p15, 0, %0, c9, c12, 5" : : "r" (counter
));
790 static inline u32
armv7pmu_read_counter(int idx
)
794 if (!armv7_pmnc_counter_valid(idx
))
795 pr_err("CPU%u reading wrong counter %d\n",
796 smp_processor_id(), idx
);
797 else if (idx
== ARMV7_IDX_CYCLE_COUNTER
)
798 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (value
));
799 else if (armv7_pmnc_select_counter(idx
) == idx
)
800 asm volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (value
));
805 static inline void armv7pmu_write_counter(int idx
, u32 value
)
807 if (!armv7_pmnc_counter_valid(idx
))
808 pr_err("CPU%u writing wrong counter %d\n",
809 smp_processor_id(), idx
);
810 else if (idx
== ARMV7_IDX_CYCLE_COUNTER
)
811 asm volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (value
));
812 else if (armv7_pmnc_select_counter(idx
) == idx
)
813 asm volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (value
));
816 static inline void armv7_pmnc_write_evtsel(int idx
, u32 val
)
818 if (armv7_pmnc_select_counter(idx
) == idx
) {
819 val
&= ARMV7_EVTYPE_MASK
;
820 asm volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (val
));
824 static inline int armv7_pmnc_enable_counter(int idx
)
828 if (!armv7_pmnc_counter_valid(idx
)) {
829 pr_err("CPU%u enabling wrong PMNC counter %d\n",
830 smp_processor_id(), idx
);
834 counter
= ARMV7_IDX_TO_COUNTER(idx
);
835 asm volatile("mcr p15, 0, %0, c9, c12, 1" : : "r" (BIT(counter
)));
839 static inline int armv7_pmnc_disable_counter(int idx
)
843 if (!armv7_pmnc_counter_valid(idx
)) {
844 pr_err("CPU%u disabling wrong PMNC counter %d\n",
845 smp_processor_id(), idx
);
849 counter
= ARMV7_IDX_TO_COUNTER(idx
);
850 asm volatile("mcr p15, 0, %0, c9, c12, 2" : : "r" (BIT(counter
)));
854 static inline int armv7_pmnc_enable_intens(int idx
)
858 if (!armv7_pmnc_counter_valid(idx
)) {
859 pr_err("CPU%u enabling wrong PMNC counter IRQ enable %d\n",
860 smp_processor_id(), idx
);
864 counter
= ARMV7_IDX_TO_COUNTER(idx
);
865 asm volatile("mcr p15, 0, %0, c9, c14, 1" : : "r" (BIT(counter
)));
869 static inline int armv7_pmnc_disable_intens(int idx
)
873 if (!armv7_pmnc_counter_valid(idx
)) {
874 pr_err("CPU%u disabling wrong PMNC counter IRQ enable %d\n",
875 smp_processor_id(), idx
);
879 counter
= ARMV7_IDX_TO_COUNTER(idx
);
880 asm volatile("mcr p15, 0, %0, c9, c14, 2" : : "r" (BIT(counter
)));
884 static inline u32
armv7_pmnc_getreset_flags(void)
889 asm volatile("mrc p15, 0, %0, c9, c12, 3" : "=r" (val
));
891 /* Write to clear flags */
892 val
&= ARMV7_FLAG_MASK
;
893 asm volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (val
));
899 static void armv7_pmnc_dump_regs(void)
904 printk(KERN_INFO
"PMNC registers dump:\n");
906 asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r" (val
));
907 printk(KERN_INFO
"PMNC =0x%08x\n", val
);
909 asm volatile("mrc p15, 0, %0, c9, c12, 1" : "=r" (val
));
910 printk(KERN_INFO
"CNTENS=0x%08x\n", val
);
912 asm volatile("mrc p15, 0, %0, c9, c14, 1" : "=r" (val
));
913 printk(KERN_INFO
"INTENS=0x%08x\n", val
);
915 asm volatile("mrc p15, 0, %0, c9, c12, 3" : "=r" (val
));
916 printk(KERN_INFO
"FLAGS =0x%08x\n", val
);
918 asm volatile("mrc p15, 0, %0, c9, c12, 5" : "=r" (val
));
919 printk(KERN_INFO
"SELECT=0x%08x\n", val
);
921 asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (val
));
922 printk(KERN_INFO
"CCNT =0x%08x\n", val
);
924 for (cnt
= ARMV7_IDX_COUNTER0
; cnt
<= ARMV7_IDX_COUNTER_LAST
; cnt
++) {
925 armv7_pmnc_select_counter(cnt
);
926 asm volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (val
));
927 printk(KERN_INFO
"CNT[%d] count =0x%08x\n",
928 ARMV7_IDX_TO_COUNTER(cnt
), val
);
929 asm volatile("mrc p15, 0, %0, c9, c13, 1" : "=r" (val
));
930 printk(KERN_INFO
"CNT[%d] evtsel=0x%08x\n",
931 ARMV7_IDX_TO_COUNTER(cnt
), val
);
936 static void armv7pmu_enable_event(struct hw_perf_event
*hwc
, int idx
)
939 struct pmu_hw_events
*events
= cpu_pmu
->get_hw_events();
942 * Enable counter and interrupt, and set the counter to count
943 * the event that we're interested in.
945 raw_spin_lock_irqsave(&events
->pmu_lock
, flags
);
950 armv7_pmnc_disable_counter(idx
);
953 * Set event (if destined for PMNx counters)
954 * We only need to set the event for the cycle counter if we
955 * have the ability to perform event filtering.
957 if (armv7pmu
.set_event_filter
|| idx
!= ARMV7_IDX_CYCLE_COUNTER
)
958 armv7_pmnc_write_evtsel(idx
, hwc
->config_base
);
961 * Enable interrupt for this counter
963 armv7_pmnc_enable_intens(idx
);
968 armv7_pmnc_enable_counter(idx
);
970 raw_spin_unlock_irqrestore(&events
->pmu_lock
, flags
);
973 static void armv7pmu_disable_event(struct hw_perf_event
*hwc
, int idx
)
976 struct pmu_hw_events
*events
= cpu_pmu
->get_hw_events();
979 * Disable counter and interrupt
981 raw_spin_lock_irqsave(&events
->pmu_lock
, flags
);
986 armv7_pmnc_disable_counter(idx
);
989 * Disable interrupt for this counter
991 armv7_pmnc_disable_intens(idx
);
993 raw_spin_unlock_irqrestore(&events
->pmu_lock
, flags
);
996 static irqreturn_t
armv7pmu_handle_irq(int irq_num
, void *dev
)
999 struct perf_sample_data data
;
1000 struct pmu_hw_events
*cpuc
;
1001 struct pt_regs
*regs
;
1005 * Get and reset the IRQ flags
1007 pmnc
= armv7_pmnc_getreset_flags();
1010 * Did an overflow occur?
1012 if (!armv7_pmnc_has_overflowed(pmnc
))
1016 * Handle the counter(s) overflow(s)
1018 regs
= get_irq_regs();
1020 perf_sample_data_init(&data
, 0);
1022 cpuc
= &__get_cpu_var(cpu_hw_events
);
1023 for (idx
= 0; idx
< cpu_pmu
->num_events
; ++idx
) {
1024 struct perf_event
*event
= cpuc
->events
[idx
];
1025 struct hw_perf_event
*hwc
;
1028 * We have a single interrupt for all counters. Check that
1029 * each counter has overflowed before we process it.
1031 if (!armv7_pmnc_counter_has_overflowed(pmnc
, idx
))
1035 armpmu_event_update(event
, hwc
, idx
, 1);
1036 data
.period
= event
->hw
.last_period
;
1037 if (!armpmu_event_set_period(event
, hwc
, idx
))
1040 if (perf_event_overflow(event
, &data
, regs
))
1041 cpu_pmu
->disable(hwc
, idx
);
1045 * Handle the pending perf events.
1047 * Note: this call *must* be run with interrupts disabled. For
1048 * platforms that can have the PMU interrupts raised as an NMI, this
1056 static void armv7pmu_start(void)
1058 unsigned long flags
;
1059 struct pmu_hw_events
*events
= cpu_pmu
->get_hw_events();
1061 raw_spin_lock_irqsave(&events
->pmu_lock
, flags
);
1062 /* Enable all counters */
1063 armv7_pmnc_write(armv7_pmnc_read() | ARMV7_PMNC_E
);
1064 raw_spin_unlock_irqrestore(&events
->pmu_lock
, flags
);
1067 static void armv7pmu_stop(void)
1069 unsigned long flags
;
1070 struct pmu_hw_events
*events
= cpu_pmu
->get_hw_events();
1072 raw_spin_lock_irqsave(&events
->pmu_lock
, flags
);
1073 /* Disable all counters */
1074 armv7_pmnc_write(armv7_pmnc_read() & ~ARMV7_PMNC_E
);
1075 raw_spin_unlock_irqrestore(&events
->pmu_lock
, flags
);
1078 static int armv7pmu_get_event_idx(struct pmu_hw_events
*cpuc
,
1079 struct hw_perf_event
*event
)
1082 unsigned long evtype
= event
->config_base
& ARMV7_EVTYPE_EVENT
;
1084 /* Always place a cycle counter into the cycle counter. */
1085 if (evtype
== ARMV7_PERFCTR_CPU_CYCLES
) {
1086 if (test_and_set_bit(ARMV7_IDX_CYCLE_COUNTER
, cpuc
->used_mask
))
1089 return ARMV7_IDX_CYCLE_COUNTER
;
1093 * For anything other than a cycle counter, try and use
1094 * the events counters
1096 for (idx
= ARMV7_IDX_COUNTER0
; idx
< cpu_pmu
->num_events
; ++idx
) {
1097 if (!test_and_set_bit(idx
, cpuc
->used_mask
))
1101 /* The counters are all in use. */
1106 * Add an event filter to a given event. This will only work for PMUv2 PMUs.
1108 static int armv7pmu_set_event_filter(struct hw_perf_event
*event
,
1109 struct perf_event_attr
*attr
)
1111 unsigned long config_base
= 0;
1113 if (attr
->exclude_idle
)
1115 if (attr
->exclude_user
)
1116 config_base
|= ARMV7_EXCLUDE_USER
;
1117 if (attr
->exclude_kernel
)
1118 config_base
|= ARMV7_EXCLUDE_PL1
;
1119 if (!attr
->exclude_hv
)
1120 config_base
|= ARMV7_INCLUDE_HYP
;
1123 * Install the filter into config_base as this is used to
1124 * construct the event type.
1126 event
->config_base
= config_base
;
1131 static void armv7pmu_reset(void *info
)
1133 u32 idx
, nb_cnt
= cpu_pmu
->num_events
;
1135 /* The counter and interrupt enable registers are unknown at reset. */
1136 for (idx
= ARMV7_IDX_CYCLE_COUNTER
; idx
< nb_cnt
; ++idx
)
1137 armv7pmu_disable_event(NULL
, idx
);
1139 /* Initialize & Reset PMNC: C and P bits */
1140 armv7_pmnc_write(ARMV7_PMNC_P
| ARMV7_PMNC_C
);
1143 static int armv7_a8_map_event(struct perf_event
*event
)
1145 return map_cpu_event(event
, &armv7_a8_perf_map
,
1146 &armv7_a8_perf_cache_map
, 0xFF);
1149 static int armv7_a9_map_event(struct perf_event
*event
)
1151 return map_cpu_event(event
, &armv7_a9_perf_map
,
1152 &armv7_a9_perf_cache_map
, 0xFF);
1155 static int armv7_a5_map_event(struct perf_event
*event
)
1157 return map_cpu_event(event
, &armv7_a5_perf_map
,
1158 &armv7_a5_perf_cache_map
, 0xFF);
1161 static int armv7_a15_map_event(struct perf_event
*event
)
1163 return map_cpu_event(event
, &armv7_a15_perf_map
,
1164 &armv7_a15_perf_cache_map
, 0xFF);
1167 static struct arm_pmu armv7pmu
= {
1168 .handle_irq
= armv7pmu_handle_irq
,
1169 .enable
= armv7pmu_enable_event
,
1170 .disable
= armv7pmu_disable_event
,
1171 .read_counter
= armv7pmu_read_counter
,
1172 .write_counter
= armv7pmu_write_counter
,
1173 .get_event_idx
= armv7pmu_get_event_idx
,
1174 .start
= armv7pmu_start
,
1175 .stop
= armv7pmu_stop
,
1176 .reset
= armv7pmu_reset
,
1177 .max_period
= (1LLU << 32) - 1,
1180 static u32 __init
armv7_read_num_pmnc_events(void)
1184 /* Read the nb of CNTx counters supported from PMNC */
1185 nb_cnt
= (armv7_pmnc_read() >> ARMV7_PMNC_N_SHIFT
) & ARMV7_PMNC_N_MASK
;
1187 /* Add the CPU cycles counter and return */
1191 static struct arm_pmu
*__init
armv7_a8_pmu_init(void)
1193 armv7pmu
.id
= ARM_PERF_PMU_ID_CA8
;
1194 armv7pmu
.name
= "ARMv7 Cortex-A8";
1195 armv7pmu
.map_event
= armv7_a8_map_event
;
1196 armv7pmu
.num_events
= armv7_read_num_pmnc_events();
1200 static struct arm_pmu
*__init
armv7_a9_pmu_init(void)
1202 armv7pmu
.id
= ARM_PERF_PMU_ID_CA9
;
1203 armv7pmu
.name
= "ARMv7 Cortex-A9";
1204 armv7pmu
.map_event
= armv7_a9_map_event
;
1205 armv7pmu
.num_events
= armv7_read_num_pmnc_events();
1209 static struct arm_pmu
*__init
armv7_a5_pmu_init(void)
1211 armv7pmu
.id
= ARM_PERF_PMU_ID_CA5
;
1212 armv7pmu
.name
= "ARMv7 Cortex-A5";
1213 armv7pmu
.map_event
= armv7_a5_map_event
;
1214 armv7pmu
.num_events
= armv7_read_num_pmnc_events();
1218 static struct arm_pmu
*__init
armv7_a15_pmu_init(void)
1220 armv7pmu
.id
= ARM_PERF_PMU_ID_CA15
;
1221 armv7pmu
.name
= "ARMv7 Cortex-A15";
1222 armv7pmu
.map_event
= armv7_a15_map_event
;
1223 armv7pmu
.num_events
= armv7_read_num_pmnc_events();
1224 armv7pmu
.set_event_filter
= armv7pmu_set_event_filter
;
1228 static struct arm_pmu
*__init
armv7_a8_pmu_init(void)
1233 static struct arm_pmu
*__init
armv7_a9_pmu_init(void)
1238 static struct arm_pmu
*__init
armv7_a5_pmu_init(void)
1243 static struct arm_pmu
*__init
armv7_a15_pmu_init(void)
1247 #endif /* CONFIG_CPU_V7 */