selftests/powerpc/pmu: Refactor the platform check and add macros to find array size/PVR
authorAthira Rajeev <atrajeev@linux.vnet.ibm.com>
Fri, 10 Jun 2022 13:40:47 +0000 (19:10 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 28 Jun 2022 22:57:39 +0000 (08:57 +1000)
commit9cfd110a36649f9452120a648f15f32d1c82b99d
treea30e5a2c4ad3c0fb8f647dbbe953865fc3439162
parent84cc4e66d90f6624f821df381073813dd502f657
selftests/powerpc/pmu: Refactor the platform check and add macros to find array size/PVR

The platform check for selftest support "check_pvr_for_sampling_tests"
is specific to sampling tests which includes PVR check, presence of
PMU and extended regs support. Extended regs support is needed for
sampling tests which tests whether PMU registers are programmed
correctly. There could be other sampling tests which may not need
extended regs, example, bhrb filter tests which only needs validity
check via event open.

Hence refactor the platform check to have a common function
"platform_check_for_tests" that checks only for PVR check
and presence of PMU. The existing function
"check_pvr_for_sampling_tests" will invoke the common function
and also will include checks for extended regs specific for
sampling. The common function can also be used by tests other
than sampling like event code tests.

Add macro to find array size ("ARRAY_SIZE") to sampling
tests "misc.h" file. This can be used in next tests to
find event array size. Also update "include/reg.h" to
add macros to find minor and major version from PVR which
will be used in testcases.

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220610134113.62991-10-atrajeev@linux.vnet.ibm.com
tools/testing/selftests/powerpc/include/reg.h
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h