Skip to content

Commit fe07c6a

Browse files
alexdeucheropsiff
authored andcommitted
drm/amdgpu: fix pm notifier handling
commit 4aaffc8 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: 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> (cherry picked from commit 06f2dcc) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 35559ebcdc899045208f411be0cd8c18ca35b1d1)
1 parent 81b79ac commit fe07c6a

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
@@ -4125,28 +4125,20 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev)
41254125
* @data: data
41264126
*
41274127
* This function is called when the system is about to suspend or hibernate.
4128-
* It is used to evict resources from the device before the system goes to
4129-
* sleep while there is still access to swap.
4128+
* It is used to set the appropriate flags so that eviction can be optimized
4129+
* in the pm prepare callback.
41304130
*/
41314131
static int amdgpu_device_pm_notifier(struct notifier_block *nb, unsigned long mode,
41324132
void *data)
41334133
{
41344134
struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, pm_nb);
4135-
int r;
41364135

41374136
switch (mode) {
41384137
case PM_HIBERNATION_PREPARE:
41394138
adev->in_s4 = true;
4140-
fallthrough;
4141-
case PM_SUSPEND_PREPARE:
4142-
r = amdgpu_device_evict_resources(adev);
4143-
/*
4144-
* This is considered non-fatal at this time because
4145-
* amdgpu_device_prepare() will also fatally evict resources.
4146-
* See https://gitlab.freedesktop.org/drm/amd/-/issues/3781
4147-
*/
4148-
if (r)
4149-
drm_warn(adev_to_drm(adev), "Failed to evict resources, freeze active processes if problems occur: %d\n", r);
4139+
break;
4140+
case PM_POST_HIBERNATION:
4141+
adev->in_s4 = false;
41504142
break;
41514143
}
41524144

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,13 +2475,8 @@ static int amdgpu_pmops_freeze(struct device *dev)
24752475
static int amdgpu_pmops_thaw(struct device *dev)
24762476
{
24772477
struct drm_device *drm_dev = dev_get_drvdata(dev);
2478-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2479-
int r;
2480-
2481-
r = amdgpu_device_resume(drm_dev, true);
2482-
adev->in_s4 = false;
24832478

2484-
return r;
2479+
return amdgpu_device_resume(drm_dev, true);
24852480
}
24862481

24872482
static int amdgpu_pmops_poweroff(struct device *dev)
@@ -2494,9 +2489,6 @@ static int amdgpu_pmops_poweroff(struct device *dev)
24942489
static int amdgpu_pmops_restore(struct device *dev)
24952490
{
24962491
struct drm_device *drm_dev = dev_get_drvdata(dev);
2497-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2498-
2499-
adev->in_s4 = false;
25002492

25012493
return amdgpu_device_resume(drm_dev, true);
25022494
}

0 commit comments

Comments
 (0)