lib: sbi: extract smrnmi_hart_init() and call on non-retentive resume

On non-retentive suspend resume, the hart never initializes the
Smrnmi CSRs the way hart_detect_features() does at boot, so a hart
waking from non-retentive suspend resumes with NMIs disabled and no
RNMI handler installed.

Extract the setup into smrnmi_hart_init() and call it from both
hart_detect_features() and sbi_hart_reinit().

Fixes: 2d211fe6f9 ("lib: sbi: hart: Detect and enable Smrnmi before trap-based feature detection")
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Co-developed-by: Nia Su <nia.su@sifive.com>
Signed-off-by: Nia Su <nia.su@sifive.com>
Reviewed-by: Evgeny Voevodin <evvoevod@tenstorrent.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260915-smrnmi-context-restore-v3-1-e9dd31152515@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
Nia Su authored and Anup Patel committed 2026-11-03 13:15:33 +05:30
1 parent c9a7d00992
commit 54fad5bdda
2 files changed
+34 -26

No files matched your search

+4 -1
View File
@@ -154,7 +154,10 @@ struct sbi_platform_operations {
/** platform specific pmp disable on current HART */
void (*pmp_disable)(unsigned int n);
/** platform specific Smrnmi handlers init on current HART */
/** platform specific Smrnmi handlers init on current HART.
* May be called more than once on the same HART (e.g. once
* during boot feature detection and again during hart
* re-init), so it must be safe to call repeatedly. */
void (*smrnmi_handlers_init)(void (*rnmi_handler)(void),
void (*rnme_handler)(void));