drm/amdgpu: Update PSP interface header
Subsystems (3)
PATCH 1/3 drm/amdgpu: Update PSP interface header
Adds FW id for P2S table.
--- drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h +1 -0
@@ -296,6 +296,7 @@ enum psp_gfx_fw_type {GFX_FW_TYPE_VPEC_FW1 =100 ,/* VPEC FW1 To Save VPE */ GFX_FW_TYPE_VPEC_FW2 =101 ,/* VPEC FW2 To Save VPE */ GFX_FW_TYPE_VPE =102 , +GFX_FW_TYPE_P2S_TABLE =129 , GFX_FW_TYPE_MAX };
Signature · 1 line
2.25.1
PATCH 2/3 drm/amdgpu: Add support to load P2S tables
Add support to load P2S tables through PSP.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 27 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 6 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | 1 + 3 files changed, 34 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +27 -0
@@ -2412,6 +2412,9 @@ static int psp_get_fw_type(struct amdgpu_firmware_info *ucode,case AMDGPU_UCODE_ID_UMSCH_MM_CMD_BUFFER : *type =GFX_FW_TYPE_UMSCH_CMD_BUFFER ;break ; +case AMDGPU_UCODE_ID_P2S_TABLE : + *type =GFX_FW_TYPE_P2S_TABLE ; +break ;case AMDGPU_UCODE_ID_MAXIMUM :default :return -EINVAL ;
@@ -2503,6 +2506,24 @@ int psp_execute_ip_fw_load(struct psp_context *psp,return ret; } +static int psp_load_p2s_table (struct psp_context *psp) +{ +int ret; +struct amdgpu_device *adev = psp->adev; +struct amdgpu_firmware_info *ucode = + &adev->firmware.ucode[AMDGPU_UCODE_ID_P2S_TABLE ]; + +if (adev->in_runpm && (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO )) +return 0 ; + +if (!ucode->fw ||amdgpu_sriov_vf (psp->adev)) +return 0 ; + + ret =psp_execute_ip_fw_load (psp, ucode); + +return ret; +} +static int psp_load_smu_fw (struct psp_context *psp) {int ret;
@@ -2543,6 +2564,9 @@ static bool fw_load_skip_check(struct psp_context *psp,if (!ucode->fw || !ucode->ucode_size)return true; +if (ucode->ucode_id ==AMDGPU_UCODE_ID_P2S_TABLE ) +return true; + if (ucode->ucode_id == AMDGPU_UCODE_ID_SMC && (psp_smu_reload_quirk(psp) || psp->autoload_supported ||
@@ -2591,6 +2615,9 @@ static int psp_load_non_psp_fw(struct psp_context *psp)return ret; } +/* Load P2S table first if it's available */ +psp_load_p2s_table (psp); +for (i =0 ; i < adev->firmware.max_ucodes; i++) { ucode = &adev->firmware.ucode[i];
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +6 -0
@@ -642,6 +642,8 @@ const char *amdgpu_ucode_name(enum AMDGPU_UCODE_ID ucode_id)return "SMC" ;case AMDGPU_UCODE_ID_PPTABLE :return "PPTABLE" ; +case AMDGPU_UCODE_ID_P2S_TABLE : +return "P2STABLE" ;case AMDGPU_UCODE_ID_UVD :return "UVD" ;case AMDGPU_UCODE_ID_UVD1 :
@@ -922,6 +924,10 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev, ucode->ucode_size = ucode->fw->size; ucode_addr = (u8 *)ucode->fw->data;break ; +case AMDGPU_UCODE_ID_P2S_TABLE : + ucode->ucode_size = ucode->fw->size; + ucode_addr = (u8 *)ucode->fw->data; +break ;case AMDGPU_UCODE_ID_IMU_I : ucode->ucode_size =le32_to_cpu (imu_hdr->imu_iram_ucode_size_bytes); ucode_addr = (u8 *)ucode->fw->data +
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +1 -0
@@ -510,6 +510,7 @@ enum AMDGPU_UCODE_ID {AMDGPU_UCODE_ID_UMSCH_MM_UCODE ,AMDGPU_UCODE_ID_UMSCH_MM_DATA ,AMDGPU_UCODE_ID_UMSCH_MM_CMD_BUFFER , +AMDGPU_UCODE_ID_P2S_TABLE , AMDGPU_UCODE_ID_MAXIMUM, };
Signature · 1 line
2.25.1
PATCH 3/3 drm/amd/pm: Add P2S tables for SMU v13.0.6
In reply to Lijo LazarAdd P2S table load support on SMU v13.0.6 ASICs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 7 ++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 71 +++++++++++++++++++ 2 files changed, 78 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +7 -0
@@ -2516,6 +2516,13 @@ static int psp_load_p2s_table(struct psp_context *psp)if (adev->in_runpm && (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ))return 0 ; +if (amdgpu_ip_version (adev,MP0_HWIP ,0 ) ==IP_VERSION (11 ,0 ,6 )) { +uint32_t supp_vers = adev->flags &AMD_IS_APU ?0x0036013D : +0x0036003C ; +if (psp->sos.fw_version < supp_vers) +return 0 ; + } +if (!ucode->fw ||amdgpu_sriov_vf (psp->adev))return 0 ;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +71 -0
95 lines not on this page · raw message
Signature · 1 line
2.25.1
RE: [PATCH 3/3] drm/amd/pm: Add P2S tables for SMU v13.0.6
[AMD Official Use Only - General]
+ if (amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(11, 0, 6)) {
Typo? 11, 0, 6 -> 13, 0, 6
Regards,
Hawking
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, October 11, 2023 23:32
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 3/3] drm/amd/pm: Add P2S tables for SMU v13.0.6
Add P2S table load support on SMU v13.0.6 ASICs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 7 ++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 71 +++++++++++++++++++ 2 files changed, 78 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +7 -0
@@ -2516,6 +2516,13 @@ static int psp_load_p2s_table(struct psp_context *psp)if (adev->in_runpm && (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ))return 0 ; +if (amdgpu_ip_version (adev,MP0_HWIP ,0 ) ==IP_VERSION (11 ,0 ,6 )) { +uint32_t supp_vers = adev->flags &AMD_IS_APU ?0x0036013D : +0x0036003C ; +if (psp->sos.fw_version < supp_vers) +return 0 ; + } +if (!ucode->fw ||amdgpu_sriov_vf (psp->adev))return 0 ;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +68 -0
85 lines not on this page · raw message
.is_dpm_running = smu_v13_0_6_is_dpm_running,
.get_unique_id = smu_v13_0_6_get_unique_id,
+ .init_microcode = smu_v13_0_6_init_microcode,
+ .fini_microcode = smu_v13_0_fini_microcode,
.init_smc_tables = smu_v13_0_6_init_smc_tables,
.fini_smc_tables = smu_v13_0_fini_smc_tables,
.init_power = smu_v13_0_init_power,--
2.25.1
Re: [PATCH 3/3] drm/amd/pm: Add P2S tables for SMU v13.0.6
Quoted 6 lines · Hawking
[AMD Official Use Only - General]
+ if (
amdgpu_ip_version(adev, MP0_HWIP, 0)==IP_VERSION(11, 0, 6)) {Typo? 11, 0, 6 -> 13, 0, 6
Thanks for the catch. Will send a v2.
Thanks,
Lijo
Quoted 138 lines
Regards,
Hawking-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Wednesday, October 11, 2023 23:32
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 3/3] drm/amd/pm: Add P2S tables for SMU v13.0.6Add P2S table load support on SMU v13.0.6 ASICs.
Signed-off-by Lijo Lazar <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 7 ++ .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 71 +++++++++++++++++++ 2 files changed, 78 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +7
-0@@ -2516,6 +2516,13 @@ static int psp_load_p2s_table(struct psp_context *psp)if (adev->in_runpm && (adev->pm.rpm_mode ==AMDGPU_RUNPM_BACO ))return 0 ; +if (amdgpu_ip_version (adev,MP0_HWIP ,0 ) ==IP_VERSION (11 ,0 ,6 )) { +uint32_t supp_vers = adev->flags &AMD_IS_APU ?0x0036013D : +0x0036003C ; +if (psp->sos.fw_version < supp_vers) +return 0 ; + } +if (!ucode->fw ||amdgpu_sriov_vf (psp->adev))return 0 ;drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +70
-1@@ -65,6 +65,8 @@#undef pr_info#undef pr_debug +MODULE_FIRMWARE ("amdgpu/smu_13_0_6.bin" ); +#define to_amdgpu_device (x) (container_of(x, struct amdgpu_device, pm.smu_i2c))#define SMU_13_0_6_FEA_MAP (smu_feature, smu_13_0_6_feature) \@@ -123,6 +125,9 @@ struct mca_ras_info { enum amdgpu_mca_error_type type, int idx, uint32_t *count); }; +#define P2S_TABLE_ID_A 0x50325341 +#define P2S_TABLE_ID_X 0x50325358 +static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COUNT ] = {MSG_MAP (TestMessage, PPSMC_MSG_TestMessage,0 ),MSG_MAP (GetSmuVersion, PPSMC_MSG_GetSmuVersion,1 ),@@ -256,6 +261,70 @@ struct smu_v13_0_6_dpm_map {uint32_t *freq_table; }; +static int smu_v13_0_6_init_microcode (struct smu_context *smu) { +const struct smc_firmware_header_v2_1 *v2_1; +const struct smc_firmware_header_v1_0 *hdr; +struct amdgpu_firmware_info *ucode =NULL ; +struct smc_soft_pptable_entry *entries; +struct amdgpu_device *adev = smu->adev; +uint32_t p2s_table_id =P2S_TABLE_ID_A ; +int ret =0 , i, p2stable_count; +char ucode_prefix[30 ]; +char fw_name[30 ]; + +/* No need to load P2S tables in IOV mode */ +if (amdgpu_sriov_vf (adev)) +return 0 ; + +if (!(adev->flags &AMD_IS_APU )) + p2s_table_id =P2S_TABLE_ID_X ; + +amdgpu_ucode_ip_version_decode (adev,MP1_HWIP , ucode_prefix, +sizeof (ucode_prefix)); + +snprintf (fw_name,sizeof (fw_name),"amdgpu/%s.bin" , ucode_prefix); + + ret =amdgpu_ucode_request (adev, &adev->pm.fw, fw_name); +if (ret) + goto out; + + hdr = (const struct smc_firmware_header_v1_0 *)adev->pm.fw->data; +amdgpu_ucode_print_smc_hdr (&hdr->header); + +/* SMU v13.0.6 binary file doesn't carry pptables, instead the entries +* are used to carry p2s tables. +*/ + v2_1 = (const struct smc_firmware_header_v2_1 *)adev->pm.fw->data; + entries = (struct smc_soft_pptable_entry + *)((uint8_t *)v2_1 + +le32_to_cpu (v2_1->pptable_entry_offset)); + p2stable_count =le32_to_cpu (v2_1->pptable_count); +for (i =0 ; i < p2stable_count; i++) { +if (le32_to_cpu (entries[i].id) == p2s_table_id) { + smu->pptable_firmware.data = + ((uint8_t *)v2_1 + +le32_to_cpu (entries[i].ppt_offset_bytes)); + smu->pptable_firmware.size = +le32_to_cpu (entries[i].ppt_size_bytes); +break ; + } + } + +if (smu->pptable_firmware.data && smu->pptable_firmware.size) { + ucode = &adev->firmware.ucode[AMDGPU_UCODE_ID_P2S_TABLE ]; + ucode->ucode_id =AMDGPU_UCODE_ID_P2S_TABLE ; + ucode->fw = &smu->pptable_firmware; + adev->firmware.fw_size +=ALIGN (ucode->fw->size,PAGE_SIZE ); + } + +return 0 ; +out: +amdgpu_ucode_release (&adev->pm.fw); + +return ret; +} +static int smu_v13_0_6_tables_init (struct smu_context *smu) { struct smu_table_context *smu_table = &smu->smu_table; @@ -2787,6 +2856,8 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = { .get_power_limit = smu_v13_0_6_get_power_limit, .is_dpm_running = smu_v13_0_6_is_dpm_running, .get_unique_id = smu_v13_0_6_get_unique_id, + .init_microcode = smu_v13_0_6_init_microcode, + .fini_microcode = smu_v13_0_fini_microcode, .init_smc_tables = smu_v13_0_6_init_smc_tables, .fini_smc_tables = smu_v13_0_fini_smc_tables, .init_power = smu_v13_0_init_power, --2.25.1