linux/kernel/power
Rafael J. Wysocki 35e4a69b20 PM: sleep: Allow pm_restrict_gfp_mask() stacking
Allow pm_restrict_gfp_mask() to be called many times in a row to avoid
issues with calling dpm_suspend_start() when the GFP mask has been
already restricted.

Only the first invocation of pm_restrict_gfp_mask() will actually
restrict the GFP mask and the subsequent calls will warn if there is
a mismatch between the expected allowed GFP mask and the actual one.

Moreover, if pm_restrict_gfp_mask() is called many times in a row,
pm_restore_gfp_mask() needs to be called matching number of times in
a row to actually restore the GFP mask.  Calling it when the GFP mask
has not been restricted will cause it to warn.

This is necessary for the GFP mask restriction starting in
hibernation_snapshot() to continue throughout the entire hibernation
flow until it completes or it is aborted (either by a wakeup event or
by an error).

Fixes: 449c9c0253 ("PM: hibernate: Restrict GFP mask in hibernation_snapshot()")
Fixes: 469d80a371 ("PM: hibernate: Fix hybrid-sleep")
Reported-by: Askar Safin <safinaskar@gmail.com>
Closes: https://lore.kernel.org/linux-pm/20251025050812.421905-1-safinaskar@gmail.com/
Link: https://lore.kernel.org/linux-pm/20251028111730.2261404-1-safinaskar@gmail.com/
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Tested-by: Mario Limonciello (AMD) <superm1@kernel.org>
Cc: 6.16+ <stable@vger.kernel.org> # 6.16+
Link: https://patch.msgid.link/5935682.DvuYhMxLoT@rafael.j.wysocki
2025-10-29 18:55:32 +01:00
..
Kconfig PM: EM: Rework the depends on for CONFIG_ENERGY_MODEL 2025-03-07 15:23:46 +01:00
Makefile PM: sleep: Narrow down -DDEBUG on kernel/power/ files 2022-04-13 16:34:01 +02:00
autosleep.c PM: sleep: autosleep: don't include 'pm_wakeup.h' directly 2024-12-05 12:14:26 +01:00
console.c PM: sleep: console: Fix the black screen issue 2025-07-03 15:58:33 +02:00
energy_model.c PM: EM: Fix late boot with holes in CPU topology 2025-09-15 12:02:24 +02:00
hibernate.c PM: sleep: Allow pm_restrict_gfp_mask() stacking 2025-10-29 18:55:32 +01:00
main.c PM: sleep: Allow pm_restrict_gfp_mask() stacking 2025-10-29 18:55:32 +01:00
power.h PM: Restrict swap use to later in the suspend sequence 2025-06-26 20:39:34 +02:00
poweroff.c tty: sysrq: switch sysrq handlers from int to u8 2023-07-25 19:21:03 +02:00
process.c Revert "PM: sleep: Make pm_wakeup_clear() call more clear" 2025-10-23 12:48:04 +02:00
qos.c PM: QoS: Add check to make sure CPU latency is non-negative 2023-08-22 21:37:29 +02:00
snapshot.c PM: hibernate: Fix typo in memory bitmaps description comment 2025-09-01 11:55:53 +02:00
suspend.c Revert "PM: sleep: Make pm_wakeup_clear() call more clear" 2025-10-23 12:48:04 +02:00
suspend_test.c rtc: class: make rtc_class constant 2024-03-08 12:05:10 +01:00
swap.c PM: hibernate: Use vmalloc_array() and vcalloc() to improve code 2025-09-01 11:55:53 +02:00
user.c [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
wakelock.c PM: wakeup: Delete space in the end of string shown by pm_show_wakelocks() 2025-05-09 15:48:39 +02:00