xtensa: add hibernation support
Max Filippov
maintainerPATCH 1/1 xtensa: add hibernation support
Define ARCH_HIBERNATION_POSSIBLE in Kconfig and implement hibernation callbacks.
Signed-off-by Max Filippov <[email protected]>
--- arch/xtensa/Kconfig | 3 ++ arch/xtensa/kernel/Makefile | 1 + arch/xtensa/kernel/asm-offsets.c | 8 +++ arch/xtensa/kernel/entry.S | 92 ++++++++++++++++++++++++++++++++ arch/xtensa/kernel/hibernate.c | 25 +++++++++ 5 files changed, 129 insertions(+) create mode 100644 arch/xtensa/kernel/hibernate.c
arch/xtensa/Kconfig +3 -0
@@ -788,6 +788,9 @@ endmenu menu "Power management options" +config ARCH_HIBERNATION_POSSIBLE + def_bool y + source "kernel/power/Kconfig" endmenu
arch/xtensa/kernel/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_XTENSA_VARIANT_HAVE_PERF_EVENTS) += perf_event.o obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o obj-$(CONFIG_S32C1I_SELFTEST) += s32c1i_selftest.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o +obj-$(CONFIG_HIBERNATION) += hibernate.o # In the Xtensa architecture, assembly generates literals which must always # precede the L32R instruction with a relative offset less than 256 kB.
arch/xtensa/kernel/asm-offsets.c +8 -0
@@ -21,6 +21,7 @@#include <linux/ptrace.h> #include <linux/mm.h> #include <linux/kbuild.h> +#include <linux/suspend.h> #include <asm/ptrace.h> #include <asm/traps.h>
@@ -149,5 +150,12 @@ int main(void) offsetof(struct exc_table, fast_kernel_handler));DEFINE (EXC_TABLE_DEFAULT , offsetof(struct exc_table , default_handler)); +#ifdef CONFIG_HIBERNATION +DEFINE (PBE_ADDRESS , offsetof(struct pbe , address)); +DEFINE (PBE_ORIG_ADDRESS , offsetof(struct pbe , orig_address)); +DEFINE (PBE_NEXT , offsetof(struct pbe , next)); +DEFINE (PBE_SIZE ,sizeof (struct pbe )); +#endif +return 0 ; }
arch/xtensa/kernel/entry.S +92 -0
95 lines not on this page · raw message
arch/xtensa/kernel/hibernate.c new file +25 -0
@@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <linux/mm.h> +#include <linux/suspend.h> +#include <asm/coprocessor.h> + +int pfn_is_nosave (unsigned long pfn) +{ +unsigned long nosave_begin_pfn =PFN_DOWN (__pa (&__nosave_begin)); +unsigned long nosave_end_pfn =PFN_UP (__pa (&__nosave_end)); + +return (pfn >= nosave_begin_pfn) && (pfn < nosave_end_pfn); +} + +void notrace save_processor_state(void) +{ +WARN_ON (num_online_cpus () !=1 ); +#if XTENSA_HAVE_COPROCESSORS +local_coprocessors_flush_release_all (); +#endif +} + +void notrace restore_processor_state(void) +{ +}
Signature · 1 line
2.30.2