summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-10-11 08:31:09 +0300
committerAnup Patel <anup@brainfault.org>2021-10-18 13:37:16 +0300
commitc38973e0879e719d2b3ce1304802ea6b995d0d7e (patch)
tree4c2b32b01155d24891de407c8a2b3809a8725470
parent9283d503bd260a972f7e7ac2d895f7cfb152ef77 (diff)
downloadopensbi-c38973e0879e719d2b3ce1304802ea6b995d0d7e.tar.xz
lib: sbi: Save context for all non-retentive suspend types
Instead of saving context only for default non-retentive suspend, we should save context for all non-retentive suspend types. Fixes: 74756891cc35 ("lib: sbi: Implement SBI HSM suspend function") Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Dong Du <Dd_nirvana@sjtu.edu.cn> Reviewed-by: Xiang W <wxjstz@126.com>
-rw-r--r--lib/sbi/sbi_hsm.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c
index 67890f3..ecd2e45 100644
--- a/lib/sbi/sbi_hsm.c
+++ b/lib/sbi/sbi_hsm.c
@@ -358,12 +358,6 @@ static int __sbi_hsm_suspend_non_ret_default(struct sbi_scratch *scratch,
{
void (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr;
- /*
- * Save some of the M-mode CSRs which should be restored after
- * resuming from suspend state
- */
- __sbi_hsm_suspend_non_ret_save(scratch);
-
/* Wait for interrupt */
wfi();
@@ -463,6 +457,13 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
/* Save the suspend type */
hdata->suspend_type = suspend_type;
+ /*
+ * Save context which will be restored after resuming from
+ * non-retentive suspend.
+ */
+ if (suspend_type & SBI_HSM_SUSP_NON_RET_BIT)
+ __sbi_hsm_suspend_non_ret_save(scratch);
+
/* Try platform specific suspend */
ret = hsm_device_hart_suspend(suspend_type, scratch->warmboot_addr);
if (ret == SBI_ENOTSUPP) {