drm/amdgpu: add generic func to check if ta fw is applicable

Separated xgmi ta is required for specific APU, and driver needs
parse the ta binary properly with aux xgmi ta packed.

v2: make the check function more generic (Lijo)

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Le Ma
2024-10-25 17:43:57 +08:00
committed by Alex Deucher
parent d5e3d8a2a6
commit ea9d8863da
2 changed files with 35 additions and 0 deletions

View File

@@ -3563,6 +3563,36 @@ out:
return err;
}
static bool is_ta_fw_applicable(struct psp_context *psp,
const struct psp_fw_bin_desc *desc)
{
struct amdgpu_device *adev = psp->adev;
uint32_t fw_version;
switch (desc->fw_type) {
case TA_FW_TYPE_PSP_XGMI:
case TA_FW_TYPE_PSP_XGMI_AUX:
/* for now, AUX TA only exists on 13.0.6 ta bin,
* from v20.00.0x.14
*/
if (amdgpu_ip_version(adev, MP0_HWIP, 0) ==
IP_VERSION(13, 0, 6)) {
fw_version = le32_to_cpu(desc->fw_version);
if (adev->flags & AMD_IS_APU &&
(fw_version & 0xff) >= 0x14)
return desc->fw_type == TA_FW_TYPE_PSP_XGMI_AUX;
else
return desc->fw_type == TA_FW_TYPE_PSP_XGMI;
}
break;
default:
break;
}
return true;
}
static int parse_ta_bin_descriptor(struct psp_context *psp,
const struct psp_fw_bin_desc *desc,
const struct ta_firmware_header_v2_0 *ta_hdr)
@@ -3572,6 +3602,9 @@ static int parse_ta_bin_descriptor(struct psp_context *psp,
if (!psp || !desc || !ta_hdr)
return -EINVAL;
if (!is_ta_fw_applicable(psp, desc))
return 0;
ucode_start_addr = (uint8_t *)ta_hdr +
le32_to_cpu(desc->offset_bytes) +
le32_to_cpu(ta_hdr->header.ucode_array_offset_bytes);
@@ -3584,6 +3617,7 @@ static int parse_ta_bin_descriptor(struct psp_context *psp,
psp->asd_context.bin_desc.start_addr = ucode_start_addr;
break;
case TA_FW_TYPE_PSP_XGMI:
case TA_FW_TYPE_PSP_XGMI_AUX:
psp->xgmi_context.context.bin_desc.fw_version = le32_to_cpu(desc->fw_version);
psp->xgmi_context.context.bin_desc.size_bytes = le32_to_cpu(desc->size_bytes);
psp->xgmi_context.context.bin_desc.start_addr = ucode_start_addr;