]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amd: Add concept of running prepare_suspend() sequence for IP blocks
authorMario Limonciello <mario.limonciello@amd.com>
Fri, 6 Oct 2023 18:50:21 +0000 (13:50 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 13 Oct 2023 15:00:58 +0000 (11:00 -0400)
If any IP blocks allocate memory during their hw_fini() sequence
this can cause the suspend to fail under memory pressure.  Introduce
a new phase that IP blocks can use to allocate memory before suspend
starts so that it can potentially be evicted into swap instead.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/include/amd_shared.h

index 0a7cc9107f072a5a4eaad6785d7a775c5dd4db8a..0f98f720d9ca6fbbc3e5bab5e01ac8fd0f7f2490 100644 (file)
@@ -4348,7 +4348,7 @@ static int amdgpu_device_evict_resources(struct amdgpu_device *adev)
 int amdgpu_device_prepare(struct drm_device *dev)
 {
        struct amdgpu_device *adev = drm_to_adev(dev);
-       int r;
+       int i, r;
 
        if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
                return 0;
@@ -4358,6 +4358,16 @@ int amdgpu_device_prepare(struct drm_device *dev)
        if (r)
                return r;
 
+       for (i = 0; i < adev->num_ip_blocks; i++) {
+               if (!adev->ip_blocks[i].status.valid)
+                       continue;
+               if (!adev->ip_blocks[i].version->funcs->prepare_suspend)
+                       continue;
+               r = adev->ip_blocks[i].version->funcs->prepare_suspend((void *)adev);
+               if (r)
+                       return r;
+       }
+
        return 0;
 }
 
index ce75351204bb03794e3ebba196bf8755681c0642..98e60bc868ddf87dd405486b79d40fcdfaf76d8d 100644 (file)
@@ -299,6 +299,7 @@ struct amd_ip_funcs {
        int (*hw_init)(void *handle);
        int (*hw_fini)(void *handle);
        void (*late_fini)(void *handle);
+       int (*prepare_suspend)(void *handle);
        int (*suspend)(void *handle);
        int (*resume)(void *handle);
        bool (*is_idle)(void *handle);