It's more sense to put the mes context BO allocation in the mes
sw_init, and this also can resolve the risk deadlock issue between
bo allocation reservation_ww_class_mutex and mutex lock voliation.

Signed-off-by: Prike Liang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
index 33ff1afd7c4c..b755d9239888 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v11_0.c
@@ -1734,6 +1734,7 @@ static int mes_v11_0_sw_init(struct amdgpu_ip_block 
*ip_block)
        struct amdgpu_device *adev = ip_block->adev;
        int pipe, r, bo_size;
 
+       adev->mes.use_rs64mem = false;
        adev->mes.funcs = &mes_v11_0_funcs;
        adev->mes.kiq_hw_init = &mes_v11_0_kiq_hw_init;
        adev->mes.kiq_hw_fini = &mes_v11_0_kiq_hw_fini;
@@ -1784,6 +1785,15 @@ static int mes_v11_0_sw_init(struct amdgpu_ip_block 
*ip_block)
                return r;
        }
 
+       /* Allocate GPU buffer for array size query results */
+       r = amdgpu_mes_rs64mem_init(&adev->mes);
+       if (r) {
+               dev_warn(adev->dev,
+                       "RS64 local memory init failed (%d),"
+                       "falling back to system memory path\n", r);
+               adev->mes.use_rs64mem = false;
+       }
+
        return 0;
 }
 
@@ -1961,8 +1971,6 @@ static int mes_v11_0_hw_init(struct amdgpu_ip_block 
*ip_block)
        if (adev->mes.ring[0].sched.ready)
                goto out;
 
-       adev->mes.use_rs64mem = false;
-
        if (!adev->enable_mes_kiq) {
                if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
                        r = mes_v11_0_load_microcode(adev,
@@ -1980,14 +1988,6 @@ static int mes_v11_0_hw_init(struct amdgpu_ip_block 
*ip_block)
        if (r)
                goto failure;
 
-       /* Allocate GPU buffer for array size query results */
-       r = amdgpu_mes_rs64mem_init(&adev->mes);
-       if (r) {
-               dev_warn(adev->dev,
-                        "RS64 local memory init failed (%d),"
-                        "falling back to system memory path\n", r);
-               adev->mes.use_rs64mem = false;
-       }
        r = mes_v11_0_set_hw_resources(&adev->mes);
 
        if (r)
-- 
2.34.1

Reply via email to