1 | // SPDX-License-Identifier: GPL-2.0-only |
2 | /* |
3 | * Copyright 2022, Athira Rajeev, IBM Corp. |
4 | */ |
5 | |
6 | #include <stdio.h> |
7 | #include "../event.h" |
8 | #include "../sampling_tests/misc.h" |
9 | |
10 | /* |
11 | * Testcase for checking constraint checks for |
12 | * Performance Monitor Counter 5 (PMC5) and also |
13 | * Performance Monitor Counter 6 (PMC6). Events using |
14 | * PMC5/PMC6 shouldn't have other fields in event |
15 | * code like cache bits, thresholding or marked bit. |
16 | */ |
17 | |
18 | static int group_constraint_pmc56(void) |
19 | { |
20 | struct event event; |
21 | |
22 | /* Check for platform support for the test */ |
23 | SKIP_IF(platform_check_for_tests()); |
24 | |
25 | /* |
26 | * Events using PMC5 and PMC6 with cache bit |
27 | * set in event code is expected to fail. |
28 | */ |
29 | event_init(e: &event, config: 0x2500fa); |
30 | FAIL_IF(!event_open(e: &event)); |
31 | |
32 | event_init(e: &event, config: 0x2600f4); |
33 | FAIL_IF(!event_open(e: &event)); |
34 | |
35 | /* |
36 | * PMC5 and PMC6 only supports base events: |
37 | * ie 500fa and 600f4. Other combinations |
38 | * should fail. |
39 | */ |
40 | event_init(e: &event, config: 0x501e0); |
41 | FAIL_IF(!event_open(e: &event)); |
42 | |
43 | event_init(e: &event, config: 0x6001e); |
44 | FAIL_IF(!event_open(e: &event)); |
45 | |
46 | event_init(e: &event, config: 0x501fa); |
47 | FAIL_IF(!event_open(e: &event)); |
48 | |
49 | /* |
50 | * Events using PMC5 and PMC6 with random |
51 | * sampling bits set in event code should fail |
52 | * to schedule. |
53 | */ |
54 | event_init(e: &event, config: 0x35340500fa); |
55 | FAIL_IF(!event_open(e: &event)); |
56 | |
57 | return 0; |
58 | } |
59 | |
60 | int main(void) |
61 | { |
62 | return test_harness(group_constraint_pmc56, "group_constraint_pmc56" ); |
63 | } |
64 | |