Skip to content

Commit fa7d733

Browse files
SiFiveHollandpalmer-dabbelt
authored andcommitted
riscv: Do not save the scratch CSR during suspend
While the processor is executing kernel code, the value of the scratch CSR is always zero, so there is no need to save the value. Continue to write the CSR during the resume flow, so we do not rely on firmware to initialize it. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent d4b500c commit fa7d733

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

arch/riscv/include/asm/suspend.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ struct suspend_context {
1313
/* Saved and restored by low-level functions */
1414
struct pt_regs regs;
1515
/* Saved and restored by high-level functions */
16-
unsigned long scratch;
1716
unsigned long envcfg;
1817
unsigned long tvec;
1918
unsigned long ie;

arch/riscv/kernel/suspend.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
void suspend_save_csrs(struct suspend_context *context)
1616
{
17-
context->scratch = csr_read(CSR_SCRATCH);
1817
if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_XLINUXENVCFG))
1918
context->envcfg = csr_read(CSR_ENVCFG);
2019
context->tvec = csr_read(CSR_TVEC);
@@ -37,7 +36,7 @@ void suspend_save_csrs(struct suspend_context *context)
3736

3837
void suspend_restore_csrs(struct suspend_context *context)
3938
{
40-
csr_write(CSR_SCRATCH, context->scratch);
39+
csr_write(CSR_SCRATCH, 0);
4140
if (riscv_cpu_has_extension_unlikely(smp_processor_id(), RISCV_ISA_EXT_XLINUXENVCFG))
4241
csr_write(CSR_ENVCFG, context->envcfg);
4342
csr_write(CSR_TVEC, context->tvec);

0 commit comments

Comments
 (0)