]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PM: hibernate: add configurable delay for pm_test
authorZihuan Zhang <zhangzihuan@kylinos.cn>
Wed, 7 May 2025 06:35:20 +0000 (14:35 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 9 May 2025 13:59:10 +0000 (15:59 +0200)
Turn the default 5 second test delay for hibernation into a
configurable module parameter, so users can determine how
long to wait in this pseudo-hibernate state before resuming
the system.

The configurable delay parameter has been added for suspend, so
add an analogous one for hibernation.

Example (wait 30 seconds);

  # echo 30 > /sys/module/hibernate/parameters/pm_test_delay
  # echo core > /sys/power/pm_test

Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
Reviewed-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://patch.msgid.link/20250507063520.419635-1-zhangzihuan@kylinos.cn
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Documentation/admin-guide/kernel-parameters.txt
kernel/power/hibernate.c

index 76e538c77e31615c9cd6a650bb8a72ead14b8008..ccd61e22403f6537800bc5e0a40dd998158e8aed 100644 (file)
                                lz4: Select LZ4 compression algorithm to
                                compress/decompress hibernation image.
 
+       hibernate.pm_test_delay=
+                       [HIBERNATION]
+                       Sets the number of seconds to remain in a hibernation test
+                       mode before resuming the system (see
+                       /sys/power/pm_test). Only available when CONFIG_PM_DEBUG
+                       is set. Default value is 5.
+
        highmem=nn[KMG] [KNL,BOOT,EARLY] forces the highmem zone to have an exact
                        size of <nn>. This works even on boxes that have no
                        highmem otherwise. This also works to reduce highmem
index f0db9d1896e8025a5d6b86f16a007454a2095b01..f4db2e82fd873316b28c6d2669eb7dedcc7f4d97 100644 (file)
@@ -133,10 +133,15 @@ bool system_entering_hibernation(void)
 EXPORT_SYMBOL(system_entering_hibernation);
 
 #ifdef CONFIG_PM_DEBUG
+static unsigned int pm_test_delay = 5;
+module_param(pm_test_delay, uint, 0644);
+MODULE_PARM_DESC(pm_test_delay,
+                "Number of seconds to wait before resuming from hibernation test");
 static void hibernation_debug_sleep(void)
 {
-       pr_info("debug: Waiting for 5 seconds.\n");
-       mdelay(5000);
+       pr_info("hibernation debug: Waiting for %d second(s).\n",
+               pm_test_delay);
+       mdelay(pm_test_delay * 1000);
 }
 
 static int hibernation_test(int level)