drm/amdgpu: Add kfd init_complete flag to check from amdgpu side
authorshaoyunl <shaoyun.liu@amd.com>
Tue, 16 Feb 2021 15:57:17 +0000 (10:57 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 24 Mar 2021 03:10:28 +0000 (23:10 -0400)
amdgpu driver may be in reset state during init which will not initialize the kfd,
driver need to initialize the KFD after reset by check the flag

Signed-off-by: shaoyunl <shaoyun.liu@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index f44185f..fa27262 100644 (file)
@@ -165,7 +165,8 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
                                        adev->doorbell_index.last_non_cp;
                }
 
-               kgd2kfd_device_init(adev->kfd.dev, adev_to_drm(adev), &gpu_resources);
+               adev->kfd.init_complete = kgd2kfd_device_init(adev->kfd.dev,
+                                               adev_to_drm(adev), &gpu_resources);
        }
 }
 
index a81d9ca..14f68c0 100644 (file)
@@ -80,6 +80,7 @@ struct amdgpu_amdkfd_fence {
 struct amdgpu_kfd_dev {
        struct kfd_dev *dev;
        uint64_t vram_used;
+       bool init_complete;
 };
 
 enum kgd_engine_type {
index e247c3a..db88fae 100644 (file)
@@ -4835,9 +4835,16 @@ skip_hw_reset:
 
 skip_sched_resume:
        list_for_each_entry(tmp_adev, device_list_handle, gmc.xgmi.head) {
-               /*unlock kfd: SRIOV would do it separately */
+               /* unlock kfd: SRIOV would do it separately */
                if (!need_emergency_restart && !amdgpu_sriov_vf(tmp_adev))
                        amdgpu_amdkfd_post_reset(tmp_adev);
+
+               /* kfd_post_reset will do nothing if kfd device is not initialized,
+                * need to bring up kfd here if it's not be initialized before
+                */
+               if (!adev->kfd.init_complete)
+                       amdgpu_amdkfd_device_init(adev);
+
                if (audio_suspended)
                        amdgpu_device_resume_display_audio(tmp_adev);
                amdgpu_device_unlock_adev(tmp_adev);