1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright 2022, Kajol Jain, IBM Corp.
14 * Primary PMU event used here is PM_MRK_INST_CMPL (0x401e0)
15 * Threshold event selection used is issue to complete for cycles
16 * Sampling criteria is Load only sampling
18 #define EventCode 0x35340401e0
20 extern void thirty_two_instruction_loop_with_ll_sc(u64 loops, u64 *ll_sc_target);
22 /* A perf sampling test to test mmcra fields */
23 static int mmcra_thresh_marked_sample(void)
29 /* Check for platform support for the test */
30 SKIP_IF(check_pvr_for_sampling_tests());
32 /* Init the event for the sampling test */
33 event_init_sampling(&event, EventCode);
34 event.attr.sample_regs_intr = platform_extended_mask;
35 FAIL_IF(event_open(&event));
36 event.mmap_buffer = event_sample_buf_mmap(event.fd, 1);
38 FAIL_IF(event_enable(&event));
40 /* workload to make the event overflow */
41 thirty_two_instruction_loop_with_ll_sc(1000000, &dummy);
43 FAIL_IF(event_disable(&event));
45 /* Check for sample count */
46 FAIL_IF(!collect_samples(event.mmap_buffer));
48 intr_regs = get_intr_regs(&event, event.mmap_buffer);
50 /* Check for intr_regs */
54 * Verify that thresh sel/start/stop, marked, random sample
55 * eligibility, sdar mode and sample mode fields match with
56 * the corresponding event code fields
58 FAIL_IF(EV_CODE_EXTRACT(event.attr.config, thd_sel) !=
59 get_mmcra_thd_sel(get_reg_value(intr_regs, "MMCRA"), 4));
60 FAIL_IF(EV_CODE_EXTRACT(event.attr.config, thd_start) !=
61 get_mmcra_thd_start(get_reg_value(intr_regs, "MMCRA"), 4));
62 FAIL_IF(EV_CODE_EXTRACT(event.attr.config, thd_stop) !=
63 get_mmcra_thd_stop(get_reg_value(intr_regs, "MMCRA"), 4));
64 FAIL_IF(EV_CODE_EXTRACT(event.attr.config, marked) !=
65 get_mmcra_marked(get_reg_value(intr_regs, "MMCRA"), 4));
66 FAIL_IF((EV_CODE_EXTRACT(event.attr.config, sample) >> 2) !=
67 get_mmcra_rand_samp_elig(get_reg_value(intr_regs, "MMCRA"), 4));
68 FAIL_IF((EV_CODE_EXTRACT(event.attr.config, sample) & 0x3) !=
69 get_mmcra_sample_mode(get_reg_value(intr_regs, "MMCRA"), 4));
70 FAIL_IF(EV_CODE_EXTRACT(event.attr.config, sm) !=
71 get_mmcra_sm(get_reg_value(intr_regs, "MMCRA"), 4));
79 return test_harness(mmcra_thresh_marked_sample, "mmcra_thresh_marked_sample");