2 * Copyright 2014, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
13 * Test that PMC5 & 6 are frozen (ie. don't overflow) when they are not being
14 * used. Tests the MMCR0_FC56 logic in the kernel.
17 static int pmc56_overflowed;
19 static void ebb_callee(void)
23 val = mfspr(SPRN_BESCR);
24 if (!(val & BESCR_PMEO)) {
25 ebb_state.stats.spurious++;
29 ebb_state.stats.ebb_count++;
30 count_pmc(2, sample_period);
32 val = mfspr(SPRN_PMC5);
33 if (val >= COUNTER_OVERFLOW)
36 count_pmc(5, COUNTER_OVERFLOW);
38 val = mfspr(SPRN_PMC6);
39 if (val >= COUNTER_OVERFLOW)
42 count_pmc(6, COUNTER_OVERFLOW);
48 int pmc56_overflow(void)
52 SKIP_IF(!ebb_is_supported());
54 /* Use PMC2 so we set PMCjCE, which enables PMC5/6 */
55 event_init(&event, 0x2001e);
56 event_leader_ebb_init(&event);
58 event.attr.exclude_kernel = 1;
59 event.attr.exclude_hv = 1;
60 event.attr.exclude_idle = 1;
62 FAIL_IF(event_open(&event));
64 setup_ebb_handler(ebb_callee);
67 FAIL_IF(ebb_event_enable(&event));
69 mtspr(SPRN_PMC2, pmc_sample_period(sample_period));
73 while (ebb_state.stats.ebb_count < 10)
74 FAIL_IF(core_busy_loop());
79 count_pmc(2, sample_period);
83 printf("PMC5/6 overflow %d\n", pmc56_overflowed);
87 FAIL_IF(ebb_state.stats.ebb_count == 0 || pmc56_overflowed != 0);
94 return test_harness(pmc56_overflow, "pmc56_overflow");