This patch enables the logic where if PSP ring has initialized then submit the register write command via ring.
If the ring is initialized then PSP retunrs error for prograaming register via non-ring method. This fixes the case for FLR, where PSP ring is already initialized and the driver was tryin to program L1_TLB_CNTL reg vis no ring method. v2: Add more details for the patch Signed-off-by: Ahmad Rehman <ahmad.reh...@amd.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 17 ++++++++++++----- drivers/gpu/drm/amd/amdgpu/mmhub_v1_8.c | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c index dbc3313fc141..8f34a277c821 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c @@ -1189,15 +1189,22 @@ int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg, if (reg >= PSP_REG_LAST) return -EINVAL; - cmd = acquire_psp_cmd_buf(psp); + /* Check if psp ring has initialized */ + if (psp->km_ring.ring_mem && psp->km_ring.ring_size) { + cmd = acquire_psp_cmd_buf(psp); + + psp_prep_reg_prog_cmd_buf(cmd, reg, value); + ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); + + release_psp_cmd_buf(psp); + } else { + /* Program reg without ring via registers */ + ret = psp_reg_program_no_ring(psp, value, reg); + } - psp_prep_reg_prog_cmd_buf(cmd, reg, value); - ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); if (ret) dev_err(psp->adev->dev, "PSP failed to program reg id %d\n", reg); - release_psp_cmd_buf(psp); - return ret; } diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_8.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_8.c index 4a43c9ab95a2..05935b2c99b6 100644 --- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_8.c +++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_8.c @@ -208,7 +208,7 @@ static void mmhub_v1_8_init_tlb_regs(struct amdgpu_device *adev) MTYPE, MTYPE_UC);/* XXX for emulation. */ tmp = REG_SET_FIELD(tmp, MC_VM_MX_L1_TLB_CNTL, ATC_EN, 1); - psp_reg_program_no_ring(&adev->psp, tmp, PSP_REG_MMHUB_L1_TLB_CNTL); + psp_reg_program(&adev->psp, PSP_REG_MMHUB_L1_TLB_CNTL, tmp); } else { inst_mask = adev->aid_mask; for_each_inst(i, inst_mask) { -- 2.34.1