1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2022, Kajol Jain, IBM Corp.
13 extern void thirty_two_instruction_loop(int loops);
16 #define EventCode 0x500fa
19 * A perf sampling test for mmcra
20 * field: bhrb_disable.
22 static int mmcra_bhrb_disable_test(void)
28 * Check for platform support for the test.
29 * This test is only aplicable on power10
31 SKIP_IF(check_pvr_for_sampling_tests());
32 SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
34 /* Init the event for the sampling test */
35 event_init_sampling(&event, EventCode);
36 event.attr.sample_regs_intr = platform_extended_mask;
37 event.attr.sample_type |= PERF_SAMPLE_BRANCH_STACK;
38 event.attr.branch_sample_type = PERF_SAMPLE_BRANCH_ANY;
39 event.attr.exclude_kernel = 1;
41 FAIL_IF(event_open(&event));
42 event.mmap_buffer = event_sample_buf_mmap(event.fd, 1);
44 FAIL_IF(event_enable(&event));
46 /* workload to make the event overflow */
47 thirty_two_instruction_loop(10000);
49 FAIL_IF(event_disable(&event));
51 intr_regs = get_intr_regs(&event, event.mmap_buffer);
53 /* Check for intr_regs */
56 /* Verify that bhrb_disable bit is set in MMCRA */
57 FAIL_IF(get_mmcra_bhrb_disable(get_reg_value(intr_regs, "MMCRA"), 5));
65 return test_harness(mmcra_bhrb_disable_test, "mmcra_bhrb_disable_test");