linux/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c
Athira Rajeev 45677c9aeb selftests/powerpc: Fix "no_handler" EBB selftest
The "no_handler_test" in ebb selftests attempts to read the PMU
registers twice via helper function "dump_ebb_state". First dump is
just before closing of event and the second invocation is done after
closing of the event. The original intention of second
dump_ebb_state was to dump the state of registers at the end of
the test when the counters are frozen. But this will be achieved
with the first call itself since sample period is set to low value
and PMU will be frozen by then. Hence patch removes the
dump which was done before closing of the event.

Reported-by: Shirisha Ganta <shirisha.ganta1@ibm.com>
Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Tested-by: Nageswara R Sastry <rnsastry@linux.ibm.com <mailto:rnsastry@linux.ibm.com>>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1621950703-1532-2-git-send-email-atrajeev@linux.vnet.ibm.com
2021-06-17 00:09:11 +10:00

62 lines
1.1 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2014, Michael Ellerman, IBM Corp.
*/
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <signal.h>
#include "ebb.h"
/* Test that things work sanely if we have no handler */
static int no_handler_test(void)
{
struct event event;
u64 val;
int i;
SKIP_IF(!ebb_is_supported());
event_init_named(&event, 0x1001e, "cycles");
event_leader_ebb_init(&event);
event.attr.exclude_kernel = 1;
event.attr.exclude_hv = 1;
event.attr.exclude_idle = 1;
FAIL_IF(event_open(&event));
FAIL_IF(ebb_event_enable(&event));
val = mfspr(SPRN_EBBHR);
FAIL_IF(val != 0);
/* Make sure it overflows quickly */
sample_period = 1000;
mtspr(SPRN_PMC1, pmc_sample_period(sample_period));
/* Spin to make sure the event has time to overflow */
for (i = 0; i < 1000; i++)
mb();
dump_ebb_state();
/* We expect to see the PMU frozen & PMAO set */
val = mfspr(SPRN_MMCR0);
FAIL_IF(val != 0x0000000080000080);
event_close(&event);
/* The real test is that we never took an EBB at 0x0 */
return 0;
}
int main(void)
{
return test_harness(no_handler_test,"no_handler_test");
}