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.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3634
Signed-off-by: Harald Judt <[email protected]>
---
  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(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 91a874bb0e24..05ac13f1aa6a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
@@ -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)
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
index 9dc82f4d7c93..1a8624b2f388 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c
@@ -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

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to