Skip to content

Commit 25e07c8

Browse files
alexdeuchergregkh
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 <[email protected]> Reviewed-by: Mario Limonciello <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit 06f2dcc) Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8e7583f commit 25e07c8

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
@@ -4728,28 +4728,20 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev)
47284728
* @data: data
47294729
*
47304730
* This function is called when the system is about to suspend or hibernate.
4731-
* It is used to evict resources from the device before the system goes to
4732-
* sleep while there is still access to swap.
4731+
* It is used to set the appropriate flags so that eviction can be optimized
4732+
* in the pm prepare callback.
47334733
*/
47344734
static int amdgpu_device_pm_notifier(struct notifier_block *nb, unsigned long mode,
47354735
void *data)
47364736
{
47374737
struct amdgpu_device *adev = container_of(nb, struct amdgpu_device, pm_nb);
4738-
int r;
47394738

47404739
switch (mode) {
47414740
case PM_HIBERNATION_PREPARE:
47424741
adev->in_s4 = true;
4743-
fallthrough;
4744-
case PM_SUSPEND_PREPARE:
4745-
r = amdgpu_device_evict_resources(adev);
4746-
/*
4747-
* This is considered non-fatal at this time because
4748-
* amdgpu_device_prepare() will also fatally evict resources.
4749-
* See https://gitlab.freedesktop.org/drm/amd/-/issues/3781
4750-
*/
4751-
if (r)
4752-
drm_warn(adev_to_drm(adev), "Failed to evict resources, freeze active processes if problems occur: %d\n", r);
4742+
break;
4743+
case PM_POST_HIBERNATION:
4744+
adev->in_s4 = false;
47534745
break;
47544746
}
47554747

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,13 +2647,8 @@ static int amdgpu_pmops_freeze(struct device *dev)
26472647
static int amdgpu_pmops_thaw(struct device *dev)
26482648
{
26492649
struct drm_device *drm_dev = dev_get_drvdata(dev);
2650-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2651-
int r;
2652-
2653-
r = amdgpu_device_resume(drm_dev, true);
2654-
adev->in_s4 = false;
26552650

2656-
return r;
2651+
return amdgpu_device_resume(drm_dev, true);
26572652
}
26582653

26592654
static int amdgpu_pmops_poweroff(struct device *dev)
@@ -2666,9 +2661,6 @@ static int amdgpu_pmops_poweroff(struct device *dev)
26662661
static int amdgpu_pmops_restore(struct device *dev)
26672662
{
26682663
struct drm_device *drm_dev = dev_get_drvdata(dev);
2669-
struct amdgpu_device *adev = drm_to_adev(drm_dev);
2670-
2671-
adev->in_s4 = false;
26722664

26732665
return amdgpu_device_resume(drm_dev, true);
26742666
}

0 commit comments

Comments
 (0)