Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: add wait_for helper for spirom update

Spirom update typically requires extremely long
duration for command execution, and special helper
function to wait for it completion.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Likun Gao and committed by
Alex Deucher
d4a4ff1c ebbb0b10

+29 -4
+20
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 569 569 return -ETIME; 570 570 } 571 571 572 + int psp_wait_for_spirom_update(struct psp_context *psp, uint32_t reg_index, 573 + uint32_t reg_val, uint32_t mask, uint32_t msec_timeout) 574 + { 575 + uint32_t val; 576 + int i; 577 + struct amdgpu_device *adev = psp->adev; 578 + 579 + if (psp->adev->no_hw_access) 580 + return 0; 581 + 582 + for (i = 0; i < msec_timeout; i++) { 583 + val = RREG32(reg_index); 584 + if ((val & mask) == reg_val) 585 + return 0; 586 + msleep(1); 587 + } 588 + 589 + return -ETIME; 590 + } 591 + 572 592 static const char *psp_gfx_cmd_name(enum psp_gfx_cmd_id cmd_id) 573 593 { 574 594 switch (cmd_id) {
+2
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
··· 455 455 456 456 extern int psp_wait_for(struct psp_context *psp, uint32_t reg_index, 457 457 uint32_t field_val, uint32_t mask, bool check_changed); 458 + extern int psp_wait_for_spirom_update(struct psp_context *psp, uint32_t reg_index, 459 + uint32_t field_val, uint32_t mask, uint32_t msec_timeout); 458 460 459 461 int psp_gpu_reset(struct amdgpu_device *adev); 460 462 int psp_update_vcn_sram(struct amdgpu_device *adev, int inst_idx,
+5 -4
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c
··· 624 624 WREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_73, 1); 625 625 626 626 if (cmd == C2PMSG_CMD_SPI_UPDATE_FLASH_IMAGE) 627 - return 0; 628 - 629 - ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, regMP0_SMN_C2PMSG_115), 630 - MBOX_READY_FLAG, MBOX_READY_MASK, false); 627 + ret = psp_wait_for_spirom_update(psp, SOC15_REG_OFFSET(MP0, 0, regMP0_SMN_C2PMSG_115), 628 + MBOX_READY_FLAG, MBOX_READY_MASK, PSP_SPIROM_UPDATE_TIMEOUT); 629 + else 630 + ret = psp_wait_for(psp, SOC15_REG_OFFSET(MP0, 0, regMP0_SMN_C2PMSG_115), 631 + MBOX_READY_FLAG, MBOX_READY_MASK, false); 631 632 if (ret) { 632 633 dev_err(adev->dev, "SPI cmd %x timed out, ret = %d", cmd, ret); 633 634 return ret;
+2
drivers/gpu/drm/amd/amdgpu/psp_v13_0.h
··· 25 25 26 26 #include "amdgpu_psp.h" 27 27 28 + #define PSP_SPIROM_UPDATE_TIMEOUT 60000 /* 60s */ 29 + 28 30 void psp_v13_0_set_psp_funcs(struct psp_context *psp); 29 31 30 32 #endif