From: Mike Yuan Date: Tue, 24 Oct 2023 10:10:21 +0000 (+0800) Subject: sleep-config: make hybrid sleep always use 'suspend' disk mode X-Git-Tag: v255-rc1~155 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=828ad30470e78efcde27b6ca2a0d997c0f37216f;p=thirdparty%2Fsystemd.git 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 --- diff --git a/man/systemd-sleep.conf.xml b/man/systemd-sleep.conf.xml index b33699b6c56..91ea909afe9 100644 --- a/man/systemd-sleep.conf.xml +++ b/man/systemd-sleep.conf.xml @@ -145,12 +145,9 @@ HibernateMode= - HybridSleepMode= - The string to be written to /sys/power/disk by, respectively, - systemd-hibernate.service8 - and - systemd-hybrid-sleep.service8. + The string to be written to /sys/power/disk by + systemd-hibernate.service8. 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. @@ -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 for more details. - Note that hybrid sleep corresponds to the suspend disk mode. If HybridSleepMode= - is overridden, you might get plain hibernation instead. - systemd-suspend-then-hibernate.service8 uses the value of SuspendMode= when suspending and the value of diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index b63071a6928..ab095303557 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -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 }, {} }; diff --git a/src/sleep/sleep.conf b/src/sleep/sleep.conf index 06f7dc38a4c..fad95b38977 100644 --- a/src/sleep/sleep.conf +++ b/src/sleep/sleep.conf @@ -23,6 +23,5 @@ #AllowHybridSleep=yes #SuspendState=mem standby freeze #HibernateMode=platform shutdown -#HybridSleepMode=suspend platform shutdown #HibernateDelaySec= #SuspendEstimationSec=60min