Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright 2022, Athira Rajeev, IBM Corp.
0004  */
0005 
0006 #include <stdio.h>
0007 #include <stdlib.h>
0008 
0009 #include "../event.h"
0010 #include "misc.h"
0011 #include "utils.h"
0012 
0013 extern void thirty_two_instruction_loop(int loops);
0014 
0015 /*
0016  * A perf sampling test for mmcr0
0017  * field: pmcjce
0018  */
0019 static int mmcr0_pmcjce(void)
0020 {
0021     struct event event;
0022     u64 *intr_regs;
0023 
0024     /* Check for platform support for the test */
0025     SKIP_IF(check_pvr_for_sampling_tests());
0026 
0027     /* Init the event for the sampling test */
0028     event_init_sampling(&event, 0x500fa);
0029     event.attr.sample_regs_intr = platform_extended_mask;
0030     FAIL_IF(event_open(&event));
0031     event.mmap_buffer = event_sample_buf_mmap(event.fd, 1);
0032 
0033     FAIL_IF(event_enable(&event));
0034 
0035     /* workload to make the event overflow */
0036     thirty_two_instruction_loop(10000);
0037 
0038     FAIL_IF(event_disable(&event));
0039 
0040     /* Check for sample count */
0041     FAIL_IF(!collect_samples(event.mmap_buffer));
0042 
0043     intr_regs = get_intr_regs(&event, event.mmap_buffer);
0044 
0045     /* Check for intr_regs */
0046     FAIL_IF(!intr_regs);
0047 
0048     /* Verify that pmcjce field is set in MMCR0 */
0049     FAIL_IF(!get_mmcr0_pmcjce(get_reg_value(intr_regs, "MMCR0"), 5));
0050 
0051     event_close(&event);
0052     return 0;
0053 }
0054 
0055 int main(void)
0056 {
0057     return test_harness(mmcr0_pmcjce, "mmcr0_pmcjce");
0058 }