1*6e11374bSAthira Rajeev // SPDX-License-Identifier: GPL-2.0-only 2*6e11374bSAthira Rajeev /* 3*6e11374bSAthira Rajeev * Copyright 2022, Athira Rajeev, IBM Corp. 4*6e11374bSAthira Rajeev */ 5*6e11374bSAthira Rajeev 6*6e11374bSAthira Rajeev #include <stdio.h> 7*6e11374bSAthira Rajeev #include <stdlib.h> 8*6e11374bSAthira Rajeev 9*6e11374bSAthira Rajeev #include "../event.h" 10*6e11374bSAthira Rajeev #include "misc.h" 11*6e11374bSAthira Rajeev #include "utils.h" 12*6e11374bSAthira Rajeev 13*6e11374bSAthira Rajeev extern void thirty_two_instruction_loop(int loops); 14*6e11374bSAthira Rajeev 15*6e11374bSAthira Rajeev /* 16*6e11374bSAthira Rajeev * A perf sampling test for mmcr0 17*6e11374bSAthira Rajeev * fields: fc56_pmc56 18*6e11374bSAthira Rajeev */ mmcr0_fc56_pmc56(void)19*6e11374bSAthira Rajeevstatic int mmcr0_fc56_pmc56(void) 20*6e11374bSAthira Rajeev { 21*6e11374bSAthira Rajeev struct event event; 22*6e11374bSAthira Rajeev u64 *intr_regs; 23*6e11374bSAthira Rajeev 24*6e11374bSAthira Rajeev /* Check for platform support for the test */ 25*6e11374bSAthira Rajeev SKIP_IF(check_pvr_for_sampling_tests()); 26*6e11374bSAthira Rajeev 27*6e11374bSAthira Rajeev /* Init the event for the sampling test */ 28*6e11374bSAthira Rajeev event_init_sampling(&event, 0x500fa); 29*6e11374bSAthira Rajeev event.attr.sample_regs_intr = platform_extended_mask; 30*6e11374bSAthira Rajeev FAIL_IF(event_open(&event)); 31*6e11374bSAthira Rajeev event.mmap_buffer = event_sample_buf_mmap(event.fd, 1); 32*6e11374bSAthira Rajeev 33*6e11374bSAthira Rajeev FAIL_IF(event_enable(&event)); 34*6e11374bSAthira Rajeev 35*6e11374bSAthira Rajeev /* workload to make the event overflow */ 36*6e11374bSAthira Rajeev thirty_two_instruction_loop(10000); 37*6e11374bSAthira Rajeev 38*6e11374bSAthira Rajeev FAIL_IF(event_disable(&event)); 39*6e11374bSAthira Rajeev 40*6e11374bSAthira Rajeev /* Check for sample count */ 41*6e11374bSAthira Rajeev FAIL_IF(!collect_samples(event.mmap_buffer)); 42*6e11374bSAthira Rajeev 43*6e11374bSAthira Rajeev intr_regs = get_intr_regs(&event, event.mmap_buffer); 44*6e11374bSAthira Rajeev 45*6e11374bSAthira Rajeev /* Check for intr_regs */ 46*6e11374bSAthira Rajeev FAIL_IF(!intr_regs); 47*6e11374bSAthira Rajeev 48*6e11374bSAthira Rajeev /* Verify that fc56 is not set in MMCR0 when using PMC5 */ 49*6e11374bSAthira Rajeev FAIL_IF(get_mmcr0_fc56(get_reg_value(intr_regs, "MMCR0"), 5)); 50*6e11374bSAthira Rajeev 51*6e11374bSAthira Rajeev event_close(&event); 52*6e11374bSAthira Rajeev return 0; 53*6e11374bSAthira Rajeev } 54*6e11374bSAthira Rajeev main(void)55*6e11374bSAthira Rajeevint main(void) 56*6e11374bSAthira Rajeev { 57*6e11374bSAthira Rajeev return test_harness(mmcr0_fc56_pmc56, "mmcr0_fc56_pmc56"); 58*6e11374bSAthira Rajeev } 59