1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright 2022, Kajol Jain, IBM Corp. 4 */ 5 6 #include <stdio.h> 7 #include <stdlib.h> 8 9 #include "../event.h" 10 #include "utils.h" 11 #include "../sampling_tests/misc.h" 12 13 /* All successful D-side store dispatches for this thread */ 14 #define EventCode_1 0x010000046080 15 /* All successful D-side store dispatches for this thread that were L2 Miss */ 16 #define EventCode_2 0x26880 17 /* All successful D-side store dispatches for this thread that were L2 Miss */ 18 #define EventCode_3 0x010000026880 19 20 /* 21 * Testcase for group constraint check of l2l3_sel bits which is 22 * used to program l2l3 select field in Monitor Mode Control Register 0 23 * (MMCR0: 56-60). 24 * All events in the group should match l2l3_sel bits otherwise 25 * event_open for the group should fail. 26 */ 27 static int group_constraint_l2l3_sel(void) 28 { 29 struct event event, leader; 30 31 /* 32 * Check for platform support for the test. 33 * This test is only aplicable on power10 34 */ 35 SKIP_IF(platform_check_for_tests()); 36 SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1)); 37 38 /* Init the events for the group contraint check for l2l3_sel bits */ 39 event_init(&leader, EventCode_1); 40 FAIL_IF(event_open(&leader)); 41 42 event_init(&event, EventCode_2); 43 44 /* Expected to fail as sibling event doesn't request same l2l3_sel bits as leader */ 45 FAIL_IF(!event_open_with_group(&event, leader.fd)); 46 47 event_close(&event); 48 49 /* Init the event for the group contraint l2l3_sel test */ 50 event_init(&event, EventCode_3); 51 52 /* Expected to succeed as sibling event request same l2l3_sel bits as leader */ 53 FAIL_IF(event_open_with_group(&event, leader.fd)); 54 55 event_close(&leader); 56 event_close(&event); 57 58 return 0; 59 } 60 61 int main(void) 62 { 63 return test_harness(group_constraint_l2l3_sel, "group_constraint_l2l3_sel"); 64 } 65