[PATCH v2 0/3] lib: sbi: Fix Smrnmi resume init and optional platform callback

Nia Su nia.su at sifive.com
Thu Sep 3 21:43:49 PDT 2026


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.

Patch 1 extracts the setup into sbi_smrnmi_hart_init() and calls it
from both hart_detect_features() and sbi_hart_reinit().

Patch 2 changes smrnmi_handlers_init to return int, so a platform
callback that fails to program its NMI vector register is no longer
silently ignored before NMIE gets enabled anyway.

Patch 3 allows a NULL smrnmi_handlers_init instead of calling
sbi_panic(), since platforms with fixed or mtvec-based NMI vectors
need no vendor register programming and an unhandled RNMI already
falls back safely to sbi_trap_error(). It also reports the init mode
("Platform" or "Default") in the boot HART banner for visibility.

Signed-off-by: Nia Su <nia.su at sifive.com>
---
Changes in v2:
- Break v1's patch 1 into three smaller, self-contained patches for
  a clearer structure.
- Dropped v1's patch 2, which is unrelated to this fix and will be
  sent separately.
- Link to v1: https://lore.kernel.org/opensbi/20260827-rnmi-trap-fixes-v1-0-df371cf92301@sifive.com/

---
Nia Su (3):
      lib: sbi: extract sbi_smrnmi_hart_init() and call on non-retentive resume
      lib: sbi: report smrnmi_handlers_init failures instead of ignoring them
      lib: sbi: allow NULL smrnmi_handlers_init and report init mode at boot

 include/sbi/sbi_hart.h     |  8 +++++
 include/sbi/sbi_platform.h |  2 +-
 lib/sbi/sbi_hart.c         | 75 +++++++++++++++++++++++++++++++++-------------
 lib/sbi/sbi_init.c         |  4 +++
 4 files changed, 68 insertions(+), 21 deletions(-)
---
base-commit: 35511bc6ee1c9c17b6a89b44c52e2044bb51b979
change-id: 20260901-smrnmi-context-restore-b3b1f23bec28

--




More information about the opensbi mailing list