]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amd/display: Add and use new dm_prepare_suspend() callback
authorMario Limonciello <mario.limonciello@amd.com>
Thu, 13 Feb 2025 22:26:22 +0000 (16:26 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 10 Mar 2025 17:28:04 +0000 (13:28 -0400)
[Why]
The displays currently don't get turned off until after other IP blocks
have been suspended.  However turning off the displays first gives a
very visible response that the system is on it's way down.

[How]
Turn off displays in a prepare_suspend() callback instead when possible.
This will help for suspend and hibernate sequences.
The shutdown sequence however will not call prepare() so check whether
the state has been already saved to decide what to do.

Acked-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Tom Chung <chiahsuan.chung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index bf69cd50712e34b882421b51de039b2622e87e8c..4f1cf8afe25f15651b28c741b240b9fde06f6f7b 100644 (file)
@@ -3141,6 +3141,21 @@ static void hpd_rx_irq_work_suspend(struct amdgpu_display_manager *dm)
        }
 }
 
+static int dm_prepare_suspend(struct amdgpu_ip_block *ip_block)
+{
+       struct amdgpu_device *adev = ip_block->adev;
+
+       if (amdgpu_in_reset(adev))
+               return 0;
+
+       WARN_ON(adev->dm.cached_state);
+       adev->dm.cached_state = drm_atomic_helper_suspend(adev_to_drm(adev));
+       if (IS_ERR(adev->dm.cached_state))
+               return PTR_ERR(adev->dm.cached_state);
+
+       return 0;
+}
+
 static int dm_suspend(struct amdgpu_ip_block *ip_block)
 {
        struct amdgpu_device *adev = ip_block->adev;
@@ -3171,10 +3186,11 @@ static int dm_suspend(struct amdgpu_ip_block *ip_block)
                return 0;
        }
 
-       WARN_ON(adev->dm.cached_state);
-       adev->dm.cached_state = drm_atomic_helper_suspend(adev_to_drm(adev));
-       if (IS_ERR(adev->dm.cached_state))
-               return PTR_ERR(adev->dm.cached_state);
+       if (!adev->dm.cached_state) {
+               adev->dm.cached_state = drm_atomic_helper_suspend(adev_to_drm(adev));
+               if (IS_ERR(adev->dm.cached_state))
+                       return PTR_ERR(adev->dm.cached_state);
+       }
 
        s3_handle_hdmi_cec(adev_to_drm(adev), true);
 
@@ -3606,6 +3622,7 @@ static const struct amd_ip_funcs amdgpu_dm_funcs = {
        .early_fini = amdgpu_dm_early_fini,
        .hw_init = dm_hw_init,
        .hw_fini = dm_hw_fini,
+       .prepare_suspend = dm_prepare_suspend,
        .suspend = dm_suspend,
        .resume = dm_resume,
        .is_idle = dm_is_idle,