Skip to content

Commit f20f3b0

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amd/pm: Add P2S tables for SMU v13.0.6
Add P2S table load support on SMU v13.0.6 ASICs. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Reviewed-by: Yang Wang <kevinyang.wang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 79daf69 commit f20f3b0

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,13 @@ static int psp_load_p2s_table(struct psp_context *psp)
25162516
if (adev->in_runpm && (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO))
25172517
return 0;
25182518

2519+
if (amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 6)) {
2520+
uint32_t supp_vers = adev->flags & AMD_IS_APU ? 0x0036013D :
2521+
0x0036003C;
2522+
if (psp->sos.fw_version < supp_vers)
2523+
return 0;
2524+
}
2525+
25192526
if (!ucode->fw || amdgpu_sriov_vf(psp->adev))
25202527
return 0;
25212528

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
#undef pr_info
6666
#undef pr_debug
6767

68+
MODULE_FIRMWARE("amdgpu/smu_13_0_6.bin");
69+
6870
#define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c))
6971

7072
#define SMU_13_0_6_FEA_MAP(smu_feature, smu_13_0_6_feature) \
@@ -123,6 +125,9 @@ struct mca_ras_info {
123125
enum amdgpu_mca_error_type type, int idx, uint32_t *count);
124126
};
125127

128+
#define P2S_TABLE_ID_A 0x50325341
129+
#define P2S_TABLE_ID_X 0x50325358
130+
126131
static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COUNT] = {
127132
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 0),
128133
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion, 1),
@@ -256,6 +261,70 @@ struct smu_v13_0_6_dpm_map {
256261
uint32_t *freq_table;
257262
};
258263

264+
static int smu_v13_0_6_init_microcode(struct smu_context *smu)
265+
{
266+
const struct smc_firmware_header_v2_1 *v2_1;
267+
const struct common_firmware_header *hdr;
268+
struct amdgpu_firmware_info *ucode = NULL;
269+
struct smc_soft_pptable_entry *entries;
270+
struct amdgpu_device *adev = smu->adev;
271+
uint32_t p2s_table_id = P2S_TABLE_ID_A;
272+
int ret = 0, i, p2stable_count;
273+
char ucode_prefix[30];
274+
char fw_name[30];
275+
276+
/* No need to load P2S tables in IOV mode */
277+
if (amdgpu_sriov_vf(adev))
278+
return 0;
279+
280+
if (!(adev->flags & AMD_IS_APU))
281+
p2s_table_id = P2S_TABLE_ID_X;
282+
283+
amdgpu_ucode_ip_version_decode(adev, MP1_HWIP, ucode_prefix,
284+
sizeof(ucode_prefix));
285+
286+
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
287+
288+
ret = amdgpu_ucode_request(adev, &adev->pm.fw, fw_name);
289+
if (ret)
290+
goto out;
291+
292+
hdr = (const struct common_firmware_header *)adev->pm.fw->data;
293+
amdgpu_ucode_print_smc_hdr(hdr);
294+
295+
/* SMU v13.0.6 binary file doesn't carry pptables, instead the entries
296+
* are used to carry p2s tables.
297+
*/
298+
v2_1 = (const struct smc_firmware_header_v2_1 *)adev->pm.fw->data;
299+
entries = (struct smc_soft_pptable_entry
300+
*)((uint8_t *)v2_1 +
301+
le32_to_cpu(v2_1->pptable_entry_offset));
302+
p2stable_count = le32_to_cpu(v2_1->pptable_count);
303+
for (i = 0; i < p2stable_count; i++) {
304+
if (le32_to_cpu(entries[i].id) == p2s_table_id) {
305+
smu->pptable_firmware.data =
306+
((uint8_t *)v2_1 +
307+
le32_to_cpu(entries[i].ppt_offset_bytes));
308+
smu->pptable_firmware.size =
309+
le32_to_cpu(entries[i].ppt_size_bytes);
310+
break;
311+
}
312+
}
313+
314+
if (smu->pptable_firmware.data && smu->pptable_firmware.size) {
315+
ucode = &adev->firmware.ucode[AMDGPU_UCODE_ID_P2S_TABLE];
316+
ucode->ucode_id = AMDGPU_UCODE_ID_P2S_TABLE;
317+
ucode->fw = &smu->pptable_firmware;
318+
adev->firmware.fw_size += ALIGN(ucode->fw->size, PAGE_SIZE);
319+
}
320+
321+
return 0;
322+
out:
323+
amdgpu_ucode_release(&adev->pm.fw);
324+
325+
return ret;
326+
}
327+
259328
static int smu_v13_0_6_tables_init(struct smu_context *smu)
260329
{
261330
struct smu_table_context *smu_table = &smu->smu_table;
@@ -2775,6 +2844,8 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = {
27752844
.get_power_limit = smu_v13_0_6_get_power_limit,
27762845
.is_dpm_running = smu_v13_0_6_is_dpm_running,
27772846
.get_unique_id = smu_v13_0_6_get_unique_id,
2847+
.init_microcode = smu_v13_0_6_init_microcode,
2848+
.fini_microcode = smu_v13_0_fini_microcode,
27782849
.init_smc_tables = smu_v13_0_6_init_smc_tables,
27792850
.fini_smc_tables = smu_v13_0_fini_smc_tables,
27802851
.init_power = smu_v13_0_init_power,

0 commit comments

Comments
 (0)