drm/amdgpu: Optimize RAS TA initialization and TA unload funcs
authorCandice Li <candice.li@amd.com>
Tue, 25 Oct 2022 10:07:44 +0000 (18:07 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 27 Oct 2022 19:12:08 +0000 (15:12 -0400)
1. Save TA unload psp response status
2. Add RAS TA loading status check for initializaiton
3. Drop RAS context teardown to allow RAS TA to be reloaded

Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Candice Li <candice.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c

index 7bbf869..b8d07e8 100644 (file)
@@ -988,6 +988,8 @@ int psp_ta_unload(struct psp_context *psp, struct ta_context *context)
 
        ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr);
 
+       context->resp_status = cmd->resp.status;
+
        release_psp_cmd_buf(psp);
 
        return ret;
@@ -1560,6 +1562,11 @@ static int psp_ras_initialize(struct psp_context *psp)
        if (amdgpu_sriov_vf(adev))
                return 0;
 
+       if (psp->ras_context.context.initialized) {
+               dev_warn(adev->dev, "RAS WARN: TA has already been loaded\n");
+               return 0;
+       }
+
        if (!adev->psp.ras_context.context.bin_desc.size_bytes ||
            !adev->psp.ras_context.context.bin_desc.start_addr) {
                dev_info(adev->dev, "RAS: optional ras ta ucode is not available\n");
@@ -1610,7 +1617,7 @@ static int psp_ras_initialize(struct psp_context *psp)
        psp->ras_context.context.mem_context.shared_mem_size = PSP_RAS_SHARED_MEM_SIZE;
        psp->ras_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA;
 
-       if (!psp->ras_context.context.initialized) {
+       if (!psp->ras_context.context.mem_context.shared_buf) {
                ret = psp_ta_init_shared_buf(psp, &psp->ras_context.context.mem_context);
                if (ret)
                        return ret;
@@ -1631,7 +1638,6 @@ static int psp_ras_initialize(struct psp_context *psp)
        else {
                if (ras_cmd->ras_status)
                        dev_warn(psp->adev->dev, "RAS Init Status: 0x%X\n", ras_cmd->ras_status);
-               amdgpu_ras_fini(psp->adev);
        }
 
        return ret;