When amdgpu_init_minimal_xgmi is used, SDMA engines init
is delayed so amdgpu_ttm_enable_buffer_funcs must be
called later.

Without this, the check for num_buffer_funcs_scheds will
fail and using ttm buffer funcs later will fail.

Given that amdgpu_ttm_enable_buffer_funcs is a no-op if
amdgpu_in_reset() returns true, the call has to occur
after the reset lock is dropped.

Fixes: 3a5da695c8d1 ("drm/amdgpu: only use working sdma schedulers for ttm")
Signed-off-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 +++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c   | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b7751dde2894..1ec3162cb175 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2474,7 +2474,11 @@ static int amdgpu_device_ip_init(struct amdgpu_device 
*adev)
        if (r)
                goto init_failed;
 
-       amdgpu_ttm_enable_buffer_funcs(adev);
+       /* If SDMA is not brought up during hwini, the ttm buffer funcs 
enablement
+        * is delayed after reset-on-init completes.
+        */
+       if (amdgpu_ip_member_of_hwini(adev, AMD_IP_BLOCK_TYPE_SDMA))
+               amdgpu_ttm_enable_buffer_funcs(adev);
 
        /* Don't init kfd if whole hive need to be reset during init */
        if (adev->init_lvl->level != AMDGPU_INIT_LEVEL_MINIMAL_XGMI) {
@@ -5088,8 +5092,6 @@ int amdgpu_device_reinit_after_reset(struct 
amdgpu_reset_context *reset_context)
                                if (r)
                                        goto out;
 
-                               amdgpu_ttm_enable_buffer_funcs(tmp_adev);
-
                                r = amdgpu_device_ip_resume_phase3(tmp_adev);
                                if (r)
                                        goto out;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 2725230aa5e3..45e31b3daf06 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -1380,6 +1380,9 @@ static void amdgpu_xgmi_reset_on_init_work(struct 
work_struct *work)
        amdgpu_device_unlock_reset_domain(tmp_adev->reset_domain);
 
        list_for_each_entry(tmp_adev, &hive->device_list, gmc.xgmi.head) {
+               /* Enable ttm buffers funcs after the reset lock has been 
dropped. */
+               amdgpu_ttm_enable_buffer_funcs(tmp_adev);
+
                r = amdgpu_ras_init_badpage_info(tmp_adev);
                if (r && r != -EHWPOISON)
                        dev_err(tmp_adev->dev,
-- 
2.43.0

Reply via email to