aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_cache_test.c
blob: f4be05aa3a3dc4d6f01f0839ddf7f7cef837c884 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright 2022, Kajol Jain, IBM Corp.
 */

#include <stdio.h>
#include <stdlib.h>

#include "../event.h"
#include "utils.h"
#include "../sampling_tests/misc.h"

/* All L1 D cache load references counted at finish, gated by reject */
#define EventCode_1 0x1100fc
/* Load Missed L1 */
#define EventCode_2 0x23e054
/* Load Missed L1 */
#define EventCode_3 0x13e054

/*
 * Testcase for group constraint check of data and instructions
 * cache qualifier bits which is used to program cache select field in
 * Monitor Mode Control Register 1 (MMCR1: 16-17) for l1 cache.
 * All events in the group should match cache select bits otherwise
 * event_open for the group will fail.
 */
static int group_constraint_cache(void)
{
	struct event event, leader;

	/* Check for platform support for the test */
	SKIP_IF(platform_check_for_tests());

	/* Init the events for the group contraint check for l1 cache select bits */
	event_init(&leader, EventCode_1);
	FAIL_IF(event_open(&leader));

	event_init(&event, EventCode_2);

	/* Expected to fail as sibling event doesn't request same l1 cache select bits as leader */
	FAIL_IF(!event_open_with_group(&event, leader.fd));

	event_close(&event);

	/* Init the event for the group contraint l1 cache select test */
	event_init(&event, EventCode_3);

	/* Expected to succeed as sibling event request same l1 cache select bits as leader */
	FAIL_IF(event_open_with_group(&event, leader.fd));

	event_close(&leader);
	event_close(&event);

	return 0;
}

int main(void)
{
	return test_harness(group_constraint_cache, "group_constraint_cache");
}