summaryrefslogtreecommitdiffstats
path: root/src/sleep
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2024-03-27 12:45:34 +0100
committerMike Yuan <me@yhndnzj.com>2024-03-28 10:19:35 +0100
commita2124b35e92178fd028d7c29ecdd5e80ea7f7b8f (patch)
tree0ff768a0ed336bd290d6279a1c93b9ac74f54990 /src/sleep
parentsleep: make write_mode take a path (diff)
downloadsystemd-a2124b35e92178fd028d7c29ecdd5e80ea7f7b8f.tar.xz
systemd-a2124b35e92178fd028d7c29ecdd5e80ea7f7b8f.zip
sleep: add SleepMemMode= setting for configuring /sys/power/mem_sleep
The setting is used when /sys/power/state is set to 'mem' (common for suspend) or /sys/power/disk is set to 'suspend' (hybrid-sleep). We default to kernel choice here, i.e. respect what's set through 'mem_sleep_default=' kernel cmdline option.
Diffstat (limited to 'src/sleep')
-rw-r--r--src/sleep/sleep.c6
-rw-r--r--src/sleep/sleep.conf1
2 files changed, 7 insertions, 0 deletions
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 72489b31a0..693484e886 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -237,6 +237,12 @@ static int execute(
if (state_fd < 0)
return log_error_errno(errno, "Failed to open /sys/power/state: %m");
+ if (SLEEP_NEEDS_MEM_SLEEP(sleep_config, operation)) {
+ r = write_mode("/sys/power/mem_sleep", sleep_config->mem_modes);
+ if (r < 0)
+ return log_error_errno(r, "Failed to write mode to /sys/power/mem_sleep: %m");
+ }
+
/* Configure hibernation settings if we are supposed to hibernate */
if (SLEEP_OPERATION_IS_HIBERNATION(operation)) {
_cleanup_(hibernation_device_done) HibernationDevice hibernation_device = {};
diff --git a/src/sleep/sleep.conf b/src/sleep/sleep.conf
index fad95b3897..d12f97099a 100644
--- a/src/sleep/sleep.conf
+++ b/src/sleep/sleep.conf
@@ -23,5 +23,6 @@
#AllowHybridSleep=yes
#SuspendState=mem standby freeze
#HibernateMode=platform shutdown
+#SleepMemMode=
#HibernateDelaySec=
#SuspendEstimationSec=60min