Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/hv-gpci: Fix hv_gpci event list

Based on getPerfCountInfo v1.018 documentation, some of the
hv_gpci events were deprecated for platform firmware that
supports counter_info_version 0x8 or above.

Fix the hv_gpci event list by adding a new attribute group
called "hv_gpci_event_attrs_v6" and a "ENABLE_EVENTS_COUNTERINFO_V6"
macro to enable these events for platform firmware
that supports counter_info_version 0x6 or below. And assigning
the hv_gpci event list based on output counter info version
of underlying plaform.

Fixes: 97bf2640184f ("powerpc/perf/hv-gpci: add the remaining gpci requests")
Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Reviewed-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Reviewed-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221130174513.87501-1-kjain@linux.ibm.com

authored by

Kajol Jain and committed by
Michael Ellerman
03f7c1d2 4d0eea41

+58 -2
+4
arch/powerpc/perf/hv-gpci-requests.h
··· 79 79 ) 80 80 #include I(REQUEST_END) 81 81 82 + #ifdef ENABLE_EVENTS_COUNTERINFO_V6 82 83 /* 83 84 * Not available for counter_info_version >= 0x8, use 84 85 * run_instruction_cycles_by_partition(0x100) instead. ··· 93 92 __count(0x10, 8, cycles) 94 93 ) 95 94 #include I(REQUEST_END) 95 + #endif 96 96 97 97 #define REQUEST_NAME system_performance_capabilities 98 98 #define REQUEST_NUM 0x40 ··· 105 103 ) 106 104 #include I(REQUEST_END) 107 105 106 + #ifdef ENABLE_EVENTS_COUNTERINFO_V6 108 107 #define REQUEST_NAME processor_bus_utilization_abc_links 109 108 #define REQUEST_NUM 0x50 110 109 #define REQUEST_IDX_KIND "hw_chip_id=?" ··· 197 194 __count(0x28, 8, instructions_completed) 198 195 ) 199 196 #include I(REQUEST_END) 197 + #endif 200 198 201 199 /* Processor_core_power_mode (0x95) skipped, no counters */ 202 200 /* Affinity_domain_information_by_virtual_processor (0xA0) skipped,
+33 -2
arch/powerpc/perf/hv-gpci.c
··· 70 70 .attrs = format_attrs, 71 71 }; 72 72 73 - static const struct attribute_group event_group = { 73 + static struct attribute_group event_group = { 74 74 .name = "events", 75 - .attrs = hv_gpci_event_attrs, 75 + /* .attrs is set in init */ 76 76 }; 77 77 78 78 #define HV_CAPS_ATTR(_name, _format) \ ··· 330 330 int r; 331 331 unsigned long hret; 332 332 struct hv_perf_caps caps; 333 + struct hv_gpci_request_buffer *arg; 333 334 334 335 hv_gpci_assert_offsets_correct(); 335 336 ··· 353 352 354 353 /* sampling not supported */ 355 354 h_gpci_pmu.capabilities |= PERF_PMU_CAP_NO_INTERRUPT; 355 + 356 + arg = (void *)get_cpu_var(hv_gpci_reqb); 357 + memset(arg, 0, HGPCI_REQ_BUFFER_SIZE); 358 + 359 + /* 360 + * hcall H_GET_PERF_COUNTER_INFO populates the output 361 + * counter_info_version value based on the system hypervisor. 362 + * Pass the counter request 0x10 corresponds to request type 363 + * 'Dispatch_timebase_by_processor', to get the supported 364 + * counter_info_version. 365 + */ 366 + arg->params.counter_request = cpu_to_be32(0x10); 367 + 368 + r = plpar_hcall_norets(H_GET_PERF_COUNTER_INFO, 369 + virt_to_phys(arg), HGPCI_REQ_BUFFER_SIZE); 370 + if (r) { 371 + pr_devel("hcall failed, can't get supported counter_info_version: 0x%x\n", r); 372 + arg->params.counter_info_version_out = 0x8; 373 + } 374 + 375 + /* 376 + * Use counter_info_version_out value to assign 377 + * required hv-gpci event list. 378 + */ 379 + if (arg->params.counter_info_version_out >= 0x8) 380 + event_group.attrs = hv_gpci_event_attrs; 381 + else 382 + event_group.attrs = hv_gpci_event_attrs_v6; 383 + 384 + put_cpu_var(hv_gpci_reqb); 356 385 357 386 r = perf_pmu_register(&h_gpci_pmu, h_gpci_pmu.name, -1); 358 387 if (r)
+1
arch/powerpc/perf/hv-gpci.h
··· 26 26 #define REQUEST_FILE "../hv-gpci-requests.h" 27 27 #define NAME_LOWER hv_gpci 28 28 #define NAME_UPPER HV_GPCI 29 + #define ENABLE_EVENTS_COUNTERINFO_V6 29 30 #include "req-gen/perf.h" 30 31 #undef REQUEST_FILE 31 32 #undef NAME_LOWER
+20
arch/powerpc/perf/req-gen/perf.h
··· 139 139 #define REQUEST_(r_name, r_value, r_idx_1, r_fields) \ 140 140 r_fields 141 141 142 + /* Generate event list for platforms with counter_info_version 0x6 or below */ 143 + static __maybe_unused struct attribute *hv_gpci_event_attrs_v6[] = { 144 + #include REQUEST_FILE 145 + NULL 146 + }; 147 + 148 + /* 149 + * Based on getPerfCountInfo v1.018 documentation, some of the hv-gpci 150 + * events were deprecated for platform firmware that supports 151 + * counter_info_version 0x8 or above. 152 + * Those deprecated events are still part of platform firmware that 153 + * support counter_info_version 0x6 and below. As per the getPerfCountInfo 154 + * v1.018 documentation there is no counter_info_version 0x7. 155 + * Undefining macro ENABLE_EVENTS_COUNTERINFO_V6, to disable the addition of 156 + * deprecated events in "hv_gpci_event_attrs" attribute group, for platforms 157 + * that supports counter_info_version 0x8 or above. 158 + */ 159 + #undef ENABLE_EVENTS_COUNTERINFO_V6 160 + 161 + /* Generate event list for platforms with counter_info_version 0x8 or above*/ 142 162 static __maybe_unused struct attribute *hv_gpci_event_attrs[] = { 143 163 #include REQUEST_FILE 144 164 NULL