Skip to content

Commit 4aaffc8

Browse files
committed
drm/amdgpu: fix pm notifier handling
Set the s3/s0ix and s4 flags in the pm notifier so that we can skip the resource evictions properly in pm prepare based on whether we are suspending or hibernating. Drop the eviction as processes are not frozen at this time, we we can end up getting stuck trying to evict VRAM while applications continue to submit work which causes the buffers to get pulled back into VRAM. v2: Move suspend flags out of pm notifier (Mario) Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4178 Fixes: 2965e63 ("drm/amd: Add Suspend/Hibernate notification callback support") Cc: Mario Limonciello <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit 06f2dcc) Cc: [email protected]
1 parent d0ce1aa commit 4aaffc8

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,28 +4907,20 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev)
49074907
* @data: data
49084908
*
49094909
* This function is called when the system is about to suspend or hibernate.
4910-
* It is used to evict resources from the device before the system goes to
4911-
* sleep while there is still access to swap.
4910+
* It is used to set the appropriate flags so that eviction can be optimized
4911+
* in the pm prepare callback.
49124912
*/
49134913
static int amdgpu_device_pm_notifier(struct notifier_block *nb, unsigned long mode,
49144914
void *data)
49154915
{
49164916
struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, pm_nb);
4917-
int r;
49184917

49194918
switch (mode) {
49204919
case PM_HIBERNATION_PREPARE:
49214920
adev->in_s4 = true;
4922-
fallthrough;
4923-
case PM_SUSPEND_PREPARE:
4924-
r = amdgpu_device_evict_resources(adev);
4925-
/*
4926-
* This is considered non-fatal at this time because
4927-
* amdgpu_device_prepare() will also fatally evict resources.
4928-
* See https://gitlab.freedesktop.org/drm/amd/-/issues/3781
4929-
*/
4930-
if (r)
4931-
drm_warn(adev_to_drm(adev), "Failed to evict resources, freeze active processes if problems occur: %d\n", r);
4921+
break;
4922+
case PM_POST_HIBERNATION:
4923+
adev->in_s4 = false;
49324924
break;
49334925
}
49344926

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,13 +2615,8 @@ static int amdgpu_pmops_freeze(struct device *dev)
26152615
static int amdgpu_pmops_thaw(struct device *dev)
26162616
{
26172617
struct drm_device *drm_dev = dev_get_drvdata(dev);
2618-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2619-
int r;
2620-
2621-
r = amdgpu_device_resume(drm_dev, true);
2622-
adev->in_s4 = false;
26232618

2624-
return r;
2619+
return amdgpu_device_resume(drm_dev, true);
26252620
}
26262621

26272622
static int amdgpu_pmops_poweroff(struct device *dev)
@@ -2634,9 +2629,6 @@ static int amdgpu_pmops_poweroff(struct device *dev)
26342629
static int amdgpu_pmops_restore(struct device *dev)
26352630
{
26362631
struct drm_device *drm_dev = dev_get_drvdata(dev);
2637-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2638-
2639-
adev->in_s4 = false;
26402632

26412633
return amdgpu_device_resume(drm_dev, true);
26422634
}

0 commit comments

Comments
 (0)