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

tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests

Some of the tests depends on pvr value to choose
the event. Example:
- event_alternatives_tests_p10: alternative event depends
on registered PMU driver which is based on pvr
- generic_events_valid_test varies based on platform
- bhrb_filter_map_test: again its dependent on pmu to
decide which bhrb filter to use
- reserved_bits_mmcra_sample_elig_mode: randome sampling
mode reserved bits is also varies based on platform

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Tested-by: Disha Goel <disgoel@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250113075858.45137-2-atrajeev@linux.vnet.ibm.com

authored by

Athira Rajeev and committed by
Madhavan Srinivasan
520ee327 fd4d2f32

+11 -5
+2 -1
tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c
··· 26 26 { 27 27 struct event *e, events[5]; 28 28 int i; 29 + int pvr = PVR_VER(mfspr(SPRN_PVR)); 29 30 30 31 /* Check for platform support for the test */ 31 32 SKIP_IF(platform_check_for_tests()); ··· 37 36 * code and using PVR will work correctly for all cases 38 37 * including generic compat mode. 39 38 */ 40 - SKIP_IF(PVR_VER(mfspr(SPRN_PVR)) != POWER10); 39 + SKIP_IF((pvr != POWER10) && (pvr != POWER11)); 41 40 42 41 SKIP_IF(check_for_generic_compat_pmu()); 43 42
+2 -1
tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c
··· 17 17 static int generic_events_valid_test(void) 18 18 { 19 19 struct event event; 20 + int pvr = mfspr(SPRN_PVR); 20 21 21 22 /* Check for platform support for the test */ 22 23 SKIP_IF(platform_check_for_tests()); ··· 32 31 * - PERF_COUNT_HW_STALLED_CYCLES_BACKEND 33 32 * - PERF_COUNT_HW_REF_CPU_CYCLES 34 33 */ 35 - if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) { 34 + if ((pvr == POWER10) || (pvr == POWER11)) { 36 35 event_init_opts(&event, PERF_COUNT_HW_CPU_CYCLES, PERF_TYPE_HARDWARE, "event"); 37 36 FAIL_IF(event_open(&event)); 38 37 event_close(&event);
+2 -1
tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
··· 21 21 static int reserved_bits_mmcra_sample_elig_mode(void) 22 22 { 23 23 struct event event; 24 + int pvr = PVR_VER(mfspr(SPRN_PVR)); 24 25 25 26 /* Check for platform support for the test */ 26 27 SKIP_IF(platform_check_for_tests()); ··· 60 59 * is reserved in power10 and 0xC is reserved in 61 60 * power9. 62 61 */ 63 - if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) { 62 + if ((pvr == POWER10) || (pvr == POWER11)) { 64 63 event_init(&event, 0x100401e0); 65 64 FAIL_IF(!event_open(&event)); 66 65 } else if (PVR_VER(mfspr(SPRN_PVR)) == POWER9) {
+5 -2
tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
··· 83 83 * using PVR will work correctly for all cases including generic 84 84 * compat mode. 85 85 */ 86 - if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) { 86 + switch (PVR_VER(mfspr(SPRN_PVR))) { 87 + case POWER11: 88 + case POWER10: 87 89 for (i = 0; i < ARRAY_SIZE(bhrb_filter_map_valid_p10); i++) { 88 90 event.attr.branch_sample_type = bhrb_filter_map_valid_p10[i]; 89 91 FAIL_IF(event_open(&event)); 90 92 event_close(&event); 91 93 } 92 - } else { 94 + break; 95 + default: 93 96 for (i = 0; i < ARRAY_SIZE(bhrb_filter_map_valid_p10); i++) { 94 97 event.attr.branch_sample_type = bhrb_filter_map_valid_p10[i]; 95 98 FAIL_IF(!event_open(&event));