sleep-config: make hybrid sleep always use 'suspend' disk mode

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
This commit is contained in:
Mike Yuan
2023-10-24 19:07:03 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent e5cd8bc060
commit 828ad30470
3 changed files with 15 additions and 26 deletions
+2 -8
View File
@@ -145,12 +145,9 @@
<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>
@@ -160,9 +157,6 @@
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
+13 -17
View 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 },
{}
};
-1
View File
@@ -23,6 +23,5 @@
#AllowHybridSleep=yes
#SuspendState=mem standby freeze
#HibernateMode=platform shutdown
#HybridSleepMode=suspend platform shutdown
#HibernateDelaySec=
#SuspendEstimationSec=60min