We can't evict VRAM while processes are running as they
will continue to submit work which causes buffers to
get pulled back into VRAM.

Unfortunately we need a way to still have swap while
processes are fozen if memory is limited.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4178
Fixes: 2965e6355dcd ("drm/amd: Add Suspend/Hibernate notification callback 
support")
Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index a3e9f289e37c9..dd2a557f97634 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4907,40 +4907,23 @@ static int amdgpu_device_evict_resources(struct 
amdgpu_device *adev)
  * @data: data
  *
  * This function is called when the system is about to suspend or hibernate.
- * It is used to evict resources from the device before the system goes to
- * sleep while there is still access to swap.
+ * It is used to set the appropriate flags so that eviction can be optimized
+ * in the pm prepare callback.
  */
 static int amdgpu_device_pm_notifier(struct notifier_block *nb, unsigned long 
mode,
                                     void *data)
 {
        struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, 
pm_nb);
-       int r;
 
        switch (mode) {
        case PM_HIBERNATION_PREPARE:
                adev->in_s4 = true;
-               r = amdgpu_device_evict_resources(adev);
-               /*
-                * This is considered non-fatal at this time because
-                * amdgpu_device_prepare() will also fatally evict resources.
-                * See https://gitlab.freedesktop.org/drm/amd/-/issues/3781
-                */
-               if (r)
-                       drm_warn(adev_to_drm(adev), "Failed to evict resources, 
freeze active processes if problems occur: %d\n", r);
                break;
        case PM_SUSPEND_PREPARE:
                if (amdgpu_acpi_is_s0ix_active(adev))
                        adev->in_s0ix = true;
                else if (amdgpu_acpi_is_s3_active(adev))
                        adev->in_s3 = true;
-               r = amdgpu_device_evict_resources(adev);
-               /*
-                * This is considered non-fatal at this time because
-                * amdgpu_device_prepare() will also fatally evict resources.
-                * See https://gitlab.freedesktop.org/drm/amd/-/issues/3781
-                */
-               if (r)
-                       drm_warn(adev_to_drm(adev), "Failed to evict resources, 
freeze active processes if problems occur: %d\n", r);
                break;
        }
 
-- 
2.49.0

Reply via email to