lib: sbi: report smrnmi_handlers_init failures instead of ignoring them

smrnmi_handlers_init returned void, so a failed callback went
unreported and NMIE was enabled anyway.

Change it to return int and skip enabling NMIE on failure. Also
update the doc comment on rnmi_handler to use SBI_OK instead of
SBI_SUCCESS, so both callbacks consistently reference the correct
firmware-internal success constant rather than the ecall-facing one.

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-2-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 54fad5bdda
commit 894435d28f
2 files changed
+20 -8

No files matched your search

+4 -3
View File
@@ -157,12 +157,13 @@ struct sbi_platform_operations {
/** 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),
* re-init), so it must be safe to call repeatedly.
* Returns SBI_OK on success, error code otherwise. */
int (*smrnmi_handlers_init)(void (*rnmi_handler)(void),
void (*rnme_handler)(void));
/** platform specific Smrnmi NMI handler.
* Returns SBI_SUCCESS on success, error code if NMI cannot be handled. */
* Returns SBI_OK on success, error code if NMI cannot be handled. */
int (*rnmi_handler)(struct sbi_trap_context *tcntx);
};