.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Performance counter support for POWER9 processors. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2009 Paul Mackerras, IBM Corporation. |
---|
5 | 6 | * Copyright 2013 Michael Ellerman, IBM Corporation. |
---|
6 | 7 | * Copyright 2016 Madhavan Srinivasan, IBM Corporation. |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or |
---|
9 | | - * modify it under the terms of the GNU General Public License |
---|
10 | | - * as published by the Free Software Foundation; either version |
---|
11 | | - * 2 of the License, or later version. |
---|
12 | 8 | */ |
---|
13 | 9 | |
---|
14 | 10 | #define pr_fmt(fmt) "power9-pmu: " fmt |
---|
.. | .. |
---|
63 | 59 | * MMCRA[9:11] = thresh_cmp[0:2] |
---|
64 | 60 | * MMCRA[12:18] = thresh_cmp[3:9] |
---|
65 | 61 | * |
---|
66 | | - * if unit == 6 or unit == 7 |
---|
67 | | - * MMCRC[53:55] = cache_sel[1:3] (L2EVENT_SEL) |
---|
68 | | - * else if unit == 8 or unit == 9: |
---|
69 | | - * if cache_sel[0] == 0: # L3 bank |
---|
70 | | - * MMCRC[47:49] = cache_sel[1:3] (L3EVENT_SEL0) |
---|
71 | | - * else if cache_sel[0] == 1: |
---|
72 | | - * MMCRC[50:51] = cache_sel[2:3] (L3EVENT_SEL1) |
---|
73 | | - * else if cache_sel[1]: # L1 event |
---|
74 | | - * MMCR1[16] = cache_sel[2] |
---|
75 | | - * MMCR1[17] = cache_sel[3] |
---|
| 62 | + * MMCR1[16] = cache_sel[2] |
---|
| 63 | + * MMCR1[17] = cache_sel[3] |
---|
76 | 64 | * |
---|
77 | 65 | * if mark: |
---|
78 | 66 | * MMCRA[63] = 1 (SAMPLE_ENABLE) |
---|
.. | .. |
---|
101 | 89 | #define POWER9_MMCRA_IFM2 0x0000000080000000UL |
---|
102 | 90 | #define POWER9_MMCRA_IFM3 0x00000000C0000000UL |
---|
103 | 91 | #define POWER9_MMCRA_BHRB_MASK 0x00000000C0000000UL |
---|
| 92 | + |
---|
| 93 | +extern u64 PERF_REG_EXTENDED_MASK; |
---|
104 | 94 | |
---|
105 | 95 | /* Nasty Power9 specific hack */ |
---|
106 | 96 | #define PVR_POWER9_CUMULUS 0x00002000 |
---|
.. | .. |
---|
143 | 133 | |
---|
144 | 134 | /* Table of alternatives, sorted by column 0 */ |
---|
145 | 135 | static const unsigned int power9_event_alternatives[][MAX_ALT] = { |
---|
146 | | - { PM_INST_DISP, PM_INST_DISP_ALT }, |
---|
147 | | - { PM_RUN_CYC_ALT, PM_RUN_CYC }, |
---|
148 | | - { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL }, |
---|
149 | | - { PM_LD_MISS_L1, PM_LD_MISS_L1_ALT }, |
---|
150 | 136 | { PM_BR_2PATH, PM_BR_2PATH_ALT }, |
---|
| 137 | + { PM_INST_DISP, PM_INST_DISP_ALT }, |
---|
| 138 | + { PM_RUN_CYC_ALT, PM_RUN_CYC }, |
---|
| 139 | + { PM_LD_MISS_L1, PM_LD_MISS_L1_ALT }, |
---|
| 140 | + { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL }, |
---|
151 | 141 | }; |
---|
152 | 142 | |
---|
153 | 143 | static int power9_get_alternatives(u64 event, unsigned int flags, u64 alt[]) |
---|
.. | .. |
---|
169 | 159 | GENERIC_EVENT_ATTR(branch-misses, PM_BR_MPRED_CMPL); |
---|
170 | 160 | GENERIC_EVENT_ATTR(cache-references, PM_LD_REF_L1); |
---|
171 | 161 | GENERIC_EVENT_ATTR(cache-misses, PM_LD_MISS_L1_FIN); |
---|
| 162 | +GENERIC_EVENT_ATTR(mem-loads, MEM_LOADS); |
---|
| 163 | +GENERIC_EVENT_ATTR(mem-stores, MEM_STORES); |
---|
172 | 164 | |
---|
173 | 165 | CACHE_EVENT_ATTR(L1-dcache-load-misses, PM_LD_MISS_L1_FIN); |
---|
174 | 166 | CACHE_EVENT_ATTR(L1-dcache-loads, PM_LD_REF_L1); |
---|
.. | .. |
---|
180 | 172 | CACHE_EVENT_ATTR(LLC-load-misses, PM_DATA_FROM_L3MISS); |
---|
181 | 173 | CACHE_EVENT_ATTR(LLC-loads, PM_DATA_FROM_L3); |
---|
182 | 174 | CACHE_EVENT_ATTR(LLC-prefetches, PM_L3_PREF_ALL); |
---|
183 | | -CACHE_EVENT_ATTR(LLC-store-misses, PM_L2_ST_MISS); |
---|
184 | | -CACHE_EVENT_ATTR(LLC-stores, PM_L2_ST); |
---|
185 | 175 | CACHE_EVENT_ATTR(branch-load-misses, PM_BR_MPRED_CMPL); |
---|
186 | 176 | CACHE_EVENT_ATTR(branch-loads, PM_BR_CMPL); |
---|
187 | 177 | CACHE_EVENT_ATTR(dTLB-load-misses, PM_DTLB_MISS); |
---|
.. | .. |
---|
196 | 186 | GENERIC_EVENT_PTR(PM_BR_MPRED_CMPL), |
---|
197 | 187 | GENERIC_EVENT_PTR(PM_LD_REF_L1), |
---|
198 | 188 | GENERIC_EVENT_PTR(PM_LD_MISS_L1_FIN), |
---|
| 189 | + GENERIC_EVENT_PTR(MEM_LOADS), |
---|
| 190 | + GENERIC_EVENT_PTR(MEM_STORES), |
---|
199 | 191 | CACHE_EVENT_PTR(PM_LD_MISS_L1_FIN), |
---|
200 | 192 | CACHE_EVENT_PTR(PM_LD_REF_L1), |
---|
201 | 193 | CACHE_EVENT_PTR(PM_L1_PREF), |
---|
.. | .. |
---|
206 | 198 | CACHE_EVENT_PTR(PM_DATA_FROM_L3MISS), |
---|
207 | 199 | CACHE_EVENT_PTR(PM_DATA_FROM_L3), |
---|
208 | 200 | CACHE_EVENT_PTR(PM_L3_PREF_ALL), |
---|
209 | | - CACHE_EVENT_PTR(PM_L2_ST_MISS), |
---|
210 | | - CACHE_EVENT_PTR(PM_L2_ST), |
---|
211 | 201 | CACHE_EVENT_PTR(PM_BR_MPRED_CMPL), |
---|
212 | 202 | CACHE_EVENT_PTR(PM_BR_CMPL), |
---|
213 | 203 | CACHE_EVENT_PTR(PM_DTLB_MISS), |
---|
.. | .. |
---|
322 | 312 | * 0 means not supported, -1 means nonsensical, other values |
---|
323 | 313 | * are event codes. |
---|
324 | 314 | */ |
---|
325 | | -static int power9_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { |
---|
| 315 | +static u64 power9_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { |
---|
326 | 316 | [ C(L1D) ] = { |
---|
327 | 317 | [ C(OP_READ) ] = { |
---|
328 | 318 | [ C(RESULT_ACCESS) ] = PM_LD_REF_L1, |
---|
.. | .. |
---|
357 | 347 | [ C(RESULT_MISS) ] = PM_DATA_FROM_L3MISS, |
---|
358 | 348 | }, |
---|
359 | 349 | [ C(OP_WRITE) ] = { |
---|
360 | | - [ C(RESULT_ACCESS) ] = PM_L2_ST, |
---|
361 | | - [ C(RESULT_MISS) ] = PM_L2_ST_MISS, |
---|
| 350 | + [ C(RESULT_ACCESS) ] = 0, |
---|
| 351 | + [ C(RESULT_MISS) ] = 0, |
---|
362 | 352 | }, |
---|
363 | 353 | [ C(OP_PREFETCH) ] = { |
---|
364 | 354 | [ C(RESULT_ACCESS) ] = PM_L3_PREF_ALL, |
---|
.. | .. |
---|
430 | 420 | .n_counter = MAX_PMU_COUNTERS, |
---|
431 | 421 | .add_fields = ISA207_ADD_FIELDS, |
---|
432 | 422 | .test_adder = ISA207_TEST_ADDER, |
---|
| 423 | + .group_constraint_mask = CNST_CACHE_PMC4_MASK, |
---|
| 424 | + .group_constraint_val = CNST_CACHE_PMC4_VAL, |
---|
433 | 425 | .compute_mmcr = isa207_compute_mmcr, |
---|
434 | 426 | .config_bhrb = power9_config_bhrb, |
---|
435 | 427 | .bhrb_filter_map = power9_bhrb_filter_map, |
---|
.. | .. |
---|
444 | 436 | .cache_events = &power9_cache_events, |
---|
445 | 437 | .attr_groups = power9_pmu_attr_groups, |
---|
446 | 438 | .bhrb_nr = 32, |
---|
| 439 | + .capabilities = PERF_PMU_CAP_EXTENDED_REGS, |
---|
447 | 440 | }; |
---|
448 | 441 | |
---|
449 | | -static int __init init_power9_pmu(void) |
---|
| 442 | +int init_power9_pmu(void) |
---|
450 | 443 | { |
---|
451 | 444 | int rc = 0; |
---|
452 | 445 | unsigned int pvr = mfspr(SPRN_PVR); |
---|
.. | .. |
---|
467 | 460 | } |
---|
468 | 461 | } |
---|
469 | 462 | |
---|
| 463 | + /* Set the PERF_REG_EXTENDED_MASK here */ |
---|
| 464 | + PERF_REG_EXTENDED_MASK = PERF_REG_PMU_MASK_300; |
---|
| 465 | + |
---|
470 | 466 | rc = register_power_pmu(&power9_pmu); |
---|
471 | 467 | if (rc) |
---|
472 | 468 | return rc; |
---|
.. | .. |
---|
476 | 472 | |
---|
477 | 473 | return 0; |
---|
478 | 474 | } |
---|
479 | | -early_initcall(init_power9_pmu); |
---|