Skip to content

Commit df57e01

Browse files
Hawking Zhangalexdeucher
authored andcommitted
drm/amdgpu: Add psp v13 function to query boot status
Add psp v13 function to query boot status. v2: limit the use case to dGPU only (Lijo) Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com> Reviewed-by: Tao Zhou <tao.zhou1@amd.com> Reviewed-by: Yang Wang <kevinyang.wang@amd.com> Reviewed-by: Le Ma <le.ma@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 908cebc commit df57e01

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,6 +2120,21 @@ int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev)
21202120
return ret;
21212121
}
21222122

2123+
int amdgpu_psp_query_boot_status(struct amdgpu_device *adev)
2124+
{
2125+
struct psp_context *psp = &adev->psp;
2126+
int ret = 0;
2127+
2128+
if (amdgpu_sriov_vf(adev) || (adev->flags & AMD_IS_APU))
2129+
return 0;
2130+
2131+
if (psp->funcs &&
2132+
psp->funcs->query_boot_status)
2133+
ret = psp->funcs->query_boot_status(psp);
2134+
2135+
return ret;
2136+
}
2137+
21232138
static int psp_hw_start(struct psp_context *psp)
21242139
{
21252140
struct amdgpu_device *adev = psp->adev;

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct psp_funcs {
134134
int (*update_spirom)(struct psp_context *psp, uint64_t fw_pri_mc_addr);
135135
int (*vbflash_stat)(struct psp_context *psp);
136136
int (*fatal_error_recovery_quirk)(struct psp_context *psp);
137+
int (*query_boot_status)(struct psp_context *psp);
137138
};
138139

139140
struct ta_funcs {
@@ -537,4 +538,6 @@ int is_psp_fw_valid(struct psp_bin_desc bin);
537538

538539
int amdgpu_psp_wait_for_bootloader(struct amdgpu_device *adev);
539540

541+
int amdgpu_psp_query_boot_status(struct amdgpu_device *adev);
542+
540543
#endif

drivers/gpu/drm/amd/amdgpu/psp_v13_0.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,83 @@ static int psp_v13_0_fatal_error_recovery_quirk(struct psp_context *psp)
759759
return 0;
760760
}
761761

762+
763+
static void psp_v13_0_boot_error_reporting(struct amdgpu_device *adev,
764+
uint32_t inst,
765+
uint32_t boot_error)
766+
{
767+
uint32_t socket_id;
768+
uint32_t aid_id;
769+
uint32_t hbm_id;
770+
uint32_t reg_data;
771+
772+
socket_id = REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, SOCKET_ID);
773+
aid_id = REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, AID_ID);
774+
hbm_id = REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, HBM_ID);
775+
776+
reg_data = RREG32_SOC15(MP0, inst, regMP0_SMN_C2PMSG_109);
777+
dev_info(adev->dev, "socket: %d, aid: %d, firmware boot failed, fw status is 0x%x\n",
778+
socket_id, aid_id, reg_data);
779+
780+
if (REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, GPU_ERR_MEM_TRAINING))
781+
dev_info(adev->dev, "socket: %d, aid: %d, hbm: %d, memory training failed\n",
782+
socket_id, aid_id, hbm_id);
783+
784+
if (REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, GPU_ERR_FW_LOAD))
785+
dev_info(adev->dev, "socket: %d, aid: %d, firmware load failed at boot time\n",
786+
socket_id, aid_id);
787+
788+
if (REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, GPU_ERR_WAFL_LINK_TRAINING))
789+
dev_info(adev->dev, "socket: %d, aid: %d, wafl link training failed\n",
790+
socket_id, aid_id);
791+
792+
if (REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, GPU_ERR_XGMI_LINK_TRAINING))
793+
dev_info(adev->dev, "socket: %d, aid: %d, xgmi link training failed\n",
794+
socket_id, aid_id);
795+
796+
if (REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, GPU_ERR_USR_CP_LINK_TRAINING))
797+
dev_info(adev->dev, "socket: %d, aid: %d, usr cp link training failed\n",
798+
socket_id, aid_id);
799+
800+
if (REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, GPU_ERR_USR_DP_LINK_TRAINING))
801+
dev_info(adev->dev, "socket: %d, aid: %d, usr dp link training failed\n",
802+
socket_id, aid_id);
803+
804+
if (REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, GPU_ERR_HBM_MEM_TEST))
805+
dev_info(adev->dev, "socket: %d, aid: %d, hbm: %d, hbm memory test failed\n",
806+
socket_id, aid_id, hbm_id);
807+
808+
if (REG_GET_FIELD(boot_error, MP0_SMN_C2PMSG_126, GPU_ERR_HBM_BIST_TEST))
809+
dev_info(adev->dev, "socket: %d, aid: %d, hbm: %d, hbm bist test failed\n",
810+
socket_id, aid_id, hbm_id);
811+
}
812+
813+
static int psp_v13_0_query_boot_status(struct psp_context *psp)
814+
{
815+
struct amdgpu_device *adev = psp->adev;
816+
int inst_mask = adev->aid_mask;
817+
uint32_t reg_data;
818+
uint32_t i;
819+
int ret = 0;
820+
821+
if (amdgpu_ip_version(adev, MP0_HWIP, 0) != IP_VERSION(13, 0, 6))
822+
return 0;
823+
824+
if (RREG32_SOC15(MP0, 0, regMP0_SMN_C2PMSG_59) < 0x00a10007)
825+
return 0;
826+
827+
for_each_inst(i, inst_mask) {
828+
reg_data = RREG32_SOC15(MP0, i, regMP0_SMN_C2PMSG_126);
829+
if (!REG_GET_FIELD(reg_data, MP0_SMN_C2PMSG_126, BOOT_STATUS)) {
830+
psp_v13_0_boot_error_reporting(adev, i, reg_data);
831+
ret = -EINVAL;
832+
break;
833+
}
834+
}
835+
836+
return ret;
837+
}
838+
762839
static const struct psp_funcs psp_v13_0_funcs = {
763840
.init_microcode = psp_v13_0_init_microcode,
764841
.wait_for_bootloader = psp_v13_0_wait_for_bootloader_steady_state,
@@ -781,6 +858,7 @@ static const struct psp_funcs psp_v13_0_funcs = {
781858
.update_spirom = psp_v13_0_update_spirom,
782859
.vbflash_stat = psp_v13_0_vbflash_status,
783860
.fatal_error_recovery_quirk = psp_v13_0_fatal_error_recovery_quirk,
861+
.query_boot_status = psp_v13_0_query_boot_status,
784862
};
785863

786864
void psp_v13_0_set_psp_funcs(struct psp_context *psp)

0 commit comments

Comments
 (0)