Skip to contentSkip to conversation

amdgpu: Do not trigger reset_method S3 workaround for S4

PATCH In review Harald Judt 2 participants 2 messages Mar 25, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amdgpu: Do not trigger reset_method S3 workaround for S4

From 9a2f16a4a43f424f5008d5c4a87e1329f682e919 Mon Sep 17 00:00:00 2001
From: Harald Judt <[email protected]>
Date: Sat, 22 Mar 2025 23:01:57 +0100
Subject: [PATCH] amdgpu: Do not trigger reset_method S3 workaround for S4

Commit 3a9626c816db ("drm/amd: Stop evicting resources on APUs in suspend") causes hibernation to fail on R390 because it triggers a workaround for S3 in amdgpu_dpm_is_baco_supported that disables BACO. With reset_method PCI CONFIG, S3 works but S4 fails on resume. This commit fixes this by modifying the workaround to only apply for S3 and not S4.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 10 ++++++----
  drivers/gpu/drm/amd/pm/amdgpu_dpm.c     |  2 +-
  2 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -4
index 91a874bb0e24..05ac13f1aa6a 100644
@@ -2556,13 +2556,15 @@ static int amdgpu_pmops_freeze(struct device *dev)
 
  	adev->in_s4 = true;
  	r = amdgpu_device_suspend(drm_dev, true);
-	adev->in_s4 = false;
  	if (r)
-		return r;
+		goto out;
 
  	if (amdgpu_acpi_should_gpu_reset(adev))
-		return amdgpu_asic_reset(adev);
-	return 0;
+		r = amdgpu_asic_reset(adev);
+
+out:
+	adev->in_s4 = false;
+	return r;
  }
 
  static int amdgpu_pmops_thaw(struct device *dev)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -1
index 9dc82f4d7c93..1a8624b2f388 100644
@@ -220,7 +220,7 @@ int amdgpu_dpm_is_baco_supported(struct amdgpu_device *adev)
  	 * Powering down/up everything may adversely affect these other
  	 * devices.  Needs more investigation.
  	 */
-	if (adev->in_s3)
+	if (adev->in_s3 && !adev->in_s4)
  		return 0;
 
  	mutex_lock(&adev->pm.mutex);
Signature · 8 lines
2.49.0


-- 
`Experience is the best teacher.'

PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD
#1 lore raw
Quoted 6 lines · Harald Judt

From 9a2f16a4a43f424f5008d5c4a87e1329f682e919 Mon Sep 17 00:00:00 2001
From: Harald Judt <[email protected]>
Date: Sat, 22 Mar 2025 23:01:57 +0100
Subject: [PATCH] amdgpu: Do not trigger reset_method S3 workaround for S4

Quoted 7 lines

Commit 3a9626c816db ("drm/amd: Stop evicting resources on APUs in suspend") causes hibernation to fail on R390 because it triggers a workaround for S3 in amdgpu_dpm_is_baco_supported that disables BACO. With reset_method PCI CONFIG, S3 works but S4 fails on resume. This commit fixes this by modifying the workaround to only apply for S3 and not S4.

Please use git-send-email to send out patches. Your email client has messed up the formatting. Also, I think this issue may already be fixed by this patch:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4afacc9948e1f8fdbca401d259ae65ad93d298c0

Alex

Quoted 55 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 10 ++++++----
   drivers/gpu/drm/amd/pm/amdgpu_dpm.c     |  2 +-
   2 files changed, 7 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +6 -4
index 91a874bb0e24..05ac13f1aa6a 100644
@@ -2556,13 +2556,15 @@ static int amdgpu_pmops_freeze(struct device *dev)
 
        adev->in_s4 = true;
        r = amdgpu_device_suspend(drm_dev, true);
-       adev->in_s4 = false;
        if (r)
-               return r;
+               goto out;
 
        if (amdgpu_acpi_should_gpu_reset(adev))
-               return amdgpu_asic_reset(adev);
-       return 0;
+               r = amdgpu_asic_reset(adev);
+
+out:
+       adev->in_s4 = false;
+       return r;
   }
 
   static int amdgpu_pmops_thaw(struct device *dev)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -2
index 9dc82f4d7c93..1a8624b2f388 100644
@@ -220,7 +220,7 @@ int amdgpu_dpm_is_baco_supported(struct amdgpu_device *adev)
         * Powering down/up everything may adversely affect these other
         * devices.  Needs more investigation.
         */
-       if (adev->in_s3)
+       if (adev->in_s3 && !adev->in_s4)
                return 0;
 
        mutex_lock(&adev->pm.mutex);
--

2.49.0

--
`Experience is the best teacher.'

PGP Key ID: 4FFFAB21B8580ABD
Fingerprint: E073 6DD8 FF40 9CF2 0665 11D4 4FFF AB21 B858 0ABD