18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Performance counter support for POWER10 processors. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2020 Madhavan Srinivasan, IBM Corporation. 68c2ecf20Sopenharmony_ci * Copyright 2020 Athira Rajeev, IBM Corporation. 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#define pr_fmt(fmt) "power10-pmu: " fmt 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include "isa207-common.h" 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Raw event encoding for Power10: 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * 60 56 52 48 44 40 36 32 178c2ecf20Sopenharmony_ci * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | 188c2ecf20Sopenharmony_ci * | | [ ] [ src_match ] [ src_mask ] | [ ] [ l2l3_sel ] [ thresh_ctl ] 198c2ecf20Sopenharmony_ci * | | | | | | 208c2ecf20Sopenharmony_ci * | | *- IFM (Linux) | | thresh start/stop -* 218c2ecf20Sopenharmony_ci * | *- BHRB (Linux) | src_sel 228c2ecf20Sopenharmony_ci * *- EBB (Linux) *invert_bit 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * 28 24 20 16 12 8 4 0 258c2ecf20Sopenharmony_ci * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | 268c2ecf20Sopenharmony_ci * [ ] [ sample ] [ ] [ ] [ pmc ] [unit ] [ ] | m [ pmcxsel ] 278c2ecf20Sopenharmony_ci * | | | | | | | 288c2ecf20Sopenharmony_ci * | | | | | | *- mark 298c2ecf20Sopenharmony_ci * | | | *- L1/L2/L3 cache_sel | |*-radix_scope_qual 308c2ecf20Sopenharmony_ci * | | sdar_mode | 318c2ecf20Sopenharmony_ci * | *- sampling mode for marked events *- combine 328c2ecf20Sopenharmony_ci * | 338c2ecf20Sopenharmony_ci * *- thresh_sel 348c2ecf20Sopenharmony_ci * 358c2ecf20Sopenharmony_ci * Below uses IBM bit numbering. 368c2ecf20Sopenharmony_ci * 378c2ecf20Sopenharmony_ci * MMCR1[x:y] = unit (PMCxUNIT) 388c2ecf20Sopenharmony_ci * MMCR1[24] = pmc1combine[0] 398c2ecf20Sopenharmony_ci * MMCR1[25] = pmc1combine[1] 408c2ecf20Sopenharmony_ci * MMCR1[26] = pmc2combine[0] 418c2ecf20Sopenharmony_ci * MMCR1[27] = pmc2combine[1] 428c2ecf20Sopenharmony_ci * MMCR1[28] = pmc3combine[0] 438c2ecf20Sopenharmony_ci * MMCR1[29] = pmc3combine[1] 448c2ecf20Sopenharmony_ci * MMCR1[30] = pmc4combine[0] 458c2ecf20Sopenharmony_ci * MMCR1[31] = pmc4combine[1] 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * if pmc == 3 and unit == 0 and pmcxsel[0:6] == 0b0101011 488c2ecf20Sopenharmony_ci * MMCR1[20:27] = thresh_ctl 498c2ecf20Sopenharmony_ci * else if pmc == 4 and unit == 0xf and pmcxsel[0:6] == 0b0101001 508c2ecf20Sopenharmony_ci * MMCR1[20:27] = thresh_ctl 518c2ecf20Sopenharmony_ci * else 528c2ecf20Sopenharmony_ci * MMCRA[48:55] = thresh_ctl (THRESH START/END) 538c2ecf20Sopenharmony_ci * 548c2ecf20Sopenharmony_ci * if thresh_sel: 558c2ecf20Sopenharmony_ci * MMCRA[45:47] = thresh_sel 568c2ecf20Sopenharmony_ci * 578c2ecf20Sopenharmony_ci * if l2l3_sel: 588c2ecf20Sopenharmony_ci * MMCR2[56:60] = l2l3_sel[0:4] 598c2ecf20Sopenharmony_ci * 608c2ecf20Sopenharmony_ci * MMCR1[16] = cache_sel[0] 618c2ecf20Sopenharmony_ci * MMCR1[17] = cache_sel[1] 628c2ecf20Sopenharmony_ci * MMCR1[18] = radix_scope_qual 638c2ecf20Sopenharmony_ci * 648c2ecf20Sopenharmony_ci * if mark: 658c2ecf20Sopenharmony_ci * MMCRA[63] = 1 (SAMPLE_ENABLE) 668c2ecf20Sopenharmony_ci * MMCRA[57:59] = sample[0:2] (RAND_SAMP_ELIG) 678c2ecf20Sopenharmony_ci * MMCRA[61:62] = sample[3:4] (RAND_SAMP_MODE) 688c2ecf20Sopenharmony_ci * 698c2ecf20Sopenharmony_ci * if EBB and BHRB: 708c2ecf20Sopenharmony_ci * MMCRA[32:33] = IFM 718c2ecf20Sopenharmony_ci * 728c2ecf20Sopenharmony_ci * MMCRA[SDAR_MODE] = sdar_mode[0:1] 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* 768c2ecf20Sopenharmony_ci * Some power10 event codes. 778c2ecf20Sopenharmony_ci */ 788c2ecf20Sopenharmony_ci#define EVENT(_name, _code) enum{_name = _code} 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#include "power10-events-list.h" 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#undef EVENT 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* MMCRA IFM bits - POWER10 */ 858c2ecf20Sopenharmony_ci#define POWER10_MMCRA_IFM1 0x0000000040000000UL 868c2ecf20Sopenharmony_ci#define POWER10_MMCRA_IFM2 0x0000000080000000UL 878c2ecf20Sopenharmony_ci#define POWER10_MMCRA_IFM3 0x00000000C0000000UL 888c2ecf20Sopenharmony_ci#define POWER10_MMCRA_BHRB_MASK 0x00000000C0000000UL 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ciextern u64 PERF_REG_EXTENDED_MASK; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* Table of alternatives, sorted by column 0 */ 938c2ecf20Sopenharmony_cistatic const unsigned int power10_event_alternatives[][MAX_ALT] = { 948c2ecf20Sopenharmony_ci { PM_RUN_CYC_ALT, PM_RUN_CYC }, 958c2ecf20Sopenharmony_ci { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL }, 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistatic int power10_get_alternatives(u64 event, unsigned int flags, u64 alt[]) 998c2ecf20Sopenharmony_ci{ 1008c2ecf20Sopenharmony_ci int num_alt = 0; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci num_alt = isa207_get_alternatives(event, alt, 1038c2ecf20Sopenharmony_ci ARRAY_SIZE(power10_event_alternatives), flags, 1048c2ecf20Sopenharmony_ci power10_event_alternatives); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci return num_alt; 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ciGENERIC_EVENT_ATTR(cpu-cycles, PM_RUN_CYC); 1108c2ecf20Sopenharmony_ciGENERIC_EVENT_ATTR(instructions, PM_RUN_INST_CMPL); 1118c2ecf20Sopenharmony_ciGENERIC_EVENT_ATTR(branch-instructions, PM_BR_CMPL); 1128c2ecf20Sopenharmony_ciGENERIC_EVENT_ATTR(branch-misses, PM_BR_MPRED_CMPL); 1138c2ecf20Sopenharmony_ciGENERIC_EVENT_ATTR(cache-references, PM_LD_REF_L1); 1148c2ecf20Sopenharmony_ciGENERIC_EVENT_ATTR(cache-misses, PM_LD_MISS_L1); 1158c2ecf20Sopenharmony_ciGENERIC_EVENT_ATTR(mem-loads, MEM_LOADS); 1168c2ecf20Sopenharmony_ciGENERIC_EVENT_ATTR(mem-stores, MEM_STORES); 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(L1-dcache-load-misses, PM_LD_MISS_L1); 1198c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(L1-dcache-loads, PM_LD_REF_L1); 1208c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(L1-dcache-prefetches, PM_LD_PREFETCH_CACHE_LINE_MISS); 1218c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(L1-dcache-store-misses, PM_ST_MISS_L1); 1228c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(L1-icache-load-misses, PM_L1_ICACHE_MISS); 1238c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(L1-icache-loads, PM_INST_FROM_L1); 1248c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(L1-icache-prefetches, PM_IC_PREF_REQ); 1258c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(LLC-load-misses, PM_DATA_FROM_L3MISS); 1268c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(LLC-loads, PM_DATA_FROM_L3); 1278c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(branch-load-misses, PM_BR_MPRED_CMPL); 1288c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(branch-loads, PM_BR_CMPL); 1298c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(dTLB-load-misses, PM_DTLB_MISS); 1308c2ecf20Sopenharmony_ciCACHE_EVENT_ATTR(iTLB-load-misses, PM_ITLB_MISS); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistatic struct attribute *power10_events_attr[] = { 1338c2ecf20Sopenharmony_ci GENERIC_EVENT_PTR(PM_RUN_CYC), 1348c2ecf20Sopenharmony_ci GENERIC_EVENT_PTR(PM_RUN_INST_CMPL), 1358c2ecf20Sopenharmony_ci GENERIC_EVENT_PTR(PM_BR_CMPL), 1368c2ecf20Sopenharmony_ci GENERIC_EVENT_PTR(PM_BR_MPRED_CMPL), 1378c2ecf20Sopenharmony_ci GENERIC_EVENT_PTR(PM_LD_REF_L1), 1388c2ecf20Sopenharmony_ci GENERIC_EVENT_PTR(PM_LD_MISS_L1), 1398c2ecf20Sopenharmony_ci GENERIC_EVENT_PTR(MEM_LOADS), 1408c2ecf20Sopenharmony_ci GENERIC_EVENT_PTR(MEM_STORES), 1418c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_LD_MISS_L1), 1428c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_LD_REF_L1), 1438c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_LD_PREFETCH_CACHE_LINE_MISS), 1448c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_ST_MISS_L1), 1458c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_L1_ICACHE_MISS), 1468c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_INST_FROM_L1), 1478c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_IC_PREF_REQ), 1488c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_DATA_FROM_L3MISS), 1498c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_DATA_FROM_L3), 1508c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_BR_MPRED_CMPL), 1518c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_BR_CMPL), 1528c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_DTLB_MISS), 1538c2ecf20Sopenharmony_ci CACHE_EVENT_PTR(PM_ITLB_MISS), 1548c2ecf20Sopenharmony_ci NULL 1558c2ecf20Sopenharmony_ci}; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistatic struct attribute_group power10_pmu_events_group = { 1588c2ecf20Sopenharmony_ci .name = "events", 1598c2ecf20Sopenharmony_ci .attrs = power10_events_attr, 1608c2ecf20Sopenharmony_ci}; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(event, "config:0-59"); 1638c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(pmcxsel, "config:0-7"); 1648c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(mark, "config:8"); 1658c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(combine, "config:10-11"); 1668c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(unit, "config:12-15"); 1678c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(pmc, "config:16-19"); 1688c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(cache_sel, "config:20-21"); 1698c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(sdar_mode, "config:22-23"); 1708c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(sample_mode, "config:24-28"); 1718c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(thresh_sel, "config:29-31"); 1728c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(thresh_stop, "config:32-35"); 1738c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(thresh_start, "config:36-39"); 1748c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(l2l3_sel, "config:40-44"); 1758c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(src_sel, "config:45-46"); 1768c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(invert_bit, "config:47"); 1778c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(src_mask, "config:48-53"); 1788c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(src_match, "config:54-59"); 1798c2ecf20Sopenharmony_ciPMU_FORMAT_ATTR(radix_scope, "config:9"); 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_cistatic struct attribute *power10_pmu_format_attr[] = { 1828c2ecf20Sopenharmony_ci &format_attr_event.attr, 1838c2ecf20Sopenharmony_ci &format_attr_pmcxsel.attr, 1848c2ecf20Sopenharmony_ci &format_attr_mark.attr, 1858c2ecf20Sopenharmony_ci &format_attr_combine.attr, 1868c2ecf20Sopenharmony_ci &format_attr_unit.attr, 1878c2ecf20Sopenharmony_ci &format_attr_pmc.attr, 1888c2ecf20Sopenharmony_ci &format_attr_cache_sel.attr, 1898c2ecf20Sopenharmony_ci &format_attr_sdar_mode.attr, 1908c2ecf20Sopenharmony_ci &format_attr_sample_mode.attr, 1918c2ecf20Sopenharmony_ci &format_attr_thresh_sel.attr, 1928c2ecf20Sopenharmony_ci &format_attr_thresh_stop.attr, 1938c2ecf20Sopenharmony_ci &format_attr_thresh_start.attr, 1948c2ecf20Sopenharmony_ci &format_attr_l2l3_sel.attr, 1958c2ecf20Sopenharmony_ci &format_attr_src_sel.attr, 1968c2ecf20Sopenharmony_ci &format_attr_invert_bit.attr, 1978c2ecf20Sopenharmony_ci &format_attr_src_mask.attr, 1988c2ecf20Sopenharmony_ci &format_attr_src_match.attr, 1998c2ecf20Sopenharmony_ci &format_attr_radix_scope.attr, 2008c2ecf20Sopenharmony_ci NULL, 2018c2ecf20Sopenharmony_ci}; 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_cistatic struct attribute_group power10_pmu_format_group = { 2048c2ecf20Sopenharmony_ci .name = "format", 2058c2ecf20Sopenharmony_ci .attrs = power10_pmu_format_attr, 2068c2ecf20Sopenharmony_ci}; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_cistatic const struct attribute_group *power10_pmu_attr_groups[] = { 2098c2ecf20Sopenharmony_ci &power10_pmu_format_group, 2108c2ecf20Sopenharmony_ci &power10_pmu_events_group, 2118c2ecf20Sopenharmony_ci NULL, 2128c2ecf20Sopenharmony_ci}; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_cistatic int power10_generic_events[] = { 2158c2ecf20Sopenharmony_ci [PERF_COUNT_HW_CPU_CYCLES] = PM_RUN_CYC, 2168c2ecf20Sopenharmony_ci [PERF_COUNT_HW_INSTRUCTIONS] = PM_RUN_INST_CMPL, 2178c2ecf20Sopenharmony_ci [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = PM_BR_CMPL, 2188c2ecf20Sopenharmony_ci [PERF_COUNT_HW_BRANCH_MISSES] = PM_BR_MPRED_CMPL, 2198c2ecf20Sopenharmony_ci [PERF_COUNT_HW_CACHE_REFERENCES] = PM_LD_REF_L1, 2208c2ecf20Sopenharmony_ci [PERF_COUNT_HW_CACHE_MISSES] = PM_LD_MISS_L1, 2218c2ecf20Sopenharmony_ci}; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_cistatic u64 power10_bhrb_filter_map(u64 branch_sample_type) 2248c2ecf20Sopenharmony_ci{ 2258c2ecf20Sopenharmony_ci u64 pmu_bhrb_filter = 0; 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci /* BHRB and regular PMU events share the same privilege state 2288c2ecf20Sopenharmony_ci * filter configuration. BHRB is always recorded along with a 2298c2ecf20Sopenharmony_ci * regular PMU event. As the privilege state filter is handled 2308c2ecf20Sopenharmony_ci * in the basic PMC configuration of the accompanying regular 2318c2ecf20Sopenharmony_ci * PMU event, we ignore any separate BHRB specific request. 2328c2ecf20Sopenharmony_ci */ 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci /* No branch filter requested */ 2358c2ecf20Sopenharmony_ci if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY) 2368c2ecf20Sopenharmony_ci return pmu_bhrb_filter; 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci /* Invalid branch filter options - HW does not support */ 2398c2ecf20Sopenharmony_ci if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_RETURN) 2408c2ecf20Sopenharmony_ci return -1; 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci if (branch_sample_type & PERF_SAMPLE_BRANCH_IND_CALL) { 2438c2ecf20Sopenharmony_ci pmu_bhrb_filter |= POWER10_MMCRA_IFM2; 2448c2ecf20Sopenharmony_ci return pmu_bhrb_filter; 2458c2ecf20Sopenharmony_ci } 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci if (branch_sample_type & PERF_SAMPLE_BRANCH_COND) { 2488c2ecf20Sopenharmony_ci pmu_bhrb_filter |= POWER10_MMCRA_IFM3; 2498c2ecf20Sopenharmony_ci return pmu_bhrb_filter; 2508c2ecf20Sopenharmony_ci } 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci if (branch_sample_type & PERF_SAMPLE_BRANCH_CALL) 2538c2ecf20Sopenharmony_ci return -1; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci if (branch_sample_type & PERF_SAMPLE_BRANCH_ANY_CALL) { 2568c2ecf20Sopenharmony_ci pmu_bhrb_filter |= POWER10_MMCRA_IFM1; 2578c2ecf20Sopenharmony_ci return pmu_bhrb_filter; 2588c2ecf20Sopenharmony_ci } 2598c2ecf20Sopenharmony_ci 2608c2ecf20Sopenharmony_ci /* Every thing else is unsupported */ 2618c2ecf20Sopenharmony_ci return -1; 2628c2ecf20Sopenharmony_ci} 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_cistatic void power10_config_bhrb(u64 pmu_bhrb_filter) 2658c2ecf20Sopenharmony_ci{ 2668c2ecf20Sopenharmony_ci pmu_bhrb_filter &= POWER10_MMCRA_BHRB_MASK; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_ci /* Enable BHRB filter in PMU */ 2698c2ecf20Sopenharmony_ci mtspr(SPRN_MMCRA, (mfspr(SPRN_MMCRA) | pmu_bhrb_filter)); 2708c2ecf20Sopenharmony_ci} 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci#define C(x) PERF_COUNT_HW_CACHE_##x 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci/* 2758c2ecf20Sopenharmony_ci * Table of generalized cache-related events. 2768c2ecf20Sopenharmony_ci * 0 means not supported, -1 means nonsensical, other values 2778c2ecf20Sopenharmony_ci * are event codes. 2788c2ecf20Sopenharmony_ci */ 2798c2ecf20Sopenharmony_cistatic u64 power10_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = { 2808c2ecf20Sopenharmony_ci [C(L1D)] = { 2818c2ecf20Sopenharmony_ci [C(OP_READ)] = { 2828c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = PM_LD_REF_L1, 2838c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = PM_LD_MISS_L1, 2848c2ecf20Sopenharmony_ci }, 2858c2ecf20Sopenharmony_ci [C(OP_WRITE)] = { 2868c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = 0, 2878c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = PM_ST_MISS_L1, 2888c2ecf20Sopenharmony_ci }, 2898c2ecf20Sopenharmony_ci [C(OP_PREFETCH)] = { 2908c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = PM_LD_PREFETCH_CACHE_LINE_MISS, 2918c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = 0, 2928c2ecf20Sopenharmony_ci }, 2938c2ecf20Sopenharmony_ci }, 2948c2ecf20Sopenharmony_ci [C(L1I)] = { 2958c2ecf20Sopenharmony_ci [C(OP_READ)] = { 2968c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = PM_INST_FROM_L1, 2978c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = PM_L1_ICACHE_MISS, 2988c2ecf20Sopenharmony_ci }, 2998c2ecf20Sopenharmony_ci [C(OP_WRITE)] = { 3008c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = PM_INST_FROM_L1MISS, 3018c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3028c2ecf20Sopenharmony_ci }, 3038c2ecf20Sopenharmony_ci [C(OP_PREFETCH)] = { 3048c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = PM_IC_PREF_REQ, 3058c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = 0, 3068c2ecf20Sopenharmony_ci }, 3078c2ecf20Sopenharmony_ci }, 3088c2ecf20Sopenharmony_ci [C(LL)] = { 3098c2ecf20Sopenharmony_ci [C(OP_READ)] = { 3108c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = PM_DATA_FROM_L3, 3118c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = PM_DATA_FROM_L3MISS, 3128c2ecf20Sopenharmony_ci }, 3138c2ecf20Sopenharmony_ci [C(OP_WRITE)] = { 3148c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3158c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3168c2ecf20Sopenharmony_ci }, 3178c2ecf20Sopenharmony_ci [C(OP_PREFETCH)] = { 3188c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3198c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = 0, 3208c2ecf20Sopenharmony_ci }, 3218c2ecf20Sopenharmony_ci }, 3228c2ecf20Sopenharmony_ci [C(DTLB)] = { 3238c2ecf20Sopenharmony_ci [C(OP_READ)] = { 3248c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = 0, 3258c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = PM_DTLB_MISS, 3268c2ecf20Sopenharmony_ci }, 3278c2ecf20Sopenharmony_ci [C(OP_WRITE)] = { 3288c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3298c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3308c2ecf20Sopenharmony_ci }, 3318c2ecf20Sopenharmony_ci [C(OP_PREFETCH)] = { 3328c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3338c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3348c2ecf20Sopenharmony_ci }, 3358c2ecf20Sopenharmony_ci }, 3368c2ecf20Sopenharmony_ci [C(ITLB)] = { 3378c2ecf20Sopenharmony_ci [C(OP_READ)] = { 3388c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = 0, 3398c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = PM_ITLB_MISS, 3408c2ecf20Sopenharmony_ci }, 3418c2ecf20Sopenharmony_ci [C(OP_WRITE)] = { 3428c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3438c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3448c2ecf20Sopenharmony_ci }, 3458c2ecf20Sopenharmony_ci [C(OP_PREFETCH)] = { 3468c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3478c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3488c2ecf20Sopenharmony_ci }, 3498c2ecf20Sopenharmony_ci }, 3508c2ecf20Sopenharmony_ci [C(BPU)] = { 3518c2ecf20Sopenharmony_ci [C(OP_READ)] = { 3528c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = PM_BR_CMPL, 3538c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = PM_BR_MPRED_CMPL, 3548c2ecf20Sopenharmony_ci }, 3558c2ecf20Sopenharmony_ci [C(OP_WRITE)] = { 3568c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3578c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3588c2ecf20Sopenharmony_ci }, 3598c2ecf20Sopenharmony_ci [C(OP_PREFETCH)] = { 3608c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3618c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3628c2ecf20Sopenharmony_ci }, 3638c2ecf20Sopenharmony_ci }, 3648c2ecf20Sopenharmony_ci [C(NODE)] = { 3658c2ecf20Sopenharmony_ci [C(OP_READ)] = { 3668c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3678c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3688c2ecf20Sopenharmony_ci }, 3698c2ecf20Sopenharmony_ci [C(OP_WRITE)] = { 3708c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3718c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3728c2ecf20Sopenharmony_ci }, 3738c2ecf20Sopenharmony_ci [C(OP_PREFETCH)] = { 3748c2ecf20Sopenharmony_ci [C(RESULT_ACCESS)] = -1, 3758c2ecf20Sopenharmony_ci [C(RESULT_MISS)] = -1, 3768c2ecf20Sopenharmony_ci }, 3778c2ecf20Sopenharmony_ci }, 3788c2ecf20Sopenharmony_ci}; 3798c2ecf20Sopenharmony_ci 3808c2ecf20Sopenharmony_ci#undef C 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_cistatic struct power_pmu power10_pmu = { 3838c2ecf20Sopenharmony_ci .name = "POWER10", 3848c2ecf20Sopenharmony_ci .n_counter = MAX_PMU_COUNTERS, 3858c2ecf20Sopenharmony_ci .add_fields = ISA207_ADD_FIELDS, 3868c2ecf20Sopenharmony_ci .test_adder = ISA207_TEST_ADDER, 3878c2ecf20Sopenharmony_ci .group_constraint_mask = CNST_CACHE_PMC4_MASK, 3888c2ecf20Sopenharmony_ci .group_constraint_val = CNST_CACHE_PMC4_VAL, 3898c2ecf20Sopenharmony_ci .compute_mmcr = isa207_compute_mmcr, 3908c2ecf20Sopenharmony_ci .config_bhrb = power10_config_bhrb, 3918c2ecf20Sopenharmony_ci .bhrb_filter_map = power10_bhrb_filter_map, 3928c2ecf20Sopenharmony_ci .get_constraint = isa207_get_constraint, 3938c2ecf20Sopenharmony_ci .get_alternatives = power10_get_alternatives, 3948c2ecf20Sopenharmony_ci .get_mem_data_src = isa207_get_mem_data_src, 3958c2ecf20Sopenharmony_ci .get_mem_weight = isa207_get_mem_weight, 3968c2ecf20Sopenharmony_ci .disable_pmc = isa207_disable_pmc, 3978c2ecf20Sopenharmony_ci .flags = PPMU_HAS_SIER | PPMU_ARCH_207S | 3988c2ecf20Sopenharmony_ci PPMU_ARCH_31, 3998c2ecf20Sopenharmony_ci .n_generic = ARRAY_SIZE(power10_generic_events), 4008c2ecf20Sopenharmony_ci .generic_events = power10_generic_events, 4018c2ecf20Sopenharmony_ci .cache_events = &power10_cache_events, 4028c2ecf20Sopenharmony_ci .attr_groups = power10_pmu_attr_groups, 4038c2ecf20Sopenharmony_ci .bhrb_nr = 32, 4048c2ecf20Sopenharmony_ci .capabilities = PERF_PMU_CAP_EXTENDED_REGS, 4058c2ecf20Sopenharmony_ci}; 4068c2ecf20Sopenharmony_ci 4078c2ecf20Sopenharmony_ciint init_power10_pmu(void) 4088c2ecf20Sopenharmony_ci{ 4098c2ecf20Sopenharmony_ci int rc; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci /* Comes from cpu_specs[] */ 4128c2ecf20Sopenharmony_ci if (!cur_cpu_spec->oprofile_cpu_type || 4138c2ecf20Sopenharmony_ci strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power10")) 4148c2ecf20Sopenharmony_ci return -ENODEV; 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci /* Set the PERF_REG_EXTENDED_MASK here */ 4178c2ecf20Sopenharmony_ci PERF_REG_EXTENDED_MASK = PERF_REG_PMU_MASK_31; 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci rc = register_power_pmu(&power10_pmu); 4208c2ecf20Sopenharmony_ci if (rc) 4218c2ecf20Sopenharmony_ci return rc; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_ci /* Tell userspace that EBB is supported */ 4248c2ecf20Sopenharmony_ci cur_cpu_spec->cpu_user_features2 |= PPC_FEATURE2_EBB; 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci return 0; 4278c2ecf20Sopenharmony_ci} 428