Skip to content

Commit 1f6bbe1

Browse files
atishp04avpatel
authored andcommitted
KVM: riscv: selftests: Do not start the counter in the overflow handler
There is no need to start the counter in the overflow handler as we intend to trigger precise number of LCOFI interrupts through these tests. The overflow irq handler has already stopped the counter. As a result, the stop call from the test function may return already stopped error which is fine as well. Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Signed-off-by: Atish Patra <atishp@rivosinc.com> Link: https://lore.kernel.org/r/20250303-kvm_pmu_improve-v2-2-41d177e45929@rivosinc.com Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent bbb6224 commit 1f6bbe1

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tools/testing/selftests/kvm/riscv/sbi_pmu_test.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ static void stop_counter(unsigned long counter, unsigned long stop_flags)
118118

119119
ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, counter, 1, stop_flags,
120120
0, 0, 0);
121-
__GUEST_ASSERT(ret.error == 0, "Unable to stop counter %ld error %ld\n",
122-
counter, ret.error);
121+
__GUEST_ASSERT(ret.error == 0 || ret.error == SBI_ERR_ALREADY_STOPPED,
122+
"Unable to stop counter %ld error %ld\n", counter, ret.error);
123123
}
124124

125125
static void guest_illegal_exception_handler(struct ex_regs *regs)
@@ -137,7 +137,6 @@ static void guest_irq_handler(struct ex_regs *regs)
137137
unsigned int irq_num = regs->cause & ~CAUSE_IRQ_FLAG;
138138
struct riscv_pmu_snapshot_data *snapshot_data = snapshot_gva;
139139
unsigned long overflown_mask;
140-
unsigned long counter_val = 0;
141140

142141
/* Validate that we are in the correct irq handler */
143142
GUEST_ASSERT_EQ(irq_num, IRQ_PMU_OVF);
@@ -151,10 +150,6 @@ static void guest_irq_handler(struct ex_regs *regs)
151150
GUEST_ASSERT(overflown_mask & 0x01);
152151

153152
WRITE_ONCE(vcpu_shared_irq_count, vcpu_shared_irq_count+1);
154-
155-
counter_val = READ_ONCE(snapshot_data->ctr_values[0]);
156-
/* Now start the counter to mimick the real driver behavior */
157-
start_counter(counter_in_use, SBI_PMU_START_FLAG_SET_INIT_VALUE, counter_val);
158153
}
159154

160155
static unsigned long get_counter_index(unsigned long cbase, unsigned long cmask,

0 commit comments

Comments
 (0)