Skip to content

Commit 4e6310e

Browse files
alexdeuchergregkh
authored andcommitted
drm/amdgpu: fix pm notifier handling
commit 4aaffc85751da5722e858e4333e8cf0aa4b6c78f upstream. 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: 2965e6355dcd ("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 06f2dcc241e7e5c681f81fbc46cacdf4bfd7d6d7) Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2c914aa commit 4e6310e

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
@@ -4199,28 +4199,20 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev)
41994199
* @data: data
42004200
*
42014201
* This function is called when the system is about to suspend or hibernate.
4202-
* It is used to evict resources from the device before the system goes to
4203-
* sleep while there is still access to swap.
4202+
* It is used to set the appropriate flags so that eviction can be optimized
4203+
* in the pm prepare callback.
42044204
*/
42054205
static int amdgpu_device_pm_notifier(struct notifier_block *nb, unsigned long mode,
42064206
void *data)
42074207
{
42084208
struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, pm_nb);
4209-
int r;
42104209

42114210
switch (mode) {
42124211
case PM_HIBERNATION_PREPARE:
42134212
adev->in_s4 = true;
4214-
fallthrough;
4215-
case PM_SUSPEND_PREPARE:
4216-
r = amdgpu_device_evict_resources(adev);
4217-
/*
4218-
* This is considered non-fatal at this time because
4219-
* amdgpu_device_prepare() will also fatally evict resources.
4220-
* See https://gitlab.freedesktop.org/drm/amd/-/issues/3781
4221-
*/
4222-
if (r)
4223-
drm_warn(adev_to_drm(adev), "Failed to evict resources, freeze active processes if problems occur: %d\n", r);
4213+
break;
4214+
case PM_POST_HIBERNATION:
4215+
adev->in_s4 = false;
42244216
break;
42254217
}
42264218

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2480,13 +2480,8 @@ static int amdgpu_pmops_freeze(struct device *dev)
24802480
static int amdgpu_pmops_thaw(struct device *dev)
24812481
{
24822482
struct drm_device *drm_dev = dev_get_drvdata(dev);
2483-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2484-
int r;
2485-
2486-
r = amdgpu_device_resume(drm_dev, true);
2487-
adev->in_s4 = false;
24882483

2489-
return r;
2484+
return amdgpu_device_resume(drm_dev, true);
24902485
}
24912486

24922487
static int amdgpu_pmops_poweroff(struct device *dev)
@@ -2499,9 +2494,6 @@ static int amdgpu_pmops_poweroff(struct device *dev)
24992494
static int amdgpu_pmops_restore(struct device *dev)
25002495
{
25012496
struct drm_device *drm_dev = dev_get_drvdata(dev);
2502-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2503-
2504-
adev->in_s4 = false;
25052497

25062498
return amdgpu_device_resume(drm_dev, true);
25072499
}

0 commit comments

Comments
 (0)