linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Kajol Jain <kjain@linux.ibm.com>
To: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org
Cc: kjain@linux.ibm.com, atrajeev@linux.vnet.ibm.com,
	maddy@linux.ibm.com, disgoel@linux.vnet.ibm.com,
	rnsastry@linux.ibm.com
Subject: [PATCH 09/35] selftest/powerpc/pmu: Refactor the platform check and add macros to find array size/PVR
Date: Fri,  6 May 2022 14:15:18 +0530	[thread overview]
Message-ID: <20220506084544.56527-10-kjain@linux.ibm.com> (raw)
In-Reply-To: <20220506084544.56527-1-kjain@linux.ibm.com>

From: Athira Rajeev <atrajeev@linux.vnet.ibm.com>

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>
---
 tools/testing/selftests/powerpc/include/reg.h |  4 ++++
 .../powerpc/pmu/sampling_tests/misc.c         | 20 +++++++++++++++----
 .../powerpc/pmu/sampling_tests/misc.h         |  3 +++
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/powerpc/include/reg.h b/tools/testing/selftests/powerpc/include/reg.h
index c422be8a42b2..2ac7a4c7749c 100644
--- a/tools/testing/selftests/powerpc/include/reg.h
+++ b/tools/testing/selftests/powerpc/include/reg.h
@@ -55,6 +55,10 @@
 #define PVR_VER(pvr)	(((pvr) >>  16) & 0xFFFF)
 #define SPRN_PVR	0x11F
 
+#define PVR_CFG(pvr)    (((pvr) >>  8) & 0xF)   /* Configuration field */
+#define PVR_MAJ(pvr)    (((pvr) >>  4) & 0xF)   /* Major revision field */
+#define PVR_MIN(pvr)    (((pvr) >>  0) & 0xF)   /* Minor revision field */
+
 #define SPRN_DSCR_PRIV 0x11	/* Privilege State DSCR */
 #define SPRN_DSCR      0x03	/* Data Stream Control Register */
 #define SPRN_PPR       896	/* Program Priority Register */
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
index 2562d8439d7d..facd6266b203 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
@@ -121,12 +121,10 @@ int check_extended_regs_support(void)
 	return -1;
 }
 
-int check_pvr_for_sampling_tests(void)
+int platform_check_for_tests(void)
 {
 	pvr = PVR_VER(mfspr(SPRN_PVR));
 
-	platform_extended_mask = perf_get_platform_reg_mask();
-
 	/*
 	 * Check for supported platforms
 	 * for sampling test
@@ -138,19 +136,33 @@ int check_pvr_for_sampling_tests(void)
 	 * Check PMU driver registered by looking for
 	 * PPC_FEATURE2_EBB bit in AT_HWCAP2
 	 */
-	if (!have_hwcap2(PPC_FEATURE2_EBB))
+	if (!have_hwcap2(PPC_FEATURE2_EBB) || !have_hwcap2(PPC_FEATURE2_ARCH_3_00))
 		goto out;
 
+	return 0;
+
+out:
+	printf("%s: Tests un-supported for this platform\n", __func__);
+	return -1;
+}
+
+int check_pvr_for_sampling_tests(void)
+{
+	SKIP_IF(platform_check_for_tests());
+
+	platform_extended_mask = perf_get_platform_reg_mask();
 	/* check if platform supports extended regs */
 	if (check_extended_regs_support())
 		goto out;
 
 	init_ev_encodes();
 	return 0;
+
 out:
 	printf("%s: Sampling tests un-supported\n", __func__);
 	return -1;
 }
+
 /*
  * Allocate mmap buffer of "mmap_pages" number of
  * pages.
diff --git a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
index 874a1596add8..4181755cf5a0 100644
--- a/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
+++ b/tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
@@ -18,6 +18,8 @@
 #define MMCR1_RSQ       0x200000000000ULL /* radix scope qual field */
 #define BHRB_DISABLE    0x2000000000ULL /* MMCRA BHRB DISABLE bit */
 
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
 extern int ev_mask_pmcxsel, ev_shift_pmcxsel;
 extern int ev_mask_marked, ev_shift_marked;
 extern int ev_mask_comb, ev_shift_comb;
@@ -36,6 +38,7 @@ extern int ev_mask_mmcr3_src, ev_shift_mmcr3_src;
 extern int pvr;
 extern u64 platform_extended_mask;
 extern int check_pvr_for_sampling_tests(void);
+extern int platform_check_for_tests(void);
 
 /*
  * Event code field extraction macro.
-- 
2.31.1


  parent reply	other threads:[~2022-05-06  8:51 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06  8:45 [PATCH 00/35] Add group constraints and event code test as part of selftest Kajol Jain
2022-05-06  8:45 ` [PATCH 01/35] selftest/powerpc/pmu: Add mask/shift bits for extracting threshold compare field Kajol Jain
2022-05-06  8:45 ` [PATCH 02/35] testing/selftests/powerpc: Add support to fetch "platform" and "base platform" from auxv to detect platform Kajol Jain
2022-05-06  8:45 ` [PATCH 03/35] selftest/powerpc/pmu: Add interface test for mmcra_thresh_cmp fields Kajol Jain
2022-05-06  8:45 ` [PATCH 04/35] selftest/powerpc/pmu: Add support for branch sampling in get_intr_regs function Kajol Jain
2022-05-06  8:45 ` [PATCH 05/35] selftest/powerpc/pmu: Add interface test for mmcra_ifm field of indirect call type Kajol Jain
2022-05-06  8:45 ` [PATCH 06/35] selftest/powerpc/pmu: Add interface test for mmcra_ifm field for any branch type Kajol Jain
2022-05-06  8:45 ` [PATCH 07/35] selftest/powerpc/pmu: Add interface test for mmcra_ifm field for conditional " Kajol Jain
2022-05-06  8:45 ` [PATCH 08/35] selftest/powerpc/pmu: Add interface test for bhrb disable field Kajol Jain
2022-05-06  8:45 ` Kajol Jain [this message]
2022-05-06  8:45 ` [PATCH 10/35] selftest/powerpc/pmu: Add selftest to check branch stack enablement will not crash on any platforms Kajol Jain
2022-05-06  8:45 ` [PATCH 11/35] selftest/powerpc/pmu: Add selftest to check PERF_SAMPLE_REGS_INTR option " Kajol Jain
2022-05-06  8:45 ` [PATCH 12/35] selftest/powerpc/pmu: Add selftest for checking valid and invalid bhrb filter maps Kajol Jain
2022-05-06  8:45 ` [PATCH 13/35] selftest/powerpc/pmu: Add selftest for mmcr1 pmcxsel/unit/cache fields Kajol Jain
2022-05-06  8:45 ` [PATCH 14/35] selftest/powerpc/pmu: Add interface test for bhrb disable field for non-branch samples Kajol Jain
2022-05-06  8:45 ` [PATCH 15/35] selftest/powerpc/pmu: Add support for perf event code tests Kajol Jain
2022-05-06  8:45 ` [PATCH 16/35] selftest/powerpc/pmu: Add selftest for group constraint check for PMC5 and PMC6 Kajol Jain
2022-05-06  8:45 ` [PATCH 17/35] selftest/powerpc/pmu: Add selftest to check PMC5/6 is excluded from some constraint checks Kajol Jain
2022-05-06  8:45 ` [PATCH 18/35] selftest/powerpc/pmu: Add selftest to check constraint for number of counters in use Kajol Jain
2022-05-06  8:45 ` [PATCH 19/35] selftest/powerpc/pmu: Add selftest for group constraint check when using same PMC Kajol Jain
2022-05-06  8:45 ` [PATCH 20/35] selftest/powerpc/pmu: Add selftest for group constraint check for radix_scope_qual field Kajol Jain
2022-05-06  8:45 ` [PATCH 21/35] selftest/powerpc/pmu: Add selftest for group constraint for MMCRA Sampling Mode field Kajol Jain
2022-05-06  8:45 ` [PATCH 22/35] selftest/powerpc/pmu: Add selftest for group constraint check MMCRA sample bits Kajol Jain
2022-05-06  8:45 ` [PATCH 23/35] selftest/powerpc/pmu: Add selftest for checking invalid bits in event code Kajol Jain
2022-05-06  8:45 ` [PATCH 24/35] selftest/powerpc/pmu: Add selftest for reserved bit check for MMCRA thresh_ctl field Kajol Jain
2022-05-06  8:45 ` [PATCH 25/35] selftest/powerpc/pmu: Add selftest for blacklist events check in power9 Kajol Jain
2022-05-06  8:45 ` [PATCH 26/35] selftest/powerpc/pmu: Add selftest for event alternatives for power9 Kajol Jain
2022-05-06  8:45 ` [PATCH 27/35] selftest/powerpc/pmu: Add selftest for event alternatives for power10 Kajol Jain
2022-05-06  8:45 ` [PATCH 28/35] selftest/powerpc/pmu: Add selftest for PERF_TYPE_HARDWARE events valid check Kajol Jain
2022-05-06  8:45 ` [PATCH 29/35] selftest/powerpc/pmu: Add selftest for group constraint check for MMCR0 l2l3_sel bits Kajol Jain
2022-05-06  8:45 ` [PATCH 30/35] selftest/powerpc/pmu: Add selftest for group constraint check for MMCR1 cache bits Kajol Jain
2022-05-06  8:45 ` [PATCH 31/35] selftest/powerpc/pmu: Add selftest for group constraint check for MMCRA thresh_cmp field Kajol Jain
2022-05-06  8:45 ` [PATCH 32/35] selftest/powerpc/pmu: Add selftest for group constraint for unit and pmc field in p9 Kajol Jain
2022-05-06  8:45 ` [PATCH 33/35] selftest/powerpc/pmu: Add selftest for group constraint check for MMCRA thresh_ctl field Kajol Jain
2022-05-06  8:45 ` [PATCH 34/35] selftest/powerpc/pmu: Add selftest for group constraint check for MMCRA thresh_sel field Kajol Jain
2022-05-06  8:45 ` [PATCH 35/35] selftest/powerpc/pmu: Add test for hardware cache events Kajol Jain
2022-05-18 13:23 ` [PATCH 00/35] Add group constraints and event code test as part of selftest Michael Ellerman
2022-05-19 16:26   ` Athira Rajeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220506084544.56527-10-kjain@linux.ibm.com \
    --to=kjain@linux.ibm.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=disgoel@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=rnsastry@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).