diff options
author | Alice Wong <shiwei.wong@amd.com> | 2022-04-27 21:03:54 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2022-05-04 09:55:07 -0400 |
commit | e2c34219d16e8c3710278b4e23ebd5bc1ec7b804 (patch) | |
tree | fb52908aebcf0d22250faef801727731f501a202 /drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | |
parent | da40bf8f9376370b5bc2fda07aadaaddc308b1eb (diff) |
drm/amdgpu/psp: deallocate memory when psp_load_fw failed
psp_load_fw failure would cause memory leak for psp tmr and psp ring
because psp_hw_init is not called as psp block is not fully initialized.
Clean up psp tmr and psp ring when psp_load_fw fail by calling
psp_free_shared_bufs and psp_ring_destroy.
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alice Wong <shiwei.wong@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index b1b6f5dd35dd..ccb7106b2f27 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -153,6 +153,12 @@ static int psp_early_init(void *handle) return 0; } +void psp_ta_free_shared_buf(struct ta_mem_context *mem_ctx) +{ + amdgpu_bo_free_kernel(&mem_ctx->shared_bo, &mem_ctx->shared_mc_addr, + &mem_ctx->shared_buf); +} + static void psp_free_shared_bufs(struct psp_context *psp) { void *tmr_buf; @@ -1003,12 +1009,6 @@ int psp_ta_init_shared_buf(struct psp_context *psp, &mem_ctx->shared_buf); } -void psp_ta_free_shared_buf(struct ta_mem_context *mem_ctx) -{ - amdgpu_bo_free_kernel(&mem_ctx->shared_bo, &mem_ctx->shared_mc_addr, - &mem_ctx->shared_buf); -} - static void psp_prep_ta_invoke_indirect_cmd_buf(struct psp_gfx_cmd_resp *cmd, uint32_t ta_cmd_id, struct ta_context *context) @@ -2409,18 +2409,18 @@ static int psp_load_fw(struct amdgpu_device *adev) ret = psp_load_non_psp_fw(psp); if (ret) - goto failed; + goto failed1; ret = psp_asd_initialize(psp); if (ret) { DRM_ERROR("PSP load asd failed!\n"); - return ret; + goto failed1; } ret = psp_rl_load(adev); if (ret) { DRM_ERROR("PSP load RL failed!\n"); - return ret; + goto failed1; } if (amdgpu_sriov_vf(adev) && amdgpu_in_reset(adev)) { @@ -2464,12 +2464,15 @@ static int psp_load_fw(struct amdgpu_device *adev) return 0; +failed1: + psp_free_shared_bufs(psp); failed: /* * all cleanup jobs (xgmi terminate, ras terminate, * ring destroy, cmd/fence/fw buffers destory, * psp->cmd destory) are delayed to psp_hw_fini */ + psp_ring_destroy(psp, PSP_RING_TYPE__KM); return ret; } |