Lines Matching refs:psp
48 static int psp_load_smu_fw(struct psp_context *psp);
49 static int psp_rap_terminate(struct psp_context *psp);
50 static int psp_securedisplay_terminate(struct psp_context *psp);
52 static int psp_ring_init(struct psp_context *psp, in psp_ring_init() argument
57 struct amdgpu_device *adev = psp->adev; in psp_ring_init()
59 ring = &psp->km_ring; in psp_ring_init()
94 static void psp_check_pmfw_centralized_cstate_management(struct psp_context *psp) in psp_check_pmfw_centralized_cstate_management() argument
96 struct amdgpu_device *adev = psp->adev; in psp_check_pmfw_centralized_cstate_management()
99 psp->pmfw_centralized_cstate_management = false; in psp_check_pmfw_centralized_cstate_management()
115 psp->pmfw_centralized_cstate_management = true; in psp_check_pmfw_centralized_cstate_management()
118 psp->pmfw_centralized_cstate_management = false; in psp_check_pmfw_centralized_cstate_management()
123 static int psp_init_sriov_microcode(struct psp_context *psp) in psp_init_sriov_microcode() argument
125 struct amdgpu_device *adev = psp->adev; in psp_init_sriov_microcode()
136 ret = psp_init_cap_microcode(psp, ucode_prefix); in psp_init_sriov_microcode()
140 ret = psp_init_cap_microcode(psp, ucode_prefix); in psp_init_sriov_microcode()
141 ret &= psp_init_ta_microcode(psp, ucode_prefix); in psp_init_sriov_microcode()
147 ret = psp_init_cap_microcode(psp, ucode_prefix); in psp_init_sriov_microcode()
148 ret &= psp_init_ta_microcode(psp, ucode_prefix); in psp_init_sriov_microcode()
152 ret = psp_init_cap_microcode(psp, ucode_prefix); in psp_init_sriov_microcode()
163 struct psp_context *psp = &adev->psp; in psp_early_init() local
167 psp_v3_1_set_psp_funcs(psp); in psp_early_init()
168 psp->autoload_supported = false; in psp_early_init()
172 psp_v10_0_set_psp_funcs(psp); in psp_early_init()
173 psp->autoload_supported = false; in psp_early_init()
177 psp_v11_0_set_psp_funcs(psp); in psp_early_init()
178 psp->autoload_supported = false; in psp_early_init()
182 adev->psp.sup_pd_fw_up = !amdgpu_sriov_vf(adev); in psp_early_init()
190 psp_v11_0_set_psp_funcs(psp); in psp_early_init()
191 psp->autoload_supported = true; in psp_early_init()
195 psp_v12_0_set_psp_funcs(psp); in psp_early_init()
199 psp_v13_0_set_psp_funcs(psp); in psp_early_init()
207 psp_v13_0_set_psp_funcs(psp); in psp_early_init()
208 psp->autoload_supported = true; in psp_early_init()
212 psp_v11_0_8_set_psp_funcs(psp); in psp_early_init()
213 psp->autoload_supported = false; in psp_early_init()
219 psp_v13_0_set_psp_funcs(psp); in psp_early_init()
220 psp->autoload_supported = true; in psp_early_init()
221 adev->psp.sup_ifwi_up = !amdgpu_sriov_vf(adev); in psp_early_init()
224 psp_v13_0_4_set_psp_funcs(psp); in psp_early_init()
225 psp->autoload_supported = true; in psp_early_init()
231 psp->adev = adev; in psp_early_init()
233 psp_check_pmfw_centralized_cstate_management(psp); in psp_early_init()
236 return psp_init_sriov_microcode(psp); in psp_early_init()
238 return psp_init_microcode(psp); in psp_early_init()
248 static void psp_free_shared_bufs(struct psp_context *psp) in psp_free_shared_bufs() argument
254 pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL; in psp_free_shared_bufs()
255 amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, pptr); in psp_free_shared_bufs()
256 psp->tmr_bo = NULL; in psp_free_shared_bufs()
259 psp_ta_free_shared_buf(&psp->xgmi_context.context.mem_context); in psp_free_shared_bufs()
262 psp_ta_free_shared_buf(&psp->ras_context.context.mem_context); in psp_free_shared_bufs()
265 psp_ta_free_shared_buf(&psp->hdcp_context.context.mem_context); in psp_free_shared_bufs()
268 psp_ta_free_shared_buf(&psp->dtm_context.context.mem_context); in psp_free_shared_bufs()
271 psp_ta_free_shared_buf(&psp->rap_context.context.mem_context); in psp_free_shared_bufs()
274 psp_ta_free_shared_buf(&psp->securedisplay_context.context.mem_context); in psp_free_shared_bufs()
279 static void psp_memory_training_fini(struct psp_context *psp) in psp_memory_training_fini() argument
281 struct psp_memory_training_context *ctx = &psp->mem_train_ctx; in psp_memory_training_fini()
288 static int psp_memory_training_init(struct psp_context *psp) in psp_memory_training_init() argument
291 struct psp_memory_training_context *ctx = &psp->mem_train_ctx; in psp_memory_training_init()
313 psp_memory_training_fini(psp); in psp_memory_training_init()
402 struct psp_context *psp = &adev->psp; in psp_sw_init() local
405 struct psp_memory_training_context *mem_training_ctx = &psp->mem_train_ctx; in psp_sw_init()
408 psp->cmd = kzalloc(sizeof(struct psp_gfx_cmd_resp), GFP_KERNEL); in psp_sw_init()
409 if (!psp->cmd) { in psp_sw_init()
414 adev->psp.xgmi_context.supports_extended_data = in psp_sw_init()
436 psp->boot_cfg_bitmask = boot_cfg_entry.boot_cfg_bitmask; in psp_sw_init()
437 if ((psp->boot_cfg_bitmask) & in psp_sw_init()
455 ret = psp_memory_training_init(psp); in psp_sw_init()
461 ret = psp_mem_training(psp, PSP_MEM_TRAIN_COLD_BOOT); in psp_sw_init()
471 &psp->fw_pri_bo, in psp_sw_init()
472 &psp->fw_pri_mc_addr, in psp_sw_init()
473 &psp->fw_pri_buf); in psp_sw_init()
480 &psp->fence_buf_bo, in psp_sw_init()
481 &psp->fence_buf_mc_addr, in psp_sw_init()
482 &psp->fence_buf); in psp_sw_init()
489 &psp->cmd_buf_bo, &psp->cmd_buf_mc_addr, in psp_sw_init()
490 (void **)&psp->cmd_buf_mem); in psp_sw_init()
497 amdgpu_bo_free_kernel(&psp->fence_buf_bo, in psp_sw_init()
498 &psp->fence_buf_mc_addr, &psp->fence_buf); in psp_sw_init()
500 amdgpu_bo_free_kernel(&psp->fw_pri_bo, in psp_sw_init()
501 &psp->fw_pri_mc_addr, &psp->fw_pri_buf); in psp_sw_init()
508 struct psp_context *psp = &adev->psp; in psp_sw_fini() local
509 struct psp_gfx_cmd_resp *cmd = psp->cmd; in psp_sw_fini()
511 psp_memory_training_fini(psp); in psp_sw_fini()
513 amdgpu_ucode_release(&psp->sos_fw); in psp_sw_fini()
514 amdgpu_ucode_release(&psp->asd_fw); in psp_sw_fini()
515 amdgpu_ucode_release(&psp->ta_fw); in psp_sw_fini()
516 amdgpu_ucode_release(&psp->cap_fw); in psp_sw_fini()
517 amdgpu_ucode_release(&psp->toc_fw); in psp_sw_fini()
522 psp_free_shared_bufs(psp); in psp_sw_fini()
524 if (psp->km_ring.ring_mem) in psp_sw_fini()
526 &psp->km_ring.ring_mem_mc_addr, in psp_sw_fini()
527 (void **)&psp->km_ring.ring_mem); in psp_sw_fini()
529 amdgpu_bo_free_kernel(&psp->fw_pri_bo, in psp_sw_fini()
530 &psp->fw_pri_mc_addr, &psp->fw_pri_buf); in psp_sw_fini()
531 amdgpu_bo_free_kernel(&psp->fence_buf_bo, in psp_sw_fini()
532 &psp->fence_buf_mc_addr, &psp->fence_buf); in psp_sw_fini()
533 amdgpu_bo_free_kernel(&psp->cmd_buf_bo, &psp->cmd_buf_mc_addr, in psp_sw_fini()
534 (void **)&psp->cmd_buf_mem); in psp_sw_fini()
539 int psp_wait_for(struct psp_context *psp, uint32_t reg_index, in psp_wait_for() argument
544 struct amdgpu_device *adev = psp->adev; in psp_wait_for()
546 if (psp->adev->no_hw_access) in psp_wait_for()
564 int psp_wait_for_spirom_update(struct psp_context *psp, uint32_t reg_index, in psp_wait_for_spirom_update() argument
569 struct amdgpu_device *adev = psp->adev; in psp_wait_for_spirom_update()
571 if (psp->adev->no_hw_access) in psp_wait_for_spirom_update()
623 psp_cmd_submit_buf(struct psp_context *psp, in psp_cmd_submit_buf() argument
633 if (psp->adev->no_hw_access) in psp_cmd_submit_buf()
636 memset(psp->cmd_buf_mem, 0, PSP_CMD_BUFFER_SIZE); in psp_cmd_submit_buf()
638 memcpy(psp->cmd_buf_mem, cmd, sizeof(struct psp_gfx_cmd_resp)); in psp_cmd_submit_buf()
640 index = atomic_inc_return(&psp->fence_value); in psp_cmd_submit_buf()
641 ret = psp_ring_cmd_submit(psp, psp->cmd_buf_mc_addr, fence_mc_addr, index); in psp_cmd_submit_buf()
643 atomic_dec(&psp->fence_value); in psp_cmd_submit_buf()
647 amdgpu_device_invalidate_hdp(psp->adev, NULL); in psp_cmd_submit_buf()
648 while (*((unsigned int *)psp->fence_buf) != index) { in psp_cmd_submit_buf()
660 amdgpu_device_invalidate_hdp(psp->adev, NULL); in psp_cmd_submit_buf()
664 skip_unsupport = (psp->cmd_buf_mem->resp.status == TEE_ERROR_NOT_SUPPORTED || in psp_cmd_submit_buf()
665 psp->cmd_buf_mem->resp.status == PSP_ERR_UNKNOWN_COMMAND) && amdgpu_sriov_vf(psp->adev); in psp_cmd_submit_buf()
667 memcpy(&cmd->resp, &psp->cmd_buf_mem->resp, sizeof(struct psp_gfx_resp)); in psp_cmd_submit_buf()
676 if (!skip_unsupport && (psp->cmd_buf_mem->resp.status || !timeout) && !ras_intr) { in psp_cmd_submit_buf()
681 psp_gfx_cmd_name(psp->cmd_buf_mem->cmd_id), psp->cmd_buf_mem->cmd_id, in psp_cmd_submit_buf()
682 psp->cmd_buf_mem->resp.status); in psp_cmd_submit_buf()
687 if ((ucode && amdgpu_sriov_vf(psp->adev)) || !timeout) { in psp_cmd_submit_buf()
694 ucode->tmr_mc_addr_lo = psp->cmd_buf_mem->resp.fw_addr_lo; in psp_cmd_submit_buf()
695 ucode->tmr_mc_addr_hi = psp->cmd_buf_mem->resp.fw_addr_hi; in psp_cmd_submit_buf()
702 static struct psp_gfx_cmd_resp *acquire_psp_cmd_buf(struct psp_context *psp) in acquire_psp_cmd_buf() argument
704 struct psp_gfx_cmd_resp *cmd = psp->cmd; in acquire_psp_cmd_buf()
706 mutex_lock(&psp->mutex); in acquire_psp_cmd_buf()
713 static void release_psp_cmd_buf(struct psp_context *psp) in release_psp_cmd_buf() argument
715 mutex_unlock(&psp->mutex); in release_psp_cmd_buf()
718 static void psp_prep_tmr_cmd_buf(struct psp_context *psp, in psp_prep_tmr_cmd_buf() argument
722 struct amdgpu_device *adev = psp->adev; in psp_prep_tmr_cmd_buf()
731 if (amdgpu_sriov_vf(psp->adev)) in psp_prep_tmr_cmd_buf()
753 static int psp_load_toc(struct psp_context *psp, in psp_load_toc() argument
757 struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); in psp_load_toc()
760 psp_copy_fw(psp, psp->toc.start_addr, psp->toc.size_bytes); in psp_load_toc()
762 psp_prep_load_toc_cmd_buf(cmd, psp->fw_pri_mc_addr, psp->toc.size_bytes); in psp_load_toc()
764 ret = psp_cmd_submit_buf(psp, NULL, cmd, in psp_load_toc()
765 psp->fence_buf_mc_addr); in psp_load_toc()
767 *tmr_size = psp->cmd_buf_mem->resp.tmr_size; in psp_load_toc()
769 release_psp_cmd_buf(psp); in psp_load_toc()
774 static bool psp_boottime_tmr(struct psp_context *psp) in psp_boottime_tmr() argument
776 switch (psp->adev->ip_versions[MP0_HWIP][0]) { in psp_boottime_tmr()
785 static int psp_tmr_init(struct psp_context *psp) in psp_tmr_init() argument
799 tmr_size = PSP_TMR_SIZE(psp->adev); in psp_tmr_init()
804 if (!amdgpu_sriov_vf(psp->adev) && in psp_tmr_init()
805 psp->toc.start_addr && in psp_tmr_init()
806 psp->toc.size_bytes && in psp_tmr_init()
807 psp->fw_pri_buf) { in psp_tmr_init()
808 ret = psp_load_toc(psp, &tmr_size); in psp_tmr_init()
815 if (!psp->tmr_bo) { in psp_tmr_init()
816 pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL; in psp_tmr_init()
817 ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, in psp_tmr_init()
819 AMDGPU_HAS_VRAM(psp->adev) ? in psp_tmr_init()
822 &psp->tmr_bo, &psp->tmr_mc_addr, in psp_tmr_init()
829 static bool psp_skip_tmr(struct psp_context *psp) in psp_skip_tmr() argument
831 switch (psp->adev->ip_versions[MP0_HWIP][0]) { in psp_skip_tmr()
843 static int psp_tmr_load(struct psp_context *psp) in psp_tmr_load() argument
851 if (amdgpu_sriov_vf(psp->adev) && psp_skip_tmr(psp)) in psp_tmr_load()
854 cmd = acquire_psp_cmd_buf(psp); in psp_tmr_load()
856 psp_prep_tmr_cmd_buf(psp, cmd, psp->tmr_mc_addr, psp->tmr_bo); in psp_tmr_load()
857 if (psp->tmr_bo) in psp_tmr_load()
859 amdgpu_bo_size(psp->tmr_bo), psp->tmr_mc_addr); in psp_tmr_load()
861 ret = psp_cmd_submit_buf(psp, NULL, cmd, in psp_tmr_load()
862 psp->fence_buf_mc_addr); in psp_tmr_load()
864 release_psp_cmd_buf(psp); in psp_tmr_load()
869 static void psp_prep_tmr_unload_cmd_buf(struct psp_context *psp, in psp_prep_tmr_unload_cmd_buf() argument
872 if (amdgpu_sriov_vf(psp->adev)) in psp_prep_tmr_unload_cmd_buf()
878 static int psp_tmr_unload(struct psp_context *psp) in psp_tmr_unload() argument
886 if (amdgpu_sriov_vf(psp->adev) && psp_skip_tmr(psp)) in psp_tmr_unload()
889 cmd = acquire_psp_cmd_buf(psp); in psp_tmr_unload()
891 psp_prep_tmr_unload_cmd_buf(psp, cmd); in psp_tmr_unload()
892 dev_dbg(psp->adev->dev, "free PSP TMR buffer\n"); in psp_tmr_unload()
894 ret = psp_cmd_submit_buf(psp, NULL, cmd, in psp_tmr_unload()
895 psp->fence_buf_mc_addr); in psp_tmr_unload()
897 release_psp_cmd_buf(psp); in psp_tmr_unload()
902 static int psp_tmr_terminate(struct psp_context *psp) in psp_tmr_terminate() argument
904 return psp_tmr_unload(psp); in psp_tmr_terminate()
907 int psp_get_fw_attestation_records_addr(struct psp_context *psp, in psp_get_fw_attestation_records_addr() argument
916 if (amdgpu_sriov_vf(psp->adev)) in psp_get_fw_attestation_records_addr()
919 cmd = acquire_psp_cmd_buf(psp); in psp_get_fw_attestation_records_addr()
923 ret = psp_cmd_submit_buf(psp, NULL, cmd, in psp_get_fw_attestation_records_addr()
924 psp->fence_buf_mc_addr); in psp_get_fw_attestation_records_addr()
931 release_psp_cmd_buf(psp); in psp_get_fw_attestation_records_addr()
938 struct psp_context *psp = &adev->psp; in psp_boot_config_get() local
945 cmd = acquire_psp_cmd_buf(psp); in psp_boot_config_get()
950 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); in psp_boot_config_get()
956 release_psp_cmd_buf(psp); in psp_boot_config_get()
964 struct psp_context *psp = &adev->psp; in psp_boot_config_set() local
970 cmd = acquire_psp_cmd_buf(psp); in psp_boot_config_set()
977 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); in psp_boot_config_set()
979 release_psp_cmd_buf(psp); in psp_boot_config_set()
987 struct psp_context *psp = &adev->psp; in psp_rl_load() local
990 if (!is_psp_fw_valid(psp->rl)) in psp_rl_load()
993 cmd = acquire_psp_cmd_buf(psp); in psp_rl_load()
995 memset(psp->fw_pri_buf, 0, PSP_1_MEG); in psp_rl_load()
996 memcpy(psp->fw_pri_buf, psp->rl.start_addr, psp->rl.size_bytes); in psp_rl_load()
999 cmd->cmd.cmd_load_ip_fw.fw_phy_addr_lo = lower_32_bits(psp->fw_pri_mc_addr); in psp_rl_load()
1000 cmd->cmd.cmd_load_ip_fw.fw_phy_addr_hi = upper_32_bits(psp->fw_pri_mc_addr); in psp_rl_load()
1001 cmd->cmd.cmd_load_ip_fw.fw_size = psp->rl.size_bytes; in psp_rl_load()
1004 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); in psp_rl_load()
1006 release_psp_cmd_buf(psp); in psp_rl_load()
1011 int psp_spatial_partition(struct psp_context *psp, int mode) in psp_spatial_partition() argument
1016 if (amdgpu_sriov_vf(psp->adev)) in psp_spatial_partition()
1019 cmd = acquire_psp_cmd_buf(psp); in psp_spatial_partition()
1024 dev_info(psp->adev->dev, "Requesting %d partitions through PSP", mode); in psp_spatial_partition()
1025 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); in psp_spatial_partition()
1027 release_psp_cmd_buf(psp); in psp_spatial_partition()
1032 static int psp_asd_initialize(struct psp_context *psp) in psp_asd_initialize() argument
1040 if (amdgpu_sriov_vf(psp->adev) || !psp->asd_context.bin_desc.size_bytes) in psp_asd_initialize()
1043 psp->asd_context.mem_context.shared_mc_addr = 0; in psp_asd_initialize()
1044 psp->asd_context.mem_context.shared_mem_size = PSP_ASD_SHARED_MEM_SIZE; in psp_asd_initialize()
1045 psp->asd_context.ta_load_type = GFX_CMD_ID_LOAD_ASD; in psp_asd_initialize()
1047 ret = psp_ta_load(psp, &psp->asd_context); in psp_asd_initialize()
1049 psp->asd_context.initialized = true; in psp_asd_initialize()
1061 int psp_ta_unload(struct psp_context *psp, struct ta_context *context) in psp_ta_unload() argument
1064 struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); in psp_ta_unload()
1068 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); in psp_ta_unload()
1072 release_psp_cmd_buf(psp); in psp_ta_unload()
1077 static int psp_asd_terminate(struct psp_context *psp) in psp_asd_terminate() argument
1081 if (amdgpu_sriov_vf(psp->adev)) in psp_asd_terminate()
1084 if (!psp->asd_context.initialized) in psp_asd_terminate()
1087 ret = psp_ta_unload(psp, &psp->asd_context); in psp_asd_terminate()
1089 psp->asd_context.initialized = false; in psp_asd_terminate()
1102 int psp_reg_program(struct psp_context *psp, enum psp_reg_prog_id reg, in psp_reg_program() argument
1111 cmd = acquire_psp_cmd_buf(psp); in psp_reg_program()
1114 ret = psp_cmd_submit_buf(psp, NULL, cmd, psp->fence_buf_mc_addr); in psp_reg_program()
1118 release_psp_cmd_buf(psp); in psp_reg_program()
1139 int psp_ta_init_shared_buf(struct psp_context *psp, in psp_ta_init_shared_buf() argument
1146 return amdgpu_bo_create_kernel(psp->adev, mem_ctx->shared_mem_size, in psp_ta_init_shared_buf()
1163 int psp_ta_invoke(struct psp_context *psp, in psp_ta_invoke() argument
1168 struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); in psp_ta_invoke()
1172 ret = psp_cmd_submit_buf(psp, NULL, cmd, in psp_ta_invoke()
1173 psp->fence_buf_mc_addr); in psp_ta_invoke()
1177 release_psp_cmd_buf(psp); in psp_ta_invoke()
1182 int psp_ta_load(struct psp_context *psp, struct ta_context *context) in psp_ta_load() argument
1187 cmd = acquire_psp_cmd_buf(psp); in psp_ta_load()
1189 psp_copy_fw(psp, context->bin_desc.start_addr, in psp_ta_load()
1192 psp_prep_ta_load_cmd_buf(cmd, psp->fw_pri_mc_addr, context); in psp_ta_load()
1194 ret = psp_cmd_submit_buf(psp, NULL, cmd, in psp_ta_load()
1195 psp->fence_buf_mc_addr); in psp_ta_load()
1202 release_psp_cmd_buf(psp); in psp_ta_load()
1207 int psp_xgmi_invoke(struct psp_context *psp, uint32_t ta_cmd_id) in psp_xgmi_invoke() argument
1209 return psp_ta_invoke(psp, ta_cmd_id, &psp->xgmi_context.context); in psp_xgmi_invoke()
1212 int psp_xgmi_terminate(struct psp_context *psp) in psp_xgmi_terminate() argument
1215 struct amdgpu_device *adev = psp->adev; in psp_xgmi_terminate()
1223 if (!psp->xgmi_context.context.initialized) in psp_xgmi_terminate()
1226 ret = psp_ta_unload(psp, &psp->xgmi_context.context); in psp_xgmi_terminate()
1228 psp->xgmi_context.context.initialized = false; in psp_xgmi_terminate()
1233 int psp_xgmi_initialize(struct psp_context *psp, bool set_extended_data, bool load_ta) in psp_xgmi_initialize() argument
1238 if (!psp->ta_fw || in psp_xgmi_initialize()
1239 !psp->xgmi_context.context.bin_desc.size_bytes || in psp_xgmi_initialize()
1240 !psp->xgmi_context.context.bin_desc.start_addr) in psp_xgmi_initialize()
1246 psp->xgmi_context.context.mem_context.shared_mem_size = PSP_XGMI_SHARED_MEM_SIZE; in psp_xgmi_initialize()
1247 psp->xgmi_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA; in psp_xgmi_initialize()
1249 if (!psp->xgmi_context.context.mem_context.shared_buf) { in psp_xgmi_initialize()
1250 ret = psp_ta_init_shared_buf(psp, &psp->xgmi_context.context.mem_context); in psp_xgmi_initialize()
1256 ret = psp_ta_load(psp, &psp->xgmi_context.context); in psp_xgmi_initialize()
1258 psp->xgmi_context.context.initialized = true; in psp_xgmi_initialize()
1264 xgmi_cmd = (struct ta_xgmi_shared_memory *)(psp->xgmi_context.context.mem_context.shared_buf); in psp_xgmi_initialize()
1269 ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id); in psp_xgmi_initialize()
1274 int psp_xgmi_get_hive_id(struct psp_context *psp, uint64_t *hive_id) in psp_xgmi_get_hive_id() argument
1279 xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.context.mem_context.shared_buf; in psp_xgmi_get_hive_id()
1285 ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id); in psp_xgmi_get_hive_id()
1294 int psp_xgmi_get_node_id(struct psp_context *psp, uint64_t *node_id) in psp_xgmi_get_node_id() argument
1299 xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.context.mem_context.shared_buf; in psp_xgmi_get_node_id()
1305 ret = psp_xgmi_invoke(psp, xgmi_cmd->cmd_id); in psp_xgmi_get_node_id()
1314 static bool psp_xgmi_peer_link_info_supported(struct psp_context *psp) in psp_xgmi_peer_link_info_supported() argument
1316 return (psp->adev->ip_versions[MP0_HWIP][0] == IP_VERSION(13, 0, 2) && in psp_xgmi_peer_link_info_supported()
1317 psp->xgmi_context.context.bin_desc.fw_version >= 0x2000000b) || in psp_xgmi_peer_link_info_supported()
1318 psp->adev->ip_versions[MP0_HWIP][0] >= IP_VERSION(13, 0, 6); in psp_xgmi_peer_link_info_supported()
1328 static void psp_xgmi_reflect_topology_info(struct psp_context *psp, in psp_xgmi_reflect_topology_info() argument
1333 uint64_t src_node_id = psp->adev->gmc.xgmi.node_id; in psp_xgmi_reflect_topology_info()
1338 hive = amdgpu_get_xgmi_hive(psp->adev); in psp_xgmi_reflect_topology_info()
1349 mirror_top_info = &mirror_adev->psp.xgmi_context.top_info; in psp_xgmi_reflect_topology_info()
1372 int psp_xgmi_get_topology_info(struct psp_context *psp, in psp_xgmi_get_topology_info() argument
1386 xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.context.mem_context.shared_buf; in psp_xgmi_get_topology_info()
1403 ret = psp_xgmi_invoke(psp, TA_COMMAND_XGMI__GET_GET_TOPOLOGY_INFO); in psp_xgmi_get_topology_info()
1427 if (psp_xgmi_peer_link_info_supported(psp)) { in psp_xgmi_get_topology_info()
1430 (psp->xgmi_context.supports_extended_data && get_extended_data) || in psp_xgmi_get_topology_info()
1431 psp->adev->ip_versions[MP0_HWIP][0] == IP_VERSION(13, 0, 6); in psp_xgmi_get_topology_info()
1435 ret = psp_xgmi_invoke(psp, TA_COMMAND_XGMI__GET_PEER_LINKS); in psp_xgmi_get_topology_info()
1451 psp_xgmi_reflect_topology_info(psp, topology->nodes[i]); in psp_xgmi_get_topology_info()
1458 int psp_xgmi_set_topology_info(struct psp_context *psp, in psp_xgmi_set_topology_info() argument
1469 xgmi_cmd = (struct ta_xgmi_shared_memory *)psp->xgmi_context.context.mem_context.shared_buf; in psp_xgmi_set_topology_info()
1484 return psp_xgmi_invoke(psp, TA_COMMAND_XGMI__SET_TOPOLOGY_INFO); in psp_xgmi_set_topology_info()
1488 static void psp_ras_ta_check_status(struct psp_context *psp) in psp_ras_ta_check_status() argument
1491 (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; in psp_ras_ta_check_status()
1495 dev_warn(psp->adev->dev, in psp_ras_ta_check_status()
1499 dev_warn(psp->adev->dev, in psp_ras_ta_check_status()
1506 dev_warn(psp->adev->dev, in psp_ras_ta_check_status()
1510 dev_warn(psp->adev->dev, in psp_ras_ta_check_status()
1516 int psp_ras_invoke(struct psp_context *psp, uint32_t ta_cmd_id) in psp_ras_invoke() argument
1521 ras_cmd = (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; in psp_ras_invoke()
1526 if (amdgpu_sriov_vf(psp->adev)) in psp_ras_invoke()
1529 ret = psp_ta_invoke(psp, ta_cmd_id, &psp->ras_context.context); in psp_ras_invoke()
1541 dev_warn(psp->adev->dev, "ECC switch disabled\n"); in psp_ras_invoke()
1545 dev_warn(psp->adev->dev, in psp_ras_invoke()
1548 psp_ras_ta_check_status(psp); in psp_ras_invoke()
1554 int psp_ras_enable_features(struct psp_context *psp, in psp_ras_enable_features() argument
1560 if (!psp->ras_context.context.initialized) in psp_ras_enable_features()
1563 ras_cmd = (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; in psp_ras_enable_features()
1573 ret = psp_ras_invoke(psp, ras_cmd->cmd_id); in psp_ras_enable_features()
1580 int psp_ras_terminate(struct psp_context *psp) in psp_ras_terminate() argument
1587 if (amdgpu_sriov_vf(psp->adev)) in psp_ras_terminate()
1590 if (!psp->ras_context.context.initialized) in psp_ras_terminate()
1593 ret = psp_ta_unload(psp, &psp->ras_context.context); in psp_ras_terminate()
1595 psp->ras_context.context.initialized = false; in psp_ras_terminate()
1600 int psp_ras_initialize(struct psp_context *psp) in psp_ras_initialize() argument
1604 struct amdgpu_device *adev = psp->adev; in psp_ras_initialize()
1613 if (!adev->psp.ras_context.context.bin_desc.size_bytes || in psp_ras_initialize()
1614 !adev->psp.ras_context.context.bin_desc.start_addr) { in psp_ras_initialize()
1627 if (!amdgpu_ras_is_supported(psp->adev, AMDGPU_RAS_BLOCK__UMC)) { in psp_ras_initialize()
1659 psp->ras_context.context.mem_context.shared_mem_size = PSP_RAS_SHARED_MEM_SIZE; in psp_ras_initialize()
1660 psp->ras_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA; in psp_ras_initialize()
1662 if (!psp->ras_context.context.mem_context.shared_buf) { in psp_ras_initialize()
1663 ret = psp_ta_init_shared_buf(psp, &psp->ras_context.context.mem_context); in psp_ras_initialize()
1668 ras_cmd = (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; in psp_ras_initialize()
1679 ret = psp_ta_load(psp, &psp->ras_context.context); in psp_ras_initialize()
1682 psp->ras_context.context.initialized = true; in psp_ras_initialize()
1685 dev_warn(psp->adev->dev, "RAS Init Status: 0x%X\n", ras_cmd->ras_status); in psp_ras_initialize()
1688 psp->ras_context.context.initialized = false; in psp_ras_initialize()
1694 int psp_ras_trigger_error(struct psp_context *psp, in psp_ras_trigger_error() argument
1698 struct amdgpu_device *adev = psp->adev; in psp_ras_trigger_error()
1702 if (!psp->ras_context.context.initialized) in psp_ras_trigger_error()
1726 ras_cmd = (struct ta_ras_shared_memory *)psp->ras_context.context.mem_context.shared_buf; in psp_ras_trigger_error()
1732 ret = psp_ras_invoke(psp, ras_cmd->cmd_id); in psp_ras_trigger_error()
1752 static int psp_hdcp_initialize(struct psp_context *psp) in psp_hdcp_initialize() argument
1759 if (amdgpu_sriov_vf(psp->adev)) in psp_hdcp_initialize()
1762 if (!psp->hdcp_context.context.bin_desc.size_bytes || in psp_hdcp_initialize()
1763 !psp->hdcp_context.context.bin_desc.start_addr) { in psp_hdcp_initialize()
1764 dev_info(psp->adev->dev, "HDCP: optional hdcp ta ucode is not available\n"); in psp_hdcp_initialize()
1768 psp->hdcp_context.context.mem_context.shared_mem_size = PSP_HDCP_SHARED_MEM_SIZE; in psp_hdcp_initialize()
1769 psp->hdcp_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA; in psp_hdcp_initialize()
1771 if (!psp->hdcp_context.context.mem_context.shared_buf) { in psp_hdcp_initialize()
1772 ret = psp_ta_init_shared_buf(psp, &psp->hdcp_context.context.mem_context); in psp_hdcp_initialize()
1777 ret = psp_ta_load(psp, &psp->hdcp_context.context); in psp_hdcp_initialize()
1779 psp->hdcp_context.context.initialized = true; in psp_hdcp_initialize()
1780 mutex_init(&psp->hdcp_context.mutex); in psp_hdcp_initialize()
1786 int psp_hdcp_invoke(struct psp_context *psp, uint32_t ta_cmd_id) in psp_hdcp_invoke() argument
1791 if (amdgpu_sriov_vf(psp->adev)) in psp_hdcp_invoke()
1794 return psp_ta_invoke(psp, ta_cmd_id, &psp->hdcp_context.context); in psp_hdcp_invoke()
1797 static int psp_hdcp_terminate(struct psp_context *psp) in psp_hdcp_terminate() argument
1804 if (amdgpu_sriov_vf(psp->adev)) in psp_hdcp_terminate()
1807 if (!psp->hdcp_context.context.initialized) in psp_hdcp_terminate()
1810 ret = psp_ta_unload(psp, &psp->hdcp_context.context); in psp_hdcp_terminate()
1812 psp->hdcp_context.context.initialized = false; in psp_hdcp_terminate()
1819 static int psp_dtm_initialize(struct psp_context *psp) in psp_dtm_initialize() argument
1826 if (amdgpu_sriov_vf(psp->adev)) in psp_dtm_initialize()
1829 if (!psp->dtm_context.context.bin_desc.size_bytes || in psp_dtm_initialize()
1830 !psp->dtm_context.context.bin_desc.start_addr) { in psp_dtm_initialize()
1831 dev_info(psp->adev->dev, "DTM: optional dtm ta ucode is not available\n"); in psp_dtm_initialize()
1835 psp->dtm_context.context.mem_context.shared_mem_size = PSP_DTM_SHARED_MEM_SIZE; in psp_dtm_initialize()
1836 psp->dtm_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA; in psp_dtm_initialize()
1838 if (!psp->dtm_context.context.mem_context.shared_buf) { in psp_dtm_initialize()
1839 ret = psp_ta_init_shared_buf(psp, &psp->dtm_context.context.mem_context); in psp_dtm_initialize()
1844 ret = psp_ta_load(psp, &psp->dtm_context.context); in psp_dtm_initialize()
1846 psp->dtm_context.context.initialized = true; in psp_dtm_initialize()
1847 mutex_init(&psp->dtm_context.mutex); in psp_dtm_initialize()
1853 int psp_dtm_invoke(struct psp_context *psp, uint32_t ta_cmd_id) in psp_dtm_invoke() argument
1858 if (amdgpu_sriov_vf(psp->adev)) in psp_dtm_invoke()
1861 return psp_ta_invoke(psp, ta_cmd_id, &psp->dtm_context.context); in psp_dtm_invoke()
1864 static int psp_dtm_terminate(struct psp_context *psp) in psp_dtm_terminate() argument
1871 if (amdgpu_sriov_vf(psp->adev)) in psp_dtm_terminate()
1874 if (!psp->dtm_context.context.initialized) in psp_dtm_terminate()
1877 ret = psp_ta_unload(psp, &psp->dtm_context.context); in psp_dtm_terminate()
1879 psp->dtm_context.context.initialized = false; in psp_dtm_terminate()
1886 static int psp_rap_initialize(struct psp_context *psp) in psp_rap_initialize() argument
1894 if (amdgpu_sriov_vf(psp->adev)) in psp_rap_initialize()
1897 if (!psp->rap_context.context.bin_desc.size_bytes || in psp_rap_initialize()
1898 !psp->rap_context.context.bin_desc.start_addr) { in psp_rap_initialize()
1899 dev_info(psp->adev->dev, "RAP: optional rap ta ucode is not available\n"); in psp_rap_initialize()
1903 psp->rap_context.context.mem_context.shared_mem_size = PSP_RAP_SHARED_MEM_SIZE; in psp_rap_initialize()
1904 psp->rap_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA; in psp_rap_initialize()
1906 if (!psp->rap_context.context.mem_context.shared_buf) { in psp_rap_initialize()
1907 ret = psp_ta_init_shared_buf(psp, &psp->rap_context.context.mem_context); in psp_rap_initialize()
1912 ret = psp_ta_load(psp, &psp->rap_context.context); in psp_rap_initialize()
1914 psp->rap_context.context.initialized = true; in psp_rap_initialize()
1915 mutex_init(&psp->rap_context.mutex); in psp_rap_initialize()
1919 ret = psp_rap_invoke(psp, TA_CMD_RAP__INITIALIZE, &status); in psp_rap_initialize()
1921 psp_rap_terminate(psp); in psp_rap_initialize()
1923 psp_ta_free_shared_buf(&psp->rap_context.context.mem_context); in psp_rap_initialize()
1925 dev_warn(psp->adev->dev, "RAP TA initialize fail (%d) status %d.\n", in psp_rap_initialize()
1934 static int psp_rap_terminate(struct psp_context *psp) in psp_rap_terminate() argument
1938 if (!psp->rap_context.context.initialized) in psp_rap_terminate()
1941 ret = psp_ta_unload(psp, &psp->rap_context.context); in psp_rap_terminate()
1943 psp->rap_context.context.initialized = false; in psp_rap_terminate()
1948 int psp_rap_invoke(struct psp_context *psp, uint32_t ta_cmd_id, enum ta_rap_status *status) in psp_rap_invoke() argument
1953 if (!psp->rap_context.context.initialized) in psp_rap_invoke()
1960 mutex_lock(&psp->rap_context.mutex); in psp_rap_invoke()
1963 psp->rap_context.context.mem_context.shared_buf; in psp_rap_invoke()
1969 ret = psp_ta_invoke(psp, rap_cmd->cmd_id, &psp->rap_context.context); in psp_rap_invoke()
1977 mutex_unlock(&psp->rap_context.mutex); in psp_rap_invoke()
1984 static int psp_securedisplay_initialize(struct psp_context *psp) in psp_securedisplay_initialize() argument
1992 if (amdgpu_sriov_vf(psp->adev)) in psp_securedisplay_initialize()
1995 if (!psp->securedisplay_context.context.bin_desc.size_bytes || in psp_securedisplay_initialize()
1996 !psp->securedisplay_context.context.bin_desc.start_addr) { in psp_securedisplay_initialize()
1997 dev_info(psp->adev->dev, "SECUREDISPLAY: securedisplay ta ucode is not available\n"); in psp_securedisplay_initialize()
2001 psp->securedisplay_context.context.mem_context.shared_mem_size = in psp_securedisplay_initialize()
2003 psp->securedisplay_context.context.ta_load_type = GFX_CMD_ID_LOAD_TA; in psp_securedisplay_initialize()
2005 if (!psp->securedisplay_context.context.initialized) { in psp_securedisplay_initialize()
2006 ret = psp_ta_init_shared_buf(psp, in psp_securedisplay_initialize()
2007 &psp->securedisplay_context.context.mem_context); in psp_securedisplay_initialize()
2012 ret = psp_ta_load(psp, &psp->securedisplay_context.context); in psp_securedisplay_initialize()
2014 psp->securedisplay_context.context.initialized = true; in psp_securedisplay_initialize()
2015 mutex_init(&psp->securedisplay_context.mutex); in psp_securedisplay_initialize()
2019 mutex_lock(&psp->securedisplay_context.mutex); in psp_securedisplay_initialize()
2021 psp_prep_securedisplay_cmd_buf(psp, &securedisplay_cmd, in psp_securedisplay_initialize()
2024 ret = psp_securedisplay_invoke(psp, TA_SECUREDISPLAY_COMMAND__QUERY_TA); in psp_securedisplay_initialize()
2026 mutex_unlock(&psp->securedisplay_context.mutex); in psp_securedisplay_initialize()
2029 psp_securedisplay_terminate(psp); in psp_securedisplay_initialize()
2031 psp_ta_free_shared_buf(&psp->securedisplay_context.context.mem_context); in psp_securedisplay_initialize()
2032 dev_err(psp->adev->dev, "SECUREDISPLAY TA initialize fail.\n"); in psp_securedisplay_initialize()
2037 psp_securedisplay_parse_resp_status(psp, securedisplay_cmd->status); in psp_securedisplay_initialize()
2038 dev_err(psp->adev->dev, "SECUREDISPLAY: query securedisplay TA failed. ret 0x%x\n", in psp_securedisplay_initialize()
2041 psp->securedisplay_context.context.bin_desc.size_bytes = 0; in psp_securedisplay_initialize()
2047 static int psp_securedisplay_terminate(struct psp_context *psp) in psp_securedisplay_terminate() argument
2054 if (amdgpu_sriov_vf(psp->adev)) in psp_securedisplay_terminate()
2057 if (!psp->securedisplay_context.context.initialized) in psp_securedisplay_terminate()
2060 ret = psp_ta_unload(psp, &psp->securedisplay_context.context); in psp_securedisplay_terminate()
2062 psp->securedisplay_context.context.initialized = false; in psp_securedisplay_terminate()
2067 int psp_securedisplay_invoke(struct psp_context *psp, uint32_t ta_cmd_id) in psp_securedisplay_invoke() argument
2071 if (!psp->securedisplay_context.context.initialized) in psp_securedisplay_invoke()
2078 ret = psp_ta_invoke(psp, ta_cmd_id, &psp->securedisplay_context.context); in psp_securedisplay_invoke()
2086 struct psp_context *psp = &adev->psp; in amdgpu_psp_wait_for_bootloader() local
2089 if (!amdgpu_sriov_vf(adev) && psp->funcs && psp->funcs->wait_for_bootloader != NULL) in amdgpu_psp_wait_for_bootloader()
2090 ret = psp->funcs->wait_for_bootloader(psp); in amdgpu_psp_wait_for_bootloader()
2095 static int psp_hw_start(struct psp_context *psp) in psp_hw_start() argument
2097 struct amdgpu_device *adev = psp->adev; in psp_hw_start()
2101 if ((is_psp_fw_valid(psp->kdb)) && in psp_hw_start()
2102 (psp->funcs->bootloader_load_kdb != NULL)) { in psp_hw_start()
2103 ret = psp_bootloader_load_kdb(psp); in psp_hw_start()
2110 if ((is_psp_fw_valid(psp->spl)) && in psp_hw_start()
2111 (psp->funcs->bootloader_load_spl != NULL)) { in psp_hw_start()
2112 ret = psp_bootloader_load_spl(psp); in psp_hw_start()
2119 if ((is_psp_fw_valid(psp->sys)) && in psp_hw_start()
2120 (psp->funcs->bootloader_load_sysdrv != NULL)) { in psp_hw_start()
2121 ret = psp_bootloader_load_sysdrv(psp); in psp_hw_start()
2128 if ((is_psp_fw_valid(psp->soc_drv)) && in psp_hw_start()
2129 (psp->funcs->bootloader_load_soc_drv != NULL)) { in psp_hw_start()
2130 ret = psp_bootloader_load_soc_drv(psp); in psp_hw_start()
2137 if ((is_psp_fw_valid(psp->intf_drv)) && in psp_hw_start()
2138 (psp->funcs->bootloader_load_intf_drv != NULL)) { in psp_hw_start()
2139 ret = psp_bootloader_load_intf_drv(psp); in psp_hw_start()
2146 if ((is_psp_fw_valid(psp->dbg_drv)) && in psp_hw_start()
2147 (psp->funcs->bootloader_load_dbg_drv != NULL)) { in psp_hw_start()
2148 ret = psp_bootloader_load_dbg_drv(psp); in psp_hw_start()
2155 if ((is_psp_fw_valid(psp->ras_drv)) && in psp_hw_start()
2156 (psp->funcs->bootloader_load_ras_drv != NULL)) { in psp_hw_start()
2157 ret = psp_bootloader_load_ras_drv(psp); in psp_hw_start()
2164 if ((is_psp_fw_valid(psp->sos)) && in psp_hw_start()
2165 (psp->funcs->bootloader_load_sos != NULL)) { in psp_hw_start()
2166 ret = psp_bootloader_load_sos(psp); in psp_hw_start()
2174 ret = psp_ring_create(psp, PSP_RING_TYPE__KM); in psp_hw_start()
2183 if (!psp_boottime_tmr(psp)) { in psp_hw_start()
2184 ret = psp_tmr_init(psp); in psp_hw_start()
2197 if (psp->pmfw_centralized_cstate_management) { in psp_hw_start()
2198 ret = psp_load_smu_fw(psp); in psp_hw_start()
2203 ret = psp_tmr_load(psp); in psp_hw_start()
2404 static void psp_print_fw_hdr(struct psp_context *psp, in psp_print_fw_hdr() argument
2407 struct amdgpu_device *adev = psp->adev; in psp_print_fw_hdr()
2470 int psp_execute_ip_fw_load(struct psp_context *psp, in psp_execute_ip_fw_load() argument
2474 struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); in psp_execute_ip_fw_load()
2478 ret = psp_cmd_submit_buf(psp, ucode, cmd, in psp_execute_ip_fw_load()
2479 psp->fence_buf_mc_addr); in psp_execute_ip_fw_load()
2482 release_psp_cmd_buf(psp); in psp_execute_ip_fw_load()
2487 static int psp_load_smu_fw(struct psp_context *psp) in psp_load_smu_fw() argument
2490 struct amdgpu_device *adev = psp->adev; in psp_load_smu_fw()
2493 struct amdgpu_ras *ras = psp->ras_context.ras; in psp_load_smu_fw()
2502 if (!ucode->fw || amdgpu_sriov_vf(psp->adev)) in psp_load_smu_fw()
2514 ret = psp_execute_ip_fw_load(psp, ucode); in psp_load_smu_fw()
2522 static bool fw_load_skip_check(struct psp_context *psp, in fw_load_skip_check() argument
2529 (psp_smu_reload_quirk(psp) || in fw_load_skip_check()
2530 psp->autoload_supported || in fw_load_skip_check()
2531 psp->pmfw_centralized_cstate_management)) in fw_load_skip_check()
2534 if (amdgpu_sriov_vf(psp->adev) && in fw_load_skip_check()
2535 amdgpu_virt_fw_load_skip_check(psp->adev, ucode->ucode_id)) in fw_load_skip_check()
2538 if (psp->autoload_supported && in fw_load_skip_check()
2547 int psp_load_fw_list(struct psp_context *psp, in psp_load_fw_list() argument
2555 psp_print_fw_hdr(psp, ucode); in psp_load_fw_list()
2556 ret = psp_execute_ip_fw_load(psp, ucode); in psp_load_fw_list()
2563 static int psp_load_non_psp_fw(struct psp_context *psp) in psp_load_non_psp_fw() argument
2567 struct amdgpu_device *adev = psp->adev; in psp_load_non_psp_fw()
2569 if (psp->autoload_supported && in psp_load_non_psp_fw()
2570 !psp->pmfw_centralized_cstate_management) { in psp_load_non_psp_fw()
2571 ret = psp_load_smu_fw(psp); in psp_load_non_psp_fw()
2580 !fw_load_skip_check(psp, ucode)) { in psp_load_non_psp_fw()
2581 ret = psp_load_smu_fw(psp); in psp_load_non_psp_fw()
2587 if (fw_load_skip_check(psp, ucode)) in psp_load_non_psp_fw()
2590 if (psp->autoload_supported && in psp_load_non_psp_fw()
2602 psp_print_fw_hdr(psp, ucode); in psp_load_non_psp_fw()
2604 ret = psp_execute_ip_fw_load(psp, ucode); in psp_load_non_psp_fw()
2609 if (psp->autoload_supported && ucode->ucode_id == (amdgpu_sriov_vf(adev) ? in psp_load_non_psp_fw()
2611 ret = psp_rlc_autoload_start(psp); in psp_load_non_psp_fw()
2625 struct psp_context *psp = &adev->psp; in psp_load_fw() local
2629 psp_ring_stop(psp, PSP_RING_TYPE__KM); in psp_load_fw()
2631 memset(psp->fence_buf, 0, PSP_FENCE_BUFFER_SIZE); in psp_load_fw()
2633 ret = psp_ring_init(psp, PSP_RING_TYPE__KM); in psp_load_fw()
2640 ret = psp_hw_start(psp); in psp_load_fw()
2644 ret = psp_load_non_psp_fw(psp); in psp_load_fw()
2648 ret = psp_asd_initialize(psp); in psp_load_fw()
2662 ret = psp_xgmi_initialize(psp, false, true); in psp_load_fw()
2667 dev_err(psp->adev->dev, in psp_load_fw()
2672 if (psp->ta_fw) { in psp_load_fw()
2673 ret = psp_ras_initialize(psp); in psp_load_fw()
2675 dev_err(psp->adev->dev, in psp_load_fw()
2678 ret = psp_hdcp_initialize(psp); in psp_load_fw()
2680 dev_err(psp->adev->dev, in psp_load_fw()
2683 ret = psp_dtm_initialize(psp); in psp_load_fw()
2685 dev_err(psp->adev->dev, in psp_load_fw()
2688 ret = psp_rap_initialize(psp); in psp_load_fw()
2690 dev_err(psp->adev->dev, in psp_load_fw()
2693 ret = psp_securedisplay_initialize(psp); in psp_load_fw()
2695 dev_err(psp->adev->dev, in psp_load_fw()
2702 psp_free_shared_bufs(psp); in psp_load_fw()
2709 psp_ring_destroy(psp, PSP_RING_TYPE__KM); in psp_load_fw()
2745 struct psp_context *psp = &adev->psp; in psp_hw_fini() local
2747 if (psp->ta_fw) { in psp_hw_fini()
2748 psp_ras_terminate(psp); in psp_hw_fini()
2749 psp_securedisplay_terminate(psp); in psp_hw_fini()
2750 psp_rap_terminate(psp); in psp_hw_fini()
2751 psp_dtm_terminate(psp); in psp_hw_fini()
2752 psp_hdcp_terminate(psp); in psp_hw_fini()
2755 psp_xgmi_terminate(psp); in psp_hw_fini()
2758 psp_asd_terminate(psp); in psp_hw_fini()
2759 psp_tmr_terminate(psp); in psp_hw_fini()
2761 psp_ring_destroy(psp, PSP_RING_TYPE__KM); in psp_hw_fini()
2770 struct psp_context *psp = &adev->psp; in psp_suspend() local
2773 psp->xgmi_context.context.initialized) { in psp_suspend()
2774 ret = psp_xgmi_terminate(psp); in psp_suspend()
2781 if (psp->ta_fw) { in psp_suspend()
2782 ret = psp_ras_terminate(psp); in psp_suspend()
2787 ret = psp_hdcp_terminate(psp); in psp_suspend()
2792 ret = psp_dtm_terminate(psp); in psp_suspend()
2797 ret = psp_rap_terminate(psp); in psp_suspend()
2802 ret = psp_securedisplay_terminate(psp); in psp_suspend()
2809 ret = psp_asd_terminate(psp); in psp_suspend()
2815 ret = psp_tmr_terminate(psp); in psp_suspend()
2821 ret = psp_ring_stop(psp, PSP_RING_TYPE__KM); in psp_suspend()
2833 struct psp_context *psp = &adev->psp; in psp_resume() local
2837 if (psp->mem_train_ctx.enable_mem_training) { in psp_resume()
2838 ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME); in psp_resume()
2847 ret = psp_hw_start(psp); in psp_resume()
2851 ret = psp_load_non_psp_fw(psp); in psp_resume()
2855 ret = psp_asd_initialize(psp); in psp_resume()
2868 ret = psp_xgmi_initialize(psp, false, true); in psp_resume()
2873 dev_err(psp->adev->dev, in psp_resume()
2877 if (psp->ta_fw) { in psp_resume()
2878 ret = psp_ras_initialize(psp); in psp_resume()
2880 dev_err(psp->adev->dev, in psp_resume()
2883 ret = psp_hdcp_initialize(psp); in psp_resume()
2885 dev_err(psp->adev->dev, in psp_resume()
2888 ret = psp_dtm_initialize(psp); in psp_resume()
2890 dev_err(psp->adev->dev, in psp_resume()
2893 ret = psp_rap_initialize(psp); in psp_resume()
2895 dev_err(psp->adev->dev, in psp_resume()
2898 ret = psp_securedisplay_initialize(psp); in psp_resume()
2900 dev_err(psp->adev->dev, in psp_resume()
2921 mutex_lock(&adev->psp.mutex); in psp_gpu_reset()
2922 ret = psp_mode1_reset(&adev->psp); in psp_gpu_reset()
2923 mutex_unlock(&adev->psp.mutex); in psp_gpu_reset()
2928 int psp_rlc_autoload_start(struct psp_context *psp) in psp_rlc_autoload_start() argument
2931 struct psp_gfx_cmd_resp *cmd = acquire_psp_cmd_buf(psp); in psp_rlc_autoload_start()
2935 ret = psp_cmd_submit_buf(psp, NULL, cmd, in psp_rlc_autoload_start()
2936 psp->fence_buf_mc_addr); in psp_rlc_autoload_start()
2938 release_psp_cmd_buf(psp); in psp_rlc_autoload_start()
2943 int psp_ring_cmd_submit(struct psp_context *psp, in psp_ring_cmd_submit() argument
2950 struct psp_ring *ring = &psp->km_ring; in psp_ring_cmd_submit()
2954 struct amdgpu_device *adev = psp->adev; in psp_ring_cmd_submit()
2959 psp_write_ptr_reg = psp_ring_get_wptr(psp); in psp_ring_cmd_submit()
2989 psp_ring_set_wptr(psp, psp_write_ptr_reg); in psp_ring_cmd_submit()
2993 int psp_init_asd_microcode(struct psp_context *psp, const char *chip_name) in psp_init_asd_microcode() argument
2995 struct amdgpu_device *adev = psp->adev; in psp_init_asd_microcode()
3001 err = amdgpu_ucode_request(adev, &adev->psp.asd_fw, fw_name); in psp_init_asd_microcode()
3005 asd_hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.asd_fw->data; in psp_init_asd_microcode()
3006 adev->psp.asd_context.bin_desc.fw_version = le32_to_cpu(asd_hdr->header.ucode_version); in psp_init_asd_microcode()
3007 adev->psp.asd_context.bin_desc.feature_version = le32_to_cpu(asd_hdr->sos.fw_version); in psp_init_asd_microcode()
3008 adev->psp.asd_context.bin_desc.size_bytes = le32_to_cpu(asd_hdr->header.ucode_size_bytes); in psp_init_asd_microcode()
3009 adev->psp.asd_context.bin_desc.start_addr = (uint8_t *)asd_hdr + in psp_init_asd_microcode()
3013 amdgpu_ucode_release(&adev->psp.asd_fw); in psp_init_asd_microcode()
3017 int psp_init_toc_microcode(struct psp_context *psp, const char *chip_name) in psp_init_toc_microcode() argument
3019 struct amdgpu_device *adev = psp->adev; in psp_init_toc_microcode()
3025 err = amdgpu_ucode_request(adev, &adev->psp.toc_fw, fw_name); in psp_init_toc_microcode()
3029 toc_hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.toc_fw->data; in psp_init_toc_microcode()
3030 adev->psp.toc.fw_version = le32_to_cpu(toc_hdr->header.ucode_version); in psp_init_toc_microcode()
3031 adev->psp.toc.feature_version = le32_to_cpu(toc_hdr->sos.fw_version); in psp_init_toc_microcode()
3032 adev->psp.toc.size_bytes = le32_to_cpu(toc_hdr->header.ucode_size_bytes); in psp_init_toc_microcode()
3033 adev->psp.toc.start_addr = (uint8_t *)toc_hdr + in psp_init_toc_microcode()
3037 amdgpu_ucode_release(&adev->psp.toc_fw); in psp_init_toc_microcode()
3041 static int parse_sos_bin_descriptor(struct psp_context *psp, in parse_sos_bin_descriptor() argument
3047 if (!psp || !desc || !sos_hdr) in parse_sos_bin_descriptor()
3056 psp->sos.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3057 psp->sos.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3058 psp->sos.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3059 psp->sos.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3062 psp->sys.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3063 psp->sys.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3064 psp->sys.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3065 psp->sys.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3068 psp->kdb.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3069 psp->kdb.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3070 psp->kdb.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3071 psp->kdb.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3074 psp->toc.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3075 psp->toc.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3076 psp->toc.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3077 psp->toc.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3080 psp->spl.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3081 psp->spl.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3082 psp->spl.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3083 psp->spl.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3086 psp->rl.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3087 psp->rl.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3088 psp->rl.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3089 psp->rl.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3092 psp->soc_drv.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3093 psp->soc_drv.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3094 psp->soc_drv.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3095 psp->soc_drv.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3098 psp->intf_drv.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3099 psp->intf_drv.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3100 psp->intf_drv.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3101 psp->intf_drv.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3104 psp->dbg_drv.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3105 psp->dbg_drv.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3106 psp->dbg_drv.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3107 psp->dbg_drv.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3110 psp->ras_drv.fw_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3111 psp->ras_drv.feature_version = le32_to_cpu(desc->fw_version); in parse_sos_bin_descriptor()
3112 psp->ras_drv.size_bytes = le32_to_cpu(desc->size_bytes); in parse_sos_bin_descriptor()
3113 psp->ras_drv.start_addr = ucode_start_addr; in parse_sos_bin_descriptor()
3116 dev_warn(psp->adev->dev, "Unsupported PSP FW type: %d\n", desc->fw_type); in parse_sos_bin_descriptor()
3129 sos_hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.sos_fw->data; in psp_init_sos_base_fw()
3135 adev->psp.sos.fw_version = le32_to_cpu(sos_hdr->header.ucode_version); in psp_init_sos_base_fw()
3136 adev->psp.sos.feature_version = le32_to_cpu(sos_hdr->sos.fw_version); in psp_init_sos_base_fw()
3138 adev->psp.sys.size_bytes = le32_to_cpu(sos_hdr->sos.offset_bytes); in psp_init_sos_base_fw()
3139 adev->psp.sys.start_addr = ucode_array_start_addr; in psp_init_sos_base_fw()
3141 adev->psp.sos.size_bytes = le32_to_cpu(sos_hdr->sos.size_bytes); in psp_init_sos_base_fw()
3142 adev->psp.sos.start_addr = ucode_array_start_addr + in psp_init_sos_base_fw()
3146 sos_hdr_v1_3 = (const struct psp_firmware_header_v1_3 *)adev->psp.sos_fw->data; in psp_init_sos_base_fw()
3148 adev->psp.sos.fw_version = le32_to_cpu(sos_hdr_v1_3->sos_aux.fw_version); in psp_init_sos_base_fw()
3149 adev->psp.sos.feature_version = le32_to_cpu(sos_hdr_v1_3->sos_aux.fw_version); in psp_init_sos_base_fw()
3151 adev->psp.sys.size_bytes = le32_to_cpu(sos_hdr_v1_3->sys_drv_aux.size_bytes); in psp_init_sos_base_fw()
3152 adev->psp.sys.start_addr = ucode_array_start_addr + in psp_init_sos_base_fw()
3155 adev->psp.sos.size_bytes = le32_to_cpu(sos_hdr_v1_3->sos_aux.size_bytes); in psp_init_sos_base_fw()
3156 adev->psp.sos.start_addr = ucode_array_start_addr + in psp_init_sos_base_fw()
3160 if ((adev->psp.sys.size_bytes == 0) || (adev->psp.sos.size_bytes == 0)) { in psp_init_sos_base_fw()
3168 int psp_init_sos_microcode(struct psp_context *psp, const char *chip_name) in psp_init_sos_microcode() argument
3170 struct amdgpu_device *adev = psp->adev; in psp_init_sos_microcode()
3182 err = amdgpu_ucode_request(adev, &adev->psp.sos_fw, fw_name); in psp_init_sos_microcode()
3186 sos_hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.sos_fw->data; in psp_init_sos_microcode()
3198 sos_hdr_v1_1 = (const struct psp_firmware_header_v1_1 *)adev->psp.sos_fw->data; in psp_init_sos_microcode()
3199 adev->psp.toc.size_bytes = le32_to_cpu(sos_hdr_v1_1->toc.size_bytes); in psp_init_sos_microcode()
3200 adev->psp.toc.start_addr = (uint8_t *)adev->psp.sys.start_addr + in psp_init_sos_microcode()
3202 adev->psp.kdb.size_bytes = le32_to_cpu(sos_hdr_v1_1->kdb.size_bytes); in psp_init_sos_microcode()
3203 adev->psp.kdb.start_addr = (uint8_t *)adev->psp.sys.start_addr + in psp_init_sos_microcode()
3207 sos_hdr_v1_2 = (const struct psp_firmware_header_v1_2 *)adev->psp.sos_fw->data; in psp_init_sos_microcode()
3208 adev->psp.kdb.size_bytes = le32_to_cpu(sos_hdr_v1_2->kdb.size_bytes); in psp_init_sos_microcode()
3209 adev->psp.kdb.start_addr = (uint8_t *)adev->psp.sys.start_addr + in psp_init_sos_microcode()
3213 sos_hdr_v1_3 = (const struct psp_firmware_header_v1_3 *)adev->psp.sos_fw->data; in psp_init_sos_microcode()
3214 adev->psp.toc.size_bytes = le32_to_cpu(sos_hdr_v1_3->v1_1.toc.size_bytes); in psp_init_sos_microcode()
3215 adev->psp.toc.start_addr = ucode_array_start_addr + in psp_init_sos_microcode()
3217 adev->psp.kdb.size_bytes = le32_to_cpu(sos_hdr_v1_3->v1_1.kdb.size_bytes); in psp_init_sos_microcode()
3218 adev->psp.kdb.start_addr = ucode_array_start_addr + in psp_init_sos_microcode()
3220 adev->psp.spl.size_bytes = le32_to_cpu(sos_hdr_v1_3->spl.size_bytes); in psp_init_sos_microcode()
3221 adev->psp.spl.start_addr = ucode_array_start_addr + in psp_init_sos_microcode()
3223 adev->psp.rl.size_bytes = le32_to_cpu(sos_hdr_v1_3->rl.size_bytes); in psp_init_sos_microcode()
3224 adev->psp.rl.start_addr = ucode_array_start_addr + in psp_init_sos_microcode()
3229 sos_hdr_v2_0 = (const struct psp_firmware_header_v2_0 *)adev->psp.sos_fw->data; in psp_init_sos_microcode()
3238 err = parse_sos_bin_descriptor(psp, in psp_init_sos_microcode()
3254 amdgpu_ucode_release(&adev->psp.sos_fw); in psp_init_sos_microcode()
3259 static int parse_ta_bin_descriptor(struct psp_context *psp, in parse_ta_bin_descriptor() argument
3265 if (!psp || !desc || !ta_hdr) in parse_ta_bin_descriptor()
3274 psp->asd_context.bin_desc.fw_version = le32_to_cpu(desc->fw_version); in parse_ta_bin_descriptor()
3275 psp->asd_context.bin_desc.feature_version = le32_to_cpu(desc->fw_version); in parse_ta_bin_descriptor()
3276 psp->asd_context.bin_desc.size_bytes = le32_to_cpu(desc->size_bytes); in parse_ta_bin_descriptor()
3277 psp->asd_context.bin_desc.start_addr = ucode_start_addr; in parse_ta_bin_descriptor()
3280 psp->xgmi_context.context.bin_desc.fw_version = le32_to_cpu(desc->fw_version); in parse_ta_bin_descriptor()
3281 psp->xgmi_context.context.bin_desc.size_bytes = le32_to_cpu(desc->size_bytes); in parse_ta_bin_descriptor()
3282 psp->xgmi_context.context.bin_desc.start_addr = ucode_start_addr; in parse_ta_bin_descriptor()
3285 psp->ras_context.context.bin_desc.fw_version = le32_to_cpu(desc->fw_version); in parse_ta_bin_descriptor()
3286 psp->ras_context.context.bin_desc.size_bytes = le32_to_cpu(desc->size_bytes); in parse_ta_bin_descriptor()
3287 psp->ras_context.context.bin_desc.start_addr = ucode_start_addr; in parse_ta_bin_descriptor()
3290 psp->hdcp_context.context.bin_desc.fw_version = le32_to_cpu(desc->fw_version); in parse_ta_bin_descriptor()
3291 psp->hdcp_context.context.bin_desc.size_bytes = le32_to_cpu(desc->size_bytes); in parse_ta_bin_descriptor()
3292 psp->hdcp_context.context.bin_desc.start_addr = ucode_start_addr; in parse_ta_bin_descriptor()
3295 psp->dtm_context.context.bin_desc.fw_version = le32_to_cpu(desc->fw_version); in parse_ta_bin_descriptor()
3296 psp->dtm_context.context.bin_desc.size_bytes = le32_to_cpu(desc->size_bytes); in parse_ta_bin_descriptor()
3297 psp->dtm_context.context.bin_desc.start_addr = ucode_start_addr; in parse_ta_bin_descriptor()
3300 psp->rap_context.context.bin_desc.fw_version = le32_to_cpu(desc->fw_version); in parse_ta_bin_descriptor()
3301 psp->rap_context.context.bin_desc.size_bytes = le32_to_cpu(desc->size_bytes); in parse_ta_bin_descriptor()
3302 psp->rap_context.context.bin_desc.start_addr = ucode_start_addr; in parse_ta_bin_descriptor()
3305 psp->securedisplay_context.context.bin_desc.fw_version = in parse_ta_bin_descriptor()
3307 psp->securedisplay_context.context.bin_desc.size_bytes = in parse_ta_bin_descriptor()
3309 psp->securedisplay_context.context.bin_desc.start_addr = in parse_ta_bin_descriptor()
3313 dev_warn(psp->adev->dev, "Unsupported TA type: %d\n", desc->fw_type); in parse_ta_bin_descriptor()
3320 static int parse_ta_v1_microcode(struct psp_context *psp) in parse_ta_v1_microcode() argument
3323 struct amdgpu_device *adev = psp->adev; in parse_ta_v1_microcode()
3325 ta_hdr = (const struct ta_firmware_header_v1_0 *) adev->psp.ta_fw->data; in parse_ta_v1_microcode()
3330 adev->psp.xgmi_context.context.bin_desc.fw_version = in parse_ta_v1_microcode()
3332 adev->psp.xgmi_context.context.bin_desc.size_bytes = in parse_ta_v1_microcode()
3334 adev->psp.xgmi_context.context.bin_desc.start_addr = in parse_ta_v1_microcode()
3338 adev->psp.ras_context.context.bin_desc.fw_version = in parse_ta_v1_microcode()
3340 adev->psp.ras_context.context.bin_desc.size_bytes = in parse_ta_v1_microcode()
3342 adev->psp.ras_context.context.bin_desc.start_addr = in parse_ta_v1_microcode()
3343 (uint8_t *)adev->psp.xgmi_context.context.bin_desc.start_addr + in parse_ta_v1_microcode()
3346 adev->psp.hdcp_context.context.bin_desc.fw_version = in parse_ta_v1_microcode()
3348 adev->psp.hdcp_context.context.bin_desc.size_bytes = in parse_ta_v1_microcode()
3350 adev->psp.hdcp_context.context.bin_desc.start_addr = in parse_ta_v1_microcode()
3354 adev->psp.dtm_context.context.bin_desc.fw_version = in parse_ta_v1_microcode()
3356 adev->psp.dtm_context.context.bin_desc.size_bytes = in parse_ta_v1_microcode()
3358 adev->psp.dtm_context.context.bin_desc.start_addr = in parse_ta_v1_microcode()
3359 (uint8_t *)adev->psp.hdcp_context.context.bin_desc.start_addr + in parse_ta_v1_microcode()
3362 adev->psp.securedisplay_context.context.bin_desc.fw_version = in parse_ta_v1_microcode()
3364 adev->psp.securedisplay_context.context.bin_desc.size_bytes = in parse_ta_v1_microcode()
3366 adev->psp.securedisplay_context.context.bin_desc.start_addr = in parse_ta_v1_microcode()
3367 (uint8_t *)adev->psp.hdcp_context.context.bin_desc.start_addr + in parse_ta_v1_microcode()
3370 adev->psp.ta_fw_version = le32_to_cpu(ta_hdr->header.ucode_version); in parse_ta_v1_microcode()
3375 static int parse_ta_v2_microcode(struct psp_context *psp) in parse_ta_v2_microcode() argument
3378 struct amdgpu_device *adev = psp->adev; in parse_ta_v2_microcode()
3382 ta_hdr = (const struct ta_firmware_header_v2_0 *)adev->psp.ta_fw->data; in parse_ta_v2_microcode()
3393 err = parse_ta_bin_descriptor(psp, in parse_ta_v2_microcode()
3403 int psp_init_ta_microcode(struct psp_context *psp, const char *chip_name) in psp_init_ta_microcode() argument
3406 struct amdgpu_device *adev = psp->adev; in psp_init_ta_microcode()
3411 err = amdgpu_ucode_request(adev, &adev->psp.ta_fw, fw_name); in psp_init_ta_microcode()
3415 hdr = (const struct common_firmware_header *)adev->psp.ta_fw->data; in psp_init_ta_microcode()
3418 err = parse_ta_v1_microcode(psp); in psp_init_ta_microcode()
3421 err = parse_ta_v2_microcode(psp); in psp_init_ta_microcode()
3429 amdgpu_ucode_release(&adev->psp.ta_fw); in psp_init_ta_microcode()
3434 int psp_init_cap_microcode(struct psp_context *psp, const char *chip_name) in psp_init_cap_microcode() argument
3436 struct amdgpu_device *adev = psp->adev; in psp_init_cap_microcode()
3448 err = amdgpu_ucode_request(adev, &adev->psp.cap_fw, fw_name); in psp_init_cap_microcode()
3460 info->fw = adev->psp.cap_fw; in psp_init_cap_microcode()
3462 adev->psp.cap_fw->data; in psp_init_cap_microcode()
3465 adev->psp.cap_fw_version = le32_to_cpu(cap_hdr_v1_0->header.ucode_version); in psp_init_cap_microcode()
3466 adev->psp.cap_feature_version = le32_to_cpu(cap_hdr_v1_0->sos.fw_version); in psp_init_cap_microcode()
3467 adev->psp.cap_ucode_size = le32_to_cpu(cap_hdr_v1_0->header.ucode_size_bytes); in psp_init_cap_microcode()
3472 amdgpu_ucode_release(&adev->psp.cap_fw); in psp_init_cap_microcode()
3502 mutex_lock(&adev->psp.mutex); in psp_usbc_pd_fw_sysfs_read()
3503 ret = psp_read_usbc_pd_fw(&adev->psp, &fw_ver); in psp_usbc_pd_fw_sysfs_read()
3504 mutex_unlock(&adev->psp.mutex); in psp_usbc_pd_fw_sysfs_read()
3552 mutex_lock(&adev->psp.mutex); in psp_usbc_pd_fw_sysfs_write()
3553 ret = psp_load_usbc_pd_fw(&adev->psp, fw_pri_mc_addr); in psp_usbc_pd_fw_sysfs_write()
3554 mutex_unlock(&adev->psp.mutex); in psp_usbc_pd_fw_sysfs_write()
3570 void psp_copy_fw(struct psp_context *psp, uint8_t *start_addr, uint32_t bin_size) in psp_copy_fw() argument
3574 if (!drm_dev_enter(adev_to_drm(psp->adev), &idx)) in psp_copy_fw()
3577 memset(psp->fw_pri_buf, 0, PSP_1_MEG); in psp_copy_fw()
3578 memcpy(psp->fw_pri_buf, start_addr, bin_size); in psp_copy_fw()
3605 adev->psp.vbflash_done = false; in amdgpu_psp_vbflash_write()
3608 if (adev->psp.vbflash_image_size > AMD_VBIOS_FILE_MAX_SIZE_B) { in amdgpu_psp_vbflash_write()
3610 kvfree(adev->psp.vbflash_tmp_buf); in amdgpu_psp_vbflash_write()
3611 adev->psp.vbflash_tmp_buf = NULL; in amdgpu_psp_vbflash_write()
3612 adev->psp.vbflash_image_size = 0; in amdgpu_psp_vbflash_write()
3617 if (!adev->psp.vbflash_tmp_buf) { in amdgpu_psp_vbflash_write()
3618 adev->psp.vbflash_tmp_buf = kvmalloc(AMD_VBIOS_FILE_MAX_SIZE_B, GFP_KERNEL); in amdgpu_psp_vbflash_write()
3619 if (!adev->psp.vbflash_tmp_buf) in amdgpu_psp_vbflash_write()
3623 mutex_lock(&adev->psp.mutex); in amdgpu_psp_vbflash_write()
3624 memcpy(adev->psp.vbflash_tmp_buf + pos, buffer, count); in amdgpu_psp_vbflash_write()
3625 adev->psp.vbflash_image_size += count; in amdgpu_psp_vbflash_write()
3626 mutex_unlock(&adev->psp.mutex); in amdgpu_psp_vbflash_write()
3645 if (adev->psp.vbflash_image_size == 0) in amdgpu_psp_vbflash_read()
3650 ret = amdgpu_bo_create_kernel(adev, adev->psp.vbflash_image_size, in amdgpu_psp_vbflash_read()
3659 memcpy_toio(fw_pri_cpu_addr, adev->psp.vbflash_tmp_buf, adev->psp.vbflash_image_size); in amdgpu_psp_vbflash_read()
3661 mutex_lock(&adev->psp.mutex); in amdgpu_psp_vbflash_read()
3662 ret = psp_update_spirom(&adev->psp, fw_pri_mc_addr); in amdgpu_psp_vbflash_read()
3663 mutex_unlock(&adev->psp.mutex); in amdgpu_psp_vbflash_read()
3668 kvfree(adev->psp.vbflash_tmp_buf); in amdgpu_psp_vbflash_read()
3669 adev->psp.vbflash_tmp_buf = NULL; in amdgpu_psp_vbflash_read()
3670 adev->psp.vbflash_image_size = 0; in amdgpu_psp_vbflash_read()
3707 vbflash_status = psp_vbflash_status(&adev->psp); in amdgpu_psp_vbflash_status()
3708 if (!adev->psp.vbflash_done) in amdgpu_psp_vbflash_status()
3710 else if (adev->psp.vbflash_done && !(vbflash_status & 0x80000000)) in amdgpu_psp_vbflash_status()
3735 return adev->psp.sup_pd_fw_up ? 0660 : 0; in amdgpu_flash_attr_is_visible()
3737 return adev->psp.sup_ifwi_up ? 0440 : 0; in amdgpu_flash_attr_is_visible()
3748 return adev->psp.sup_ifwi_up ? 0660 : 0; in amdgpu_bin_flash_attr_is_visible()