]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep-config: make hybrid sleep always use 'suspend' disk mode
authorMike Yuan <me@yhndnzj.com>
Tue, 24 Oct 2023 10:10:21 +0000 (18:10 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 24 Oct 2023 17:07:03 +0000 (19:07 +0200)
If user requests hybrid sleep, we should always use 'suspend'
disk mode. If that's not supported, let's correctly report it
so they can choose plain hibernation instead. HybridSleepMode=
serves no purpose in this case and should be removed.

Addresses https://github.com/systemd/systemd/pull/29681#discussion_r1369812785

man/systemd-sleep.conf.xml
src/shared/sleep-config.c
src/sleep/sleep.conf

index b33699b6c56f81c6d2a5dc9f5d4614f6369fa358..91ea909afe9bd932838b92744fc4f667f060904a 100644 (file)
 
       <varlistentry>
         <term><varname>HibernateMode=</varname></term>
-        <term><varname>HybridSleepMode=</varname></term>
 
-        <listitem><para>The string to be written to <filename>/sys/power/disk</filename> by, respectively,
-        <citerefentry><refentrytitle>systemd-hibernate.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
-        and
-        <citerefentry><refentrytitle>systemd-hybrid-sleep.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
+        <listitem><para>The string to be written to <filename>/sys/power/disk</filename> by <citerefentry>
+        <refentrytitle>systemd-hibernate.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
         More than one value can be specified by separating multiple values with whitespace. They will be
         tried in turn, until one is written without error. If none of the writes succeed, the operation will
         be aborted.</para>
         url="https://www.kernel.org/doc/html/latest/admin-guide/pm/sleep-states.html#basic-sysfs-interfaces-for-system-suspend-and-hibernation">the
         kernel documentation</ulink> for more details.</para>
 
-        <para>Note that hybrid sleep corresponds to the <literal>suspend</literal> disk mode. If <varname>HybridSleepMode=</varname>
-        is overridden, you might get plain hibernation instead.</para>
-
         <para>
         <citerefentry><refentrytitle>systemd-suspend-then-hibernate.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
         uses the value of <varname>SuspendMode=</varname> when suspending and the value of
index b63071a6928ed213f62890f315ee0c4395a0b38b..ab095303557e46631c474a75a9d23e960ee8f3f8 100644 (file)
@@ -42,7 +42,7 @@ static char* const* const sleep_default_state_table[_SLEEP_OPERATION_CONFIG_MAX]
 static char* const* const sleep_default_mode_table[_SLEEP_OPERATION_CONFIG_MAX] = {
         /* Not used by SLEEP_SUSPEND */
         [SLEEP_HIBERNATE]    = STRV_MAKE("platform", "shutdown"),
-        [SLEEP_HYBRID_SLEEP] = STRV_MAKE("suspend", "platform", "shutdown"),
+        [SLEEP_HYBRID_SLEEP] = STRV_MAKE("suspend"),
 };
 
 SleepConfig* sleep_config_free(SleepConfig *sc) {
@@ -76,10 +76,6 @@ static void sleep_config_validate_state_and_mode(SleepConfig *sc) {
         if (strv_contains(sc->modes[SLEEP_HIBERNATE], "suspend"))
                 log_warning("Sleep mode 'suspend' should not be used by operation %s. Please use %s instead.",
                             sleep_operation_to_string(SLEEP_HIBERNATE), sleep_operation_to_string(SLEEP_HYBRID_SLEEP));
-
-        if (!strv_contains(sc->modes[SLEEP_HYBRID_SLEEP], "suspend"))
-                log_warning("Sleep mode 'suspend' is not set for operation %s. This would likely result in a plain hibernation.",
-                            sleep_operation_to_string(SLEEP_HYBRID_SLEEP));
 }
 
 int parse_sleep_config(SleepConfig **ret) {
@@ -97,22 +93,22 @@ int parse_sleep_config(SleepConfig **ret) {
         };
 
         const ConfigTableItem items[] = {
-                { "Sleep", "AllowSuspend",              config_parse_tristate,    0,               &allow_suspend                 },
-                { "Sleep", "AllowHibernation",          config_parse_tristate,    0,               &allow_hibernate               },
-                { "Sleep", "AllowSuspendThenHibernate", config_parse_tristate,    0,               &allow_s2h                     },
-                { "Sleep", "AllowHybridSleep",          config_parse_tristate,    0,               &allow_hybrid_sleep            },
+                { "Sleep", "AllowSuspend",              config_parse_tristate,    0,               &allow_suspend               },
+                { "Sleep", "AllowHibernation",          config_parse_tristate,    0,               &allow_hibernate             },
+                { "Sleep", "AllowSuspendThenHibernate", config_parse_tristate,    0,               &allow_s2h                   },
+                { "Sleep", "AllowHybridSleep",          config_parse_tristate,    0,               &allow_hybrid_sleep          },
 
-                { "Sleep", "SuspendState",              config_parse_strv,        0,               sc->states + SLEEP_SUSPEND     },
-                { "Sleep", "SuspendMode",               config_parse_warn_compat, DISABLED_LEGACY, NULL                           },
+                { "Sleep", "SuspendState",              config_parse_strv,        0,               sc->states + SLEEP_SUSPEND   },
+                { "Sleep", "SuspendMode",               config_parse_warn_compat, DISABLED_LEGACY, NULL                         },
 
-                { "Sleep", "HibernateState",            config_parse_warn_compat, DISABLED_LEGACY, NULL                           },
-                { "Sleep", "HibernateMode",             config_parse_strv,        0,               sc->modes + SLEEP_HIBERNATE    },
+                { "Sleep", "HibernateState",            config_parse_warn_compat, DISABLED_LEGACY, NULL                         },
+                { "Sleep", "HibernateMode",             config_parse_strv,        0,               sc->modes + SLEEP_HIBERNATE  },
 
-                { "Sleep", "HybridSleepState",          config_parse_warn_compat, DISABLED_LEGACY, NULL                           },
-                { "Sleep", "HybridSleepMode",           config_parse_strv,        0,               sc->modes + SLEEP_HYBRID_SLEEP },
+                { "Sleep", "HybridSleepState",          config_parse_warn_compat, DISABLED_LEGACY, NULL                         },
+                { "Sleep", "HybridSleepMode",           config_parse_warn_compat, DISABLED_LEGACY, NULL                         },
 
-                { "Sleep", "HibernateDelaySec",         config_parse_sec,         0,               &sc->hibernate_delay_usec      },
-                { "Sleep", "SuspendEstimationSec",      config_parse_sec,         0,               &sc->suspend_estimation_usec   },
+                { "Sleep", "HibernateDelaySec",         config_parse_sec,         0,               &sc->hibernate_delay_usec    },
+                { "Sleep", "SuspendEstimationSec",      config_parse_sec,         0,               &sc->suspend_estimation_usec },
                 {}
         };
 
index 06f7dc38a4c7eaa3f9e9ededa39951f2bc683d54..fad95b389779fbbddf3f246cd60b5907a8248277 100644 (file)
@@ -23,6 +23,5 @@
 #AllowHybridSleep=yes
 #SuspendState=mem standby freeze
 #HibernateMode=platform shutdown
-#HybridSleepMode=suspend platform shutdown
 #HibernateDelaySec=
 #SuspendEstimationSec=60min