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 /* All successful D-side store dispatches for this thread that were L2 Miss */
0014 #define EventCode 0x46880
0015 
0016 extern void thirty_two_instruction_loop_with_ll_sc(u64 loops, u64 *ll_sc_target);
0017 
0018 /*
0019  * A perf sampling test for mmcr1
0020  * fields : comb.
0021  */
0022 static int mmcr1_comb(void)
0023 {
0024     struct event event;
0025     u64 *intr_regs;
0026     u64 dummy;
0027 
0028     /* Check for platform support for the test */
0029     SKIP_IF(check_pvr_for_sampling_tests());
0030 
0031     /* Init the event for the sampling test */
0032     event_init_sampling(&event, EventCode);
0033     event.attr.sample_regs_intr = platform_extended_mask;
0034     FAIL_IF(event_open(&event));
0035     event.mmap_buffer = event_sample_buf_mmap(event.fd, 1);
0036 
0037     FAIL_IF(event_enable(&event));
0038 
0039     /* workload to make the event overflow */
0040     thirty_two_instruction_loop_with_ll_sc(10000000, &dummy);
0041 
0042     FAIL_IF(event_disable(&event));
0043 
0044     /* Check for sample count */
0045     FAIL_IF(!collect_samples(event.mmap_buffer));
0046 
0047     intr_regs = get_intr_regs(&event, event.mmap_buffer);
0048 
0049     /* Check for intr_regs */
0050     FAIL_IF(!intr_regs);
0051 
0052     /*
0053      * Verify that comb field match with
0054      * corresponding event code fields
0055      */
0056     FAIL_IF(EV_CODE_EXTRACT(event.attr.config, comb) !=
0057         get_mmcr1_comb(get_reg_value(intr_regs, "MMCR1"), 4));
0058 
0059     event_close(&event);
0060     return 0;
0061 }
0062 
0063 int main(void)
0064 {
0065     return test_harness(mmcr1_comb, "mmcr1_comb");
0066 }