2 Commits
Author SHA1 Message Date
Evgenii Prokopiev d28bc6f898 lib: sbi_hart: Retrun zero length of mhpmcounter when probing failed
If writing access is not allowed, it will raise a trap, but we increase
the number of allowed bits to 32 in this approach, which isn't right.
There must be a write of 0.

Move the operation of increasing allowed bits into the 'if' condition.

Signed-off-by: Evgenii Prokopiev <eestelle0626@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260910182026.6776-1-eestelle0626@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-27 17:28:45 +05:30
Evgenii Prokopiev 3a51dc070e 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>
2026-10-27 13:58:47 +05:30