linux/arch/riscv
Sia Jee Heng c031721001
RISC-V: Add arch functions to support hibernation/suspend-to-disk
Low level Arch functions were created to support hibernation.
swsusp_arch_suspend() relies code from __cpu_suspend_enter() to write
cpu state onto the stack, then calling swsusp_save() to save the memory
image.

Arch specific hibernation header is implemented and is utilized by the
arch_hibernation_header_restore() and arch_hibernation_header_save()
functions. The arch specific hibernation header consists of satp, hartid,
and the cpu_resume address. The kernel built version is also need to be
saved into the hibernation image header to making sure only the same
kernel is restore when resume.

swsusp_arch_resume() creates a temporary page table that covering only
the linear map. It copies the restore code to a 'safe' page, then start
to restore the memory image. Once completed, it restores the original
kernel's page table. It then calls into __hibernate_cpu_resume()
to restore the CPU context. Finally, it follows the normal hibernation
path back to the hibernation core.

To enable hibernation/suspend to disk into RISCV, the below config
need to be enabled:
- CONFIG_HIBERNATION
- CONFIG_ARCH_HIBERNATION_HEADER
- CONFIG_ARCH_HIBERNATION_POSSIBLE

Signed-off-by: Sia Jee Heng <jeeheng.sia@starfivetech.com>
Reviewed-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
Reviewed-by: Mason Huo <mason.huo@starfivetech.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Link: https://lore.kernel.org/r/20230330064321.1008373-5-jeeheng.sia@starfivetech.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2023-04-29 11:25:13 -07:00
..
boot SoC: DT changes for 6.3 2023-02-20 15:49:56 -08:00
configs riscv: defconfig: Enable the Allwinner D1 platform and drivers 2023-01-27 23:10:08 +01:00
errata RISC-V: take text_mutex during alternative patching 2023-02-21 17:21:33 -08:00
include RISC-V: Add arch functions to support hibernation/suspend-to-disk 2023-04-29 11:25:13 -07:00
kernel RISC-V: Add arch functions to support hibernation/suspend-to-disk 2023-04-29 11:25:13 -07:00
kvm ARM: 2023-02-25 11:30:21 -08:00
lib riscv, lib: Fix Zbb strncmp 2023-02-28 18:42:38 -08:00
mm RISC-V: mm: Enable huge page support to kernel_page_present() function 2023-04-29 11:25:12 -07:00
net riscv, bpf: Add bpf trampoline support for RV64 2023-02-17 21:45:30 +01:00
purgatory RISC-V: add infrastructure to allow different str* implementations 2023-01-31 11:43:23 -08:00
Kbuild riscv: move errata/ and kvm/ builds to arch/riscv/Kbuild 2022-06-01 22:26:32 -07:00
Kconfig RISC-V: Add arch functions to support hibernation/suspend-to-disk 2023-04-29 11:25:13 -07:00
Kconfig.debug
Kconfig.erratas drivers/perf: riscv_pmu_sbi: add support for PMU variant on T-Head C9xx cores 2022-10-27 14:35:20 -07:00
Kconfig.socs RISC-V Patches for the 6.3 Merge Window, Part 1 2023-02-25 11:14:08 -08:00
Makefile RISC-V Patches for the 6.3 Merge Window, Part 1 2023-02-25 11:14:08 -08:00