linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11
@ 2025-01-13  7:58 Athira Rajeev
  2025-01-13  7:58 ` [PATCH V2 2/5] tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests Athira Rajeev
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Athira Rajeev @ 2025-01-13  7:58 UTC (permalink / raw)
  To: linuxppc-dev, maddy, hbathini; +Cc: atrajeev, kjain, disgoel

Add check for power11 pvr in the selftest utility
functions. Selftests uses pvr value to check for platform
support inorder to run the tests. pvr is also used to
send the extended mask value to capture sampling registers.

Update some of the utility functions to use hwcap2 inorder
to return platform specific bits from sampling registers.

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
Changelog:
 v1 -> v2
 No code changes. Rebased to latest upstream

 .../selftests/powerpc/pmu/sampling_tests/misc.c       | 11 ++++++++++-
 .../selftests/powerpc/pmu/sampling_tests/misc.h       | 10 ++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
index eac6420abdf1..c52d8bc2a5dc 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
@@ -59,6 +59,7 @@ static void init_ev_encodes(void)
 	ev_shift_thd_stop = 32;
 
 	switch (pvr) {
+	case POWER11:
 	case POWER10:
 		ev_mask_thd_cmp = 0x3ffff;
 		ev_shift_thd_cmp = 0;
@@ -129,8 +130,14 @@ int platform_check_for_tests(void)
 	 * Check for supported platforms
 	 * for sampling test
 	 */
-	if ((pvr != POWER10) && (pvr != POWER9))
+	switch (pvr) {
+	case POWER11:
+	case POWER10:
+	case POWER9:
+		break;
+	default:
 		goto out;
+	}
 
 	/*
 	 * Check PMU driver registered by looking for
@@ -499,6 +506,8 @@ static bool auxv_generic_compat_pmu(void)
 		base_pvr = POWER9;
 	else if (!strcmp(auxv_base_platform(), "power10"))
 		base_pvr = POWER10;
+	else if (!strcmp(auxv_base_platform(), "power11"))
+		base_pvr = POWER11;
 
 	return (!base_pvr);
 }
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
index 64e25cce1435..09c5abe237af 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
@@ -8,10 +8,12 @@
 #include <sys/stat.h>
 #include "../event.h"
 
+#define POWER11 0x82
 #define POWER10 0x80
 #define POWER9  0x4e
 #define PERF_POWER9_MASK        0x7f8ffffffffffff
 #define PERF_POWER10_MASK       0x7ffffffffffffff
+#define PERF_POWER11_MASK       PERF_POWER10_MASK
 
 #define MMCR0_FC56      0x00000010UL /* freeze counters 5 and 6 */
 #define MMCR0_PMCCEXT   0x00000200UL /* PMCCEXT control */
@@ -165,21 +167,21 @@ static inline int get_mmcr2_fcta(u64 mmcr2, int pmc)
 
 static inline int get_mmcr2_l2l3(u64 mmcr2, int pmc)
 {
-	if (pvr == POWER10)
+	if (have_hwcap2(PPC_FEATURE2_ARCH_3_1))
 		return ((mmcr2 & 0xf8) >> 3);
 	return 0;
 }
 
 static inline int get_mmcr3_src(u64 mmcr3, int pmc)
 {
-	if (pvr != POWER10)
+	if (!have_hwcap2(PPC_FEATURE2_ARCH_3_1))
 		return 0;
 	return ((mmcr3 >> ((49 - (15 * ((pmc) - 1))))) & 0x7fff);
 }
 
 static inline int get_mmcra_thd_cmp(u64 mmcra, int pmc)
 {
-	if (pvr == POWER10)
+	if (have_hwcap2(PPC_FEATURE2_ARCH_3_1))
 		return ((mmcra >> 45) & 0x7ff);
 	return ((mmcra >> 45) & 0x3ff);
 }
@@ -191,7 +193,7 @@ static inline int get_mmcra_sm(u64 mmcra, int pmc)
 
 static inline u64 get_mmcra_bhrb_disable(u64 mmcra, int pmc)
 {
-	if (pvr == POWER10)
+	if (have_hwcap2(PPC_FEATURE2_ARCH_3_1))
 		return mmcra & BHRB_DISABLE;
 	return 0;
 }
-- 
2.43.5



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 2/5] tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests
  2025-01-13  7:58 [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Athira Rajeev
@ 2025-01-13  7:58 ` Athira Rajeev
  2025-01-15 16:14   ` Disha Goel
  2025-01-13  7:58 ` [PATCH V2 3/5] tools/testing/selftests/powerpc/pmu: Update comment description to mention ISA v3.1 for power10 and above Athira Rajeev
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Athira Rajeev @ 2025-01-13  7:58 UTC (permalink / raw)
  To: linuxppc-dev, maddy, hbathini; +Cc: atrajeev, kjain, disgoel

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>
---
Changelog:
 v1 -> v2
 No code changes. Rebased to latest upstream

 .../pmu/event_code_tests/event_alternatives_tests_p10.c    | 3 ++-
 .../pmu/event_code_tests/generic_events_valid_test.c       | 3 ++-
 .../reserved_bits_mmcra_sample_elig_mode_test.c            | 3 ++-
 .../powerpc/pmu/sampling_tests/bhrb_filter_map_test.c      | 7 +++++--
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c
index 8be7aada6523..355f8bbe06c3 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c
@@ -26,6 +26,7 @@ static int event_alternatives_tests_p10(void)
 {
 	struct event *e, events[5];
 	int i;
+	int pvr = PVR_VER(mfspr(SPRN_PVR));
 
 	/* Check for platform support for the test */
 	SKIP_IF(platform_check_for_tests());
@@ -36,7 +37,7 @@ static int event_alternatives_tests_p10(void)
 	 * code and using PVR will work correctly for all cases
 	 * including generic compat mode.
 	 */
-	SKIP_IF(PVR_VER(mfspr(SPRN_PVR)) != POWER10);
+	SKIP_IF((pvr != POWER10) && (pvr != POWER11));
 
 	SKIP_IF(check_for_generic_compat_pmu());
 
diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c
index 0d237c15d3f2..a378fa9a5a7b 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c
@@ -17,6 +17,7 @@
 static int generic_events_valid_test(void)
 {
 	struct event event;
+	int pvr = mfspr(SPRN_PVR);
 
 	/* Check for platform support for the test */
 	SKIP_IF(platform_check_for_tests());
@@ -31,7 +32,7 @@ static int generic_events_valid_test(void)
 	 * - PERF_COUNT_HW_STALLED_CYCLES_BACKEND
 	 * - PERF_COUNT_HW_REF_CPU_CYCLES
 	 */
-	if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) {
+	if ((pvr == POWER10) || (pvr == POWER11)) {
 		event_init_opts(&event, PERF_COUNT_HW_CPU_CYCLES, PERF_TYPE_HARDWARE, "event");
 		FAIL_IF(event_open(&event));
 		event_close(&event);
diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
index 4c119c821b99..7bb26a232fbe 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
@@ -21,6 +21,7 @@
 static int reserved_bits_mmcra_sample_elig_mode(void)
 {
 	struct event event;
+	int pvr = PVR_VER(mfspr(SPRN_PVR));
 
 	/* Check for platform support for the test */
 	SKIP_IF(platform_check_for_tests());
@@ -59,7 +60,7 @@ static int reserved_bits_mmcra_sample_elig_mode(void)
 	 * is reserved in power10 and 0xC is reserved in
 	 * power9.
 	 */
-	if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) {
+	if ((pvr == POWER10) || (pvr == POWER11)) {
 		event_init(&event, 0x100401e0);
 		FAIL_IF(!event_open(&event));
 	} else if (PVR_VER(mfspr(SPRN_PVR)) == POWER9) {
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
index 3f43c315c666..64ab9784f9b1 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
@@ -83,13 +83,16 @@ static int bhrb_filter_map_test(void)
 	 * using PVR will work correctly for all cases including generic
 	 * compat mode.
 	 */
-	if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) {
+	switch (PVR_VER(mfspr(SPRN_PVR))) {
+	case POWER11:
+	case POWER10:
 		for (i = 0; i < ARRAY_SIZE(bhrb_filter_map_valid_p10); i++) {
 			event.attr.branch_sample_type = bhrb_filter_map_valid_p10[i];
 			FAIL_IF(event_open(&event));
 			event_close(&event);
 		}
-	} else {
+		break;
+	default:
 		for (i = 0; i < ARRAY_SIZE(bhrb_filter_map_valid_p10); i++) {
 			event.attr.branch_sample_type = bhrb_filter_map_valid_p10[i];
 			FAIL_IF(!event_open(&event));
-- 
2.43.5



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 3/5] tools/testing/selftests/powerpc/pmu: Update comment description to mention ISA v3.1 for power10 and above
  2025-01-13  7:58 [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Athira Rajeev
  2025-01-13  7:58 ` [PATCH V2 2/5] tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests Athira Rajeev
@ 2025-01-13  7:58 ` Athira Rajeev
  2025-01-13  7:58 ` [PATCH V2 4/5] selftests/powerpc/pmu: Add interface test for extended reg support Athira Rajeev
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Athira Rajeev @ 2025-01-13  7:58 UTC (permalink / raw)
  To: linuxppc-dev, maddy, hbathini; +Cc: atrajeev, kjain, disgoel

Updated the comments in the pmu selftests to include
power11/ISA v3.1 where ever required.

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
Changelog:
 v1 -> v2
 No code changes. Rebased to latest upstream

 .../event_code_tests/group_constraint_l2l3_sel_test.c  |  2 +-
 .../group_constraint_radix_scope_qual_test.c           |  2 +-
 .../group_constraint_thresh_cmp_test.c                 |  2 +-
 .../pmu/event_code_tests/invalid_event_code_test.c     |  4 ++--
 .../reserved_bits_mmcra_sample_elig_mode_test.c        |  2 +-
 .../powerpc/pmu/sampling_tests/bhrb_filter_map_test.c  | 10 +++++-----
 .../powerpc/pmu/sampling_tests/mmcra_bhrb_cond_test.c  |  2 +-
 .../sampling_tests/mmcra_bhrb_disable_no_branch_test.c |  2 +-
 .../pmu/sampling_tests/mmcra_bhrb_disable_test.c       |  2 +-
 .../pmu/sampling_tests/mmcra_bhrb_ind_call_test.c      |  2 +-
 10 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_l2l3_sel_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_l2l3_sel_test.c
index 85a636886069..e3c7a0c071e2 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_l2l3_sel_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_l2l3_sel_test.c
@@ -30,7 +30,7 @@ static int group_constraint_l2l3_sel(void)
 
 	/*
 	 * Check for platform support for the test.
-	 * This test is only aplicable on power10
+	 * This test is only aplicable on ISA v3.1
 	 */
 	SKIP_IF(platform_check_for_tests());
 	SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_radix_scope_qual_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_radix_scope_qual_test.c
index 9225618b846a..9233175787cc 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_radix_scope_qual_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_radix_scope_qual_test.c
@@ -26,7 +26,7 @@ static int group_constraint_radix_scope_qual(void)
 
 	/*
 	 * Check for platform support for the test.
-	 * This test is aplicable on power10 only.
+	 * This test is aplicable on ISA v3.1 only.
 	 */
 	SKIP_IF(platform_check_for_tests());
 	SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_thresh_cmp_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_thresh_cmp_test.c
index 9f1197104e8c..4b69e7214c0b 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_thresh_cmp_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_thresh_cmp_test.c
@@ -25,7 +25,7 @@
 /*
  * Testcase for group constraint check of thresh_cmp bits which is
  * used to program thresh compare field in Monitor Mode Control Register A
- * (MMCRA: 9-18 bits for power9 and MMCRA: 8-18 bits for power10).
+ * (MMCRA: 9-18 bits for power9 and MMCRA: 8-18 bits for power10/power11).
  * All events in the group should match thresh compare bits otherwise
  * event_open for the group will fail.
  */
diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/invalid_event_code_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/invalid_event_code_test.c
index f51fcab837fc..88aa7fd64ec1 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/invalid_event_code_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/invalid_event_code_test.c
@@ -20,7 +20,7 @@
  * Some of the bits in the event code is
  * reserved for specific platforms.
  * Event code bits 52-59 are reserved in power9,
- * whereas in power10, these are used for programming
+ * whereas in ISA v3.1, these are used for programming
  * Monitor Mode Control Register 3 (MMCR3).
  * Bit 9 in event code is reserved in power9,
  * whereas it is used for programming "radix_scope_qual"
@@ -39,7 +39,7 @@ static int invalid_event_code(void)
 
 	/*
 	 * Events using MMCR3 bits and radix scope qual bits
-	 * should fail in power9 and should succeed in power10.
+	 * should fail in power9 and should succeed in power10 ( ISA v3.1 )
 	 * Init the events and check for pass/fail in event open.
 	 */
 	if (have_hwcap2(PPC_FEATURE2_ARCH_3_1)) {
diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
index 7bb26a232fbe..757f454c0dc0 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
@@ -57,7 +57,7 @@ static int reserved_bits_mmcra_sample_elig_mode(void)
 
 	/*
 	 * MMCRA Random Sampling Mode (SM) value 0x10
-	 * is reserved in power10 and 0xC is reserved in
+	 * is reserved in power10/power11 and 0xC is reserved in
 	 * power9.
 	 */
 	if ((pvr == POWER10) || (pvr == POWER11)) {
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
index 64ab9784f9b1..3ad71d49ae65 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
@@ -14,7 +14,7 @@
  * A perf sampling test to check bhrb filter
  * map. All the branch filters are not supported
  * in powerpc. Supported filters in:
- * power10: any, any_call, ind_call, cond
+ * power10/power11: any, any_call, ind_call, cond
  * power9: any, any_call
  *
  * Testcase checks event open for invalid bhrb filter
@@ -24,13 +24,13 @@
  */
 
 /* Invalid types for powerpc */
-/* Valid bhrb filters in power9/power10 */
+/* Valid bhrb filters in power9/power10/power11 */
 int bhrb_filter_map_valid_common[] = {
 	PERF_SAMPLE_BRANCH_ANY,
 	PERF_SAMPLE_BRANCH_ANY_CALL,
 };
 
-/* Valid bhrb filters in power10 */
+/* Valid bhrb filters in power10/power11 */
 int bhrb_filter_map_valid_p10[] = {
 	PERF_SAMPLE_BRANCH_IND_CALL,
 	PERF_SAMPLE_BRANCH_COND,
@@ -69,7 +69,7 @@ static int bhrb_filter_map_test(void)
 		FAIL_IF(!event_open(&event));
 	}
 
-	/* valid filter maps for power9/power10 which are expected to pass in event_open */
+	/* valid filter maps for power9/power10/power11 which are expected to pass in event_open */
 	for (i = 0; i < ARRAY_SIZE(bhrb_filter_map_valid_common); i++) {
 		event.attr.branch_sample_type = bhrb_filter_map_valid_common[i];
 		FAIL_IF(event_open(&event));
@@ -77,7 +77,7 @@ static int bhrb_filter_map_test(void)
 	}
 
 	/*
-	 * filter maps which are valid in power10 and invalid in power9.
+	 * filter maps which are valid in power10/power11 and invalid in power9.
 	 * PVR check is used here since PMU specific data like bhrb filter
 	 * alternative tests is handled by respective PMU driver code and
 	 * using PVR will work correctly for all cases including generic
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_cond_test.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_cond_test.c
index 3e08176eb7f8..809de8d58b3b 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_cond_test.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_cond_test.c
@@ -29,7 +29,7 @@ static int mmcra_bhrb_cond_test(void)
 
 	/*
 	 * Check for platform support for the test.
-	 * This test is only aplicable on power10
+	 * This test is only aplicable on ISA v3.1
 	 */
 	SKIP_IF(check_pvr_for_sampling_tests());
 	SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_disable_no_branch_test.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_disable_no_branch_test.c
index 488c865387e4..fa0dc15f9123 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_disable_no_branch_test.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_disable_no_branch_test.c
@@ -26,7 +26,7 @@ static int mmcra_bhrb_disable_no_branch_test(void)
 
 	/*
 	 * Check for platform support for the test.
-	 * This test is only aplicable on power10
+	 * This test is only aplicable on ISA v3.1
 	 */
 	SKIP_IF(check_pvr_for_sampling_tests());
 	SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_disable_test.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_disable_test.c
index 186a853c0f62..bc3161ab003d 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_disable_test.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_disable_test.c
@@ -26,7 +26,7 @@ static int mmcra_bhrb_disable_test(void)
 
 	/*
 	 * Check for platform support for the test.
-	 * This test is only aplicable on power10
+	 * This test is only aplicable on ISA v3.1
 	 */
 	SKIP_IF(check_pvr_for_sampling_tests());
 	SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_ind_call_test.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_ind_call_test.c
index f0706730c099..fd6c9f12212c 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_ind_call_test.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_bhrb_ind_call_test.c
@@ -29,7 +29,7 @@ static int mmcra_bhrb_ind_call_test(void)
 
 	/*
 	 * Check for platform support for the test.
-	 * This test is only aplicable on power10
+	 * This test is only aplicable on ISA v3.1
 	 */
 	SKIP_IF(check_pvr_for_sampling_tests());
 	SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
-- 
2.43.5



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 4/5] selftests/powerpc/pmu: Add interface test for extended reg support
  2025-01-13  7:58 [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Athira Rajeev
  2025-01-13  7:58 ` [PATCH V2 2/5] tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests Athira Rajeev
  2025-01-13  7:58 ` [PATCH V2 3/5] tools/testing/selftests/powerpc/pmu: Update comment description to mention ISA v3.1 for power10 and above Athira Rajeev
@ 2025-01-13  7:58 ` Athira Rajeev
  2025-01-13  7:58 ` [PATCH V2 5/5] selftests/powerpc/pmu: Update comment with details to understand auxv_generic_compat_pmu() utility function Athira Rajeev
  2025-02-17  7:28 ` [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Madhavan Srinivasan
  4 siblings, 0 replies; 7+ messages in thread
From: Athira Rajeev @ 2025-01-13  7:58 UTC (permalink / raw)
  To: linuxppc-dev, maddy, hbathini; +Cc: atrajeev, kjain, disgoel

From: Kajol Jain <kjain@linux.ibm.com>

The testcase uses check_extended_regs_support and
perf_get_platform_reg_mask function to check if the
platform has extended reg support. This will help to
check if sampling pmu selftest is enabled or not for
a given platform.

Signed-off-by: Kajol Jain <kjain@linux.ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
Changelog:
 v1 -> v2
 No code changes. Rebased to latest upstream

 .../powerpc/pmu/sampling_tests/Makefile       |  3 +-
 .../sampling_tests/check_extended_reg_test.c  | 35 +++++++++++++++++++
 .../powerpc/pmu/sampling_tests/misc.c         |  2 +-
 .../powerpc/pmu/sampling_tests/misc.h         |  2 ++
 4 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/check_extended_reg_test.c

diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile b/tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile
index 9f79bec5fce7..0c4ed299c3b8 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile
@@ -5,7 +5,8 @@ TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test
 		   mmcr3_src_test mmcra_thresh_marked_sample_test mmcra_thresh_cmp_test \
 		   mmcra_bhrb_ind_call_test mmcra_bhrb_any_test mmcra_bhrb_cond_test \
 		   mmcra_bhrb_disable_test bhrb_no_crash_wo_pmu_test intr_regs_no_crash_wo_pmu_test \
-		   bhrb_filter_map_test mmcr1_sel_unit_cache_test mmcra_bhrb_disable_no_branch_test
+		   bhrb_filter_map_test mmcr1_sel_unit_cache_test mmcra_bhrb_disable_no_branch_test \
+		   check_extended_reg_test
 
 top_srcdir = ../../../../../..
 include ../../../lib.mk
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/check_extended_reg_test.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/check_extended_reg_test.c
new file mode 100644
index 000000000000..865bc69f920c
--- /dev/null
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/check_extended_reg_test.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright 2024, Kajol Jain, IBM Corp.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "../event.h"
+#include "misc.h"
+#include "utils.h"
+
+/*
+ * A perf sampling test to check extended
+ * reg support.
+ */
+static int check_extended_reg_test(void)
+{
+	/* Check for platform support for the test */
+	SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_00));
+
+	 /* Skip for Generic compat PMU */
+	SKIP_IF(check_for_generic_compat_pmu());
+
+	/* Check if platform supports extended regs */
+	platform_extended_mask = perf_get_platform_reg_mask();
+	FAIL_IF(check_extended_regs_support());
+
+	return 0;
+}
+
+int main(void)
+{
+	return test_harness(check_extended_reg_test, "check_extended_reg_test");
+}
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
index c52d8bc2a5dc..1ba675802ee9 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
@@ -92,7 +92,7 @@ static void init_ev_encodes(void)
 }
 
 /* Return the extended regs mask value */
-static u64 perf_get_platform_reg_mask(void)
+u64 perf_get_platform_reg_mask(void)
 {
 	if (have_hwcap2(PPC_FEATURE2_ARCH_3_1))
 		return PERF_POWER10_MASK;
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
index 09c5abe237af..357e9f0fc0f7 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
@@ -39,6 +39,8 @@ extern int pvr;
 extern u64 platform_extended_mask;
 extern int check_pvr_for_sampling_tests(void);
 extern int platform_check_for_tests(void);
+extern int check_extended_regs_support(void);
+extern u64 perf_get_platform_reg_mask(void);
 
 /*
  * Event code field extraction macro.
-- 
2.43.5



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 5/5] selftests/powerpc/pmu: Update comment with details to understand auxv_generic_compat_pmu() utility function
  2025-01-13  7:58 [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Athira Rajeev
                   ` (2 preceding siblings ...)
  2025-01-13  7:58 ` [PATCH V2 4/5] selftests/powerpc/pmu: Add interface test for extended reg support Athira Rajeev
@ 2025-01-13  7:58 ` Athira Rajeev
  2025-02-17  7:28 ` [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Madhavan Srinivasan
  4 siblings, 0 replies; 7+ messages in thread
From: Athira Rajeev @ 2025-01-13  7:58 UTC (permalink / raw)
  To: linuxppc-dev, maddy, hbathini; +Cc: atrajeev, kjain, disgoel

auxv_generic_compat_pmu() utility function is to detect whether the
system is having generic compat PMU. The check is based on base platform
value from /proc/self/auxv. Update the comment with details on how auxv
is used to detect the platform.

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
---
Changelog:
 v1 -> v2
 New patch added in V2

 tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
index 1ba675802ee9..8a538b6182a1 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
@@ -497,6 +497,13 @@ int get_thresh_cmp_val(struct event event)
  * Utility function to check for generic compat PMU
  * by comparing base_platform value from auxv and real
  * PVR value.
+ * auxv_base_platform() func gives information of "base platform"
+ * corresponding to PVR value. Incase, if the distro doesn't
+ * support platform PVR (missing cputable support), base platform
+ * in auxv will have a default value other than the real PVR's.
+ * In this case, ISAv3 PMU (generic compat PMU) will be registered
+ * in the system. auxv_generic_compat_pmu() makes use of the base
+ * platform value from auxv to do this check.
  */
 static bool auxv_generic_compat_pmu(void)
 {
-- 
2.43.5



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH V2 2/5] tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests
  2025-01-13  7:58 ` [PATCH V2 2/5] tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests Athira Rajeev
@ 2025-01-15 16:14   ` Disha Goel
  0 siblings, 0 replies; 7+ messages in thread
From: Disha Goel @ 2025-01-15 16:14 UTC (permalink / raw)
  To: Athira Rajeev, linuxppc-dev, maddy, hbathini; +Cc: kjain, disgoel

On 13/01/25 1:28 pm, Athira Rajeev wrote:

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>

I have tested the patches on PowerPC by compiling and running pmu selftest.

For the series:
Tested-by: Disha Goel<disgoel@linux.ibm.com>

---
Changelog:
  v1 -> v2
  No code changes. Rebased to latest upstream

  .../pmu/event_code_tests/event_alternatives_tests_p10.c    | 3 ++-
  .../pmu/event_code_tests/generic_events_valid_test.c       | 3 ++-
  .../reserved_bits_mmcra_sample_elig_mode_test.c            | 3 ++-
  .../powerpc/pmu/sampling_tests/bhrb_filter_map_test.c      | 7 +++++--
  4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c
index 8be7aada6523..355f8bbe06c3 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/event_alternatives_tests_p10.c
@@ -26,6 +26,7 @@ static int event_alternatives_tests_p10(void)
  {
  	struct event *e, events[5];
  	int i;
+	int pvr = PVR_VER(mfspr(SPRN_PVR));

  	/* Check for platform support for the test */
  	SKIP_IF(platform_check_for_tests());
@@ -36,7 +37,7 @@ static int event_alternatives_tests_p10(void)
  	 * code and using PVR will work correctly for all cases
  	 * including generic compat mode.
  	 */
-	SKIP_IF(PVR_VER(mfspr(SPRN_PVR)) != POWER10);
+	SKIP_IF((pvr != POWER10) && (pvr != POWER11));

  	SKIP_IF(check_for_generic_compat_pmu());

diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c
index 0d237c15d3f2..a378fa9a5a7b 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/generic_events_valid_test.c
@@ -17,6 +17,7 @@
  static int generic_events_valid_test(void)
  {
  	struct event event;
+	int pvr = mfspr(SPRN_PVR);

  	/* Check for platform support for the test */
  	SKIP_IF(platform_check_for_tests());
@@ -31,7 +32,7 @@ static int generic_events_valid_test(void)
  	 * - PERF_COUNT_HW_STALLED_CYCLES_BACKEND
  	 * - PERF_COUNT_HW_REF_CPU_CYCLES
  	 */
-	if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) {
+	if ((pvr == POWER10) || (pvr == POWER11)) {
  		event_init_opts(&event, PERF_COUNT_HW_CPU_CYCLES, PERF_TYPE_HARDWARE, "event");
  		FAIL_IF(event_open(&event));
  		event_close(&event);
diff --git a/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c b/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
index 4c119c821b99..7bb26a232fbe 100644
--- a/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
+++ b/tools/testing/selftests/powerpc/pmu/event_code_tests/reserved_bits_mmcra_sample_elig_mode_test.c
@@ -21,6 +21,7 @@
  static int reserved_bits_mmcra_sample_elig_mode(void)
  {
  	struct event event;
+	int pvr = PVR_VER(mfspr(SPRN_PVR));

  	/* Check for platform support for the test */
  	SKIP_IF(platform_check_for_tests());
@@ -59,7 +60,7 @@ static int reserved_bits_mmcra_sample_elig_mode(void)
  	 * is reserved in power10 and 0xC is reserved in
  	 * power9.
  	 */
-	if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) {
+	if ((pvr == POWER10) || (pvr == POWER11)) {
  		event_init(&event, 0x100401e0);
  		FAIL_IF(!event_open(&event));
  	} else if (PVR_VER(mfspr(SPRN_PVR)) == POWER9) {
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
index 3f43c315c666..64ab9784f9b1 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/bhrb_filter_map_test.c
@@ -83,13 +83,16 @@ static int bhrb_filter_map_test(void)
  	 * using PVR will work correctly for all cases including generic
  	 * compat mode.
  	 */
-	if (PVR_VER(mfspr(SPRN_PVR)) == POWER10) {
+	switch (PVR_VER(mfspr(SPRN_PVR))) {
+	case POWER11:
+	case POWER10:
  		for (i = 0; i < ARRAY_SIZE(bhrb_filter_map_valid_p10); i++) {
  			event.attr.branch_sample_type = bhrb_filter_map_valid_p10[i];
  			FAIL_IF(event_open(&event));
  			event_close(&event);
  		}
-	} else {
+		break;
+	default:
  		for (i = 0; i < ARRAY_SIZE(bhrb_filter_map_valid_p10); i++) {
  			event.attr.branch_sample_type = bhrb_filter_map_valid_p10[i];
  			FAIL_IF(!event_open(&event));



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11
  2025-01-13  7:58 [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Athira Rajeev
                   ` (3 preceding siblings ...)
  2025-01-13  7:58 ` [PATCH V2 5/5] selftests/powerpc/pmu: Update comment with details to understand auxv_generic_compat_pmu() utility function Athira Rajeev
@ 2025-02-17  7:28 ` Madhavan Srinivasan
  4 siblings, 0 replies; 7+ messages in thread
From: Madhavan Srinivasan @ 2025-02-17  7:28 UTC (permalink / raw)
  To: linuxppc-dev, hbathini; +Cc: kjain, disgoel

On Mon, 13 Jan 2025 13:28:54 +0530, Athira Rajeev wrote:
> Add check for power11 pvr in the selftest utility
> functions. Selftests uses pvr value to check for platform
> support inorder to run the tests. pvr is also used to
> send the extended mask value to capture sampling registers.
> 
> Update some of the utility functions to use hwcap2 inorder
> to return platform specific bits from sampling registers.
> 
> [...]

Applied to powerpc/next.

[1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11
      https://git.kernel.org/powerpc/c/fd4d2f325192a11b0bff8bf6226285a821bf38db
[2/5] tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests
      https://git.kernel.org/powerpc/c/520ee327c59d37c5520b177404f57c974cc098cc
[3/5] tools/testing/selftests/powerpc/pmu: Update comment description to mention ISA v3.1 for power10 and above
      https://git.kernel.org/powerpc/c/43751c3ce276afc475fea769ae2abf690d5f4b91
[4/5] selftests/powerpc/pmu: Add interface test for extended reg support
      https://git.kernel.org/powerpc/c/9785def2593c7c62fa3271d740eef0e1d1874ef4
[5/5] selftests/powerpc/pmu: Update comment with details to understand auxv_generic_compat_pmu() utility function
      https://git.kernel.org/powerpc/c/c96b1402cc8fe818b0aaaee280221a5e7b6b2242

Thanks


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-17  7:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13  7:58 [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Athira Rajeev
2025-01-13  7:58 ` [PATCH V2 2/5] tools/testing/selftests/powerpc: Add check for power11 pvr for pmu selfests Athira Rajeev
2025-01-15 16:14   ` Disha Goel
2025-01-13  7:58 ` [PATCH V2 3/5] tools/testing/selftests/powerpc/pmu: Update comment description to mention ISA v3.1 for power10 and above Athira Rajeev
2025-01-13  7:58 ` [PATCH V2 4/5] selftests/powerpc/pmu: Add interface test for extended reg support Athira Rajeev
2025-01-13  7:58 ` [PATCH V2 5/5] selftests/powerpc/pmu: Update comment with details to understand auxv_generic_compat_pmu() utility function Athira Rajeev
2025-02-17  7:28 ` [PATCH V2 1/5] tools/testing/selftests/powerpc: Enable pmu selftests for power11 Madhavan Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).