mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-19 18:21:41 +00:00
lib: sbi_hart: Reset mhpmcounter after probing its bits
Writting mhpmcounter3 (and 3H) to determine the allowed bit width has a side effect: the counter starts counting. Explicitly clear the counter right after the probe so the probing writes do not leave any persistent hardware side effect. Signed-off-by: Evgenii Prokopiev <eestelle0626@gmail.com> Link: https://lore.kernel.org/r/20260910180217.3256-1-eestelle0626@gmail.com Signed-off-by: Anup Patel <anup@brainfault.org> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
1 parent
f5622b4bb4
commit
3a51dc070e
1 file changed
+2
@@ -448,6 +448,7 @@ static int hart_mhpm_get_allowed_bits(void)
|
||||
csr_write_allowed(CSR_MHPMCOUNTER3, &trap, val);
|
||||
if (!trap.cause) {
|
||||
val = csr_read_allowed(CSR_MHPMCOUNTER3, &trap);
|
||||
csr_write(CSR_MHPMCOUNTER3, 0);
|
||||
if (trap.cause)
|
||||
return 0;
|
||||
}
|
||||
@@ -456,6 +457,7 @@ static int hart_mhpm_get_allowed_bits(void)
|
||||
csr_write_allowed(CSR_MHPMCOUNTER3H, &trap, val);
|
||||
if (!trap.cause) {
|
||||
val = csr_read_allowed(CSR_MHPMCOUNTER3H, &trap);
|
||||
csr_write(CSR_MHPMCOUNTER3H, 0);
|
||||
if (trap.cause)
|
||||
return num_bits;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user