drm/amd: Add concept of running prepare_suspend() sequence for IP blocks
authorjsg <jsg@openbsd.org>
Thu, 11 Apr 2024 03:27:39 +0000 (03:27 +0000)
committerjsg <jsg@openbsd.org>
Thu, 11 Apr 2024 03:27:39 +0000 (03:27 +0000)
From Mario Limonciello
da67a1139f054fc59c9c18f135729bc16aef93d4 in linux-6.6.y/6.6.26
cb11ca3233aa3303dc11dca25977d2e7f24be00f in mainline linux

sys/dev/pci/drm/amd/amdgpu/amdgpu_device.c
sys/dev/pci/drm/amd/include/amd_shared.h

index 3029753..1363d4c 100644 (file)
@@ -4218,7 +4218,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;
@@ -4228,6 +4228,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 abe829b..a9880fc 100644 (file)
@@ -295,6 +295,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);