PM: Restrict swap use to later in the suspend sequence
authorMario Limonciello <mario.limonciello@amd.com>
Fri, 13 Jun 2025 21:43:44 +0000 (16:43 -0500)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 26 Jun 2025 18:39:34 +0000 (20:39 +0200)
commit12ffc3b1513ebc1f11ae77d053948504a94a68a6
tree63a13f44f7f1b5981cb85cc9e1796dc8b8f28c4e
parent86731a2a651e58953fc949573895f2fa6d456841
PM: Restrict swap use to later in the suspend sequence

Currently swap is restricted before drivers have had a chance to do
their prepare() PM callbacks. Restricting swap this early means that if
a driver needs to evict some content from memory into sawp in it's
prepare callback, it won't be able to.

On AMD dGPUs this can lead to failed suspends under memory pressure
situations as all VRAM must be evicted to system memory or swap.

Move the swap restriction to right after all devices have had a chance
to do the prepare() callback.  If there is any problem with the sequence,
restore swap in the appropriate dpm resume callbacks or error handling
paths.

Closes: https://github.com/ROCm/ROCK-Kernel-Driver/issues/174
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/2362
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Tested-by: Nat Wittstock <nat@fardog.io>
Tested-by: Lucian Langa <lucilanga@7pot.org>
Link: https://patch.msgid.link/20250613214413.4127087-1-superm1@kernel.org
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/main.c
include/linux/suspend.h
kernel/kexec_core.c
kernel/power/hibernate.c
kernel/power/power.h
kernel/power/suspend.c