0001
0002
0003
0004
0005
0006 #include <stdio.h>
0007 #include <stdlib.h>
0008
0009 #include "ebb.h"
0010
0011
0012
0013
0014
0015
0016
0017 static int pmc56_overflowed;
0018
0019 static void ebb_callee(void)
0020 {
0021 uint64_t val;
0022
0023 val = mfspr(SPRN_BESCR);
0024 if (!(val & BESCR_PMEO)) {
0025 ebb_state.stats.spurious++;
0026 goto out;
0027 }
0028
0029 ebb_state.stats.ebb_count++;
0030 count_pmc(2, sample_period);
0031
0032 val = mfspr(SPRN_PMC5);
0033 if (val >= COUNTER_OVERFLOW)
0034 pmc56_overflowed++;
0035
0036 count_pmc(5, COUNTER_OVERFLOW);
0037
0038 val = mfspr(SPRN_PMC6);
0039 if (val >= COUNTER_OVERFLOW)
0040 pmc56_overflowed++;
0041
0042 count_pmc(6, COUNTER_OVERFLOW);
0043
0044 out:
0045 reset_ebb();
0046 }
0047
0048 int pmc56_overflow(void)
0049 {
0050 struct event event;
0051
0052 SKIP_IF(!ebb_is_supported());
0053
0054
0055 event_init(&event, 0x2001e);
0056 event_leader_ebb_init(&event);
0057
0058 event.attr.exclude_kernel = 1;
0059 event.attr.exclude_hv = 1;
0060 event.attr.exclude_idle = 1;
0061
0062 FAIL_IF(event_open(&event));
0063
0064 setup_ebb_handler(ebb_callee);
0065 ebb_global_enable();
0066
0067 FAIL_IF(ebb_event_enable(&event));
0068
0069 mtspr(SPRN_PMC2, pmc_sample_period(sample_period));
0070 mtspr(SPRN_PMC5, 0);
0071 mtspr(SPRN_PMC6, 0);
0072
0073 while (ebb_state.stats.ebb_count < 10)
0074 FAIL_IF(core_busy_loop());
0075
0076 ebb_global_disable();
0077 ebb_freeze_pmcs();
0078
0079 dump_ebb_state();
0080
0081 printf("PMC5/6 overflow %d\n", pmc56_overflowed);
0082
0083 event_close(&event);
0084
0085 FAIL_IF(ebb_state.stats.ebb_count == 0 || pmc56_overflowed != 0);
0086
0087 return 0;
0088 }
0089
0090 int main(void)
0091 {
0092 return test_harness(pmc56_overflow, "pmc56_overflow");
0093 }