Skip to content

Commit

Permalink
selftests/powerpc/pmu: Add interface test for extended reg support
Browse files Browse the repository at this point in the history
The testcase uses check_extended_regs_support and
perf_get_platform_reg_mask function to check if the
platform has extended reg support.

Signed-off-by: Kajol Jain <kjain@Linux.ibm.com>
  • Loading branch information
kjain101 authored and root committed Dec 20, 2024
1 parent 20fab1f commit b205a0d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
2 changes: 1 addition & 1 deletion tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b205a0d

Please sign in to comment.