mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-05-23 14:21:32 +01:00
lib: sbi: Fix hw a/d updating defaults
The Svade dt-binding description states that Svadu should only be enabled at boot time when only Svadu is present in the DT. Ensure that's the case. Also, when only Svadu is supported, disable FWFT.PTE_AD_HW_UPDATING, as we need both to support toggling. Signed-off-by: Andrew Jones <andrew.jones@oss.qualcomm.com> Reviewed-by: Radim Krčmář <radim.krcmar@oss.qualcomm.com> Link: https://lore.kernel.org/r/20260401220845.190680-1-andrew.jones@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
+9
-1
@@ -160,8 +160,16 @@ static int fwft_get_double_trap(struct fwft_config *conf, unsigned long *value)
|
|||||||
|
|
||||||
static int fwft_adue_supported(struct fwft_config *conf)
|
static int fwft_adue_supported(struct fwft_config *conf)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* FWFT.PTE_AD_HW_UPDATING is only supported when both Svade and Svadu
|
||||||
|
* are supported. We need both in order to support toggling and to
|
||||||
|
* ensure the reset value of zero is valid (it wouldn't be when only
|
||||||
|
* Svadu is supported).
|
||||||
|
*/
|
||||||
if (!sbi_hart_has_extension(sbi_scratch_thishart_ptr(),
|
if (!sbi_hart_has_extension(sbi_scratch_thishart_ptr(),
|
||||||
SBI_HART_EXT_SVADU))
|
SBI_HART_EXT_SVADU) ||
|
||||||
|
!sbi_hart_has_extension(sbi_scratch_thishart_ptr(),
|
||||||
|
SBI_HART_EXT_SVADE))
|
||||||
return SBI_ENOTSUPP;
|
return SBI_ENOTSUPP;
|
||||||
|
|
||||||
return SBI_OK;
|
return SBI_OK;
|
||||||
|
|||||||
+11
-9
@@ -137,6 +137,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
|
|||||||
if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_12) {
|
if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_12) {
|
||||||
menvcfg_val = csr_read64(CSR_MENVCFG);
|
menvcfg_val = csr_read64(CSR_MENVCFG);
|
||||||
|
|
||||||
|
/* Disable HW A/D updating by default */
|
||||||
|
menvcfg_val &= ~ENVCFG_ADUE;
|
||||||
|
|
||||||
/* Disable double trap by default */
|
/* Disable double trap by default */
|
||||||
menvcfg_val &= ~ENVCFG_DTE;
|
menvcfg_val &= ~ENVCFG_DTE;
|
||||||
|
|
||||||
@@ -158,19 +161,18 @@ static void mstatus_init(struct sbi_scratch *scratch)
|
|||||||
#endif
|
#endif
|
||||||
__set_menvcfg_ext(SBI_HART_EXT_SSTC, ENVCFG_STCE)
|
__set_menvcfg_ext(SBI_HART_EXT_SSTC, ENVCFG_STCE)
|
||||||
__set_menvcfg_ext(SBI_HART_EXT_SMCDELEG, ENVCFG_CDE);
|
__set_menvcfg_ext(SBI_HART_EXT_SMCDELEG, ENVCFG_CDE);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Assume only Svadu is supported when it is the only extension
|
||||||
|
* present in the ISA string. Svade is assumed when neither are
|
||||||
|
* present. When both are present we must default to Svade (see
|
||||||
|
* the zero reset value of FWFT.PTE_AD_HW_UPDATING).
|
||||||
|
*/
|
||||||
|
if (!sbi_hart_has_extension(scratch, SBI_HART_EXT_SVADE))
|
||||||
__set_menvcfg_ext(SBI_HART_EXT_SVADU, ENVCFG_ADUE);
|
__set_menvcfg_ext(SBI_HART_EXT_SVADU, ENVCFG_ADUE);
|
||||||
|
|
||||||
#undef __set_menvcfg_ext
|
#undef __set_menvcfg_ext
|
||||||
|
|
||||||
/*
|
|
||||||
* When both Svade and Svadu are present in DT, the default scheme for managing
|
|
||||||
* the PTE A/D bits should use Svade. Check Svadu before Svade extension to ensure
|
|
||||||
* that the ADUE bit is cleared when the Svade support are specified.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SVADE))
|
|
||||||
menvcfg_val &= ~ENVCFG_ADUE;
|
|
||||||
|
|
||||||
csr_write64(CSR_MENVCFG, menvcfg_val);
|
csr_write64(CSR_MENVCFG, menvcfg_val);
|
||||||
|
|
||||||
/* Enable S-mode access to seed CSR */
|
/* Enable S-mode access to seed CSR */
|
||||||
|
|||||||
Reference in New Issue
Block a user