Loading Documentation/ABI/testing/sysfs-power +13 −0 Original line number Diff line number Diff line Loading @@ -407,3 +407,16 @@ Contact: Kalesh Singh <kaleshsingh96@gmail.com> Description: The /sys/power/suspend_stats/last_failed_step file contains the last failed step in the suspend/resume path. What: /sys/power/sync_on_suspend Date: October 2019 Contact: Jonas Meurer <jonas@freesources.org> Description: This file controls whether or not the kernel will sync() filesystems during system suspend (after freezing user space and before suspending devices). Writing a "1" to this file enables the sync() and writing a "0" disables it. Reads from the file return the current value. The default is "1" if the build-time "SUSPEND_SKIP_SYNC" config flag is unset, or "0" otherwise. drivers/base/power/wakeup.c +3 −0 Original line number Diff line number Diff line Loading @@ -1125,6 +1125,9 @@ static void *wakeup_sources_stats_seq_next(struct seq_file *m, break; } if (!next_ws) print_wakeup_source_stats(m, &deleted_ws); return next_ws; } Loading include/linux/suspend.h +2 −0 Original line number Diff line number Diff line Loading @@ -329,6 +329,7 @@ extern void arch_suspend_disable_irqs(void); extern void arch_suspend_enable_irqs(void); extern int pm_suspend(suspend_state_t state); extern bool sync_on_suspend_enabled; #else /* !CONFIG_SUSPEND */ #define suspend_valid_only_mem NULL Loading @@ -342,6 +343,7 @@ static inline bool pm_suspend_default_s2idle(void) { return false; } static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {} static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; } static inline bool sync_on_suspend_enabled(void) { return true; } static inline bool idle_should_enter_s2idle(void) { return false; } static inline void __init pm_states_init(void) {} static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {} Loading kernel/power/Kconfig +4 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,10 @@ config SUSPEND_SKIP_SYNC Skip the kernel sys_sync() before freezing user processes. Some systems prefer not to pay this cost on every invocation of suspend, or they are content with invoking sync() from user-space before invoking suspend. Say Y if that's your case. user-space before invoking suspend. There's a run-time switch at '/sys/power/sync_on_suspend' to configure this behaviour. This setting changes the default for the run-tim switch. Say Y to change the default to disable the kernel sys_sync(). config HIBERNATE_CALLBACKS bool Loading kernel/power/hibernate.c +12 −11 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ * Copyright (C) 2012 Bojan Smojver <bojan@rexursive.com> */ #define pr_fmt(fmt) "PM: " fmt #define pr_fmt(fmt) "PM: hibernation: " fmt #include <linux/export.h> #include <linux/suspend.h> Loading Loading @@ -106,7 +106,7 @@ EXPORT_SYMBOL(system_entering_hibernation); #ifdef CONFIG_PM_DEBUG static void hibernation_debug_sleep(void) { pr_info("hibernation debug: Waiting for 5 seconds.\n"); pr_info("debug: Waiting for 5 seconds.\n"); mdelay(5000); } Loading Loading @@ -277,7 +277,7 @@ static int create_image(int platform_mode) error = dpm_suspend_end(PMSG_FREEZE); if (error) { pr_err("Some devices failed to power down, aborting hibernation\n"); pr_err("Some devices failed to power down, aborting\n"); return error; } Loading @@ -295,7 +295,7 @@ static int create_image(int platform_mode) error = syscore_suspend(); if (error) { pr_err("Some system devices failed to power down, aborting hibernation\n"); pr_err("Some system devices failed to power down, aborting\n"); goto Enable_irqs; } Loading @@ -310,7 +310,7 @@ static int create_image(int platform_mode) restore_processor_state(); trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, false); if (error) pr_err("Error %d creating hibernation image\n", error); pr_err("Error %d creating image\n", error); if (!in_suspend) { events_check_enabled = false; Loading Loading @@ -680,7 +680,7 @@ static int load_image_and_restore(void) if (!error) hibernation_restore(flags & SF_PLATFORM_MODE); pr_err("Failed to load hibernation image, recovering.\n"); pr_err("Failed to load image, recovering.\n"); swsusp_free(); free_basic_memory_bitmaps(); Unlock: Loading Loading @@ -743,7 +743,7 @@ int hibernate(void) else flags |= SF_CRC32_MODE; pm_pr_dbg("Writing image.\n"); pm_pr_dbg("Writing hibernation image.\n"); error = swsusp_write(flags); swsusp_free(); if (!error) { Loading @@ -755,7 +755,7 @@ int hibernate(void) in_suspend = 0; pm_restore_gfp_mask(); } else { pm_pr_dbg("Image restored successfully.\n"); pm_pr_dbg("Hibernation image restored successfully.\n"); } Free_bitmaps: Loading Loading @@ -894,7 +894,7 @@ static int software_resume(void) goto Close_Finish; } pm_pr_dbg("Preparing processes for restore.\n"); pm_pr_dbg("Preparing processes for hibernation restore.\n"); error = freeze_processes(); if (error) goto Close_Finish; Loading @@ -903,7 +903,7 @@ static int software_resume(void) Finish: __pm_notifier_call_chain(PM_POST_RESTORE, nr_calls, NULL); pm_restore_console(); pr_info("resume from hibernation failed (%d)\n", error); pr_info("resume failed (%d)\n", error); atomic_inc(&snapshot_device_available); /* For success case, the suspend path will release the lock */ Unlock: Loading Loading @@ -1068,7 +1068,8 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, lock_system_sleep(); swsusp_resume_device = res; unlock_system_sleep(); pm_pr_dbg("Configured resume from disk to %u\n", swsusp_resume_device); pm_pr_dbg("Configured hibernation resume from disk to %u\n", swsusp_resume_device); noresume = 0; software_resume(); return n; Loading Loading
Documentation/ABI/testing/sysfs-power +13 −0 Original line number Diff line number Diff line Loading @@ -407,3 +407,16 @@ Contact: Kalesh Singh <kaleshsingh96@gmail.com> Description: The /sys/power/suspend_stats/last_failed_step file contains the last failed step in the suspend/resume path. What: /sys/power/sync_on_suspend Date: October 2019 Contact: Jonas Meurer <jonas@freesources.org> Description: This file controls whether or not the kernel will sync() filesystems during system suspend (after freezing user space and before suspending devices). Writing a "1" to this file enables the sync() and writing a "0" disables it. Reads from the file return the current value. The default is "1" if the build-time "SUSPEND_SKIP_SYNC" config flag is unset, or "0" otherwise.
drivers/base/power/wakeup.c +3 −0 Original line number Diff line number Diff line Loading @@ -1125,6 +1125,9 @@ static void *wakeup_sources_stats_seq_next(struct seq_file *m, break; } if (!next_ws) print_wakeup_source_stats(m, &deleted_ws); return next_ws; } Loading
include/linux/suspend.h +2 −0 Original line number Diff line number Diff line Loading @@ -329,6 +329,7 @@ extern void arch_suspend_disable_irqs(void); extern void arch_suspend_enable_irqs(void); extern int pm_suspend(suspend_state_t state); extern bool sync_on_suspend_enabled; #else /* !CONFIG_SUSPEND */ #define suspend_valid_only_mem NULL Loading @@ -342,6 +343,7 @@ static inline bool pm_suspend_default_s2idle(void) { return false; } static inline void suspend_set_ops(const struct platform_suspend_ops *ops) {} static inline int pm_suspend(suspend_state_t state) { return -ENOSYS; } static inline bool sync_on_suspend_enabled(void) { return true; } static inline bool idle_should_enter_s2idle(void) { return false; } static inline void __init pm_states_init(void) {} static inline void s2idle_set_ops(const struct platform_s2idle_ops *ops) {} Loading
kernel/power/Kconfig +4 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,10 @@ config SUSPEND_SKIP_SYNC Skip the kernel sys_sync() before freezing user processes. Some systems prefer not to pay this cost on every invocation of suspend, or they are content with invoking sync() from user-space before invoking suspend. Say Y if that's your case. user-space before invoking suspend. There's a run-time switch at '/sys/power/sync_on_suspend' to configure this behaviour. This setting changes the default for the run-tim switch. Say Y to change the default to disable the kernel sys_sync(). config HIBERNATE_CALLBACKS bool Loading
kernel/power/hibernate.c +12 −11 Original line number Diff line number Diff line Loading @@ -9,7 +9,7 @@ * Copyright (C) 2012 Bojan Smojver <bojan@rexursive.com> */ #define pr_fmt(fmt) "PM: " fmt #define pr_fmt(fmt) "PM: hibernation: " fmt #include <linux/export.h> #include <linux/suspend.h> Loading Loading @@ -106,7 +106,7 @@ EXPORT_SYMBOL(system_entering_hibernation); #ifdef CONFIG_PM_DEBUG static void hibernation_debug_sleep(void) { pr_info("hibernation debug: Waiting for 5 seconds.\n"); pr_info("debug: Waiting for 5 seconds.\n"); mdelay(5000); } Loading Loading @@ -277,7 +277,7 @@ static int create_image(int platform_mode) error = dpm_suspend_end(PMSG_FREEZE); if (error) { pr_err("Some devices failed to power down, aborting hibernation\n"); pr_err("Some devices failed to power down, aborting\n"); return error; } Loading @@ -295,7 +295,7 @@ static int create_image(int platform_mode) error = syscore_suspend(); if (error) { pr_err("Some system devices failed to power down, aborting hibernation\n"); pr_err("Some system devices failed to power down, aborting\n"); goto Enable_irqs; } Loading @@ -310,7 +310,7 @@ static int create_image(int platform_mode) restore_processor_state(); trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, false); if (error) pr_err("Error %d creating hibernation image\n", error); pr_err("Error %d creating image\n", error); if (!in_suspend) { events_check_enabled = false; Loading Loading @@ -680,7 +680,7 @@ static int load_image_and_restore(void) if (!error) hibernation_restore(flags & SF_PLATFORM_MODE); pr_err("Failed to load hibernation image, recovering.\n"); pr_err("Failed to load image, recovering.\n"); swsusp_free(); free_basic_memory_bitmaps(); Unlock: Loading Loading @@ -743,7 +743,7 @@ int hibernate(void) else flags |= SF_CRC32_MODE; pm_pr_dbg("Writing image.\n"); pm_pr_dbg("Writing hibernation image.\n"); error = swsusp_write(flags); swsusp_free(); if (!error) { Loading @@ -755,7 +755,7 @@ int hibernate(void) in_suspend = 0; pm_restore_gfp_mask(); } else { pm_pr_dbg("Image restored successfully.\n"); pm_pr_dbg("Hibernation image restored successfully.\n"); } Free_bitmaps: Loading Loading @@ -894,7 +894,7 @@ static int software_resume(void) goto Close_Finish; } pm_pr_dbg("Preparing processes for restore.\n"); pm_pr_dbg("Preparing processes for hibernation restore.\n"); error = freeze_processes(); if (error) goto Close_Finish; Loading @@ -903,7 +903,7 @@ static int software_resume(void) Finish: __pm_notifier_call_chain(PM_POST_RESTORE, nr_calls, NULL); pm_restore_console(); pr_info("resume from hibernation failed (%d)\n", error); pr_info("resume failed (%d)\n", error); atomic_inc(&snapshot_device_available); /* For success case, the suspend path will release the lock */ Unlock: Loading Loading @@ -1068,7 +1068,8 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr, lock_system_sleep(); swsusp_resume_device = res; unlock_system_sleep(); pm_pr_dbg("Configured resume from disk to %u\n", swsusp_resume_device); pm_pr_dbg("Configured hibernation resume from disk to %u\n", swsusp_resume_device); noresume = 0; software_resume(); return n; Loading