All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: run prepare-phase eviction for hibernation on APUs
@ 2026-12-04 21:07 Mario Limonciello
  2026-12-04 21:27 ` sashiko-bot
  2026-12-04 21:42 ` Alex Deucher
  0 siblings, 2 replies; 3+ messages in thread
From: Mario Limonciello @ 2026-12-04 21:07 UTC (permalink / raw)
  To: Alex Deucher; +Cc: amd-gfx, Mario Limonciello

amdgpu_pmops_prepare() returns early when neither s0ix nor s3 is
active.  On an APU both helpers test pm_suspend_target_state, which is
only set by suspend_devices_and_enter() and so is PM_SUSPEND_ON
throughout hibernation_snapshot().  As a result amdgpu_device_prepare()
is skipped for hibernation on APUs, and with it the VRAM eviction and
ttm_device_prepare_hibernation() that the PM notifier sets in_s4 up for.

The eviction instead happens from amdgpu_pmops_freeze(), after
hibernate_preallocate_memory() has already sized the image and after
pm_restrict_gfp_mask() has made it impossible to swap anything out.
Everything evicted into shmem/TTM pools at that point lands in the
image unaccounted for, and under memory pressure snapshot creation
fails:

  PM: hibernation: Not enough free memory for image creation
  PM: hibernation: Error -12 creating image

Discrete GPUs are unaffected as amdgpu_acpi_is_s3_active() is
unconditionally true for them.

Don't take the early return when adev->in_s4 is set, so the eviction
runs in the prepare phase, before the image is preallocated.

Fixes: 06f2dcc241e7 ("drm/amdgpu: fix pm notifier handling"),
Closes: https://gitlab.freedesktop.org/drm/amd/-/work_items/4711
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 9c14008720063..60d1c194d8cff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -2636,9 +2636,11 @@ static int amdgpu_pmops_prepare(struct device *dev)
 		return 1;
 
 	/* if we will not support s3 or s2i for the device
-	 *  then skip suspend
+	 *  then skip suspend, but not for hibernation: resources need to be
+	 *  evicted here, before the hibernation image is sized.
 	 */
-	if (!amdgpu_acpi_is_s0ix_active(adev) &&
+	if (!adev->in_s4 &&
+	    !amdgpu_acpi_is_s0ix_active(adev) &&
 	    !amdgpu_acpi_is_s3_active(adev))
 		return 1;
 

---
base-commit: a64568f32390f7480e31d3a303167f9b5cba9151
change-id: 20261204-amdgpu-apu-s4-prepare-9402402a15aa

Best regards,
--  
Mario Limonciello <mario.limonciello@amd.com>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-04 21:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 21:07 [PATCH] drm/amdgpu: run prepare-phase eviction for hibernation on APUs Mario Limonciello
2026-12-04 21:27 ` sashiko-bot
2026-12-04 21:42 ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.