Skip to contentSkip to conversation

drm/amdgpu: always reset the asic in suspend (v2)

PATCH In review Alex Deucher 5 participants 5 messages Nov 12, 2021 – Nov 16, 2021

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: always reset the asic in suspend (v2)

If the platform suspend happens to fail and the power rail is not turned off, the GPU will be in an unknown state on resume, so reset the asic so that it will be in a known good state on resume even if the platform suspend failed.

v2: handle s0ix

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
index 1db76429a673..b4591f6e82dd 100644
@@ -2165,7 +2165,10 @@ static int amdgpu_pmops_suspend(struct device *dev)
 	adev->in_s3 = true;
 	r = amdgpu_device_suspend(drm_dev, true);
 	adev->in_s3 = false;
-
+	if (r)
+		return r;
+	if (!adev->in_s0ix)
+		r = amdgpu_asic_reset(adev);
 	return r;
 }
 
Signature · 1 line
2.31.1
Acked-by on v1 1/1
#1 lore raw
Quoted 28 lines · Alex Deucher

If the platform suspend happens to fail and the power rail is not turned off, the GPU will be in an unknown state on resume, so reset the asic so that it will be in a known good state on resume even if the platform suspend failed.

v2: handle s0ix

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
index 1db76429a673..b4591f6e82dd 100644
@@ -2165,7 +2165,10 @@ static int amdgpu_pmops_suspend(struct device *dev)
 	adev->in_s3 = true;
 	r = amdgpu_device_suspend(drm_dev, true);
 	adev->in_s3 = false;
-
+	if (r)
+		return r;
+	if (!adev->in_s0ix)
+		r = amdgpu_asic_reset(adev);
 	return r;
 }
 
#2 lore raw
In reply to Alex Deucher
Quoted 5 lines · Alex Deucher

If the platform suspend happens to fail and the power rail is not turned off, the GPU will be in an unknown state on resume, so reset the asic so that it will be in a known good state on resume even if the platform suspend failed.

Any more background info on the issue? Is there a need to trigger BACO or D3cold entry similar to how it's done for runtime suspend?

Thanks,
Lijo

Quoted 24 lines

v2: handle s0ix

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
index 1db76429a673..b4591f6e82dd 100644
@@ -2165,7 +2165,10 @@ static int amdgpu_pmops_suspend(struct device *dev)
  	adev->in_s3 = true;
  	r = amdgpu_device_suspend(drm_dev, true);
  	adev->in_s3 = false;
-
+	if (r)
+		return r;
+	if (!adev->in_s0ix)
+		r = amdgpu_asic_reset(adev);
  	return r;
  }
 
#3 lore raw
Quoted 4 lines · Lijo

On 11/12/2021 9:55 PM, Alex Deucher wrote:

Quoted 8 lines
Quoted 5 lines

If the platform suspend happens to fail and the power rail is not turned off, the GPU will be in an unknown state on resume, so reset the asic so that it will be in a known good state on resume even if the platform suspend failed.

Any more background info on the issue? Is there a need to trigger BACO or D3cold entry similar to how it's done for runtime suspend?

Basically something like the following, user requests S3, drivers start to do their suspend thing, but then something interrupts it (e.g., user plugs/unplugs a usb device or S3 gets interrupted for something). At that point, the power rail has not been turned off. The kernel then starts calling the resume functions for each device because the suspend was aborted. However, since the power rail was not turned off, the GPU is still initialized so the driver can't properly re-init it without a reset.

Alex

Quoted 28 lines

Thanks,
Lijo

Quoted 24 lines

v2: handle s0ix

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
index 1db76429a673..b4591f6e82dd 100644
@@ -2165,7 +2165,10 @@ static int amdgpu_pmops_suspend(struct device *dev)
      adev->in_s3 = true;
      r = amdgpu_device_suspend(drm_dev, true);
      adev->in_s3 = false;
-
+     if (r)
+             return r;
+     if (!adev->in_s0ix)
+             r = amdgpu_asic_reset(adev);
      return r;
  }
 
Acked-by on v1 1/1
#4 lore raw
In reply to Alex Deucher

[AMD Official Use Only]

Quoted 40 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Saturday, November 13, 2021 12:26 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH] drm/amdgpu: always reset the asic in suspend (v2)

If the platform suspend happens to fail and the power rail is not turned off, the GPU will be in an unknown state on resume, so reset the asic so that it will be in a known good state on resume even if the platform suspend failed.

v2: handle s0ix

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -2
index 1db76429a673..b4591f6e82dd 100644
@@ -2165,7 +2165,10 @@ static int amdgpu_pmops_suspend(struct device
 *dev)
 	adev->in_s3 = true;
 	r = amdgpu_device_suspend(drm_dev, true);
 	adev->in_s3 = false;
-
+	if (r)
+		return r;
+	if (!adev->in_s0ix)
+		r = amdgpu_asic_reset(adev);
 	return r;
 }
 
--

2.31.1