drm/amdgpu: clean up psp ip if hw_init failed v2
Subsystems (2)
PATCH 1/1 drm/amdgpu: clean up psp ip if hw_init failed v2
Call psp_hw_fini when psp_hw_init failed.
Signed-off-by Alice Wong <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 57 +++++++++++++------------ 1 file changed, 29 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +29 -28
@@ -2537,6 +2537,34 @@ static int psp_load_fw(struct amdgpu_device *adev)return ret; } +static int psp_hw_fini (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct psp_context *psp = &adev->psp; + +if (psp->ta_fw) { +psp_ras_terminate (psp); +psp_securedisplay_terminate (psp); +psp_rap_terminate (psp); +psp_dtm_terminate (psp); +psp_hdcp_terminate (psp); + } + +psp_asd_terminate (psp); + +psp_tmr_terminate (psp); +psp_ring_destroy (psp,PSP_RING_TYPE__KM ); + +amdgpu_bo_free_kernel (&psp->fw_pri_bo, + &psp->fw_pri_mc_addr, &psp->fw_pri_buf); +amdgpu_bo_free_kernel (&psp->fence_buf_bo, + &psp->fence_buf_mc_addr, &psp->fence_buf); +amdgpu_bo_free_kernel (&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr, + (void **)&psp->cmd_buf_mem); + +return 0 ; +} +static int psp_hw_init (void *handle) {int ret;
@@ -2563,37 +2591,10 @@ static int psp_hw_init(void *handle) failed: adev->firmware.load_type =AMDGPU_FW_LOAD_DIRECT ;mutex_unlock (&adev->firmware.mutex); +psp_hw_fini (handle);return -EINVAL ; } -static int psp_hw_fini (void *handle) -{ -struct amdgpu_device *adev = (struct amdgpu_device *)handle; -struct psp_context *psp = &adev->psp; - -if (psp->ta_fw) { -psp_ras_terminate (psp); -psp_securedisplay_terminate (psp); -psp_rap_terminate (psp); -psp_dtm_terminate (psp); -psp_hdcp_terminate (psp); - } - -psp_asd_terminate (psp); - -psp_tmr_terminate (psp); -psp_ring_destroy (psp,PSP_RING_TYPE__KM ); - -amdgpu_bo_free_kernel (&psp->fw_pri_bo, - &psp->fw_pri_mc_addr, &psp->fw_pri_buf); -amdgpu_bo_free_kernel (&psp->fence_buf_bo, - &psp->fence_buf_mc_addr, &psp->fence_buf); -amdgpu_bo_free_kernel (&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr, - (void **)&psp->cmd_buf_mem); - -return 0 ; -} -static int psp_suspend (void *handle) {int ret;
Signature · 1 line
2.25.1
Dear Alice,
Thank you for your patch.
Am 20.04.22 um 21:37 schrieb Alice Wong:
Quoted 1 line
Call
psp_hw_finiwhenpsp_hw_initfailed.
Please amend the commit message, and add the motivation/reasoning too [1].
I think it’s common, if a patch (series) is rerolled to list the changes between the versions.
Kind regards,
Paul
[1]: https://cbea.ms/git-commit/
Quoted 83 lines
Signed-off-by Alice Wong <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 57 +++++++++++++------------ 1 file changed, 29 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +29
-28@@ -2537,6 +2537,34 @@ static int psp_load_fw(struct amdgpu_device *adev)return ret; } +static int psp_hw_fini (void *handle) +{ +struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct psp_context *psp = &adev->psp; + +if (psp->ta_fw) { +psp_ras_terminate (psp); +psp_securedisplay_terminate (psp); +psp_rap_terminate (psp); +psp_dtm_terminate (psp); +psp_hdcp_terminate (psp); + } + +psp_asd_terminate (psp); + +psp_tmr_terminate (psp); +psp_ring_destroy (psp,PSP_RING_TYPE__KM ); + +amdgpu_bo_free_kernel (&psp->fw_pri_bo, + &psp->fw_pri_mc_addr, &psp->fw_pri_buf); +amdgpu_bo_free_kernel (&psp->fence_buf_bo, + &psp->fence_buf_mc_addr, &psp->fence_buf); +amdgpu_bo_free_kernel (&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr, + (void **)&psp->cmd_buf_mem); + +return 0 ; +} +static int psp_hw_init (void *handle) {int ret;@@ -2563,37 +2591,10 @@ static int psp_hw_init(void *handle) failed: adev->firmware.load_type =AMDGPU_FW_LOAD_DIRECT ;mutex_unlock (&adev->firmware.mutex); +psp_hw_fini (handle);return -EINVAL ; } -static int psp_hw_fini (void *handle) -{ -struct amdgpu_device *adev = (struct amdgpu_device *)handle; -struct psp_context *psp = &adev->psp; - -if (psp->ta_fw) { -psp_ras_terminate (psp); -psp_securedisplay_terminate (psp); -psp_rap_terminate (psp); -psp_dtm_terminate (psp); -psp_hdcp_terminate (psp); - } - -psp_asd_terminate (psp); - -psp_tmr_terminate (psp); -psp_ring_destroy (psp,PSP_RING_TYPE__KM ); - -amdgpu_bo_free_kernel (&psp->fw_pri_bo, - &psp->fw_pri_mc_addr, &psp->fw_pri_buf); -amdgpu_bo_free_kernel (&psp->fence_buf_bo, - &psp->fence_buf_mc_addr, &psp->fence_buf); -amdgpu_bo_free_kernel (&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr, - (void **)&psp->cmd_buf_mem); - -return 0 ; -} -static int psp_suspend (void *handle) {int ret;