diff options
author | Huacai Chen <chenhuacai@loongson.cn> | 2022-12-10 17:40:15 +0300 |
---|---|---|
committer | Huacai Chen <chenhuacai@loongson.cn> | 2022-12-14 03:41:53 +0300 |
commit | 7db54bfe44a662c8f2c10277bccfa02c2f4c719c (patch) | |
tree | 0718e06127149f29a103fee7fcccf6a458067f61 /arch/loongarch/kernel | |
parent | 366bb35a8e48198cefcd3484ac6b2374d1347873 (diff) | |
download | linux-7db54bfe44a662c8f2c10277bccfa02c2f4c719c.tar.xz |
LoongArch: Add hibernation (ACPI S4) support
Add hibernation (Suspend to Disk, aka ACPI S4) support for LoongArch.
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Diffstat (limited to 'arch/loongarch/kernel')
-rw-r--r-- | arch/loongarch/kernel/asm-offsets.c | 12 | ||||
-rw-r--r-- | arch/loongarch/kernel/reset.c | 5 | ||||
-rw-r--r-- | arch/loongarch/kernel/setup.c | 5 |
3 files changed, 22 insertions, 0 deletions
diff --git a/arch/loongarch/kernel/asm-offsets.c b/arch/loongarch/kernel/asm-offsets.c index bdd88eda9513..4ef494577813 100644 --- a/arch/loongarch/kernel/asm-offsets.c +++ b/arch/loongarch/kernel/asm-offsets.c @@ -257,3 +257,15 @@ void output_smpboot_defines(void) BLANK(); } #endif + +#ifdef CONFIG_HIBERNATION +void output_pbe_defines(void) +{ + COMMENT(" Linux struct pbe offsets. "); + OFFSET(PBE_ADDRESS, pbe, address); + OFFSET(PBE_ORIG_ADDRESS, pbe, orig_address); + OFFSET(PBE_NEXT, pbe, next); + DEFINE(PBE_SIZE, sizeof(struct pbe)); + BLANK(); +} +#endif diff --git a/arch/loongarch/kernel/reset.c b/arch/loongarch/kernel/reset.c index 8c82021eb2f4..1ef8c6383535 100644 --- a/arch/loongarch/kernel/reset.c +++ b/arch/loongarch/kernel/reset.c @@ -15,6 +15,7 @@ #include <acpi/reboot.h> #include <asm/idle.h> #include <asm/loongarch.h> +#include <asm/loongson.h> void (*pm_power_off)(void); EXPORT_SYMBOL(pm_power_off); @@ -42,6 +43,10 @@ void machine_power_off(void) preempt_disable(); smp_send_stop(); #endif +#ifdef CONFIG_PM + if (!acpi_disabled) + enable_pci_wakeup(); +#endif do_kernel_power_off(); #ifdef CONFIG_EFI efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL); diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index fdabf2ac1927..4344502c0b31 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -31,6 +31,7 @@ #include <linux/libfdt.h> #include <linux/of_fdt.h> #include <linux/of_address.h> +#include <linux/suspend.h> #include <linux/swiotlb.h> #include <asm/addrspace.h> @@ -370,6 +371,10 @@ static void __init arch_mem_init(char **cmdline_p) dma_contiguous_reserve(PFN_PHYS(max_low_pfn)); + /* Reserve for hibernation. */ + register_nosave_region(PFN_DOWN(__pa_symbol(&__nosave_begin)), + PFN_UP(__pa_symbol(&__nosave_end))); + memblock_dump_all(); early_memtest(PFN_PHYS(ARCH_PFN_OFFSET), PFN_PHYS(max_low_pfn)); |