drm/amdgpu: add psp funcs callback to check if aux fw is needed
Subsystems (2)
PATCH 1/2 drm/amdgpu: add psp funcs callback to check if aux fw is needed
Query pmfw version to determine if aux sos fw needs to be loaded in psp v13.0.
v2: refine callback to check if aux_fw loading is needed instead of
getting pmfw version barely
v3: return the comparison directly
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 4 ++++ drivers/gpu/drm/amd/amdgpu/psp_v13_0.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +4 -0
@@ -138,6 +138,7 @@ struct psp_funcs {int (*vbflash_stat)(struct psp_context *psp);int (*fatal_error_recovery_quirk)(struct psp_context *psp);bool (*get_ras_capability)(struct psp_context *psp); +bool (*is_aux_sos_load_required)(struct psp_context *psp); };struct ta_funcs {
@@ -464,6 +465,9 @@ struct amdgpu_psp_funcs { ((psp)->funcs->fatal_error_recovery_quirk ? \ (psp)->funcs->fatal_error_recovery_quirk((psp)) : 0) +#define psp_is_aux_sos_load_required (psp) \ + ((psp)->funcs->is_aux_sos_load_required ? (psp)->funcs->is_aux_sos_load_required((psp)) : 0) +extern const struct amd_ip_funcs psp_ip_funcs;extern const struct amdgpu_ip_block_version psp_v3_1_ip_block;
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +17 -0
@@ -81,6 +81,8 @@ MODULE_FIRMWARE("amdgpu/psp_14_0_4_ta.bin");/* memory training timeout define */ #define MEM_TRAIN_SEND_MSG_TIMEOUT_US 3000000 +#define regMP1_PUB_SCRATCH0 0x3b10090 +static int psp_v13_0_init_microcode (struct psp_context *psp) {struct amdgpu_device *adev = psp->adev;
@@ -807,6 +809,20 @@ static bool psp_v13_0_get_ras_capability(struct psp_context *psp) } } +static bool psp_v13_0_is_aux_sos_load_required (struct psp_context *psp) +{ +struct amdgpu_device *adev = psp->adev; +u32 pmfw_ver; + +if (amdgpu_ip_version (adev,MP0_HWIP ,0 ) !=IP_VERSION (13 ,0 ,6 )) +return false; + +/* load 4e version of sos if pmfw version less than 85.115.0 */ + pmfw_ver =RREG32 (regMP1_PUB_SCRATCH0 /4 ); + +return (pmfw_ver <0x557300 ); +} +static const struct psp_funcs psp_v13_0_funcs = { .init_microcode = psp_v13_0_init_microcode, .wait_for_bootloader = psp_v13_0_wait_for_bootloader_steady_state,
@@ -830,6 +846,7 @@ static const struct psp_funcs psp_v13_0_funcs = { .vbflash_stat = psp_v13_0_vbflash_status, .fatal_error_recovery_quirk = psp_v13_0_fatal_error_recovery_quirk, .get_ras_capability = psp_v13_0_get_ras_capability, + .is_aux_sos_load_required = psp_v13_0_is_aux_sos_load_required, };void psp_v13_0_set_psp_funcs (struct psp_context *psp)
Signature · 1 line
2.43.2
PATCH 2/2 drm/amdgpu: load sos binary properly on the basis of pmfw version
To be compatible with legacy IFWI, driver needs to carry legacy tOS and query pmfw version to load them accordingly.
Add psp_firmware_header_v2_1 to handle the combined sos binary.
Double the sos count limit for the case of aux sos fw packed.
v2: pass the correct fw_bin_desc to parse_sos_bin_descriptor
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 29 ++++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | 11 ++++++++- 2 files changed, 33 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +23 -6
@@ -3425,9 +3425,11 @@ int psp_init_sos_microcode(struct psp_context *psp, const char *chip_name)const struct psp_firmware_header_v1_2 *sos_hdr_v1_2;const struct psp_firmware_header_v1_3 *sos_hdr_v1_3;const struct psp_firmware_header_v2_0 *sos_hdr_v2_0; -int err =0 ; +const struct psp_firmware_header_v2_1 *sos_hdr_v2_1; +int fw_index, fw_bin_count, start_index =0 ; +const struct psp_fw_bin_desc *fw_bin;uint8_t *ucode_array_start_addr; -int fw_index =0 ; +int err =0 ; err =amdgpu_ucode_request (adev, &adev->psp.sos_fw,"amdgpu/%s_sos.bin" , chip_name);if (err)
@@ -3478,15 +3480,30 @@ int psp_init_sos_microcode(struct psp_context *psp, const char *chip_name)case 2 : sos_hdr_v2_0 = (const struct psp_firmware_header_v2_0 *)adev->psp.sos_fw->data; -if (le32_to_cpu (sos_hdr_v2_0->psp_fw_bin_count) >=UCODE_MAX_PSP_PACKAGING ) { + fw_bin_count =le32_to_cpu (sos_hdr_v2_0->psp_fw_bin_count); + +if (fw_bin_count >=UCODE_MAX_PSP_PACKAGING ) {dev_err (adev->dev,"packed SOS count exceeds maximum limit\n" ); err = -EINVAL ; goto out; } -for (fw_index =0 ; fw_index <le32_to_cpu (sos_hdr_v2_0->psp_fw_bin_count); fw_index++) { - err =parse_sos_bin_descriptor (psp, - &sos_hdr_v2_0->psp_fw_bin[fw_index], +if (sos_hdr_v2_0->header.header_version_minor ==1 ) { + sos_hdr_v2_1 = (const struct psp_firmware_header_v2_1 *)adev->psp.sos_fw->data; + + fw_bin = sos_hdr_v2_1->psp_fw_bin; + +if (psp_is_aux_sos_load_required (psp)) + start_index =le32_to_cpu (sos_hdr_v2_1->psp_aux_fw_bin_index); +else + fw_bin_count -=le32_to_cpu (sos_hdr_v2_1->psp_aux_fw_bin_index); + + }else { + fw_bin = sos_hdr_v2_0->psp_fw_bin; + } + +for (fw_index = start_index; fw_index < fw_bin_count; fw_index++) { + err =parse_sos_bin_descriptor (psp, fw_bin + fw_index, sos_hdr_v2_0);if (err) goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +10 -1
@@ -136,6 +136,14 @@ struct psp_firmware_header_v2_0 {struct psp_fw_bin_desc psp_fw_bin[]; }; +/* version_major=2, version_minor=1 */ +struct psp_firmware_header_v2_1 { +struct common_firmware_header header; +uint32_t psp_fw_bin_count; +uint32_t psp_aux_fw_bin_index; +struct psp_fw_bin_desc psp_fw_bin[]; +}; +/* version_major=1, version_minor=0 */ struct ta_firmware_header_v1_0 {struct common_firmware_header header;
@@ -426,6 +434,7 @@ union amdgpu_firmware_header {struct psp_firmware_header_v1_1 psp_v1_1;struct psp_firmware_header_v1_3 psp_v1_3;struct psp_firmware_header_v2_0 psp_v2_0; +struct psp_firmware_header_v2_0 psp_v2_1;struct ta_firmware_header_v1_0 ta;struct ta_firmware_header_v2_0 ta_v2_0;struct gfx_firmware_header_v1_0 gfx;
@@ -447,7 +456,7 @@ union amdgpu_firmware_header {uint8_t raw[0x100 ]; }; -#define UCODE_MAX_PSP_PACKAGING ((sizeof(union amdgpu_firmware_header) - sizeof(struct common_firmware_header) - 4) / sizeof(struct psp_fw_bin_desc)) +#define UCODE_MAX_PSP_PACKAGING ((sizeof(union amdgpu_firmware_header) - sizeof(struct common_firmware_header) - 4) / sizeof(struct psp_fw_bin_desc)) * 2/* * fw loading support
Signature · 1 line
2.43.2
RE: [PATCH 2/2] drm/amdgpu: load sos binary properly on the basis of pmfw version
[AMD Official Use Only - AMD Internal Distribution Only]
Series is
Regards,
Hawking
-----Original Message-----
From: Ma, Le <[email protected]>
Sent: Thursday, September 12, 2024 18:02
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Ma, Le <[email protected]>; Lazar, Lijo <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: load sos binary properly on the basis of pmfw version
To be compatible with legacy IFWI, driver needs to carry legacy tOS and query pmfw version to load them accordingly.
Add psp_firmware_header_v2_1 to handle the combined sos binary.
Double the sos count limit for the case of aux sos fw packed.
v2: pass the correct fw_bin_desc to parse_sos_bin_descriptor
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 29 ++++++++++++++++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | 11 ++++++++- 2 files changed, 33 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +24 -6
@@ -3425,9 +3425,11 @@ int psp_init_sos_microcode(struct psp_context *psp, const char *chip_name)const struct psp_firmware_header_v1_2 *sos_hdr_v1_2;const struct psp_firmware_header_v1_3 *sos_hdr_v1_3;const struct psp_firmware_header_v2_0 *sos_hdr_v2_0; -int err =0 ; +const struct psp_firmware_header_v2_1 *sos_hdr_v2_1; +int fw_index, fw_bin_count, start_index =0 ; +const struct psp_fw_bin_desc *fw_bin;uint8_t *ucode_array_start_addr; -int fw_index =0 ; +int err =0 ; err =amdgpu_ucode_request (adev, &adev->psp.sos_fw,"amdgpu/%s_sos.bin" , chip_name);if (err)
@@ -3478,15 +3480,30 @@ int psp_init_sos_microcode(struct psp_context *psp, const char *chip_name)case 2 : sos_hdr_v2_0 = (const struct psp_firmware_header_v2_0 *)adev->psp.sos_fw->data; -if (le32_to_cpu (sos_hdr_v2_0->psp_fw_bin_count) >=UCODE_MAX_PSP_PACKAGING ) { + fw_bin_count =le32_to_cpu (sos_hdr_v2_0->psp_fw_bin_count); + +if (fw_bin_count >=UCODE_MAX_PSP_PACKAGING ) {dev_err (adev->dev,"packed SOS count exceeds maximum limit\n" ); err = -EINVAL ; goto out; } -for (fw_index =0 ; fw_index <le32_to_cpu (sos_hdr_v2_0->psp_fw_bin_count); fw_index++) { - err =parse_sos_bin_descriptor (psp, - &sos_hdr_v2_0->psp_fw_bin[fw_index], +if (sos_hdr_v2_0->header.header_version_minor ==1 ) { + sos_hdr_v2_1 = (const struct psp_firmware_header_v2_1 +*)adev->psp.sos_fw->data; + + fw_bin = sos_hdr_v2_1->psp_fw_bin; + +if (psp_is_aux_sos_load_required (psp)) + start_index =le32_to_cpu (sos_hdr_v2_1->psp_aux_fw_bin_index); +else + fw_bin_count -=le32_to_cpu (sos_hdr_v2_1->psp_aux_fw_bin_index); + + }else { + fw_bin = sos_hdr_v2_0->psp_fw_bin; + } + +for (fw_index = start_index; fw_index < fw_bin_count; fw_index++) { + err =parse_sos_bin_descriptor (psp, fw_bin + fw_index, sos_hdr_v2_0);if (err)
goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +12 -1
@@ -136,6 +136,14 @@ struct psp_firmware_header_v2_0 {struct psp_fw_bin_desc psp_fw_bin[]; }; +/* version_major=2, version_minor=1 */ +struct psp_firmware_header_v2_1 { +struct common_firmware_header header; +uint32_t psp_fw_bin_count; +uint32_t psp_aux_fw_bin_index; +struct psp_fw_bin_desc psp_fw_bin[]; +}; +/* version_major=1, version_minor=0 */ struct ta_firmware_header_v1_0 {struct common_firmware_header header;
@@ -426,6 +434,7 @@ union amdgpu_firmware_header {struct psp_firmware_header_v1_1 psp_v1_1;struct psp_firmware_header_v1_3 psp_v1_3;struct psp_firmware_header_v2_0 psp_v2_0; +struct psp_firmware_header_v2_0 psp_v2_1;struct ta_firmware_header_v1_0 ta;struct ta_firmware_header_v2_0 ta_v2_0;struct gfx_firmware_header_v1_0 gfx;
@@ -447,7 +456,7 @@ union amdgpu_firmware_header {uint8_t raw[0x100 ]; }; -#define UCODE_MAX_PSP_PACKAGING ((sizeof(union amdgpu_firmware_header) - sizeof(struct common_firmware_header) - 4) / sizeof(struct psp_fw_bin_desc)) +#define UCODE_MAX_PSP_PACKAGING ((sizeof(union amdgpu_firmware_header) +- sizeof(struct common_firmware_header) - 4) / sizeof(struct +psp_fw_bin_desc)) * 2
/*
* fw loading support
--
2.43.2