Skip to content

Commit 06f2dcc

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 <mario.limonciello@amd.com> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 086809c commit 06f2dcc

2 files changed

Lines changed: 6 additions & 22 deletions

File tree

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4976,28 +4976,20 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev)
49764976
* @data: data
49774977
*
49784978
* This function is called when the system is about to suspend or hibernate.
4979-
* It is used to evict resources from the device before the system goes to
4980-
* sleep while there is still access to swap.
4979+
* It is used to set the appropriate flags so that eviction can be optimized
4980+
* in the pm prepare callback.
49814981
*/
49824982
static int amdgpu_device_pm_notifier(struct notifier_block *nb, unsigned long mode,
49834983
void *data)
49844984
{
49854985
struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, pm_nb);
4986-
int r;
49874986

49884987
switch (mode) {
49894988
case PM_HIBERNATION_PREPARE:
49904989
adev->in_s4 = true;
4991-
fallthrough;
4992-
case PM_SUSPEND_PREPARE:
4993-
r = amdgpu_device_evict_resources(adev);
4994-
/*
4995-
* This is considered non-fatal at this time because
4996-
* amdgpu_device_prepare() will also fatally evict resources.
4997-
* See https://gitlab.freedesktop.org/drm/amd/-/issues/3781
4998-
*/
4999-
if (r)
5000-
drm_warn(adev_to_drm(adev), "Failed to evict resources, freeze active processes if problems occur: %d\n", r);
4990+
break;
4991+
case PM_POST_HIBERNATION:
4992+
adev->in_s4 = false;
50014993
break;
50024994
}
50034995

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,13 +2644,8 @@ static int amdgpu_pmops_freeze(struct device *dev)
26442644
static int amdgpu_pmops_thaw(struct device *dev)
26452645
{
26462646
struct drm_device *drm_dev = dev_get_drvdata(dev);
2647-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2648-
int r;
2649-
2650-
r = amdgpu_device_resume(drm_dev, true);
2651-
adev->in_s4 = false;
26522647

2653-
return r;
2648+
return amdgpu_device_resume(drm_dev, true);
26542649
}
26552650

26562651
static int amdgpu_pmops_poweroff(struct device *dev)
@@ -2663,9 +2658,6 @@ static int amdgpu_pmops_poweroff(struct device *dev)
26632658
static int amdgpu_pmops_restore(struct device *dev)
26642659
{
26652660
struct drm_device *drm_dev = dev_get_drvdata(dev);
2666-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2667-
2668-
adev->in_s4 = false;
26692661

26702662
return amdgpu_device_resume(drm_dev, true);
26712663
}

0 commit comments

Comments
 (0)