drm/amdgpu: Skip TMR allocation if not required
Subsystems (2)
Alex Deucher
maintainerPATCH 1/23 drm/amdgpu: Skip TMR allocation if not required
From: Lijo Lazar <[email protected]>
On ASICs with PSPv13.0.6, TMR is reserved at boot time. There is no need to allocate TMR region by driver. However, it's still required to send SETUP_TMR command to PSP.
Signed-off-by Lijo Lazar <[email protected]>
Reviewed-by Hawking Zhang <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 34 +++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +26 -8
@@ -702,8 +702,13 @@ static void psp_prep_tmr_cmd_buf(struct psp_context *psp, uint64_t tmr_mc, struct amdgpu_bo *tmr_bo) { struct amdgpu_device *adev = psp->adev; -uint32_t size =amdgpu_bo_size (tmr_bo); -uint64_t tmr_pa =amdgpu_gmc_vram_pa (adev, tmr_bo); +uint32_t size =0 ; +uint64_t tmr_pa =0 ; + +if (tmr_bo) { + size =amdgpu_bo_size (tmr_bo); + tmr_pa =amdgpu_gmc_vram_pa (adev, tmr_bo); + }if (amdgpu_sriov_vf (psp->adev)) cmd->cmd_id =GFX_CMD_ID_SETUP_VMR ;
@@ -748,6 +753,16 @@ static int psp_load_toc(struct psp_context *psp,return ret; } +static bool psp_boottime_tmr (struct psp_context *psp) +{ +switch (psp->adev->ip_versions[MP0_HWIP ][0 ]) { +case IP_VERSION (13 ,0 ,6 ): +return true; +default : +return false; + } +} +/* Set up Trusted Memory Region */ static int psp_tmr_init (struct psp_context *psp) {
@@ -819,8 +834,9 @@ static int psp_tmr_load(struct psp_context *psp) cmd =acquire_psp_cmd_buf (psp);psp_prep_tmr_cmd_buf (psp, cmd, psp->tmr_mc_addr, psp->tmr_bo); -DRM_INFO ("reserve 0x%lx from 0x%llx for PSP TMR\n" , -amdgpu_bo_size (psp->tmr_bo), psp->tmr_mc_addr); +if (psp->tmr_bo) +DRM_INFO ("reserve 0x%lx from 0x%llx for PSP TMR\n" , +amdgpu_bo_size (psp->tmr_bo), psp->tmr_mc_addr); ret =psp_cmd_submit_buf (psp,NULL , cmd, psp->fence_buf_mc_addr);
@@ -2083,10 +2099,12 @@ static int psp_hw_start(struct psp_context *psp)if (amdgpu_sriov_vf (adev) &&amdgpu_in_reset (adev)) goto skip_pin_bo; - ret =psp_tmr_init (psp); -if (ret) { -DRM_ERROR ("PSP tmr init failed!\n" ); -return ret; +if (!psp_boottime_tmr (psp)) { + ret =psp_tmr_init (psp); +if (ret) { +DRM_ERROR ("PSP tmr init failed!\n" ); +return ret; + } } skip_pin_bo:
Signature · 1 line
2.39.2
Alex Deucher
maintainerPATCH 2/23 drm/amdgpu: Fix the KCQ hang when binding back
From: Shiwu Zhang <[email protected]>
Just like the KIQ, KCQ need to clear the doorbell related regs as well to avoid hangs when to load driver again after unloading.
Signed-off-by Shiwu Zhang <[email protected]>
Reviewed-by Le Ma <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 28 ++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +25 -3
@@ -1675,7 +1675,7 @@ static int gfx_v9_4_3_xcc_kiq_init_register(struct amdgpu_ring *ring,return 0 ; } -static int gfx_v9_4_3_xcc_kiq_fini_register (struct amdgpu_ring *ring, +static int gfx_v9_4_3_xcc_q_fini_register (struct amdgpu_ring *ring,int xcc_id) {struct amdgpu_device *adev = ring->adev;
@@ -1693,7 +1693,7 @@ static int gfx_v9_4_3_xcc_kiq_fini_register(struct amdgpu_ring *ring, }if (j ==AMDGPU_MAX_USEC_TIMEOUT ) { -DRM_DEBUG ("KIQ dequeue request failed.\n" ); +DRM_DEBUG ("%s dequeue request failed.\n" , ring->name);/* Manual disable if dequeue request times out */ WREG32_SOC15_RLC (GC ,GET_INST (GC , xcc_id), regCP_HQD_ACTIVE,0 );
@@ -1801,6 +1801,27 @@ static int gfx_v9_4_3_xcc_kcq_init_queue(struct amdgpu_ring *ring, int xcc_id)return 0 ; } +static int gfx_v9_4_3_xcc_kcq_fini_register (struct amdgpu_device *adev,int xcc_id) +{ +struct amdgpu_ring *ring; +int j; + +for (j =0 ; j < adev->gfx.num_compute_rings; j++) { + ring = &adev->gfx.compute_ring[j + xcc_id * adev->gfx.num_compute_rings]; +if (!amdgpu_in_reset (adev) && !adev->in_suspend) { +mutex_lock (&adev->srbm_mutex); +soc15_grbm_select (adev, ring->me, + ring->pipe, + ring->queue,0 ,GET_INST (GC , xcc_id)); +gfx_v9_4_3_xcc_q_fini_register (ring, xcc_id); +soc15_grbm_select (adev,0 ,0 ,0 ,0 ,GET_INST (GC , xcc_id)); +mutex_unlock (&adev->srbm_mutex); + } + } + +return 0 ; +} +static int gfx_v9_4_3_xcc_kiq_resume (struct amdgpu_device *adev,int xcc_id) {struct amdgpu_ring *ring;
@@ -1929,12 +1950,13 @@ static void gfx_v9_4_3_xcc_fini(struct amdgpu_device *adev, int xcc_id) adev->gfx.kiq[xcc_id].ring.pipe, adev->gfx.kiq[xcc_id].ring.queue,0 , GET_INST(GC, xcc_id)); -gfx_v9_4_3_xcc_kiq_fini_register (&adev->gfx.kiq[xcc_id].ring, +gfx_v9_4_3_xcc_q_fini_register (&adev->gfx.kiq[xcc_id].ring, xcc_id);soc15_grbm_select (adev,0 ,0 ,0 ,0 ,GET_INST (GC , xcc_id));mutex_unlock (&adev->srbm_mutex); } +gfx_v9_4_3_xcc_kcq_fini_register (adev, xcc_id);gfx_v9_4_3_xcc_cp_enable (adev, false, xcc_id);/* Skip suspend with A+A reset */
Signature · 1 line
2.39.2