mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-05-23 14:21:32 +01:00
lib: sbi: hart: Move device tree features detection before trap-based checks
Smrnmi detection and enablement in the following commits will happen before any trap-based mechanism. As it relies on device tree, move sbi_platform_extensions_init() to the beginning of hart_detect_features(). Signed-off-by: Evgeny Voevodin <evvoevod@tenstorrent.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/d066935990f12e1f4f21cd709eb20afba618b134.1778176768.git.evvoevod@tenstorrent.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
committed by
Anup Patel
parent
00fec20b49
commit
882b8b081c
+10
-6
@@ -522,6 +522,16 @@ static int hart_detect_features(struct sbi_scratch *scratch)
|
|||||||
hfeatures->mhpm_mask = 0;
|
hfeatures->mhpm_mask = 0;
|
||||||
hfeatures->priv_version = SBI_HART_PRIV_VER_UNKNOWN;
|
hfeatures->priv_version = SBI_HART_PRIV_VER_UNKNOWN;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Parse device tree extensions early, before any trap-based checks.
|
||||||
|
* Needed to detect Smrnmi and install NMI handlers before CSR probes
|
||||||
|
* that may trigger traps.
|
||||||
|
*/
|
||||||
|
rc = sbi_platform_extensions_init(sbi_platform_thishart_ptr(),
|
||||||
|
hfeatures);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
#define __check_hpm_csr(__csr, __mask) \
|
#define __check_hpm_csr(__csr, __mask) \
|
||||||
oldval = csr_read_allowed(__csr, &trap); \
|
oldval = csr_read_allowed(__csr, &trap); \
|
||||||
if (!trap.cause) { \
|
if (!trap.cause) { \
|
||||||
@@ -676,12 +686,6 @@ __pmp_skip:
|
|||||||
|
|
||||||
#undef __check_csr_existence
|
#undef __check_csr_existence
|
||||||
|
|
||||||
/* Let platform populate extensions */
|
|
||||||
rc = sbi_platform_extensions_init(sbi_platform_thishart_ptr(),
|
|
||||||
hfeatures);
|
|
||||||
if (rc)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
/* Zicntr should only be detected using traps */
|
/* Zicntr should only be detected using traps */
|
||||||
__sbi_hart_update_extension(hfeatures, SBI_HART_EXT_ZICNTR,
|
__sbi_hart_update_extension(hfeatures, SBI_HART_EXT_ZICNTR,
|
||||||
sbi_hart_has_csr(scratch, SBI_HART_CSR_CYCLE) &&
|
sbi_hart_has_csr(scratch, SBI_HART_CSR_CYCLE) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user