2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
14 * Test counting multiple events using EBBs.
16 int multi_counter(void)
18 struct event events[6];
21 SKIP_IF(!ebb_is_supported());
23 event_init_named(&events[0], 0x1001C, "PM_CMPLU_STALL_THRD");
24 event_init_named(&events[1], 0x2D016, "PM_CMPLU_STALL_FXU");
25 event_init_named(&events[2], 0x30006, "PM_CMPLU_STALL_OTHER_CMPL");
26 event_init_named(&events[3], 0x4000A, "PM_CMPLU_STALL");
27 event_init_named(&events[4], 0x600f4, "PM_RUN_CYC");
28 event_init_named(&events[5], 0x500fa, "PM_RUN_INST_CMPL");
30 event_leader_ebb_init(&events[0]);
31 for (i = 1; i < 6; i++)
32 event_ebb_init(&events[i]);
35 for (i = 0; i < 6; i++) {
36 events[i].attr.exclude_kernel = 1;
37 events[i].attr.exclude_hv = 1;
38 events[i].attr.exclude_idle = 1;
40 FAIL_IF(event_open_with_group(&events[i], group_fd));
42 group_fd = events[0].fd;
45 ebb_enable_pmc_counting(1);
46 ebb_enable_pmc_counting(2);
47 ebb_enable_pmc_counting(3);
48 ebb_enable_pmc_counting(4);
49 ebb_enable_pmc_counting(5);
50 ebb_enable_pmc_counting(6);
51 setup_ebb_handler(standard_ebb_callee);
53 FAIL_IF(ioctl(events[0].fd, PERF_EVENT_IOC_ENABLE, PERF_IOC_FLAG_GROUP));
54 FAIL_IF(event_read(&events[0]));
58 mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
59 mtspr(SPRN_PMC2, pmc_sample_period(sample_period));
60 mtspr(SPRN_PMC3, pmc_sample_period(sample_period));
61 mtspr(SPRN_PMC4, pmc_sample_period(sample_period));
62 mtspr(SPRN_PMC5, pmc_sample_period(sample_period));
63 mtspr(SPRN_PMC6, pmc_sample_period(sample_period));
65 while (ebb_state.stats.ebb_count < 50) {
66 FAIL_IF(core_busy_loop());
67 FAIL_IF(ebb_check_mmcr0());
75 for (i = 0; i < 6; i++)
76 event_close(&events[i]);
78 FAIL_IF(ebb_state.stats.ebb_count == 0);
85 return test_harness(multi_counter, "multi_counter");