Lines Matching full:smu
50 #define smu_cmn_call_asic_func(intf, smu, args...) \ argument
51 ((smu)->ppt_funcs ? ((smu)->ppt_funcs->intf ? \
52 (smu)->ppt_funcs->intf(smu, ##args) : \
56 static const char *smu_get_message_name(struct smu_context *smu, in smu_get_message_name() argument
60 return "unknown smu message"; in smu_get_message_name()
65 static void smu_cmn_read_arg(struct smu_context *smu, in smu_cmn_read_arg() argument
68 struct amdgpu_device *adev = smu->adev; in smu_cmn_read_arg()
70 *arg = RREG32(smu->param_reg); in smu_cmn_read_arg()
73 /* Redefine the SMU error codes here.
76 * when the SMU has exported a unified header file containing these
77 * macros, which header file we can just include and use the SMU's
78 * macros. At the moment, these error codes are defined by the SMU
90 * __smu_cmn_poll_stat -- poll for a status from the SMU
91 * @smu: a pointer to SMU context
93 * Returns the status of the SMU, which could be,
94 * 0, the SMU is busy with your command;
99 * 0xFC, the command was rejected as the SMU is busy;
104 * maintained by the SMU FW team, so that we're impervious to firmware
109 static u32 __smu_cmn_poll_stat(struct smu_context *smu) in __smu_cmn_poll_stat() argument
111 struct amdgpu_device *adev = smu->adev; in __smu_cmn_poll_stat()
116 reg = RREG32(smu->resp_reg); in __smu_cmn_poll_stat()
126 static void __smu_cmn_reg_print_error(struct smu_context *smu, in __smu_cmn_reg_print_error() argument
132 struct amdgpu_device *adev = smu->adev; in __smu_cmn_reg_print_error()
133 const char *message = smu_get_message_name(smu, msg); in __smu_cmn_reg_print_error()
138 msg_idx = RREG32(smu->msg_reg); in __smu_cmn_reg_print_error()
139 prm = RREG32(smu->param_reg); in __smu_cmn_reg_print_error()
141 "SMU: I'm not done with your previous command: SMN_C2PMSG_66:0x%08X SMN_C2PMSG_82:0x%08X", in __smu_cmn_reg_print_error()
146 /* The SMU executed the command. It completed with a in __smu_cmn_reg_print_error()
151 /* The SMU executed the command. It completed with an in __smu_cmn_reg_print_error()
157 "SMU: unknown command: index:%d param:0x%08X message:%s", in __smu_cmn_reg_print_error()
162 "SMU: valid command, bad prerequisites: index:%d param:0x%08X message:%s", in __smu_cmn_reg_print_error()
167 "SMU: I'm very busy for your command: index:%d param:0x%08X message:%s", in __smu_cmn_reg_print_error()
172 "SMU: I'm debugging!"); in __smu_cmn_reg_print_error()
176 "SMU: response:0x%08X for index:%d param:0x%08X message:%s?", in __smu_cmn_reg_print_error()
182 static int __smu_cmn_reg2errno(struct smu_context *smu, u32 reg_c2pmsg_90) in __smu_cmn_reg2errno() argument
188 /* The SMU is busy--still executing your command. in __smu_cmn_reg2errno()
202 /* Unknown command--ignored by the SMU. in __smu_cmn_reg2errno()
212 /* The SMU is busy with other commands. The client in __smu_cmn_reg2errno()
218 /* Unknown or debug response from the SMU. in __smu_cmn_reg2errno()
227 static void __smu_cmn_send_msg(struct smu_context *smu, in __smu_cmn_send_msg() argument
231 struct amdgpu_device *adev = smu->adev; in __smu_cmn_send_msg()
233 WREG32(smu->resp_reg, 0); in __smu_cmn_send_msg()
234 WREG32(smu->param_reg, param); in __smu_cmn_send_msg()
235 WREG32(smu->msg_reg, msg); in __smu_cmn_send_msg()
238 static inline uint32_t __smu_cmn_get_msg_flags(struct smu_context *smu, in __smu_cmn_get_msg_flags() argument
241 return smu->message_map[msg].flags; in __smu_cmn_get_msg_flags()
244 static int __smu_cmn_ras_filter_msg(struct smu_context *smu, in __smu_cmn_ras_filter_msg() argument
247 struct amdgpu_device *adev = smu->adev; in __smu_cmn_ras_filter_msg()
251 flags = __smu_cmn_get_msg_flags(smu, msg); in __smu_cmn_ras_filter_msg()
262 smu_get_message_name(smu, msg)); in __smu_cmn_ras_filter_msg()
271 resp = RREG32(smu->resp_reg); in __smu_cmn_ras_filter_msg()
274 smu_get_message_name(smu, msg), resp); in __smu_cmn_ras_filter_msg()
282 static int __smu_cmn_send_debug_msg(struct smu_context *smu, in __smu_cmn_send_debug_msg() argument
286 struct amdgpu_device *adev = smu->adev; in __smu_cmn_send_debug_msg()
288 WREG32(smu->debug_param_reg, param); in __smu_cmn_send_debug_msg()
289 WREG32(smu->debug_msg_reg, msg); in __smu_cmn_send_debug_msg()
290 WREG32(smu->debug_resp_reg, 0); in __smu_cmn_send_debug_msg()
296 * @smu: pointer to an SMU context
298 * @param: message parameter to send to the SMU
300 * Send a message to the SMU with the parameter passed. Do not wait
307 int smu_cmn_send_msg_without_waiting(struct smu_context *smu, in smu_cmn_send_msg_without_waiting() argument
311 struct amdgpu_device *adev = smu->adev; in smu_cmn_send_msg_without_waiting()
318 if (smu->smc_fw_state == SMU_FW_HANG) { in smu_cmn_send_msg_without_waiting()
319 dev_err(adev->dev, "SMU is in hanged state, failed to send smu message!\n"); in smu_cmn_send_msg_without_waiting()
324 if (smu->smc_fw_state == SMU_FW_INIT) { in smu_cmn_send_msg_without_waiting()
325 smu->smc_fw_state = SMU_FW_RUNTIME; in smu_cmn_send_msg_without_waiting()
327 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_msg_without_waiting()
328 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_msg_without_waiting()
333 __smu_cmn_send_msg(smu, msg_index, param); in smu_cmn_send_msg_without_waiting()
346 * smu_cmn_wait_for_response -- wait for response from the SMU
347 * @smu: pointer to an SMU context
349 * Wait for status from the SMU.
355 int smu_cmn_wait_for_response(struct smu_context *smu) in smu_cmn_wait_for_response() argument
360 reg = __smu_cmn_poll_stat(smu); in smu_cmn_wait_for_response()
361 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_wait_for_response()
364 smu->smc_fw_state = SMU_FW_HANG; in smu_cmn_wait_for_response()
366 if (unlikely(smu->adev->pm.smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && in smu_cmn_wait_for_response()
368 amdgpu_device_halt(smu->adev); in smu_cmn_wait_for_response()
377 * @smu: pointer to an SMU context
379 * @param: parameter to send to the SMU
380 * @read_arg: pointer to u32 to return a value from the SMU back
383 * Send the message @msg with parameter @param to the SMU, wait for
384 * completion of the command, and return back a value from the SMU in
393 * If we weren't able to send the message to the SMU, we also print
397 * -EREMOTEIO, indicating that the SMU returned back an
407 int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, in smu_cmn_send_smc_msg_with_param() argument
412 struct amdgpu_device *adev = smu->adev; in smu_cmn_send_smc_msg_with_param()
420 index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_send_smc_msg_with_param()
426 mutex_lock(&smu->message_lock); in smu_cmn_send_smc_msg_with_param()
428 if (smu->smc_fw_caps & SMU_FW_CAP_RAS_PRI) { in smu_cmn_send_smc_msg_with_param()
429 res = __smu_cmn_ras_filter_msg(smu, msg, &poll); in smu_cmn_send_smc_msg_with_param()
434 if (smu->smc_fw_state == SMU_FW_HANG) { in smu_cmn_send_smc_msg_with_param()
435 dev_err(adev->dev, "SMU is in hanged state, failed to send smu message!\n"); in smu_cmn_send_smc_msg_with_param()
438 } else if (smu->smc_fw_state == SMU_FW_INIT) { in smu_cmn_send_smc_msg_with_param()
439 /* Ignore initial smu response register value */ in smu_cmn_send_smc_msg_with_param()
441 smu->smc_fw_state = SMU_FW_RUNTIME; in smu_cmn_send_smc_msg_with_param()
445 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_smc_msg_with_param()
446 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_smc_msg_with_param()
448 __smu_cmn_reg_print_error(smu, reg, index, param, msg); in smu_cmn_send_smc_msg_with_param()
452 __smu_cmn_send_msg(smu, (uint16_t) index, param); in smu_cmn_send_smc_msg_with_param()
453 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_smc_msg_with_param()
454 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_smc_msg_with_param()
457 smu->smc_fw_state = SMU_FW_HANG; in smu_cmn_send_smc_msg_with_param()
458 __smu_cmn_reg_print_error(smu, reg, index, param, msg); in smu_cmn_send_smc_msg_with_param()
461 smu_cmn_read_arg(smu, read_arg); in smu_cmn_send_smc_msg_with_param()
462 dev_dbg(adev->dev, "smu send message: %s(%d) param: 0x%08x, resp: 0x%08x, readval: 0x%08x\n", in smu_cmn_send_smc_msg_with_param()
463 smu_get_message_name(smu, msg), index, param, reg, *read_arg); in smu_cmn_send_smc_msg_with_param()
465 dev_dbg(adev->dev, "smu send message: %s(%d) param: 0x%08x, resp: 0x%08x\n", in smu_cmn_send_smc_msg_with_param()
466 smu_get_message_name(smu, msg), index, param, reg); in smu_cmn_send_smc_msg_with_param()
474 mutex_unlock(&smu->message_lock); in smu_cmn_send_smc_msg_with_param()
478 int smu_cmn_send_smc_msg(struct smu_context *smu, in smu_cmn_send_smc_msg() argument
482 return smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_send_smc_msg()
488 int smu_cmn_send_debug_smc_msg(struct smu_context *smu, in smu_cmn_send_debug_smc_msg() argument
491 return __smu_cmn_send_debug_msg(smu, msg, 0); in smu_cmn_send_debug_smc_msg()
494 int smu_cmn_send_debug_smc_msg_with_param(struct smu_context *smu, in smu_cmn_send_debug_smc_msg_with_param() argument
497 return __smu_cmn_send_debug_msg(smu, msg, param); in smu_cmn_send_debug_smc_msg_with_param()
500 int smu_cmn_to_asic_specific_index(struct smu_context *smu, in smu_cmn_to_asic_specific_index() argument
510 !smu->message_map) in smu_cmn_to_asic_specific_index()
513 msg_mapping = smu->message_map[index]; in smu_cmn_to_asic_specific_index()
517 if (amdgpu_sriov_vf(smu->adev) && in smu_cmn_to_asic_specific_index()
525 !smu->clock_map) in smu_cmn_to_asic_specific_index()
528 mapping = smu->clock_map[index]; in smu_cmn_to_asic_specific_index()
536 !smu->feature_map) in smu_cmn_to_asic_specific_index()
539 mapping = smu->feature_map[index]; in smu_cmn_to_asic_specific_index()
547 !smu->table_map) in smu_cmn_to_asic_specific_index()
550 mapping = smu->table_map[index]; in smu_cmn_to_asic_specific_index()
558 !smu->pwr_src_map) in smu_cmn_to_asic_specific_index()
561 mapping = smu->pwr_src_map[index]; in smu_cmn_to_asic_specific_index()
569 !smu->workload_map) in smu_cmn_to_asic_specific_index()
572 mapping = smu->workload_map[index]; in smu_cmn_to_asic_specific_index()
583 int smu_cmn_feature_is_supported(struct smu_context *smu, in smu_cmn_feature_is_supported() argument
586 struct smu_feature *feature = &smu->smu_feature; in smu_cmn_feature_is_supported()
589 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_is_supported()
600 static int __smu_get_enabled_features(struct smu_context *smu, in __smu_get_enabled_features() argument
603 return smu_cmn_call_asic_func(get_enabled_mask, smu, enabled_features); in __smu_get_enabled_features()
606 int smu_cmn_feature_is_enabled(struct smu_context *smu, in smu_cmn_feature_is_enabled() argument
609 struct amdgpu_device *adev = smu->adev; in smu_cmn_feature_is_enabled()
613 if (__smu_get_enabled_features(smu, &enabled_features)) { in smu_cmn_feature_is_enabled()
626 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_is_enabled()
635 bool smu_cmn_clk_dpm_is_enabled(struct smu_context *smu, in smu_cmn_clk_dpm_is_enabled() argument
667 if (!smu_cmn_feature_is_enabled(smu, feature_id)) in smu_cmn_clk_dpm_is_enabled()
673 int smu_cmn_get_enabled_mask(struct smu_context *smu, in smu_cmn_get_enabled_mask() argument
686 index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_get_enabled_mask()
690 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_get_enabled_mask()
697 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_get_enabled_mask()
702 ret = smu_cmn_send_smc_msg(smu, in smu_cmn_get_enabled_mask()
708 ret = smu_cmn_send_smc_msg(smu, in smu_cmn_get_enabled_mask()
729 int smu_cmn_feature_update_enable_state(struct smu_context *smu, in smu_cmn_feature_update_enable_state() argument
736 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
742 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
747 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
753 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
762 int smu_cmn_feature_set_enabled(struct smu_context *smu, in smu_cmn_feature_set_enabled() argument
768 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_set_enabled()
774 return smu_cmn_feature_update_enable_state(smu, in smu_cmn_feature_set_enabled()
785 static const char *smu_get_feature_name(struct smu_context *smu, in smu_get_feature_name() argument
789 return "unknown smu feature"; in smu_get_feature_name()
793 size_t smu_cmn_get_pp_feature_mask(struct smu_context *smu, in smu_cmn_get_pp_feature_mask() argument
802 if (__smu_get_enabled_features(smu, &feature_mask)) in smu_cmn_get_pp_feature_mask()
811 feature_index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_get_pp_feature_mask()
829 smu_get_feature_name(smu, sort_feature[feature_index]), in smu_cmn_get_pp_feature_mask()
838 int smu_cmn_set_pp_feature_mask(struct smu_context *smu, in smu_cmn_set_pp_feature_mask() argument
846 ret = __smu_get_enabled_features(smu, &feature_mask); in smu_cmn_set_pp_feature_mask()
854 ret = smu_cmn_feature_update_enable_state(smu, in smu_cmn_set_pp_feature_mask()
861 ret = smu_cmn_feature_update_enable_state(smu, in smu_cmn_set_pp_feature_mask()
876 * @smu: smu_context pointer
884 int smu_cmn_disable_all_features_with_exception(struct smu_context *smu, in smu_cmn_disable_all_features_with_exception() argument
891 skipped_feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_disable_all_features_with_exception()
900 return smu_cmn_feature_update_enable_state(smu, in smu_cmn_disable_all_features_with_exception()
905 int smu_cmn_get_smc_version(struct smu_context *smu, in smu_cmn_get_smc_version() argument
914 if (smu->smc_fw_if_version && smu->smc_fw_version) in smu_cmn_get_smc_version()
917 *if_version = smu->smc_fw_if_version; in smu_cmn_get_smc_version()
920 *smu_version = smu->smc_fw_version; in smu_cmn_get_smc_version()
926 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetDriverIfVersion, if_version); in smu_cmn_get_smc_version()
930 smu->smc_fw_if_version = *if_version; in smu_cmn_get_smc_version()
934 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetSmuVersion, smu_version); in smu_cmn_get_smc_version()
938 smu->smc_fw_version = *smu_version; in smu_cmn_get_smc_version()
944 int smu_cmn_update_table(struct smu_context *smu, in smu_cmn_update_table() argument
950 struct smu_table_context *smu_table = &smu->smu_table; in smu_cmn_update_table()
951 struct amdgpu_device *adev = smu->adev; in smu_cmn_update_table()
953 int table_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_update_table()
972 ret = smu_cmn_send_smc_msg_with_param(smu, drv2smu ? in smu_cmn_update_table()
988 int smu_cmn_write_watermarks_table(struct smu_context *smu) in smu_cmn_write_watermarks_table() argument
990 void *watermarks_table = smu->smu_table.watermarks_table; in smu_cmn_write_watermarks_table()
995 return smu_cmn_update_table(smu, in smu_cmn_write_watermarks_table()
1002 int smu_cmn_write_pptable(struct smu_context *smu) in smu_cmn_write_pptable() argument
1004 void *pptable = smu->smu_table.driver_pptable; in smu_cmn_write_pptable()
1006 return smu_cmn_update_table(smu, in smu_cmn_write_pptable()
1013 int smu_cmn_get_metrics_table(struct smu_context *smu, in smu_cmn_get_metrics_table() argument
1017 struct smu_table_context *smu_table = &smu->smu_table; in smu_cmn_get_metrics_table()
1025 ret = smu_cmn_update_table(smu, in smu_cmn_get_metrics_table()
1031 dev_info(smu->adev->dev, "Failed to export SMU metrics table!\n"); in smu_cmn_get_metrics_table()
1043 int smu_cmn_get_combo_pptable(struct smu_context *smu) in smu_cmn_get_combo_pptable() argument
1045 void *pptable = smu->smu_table.combo_pptable; in smu_cmn_get_combo_pptable()
1047 return smu_cmn_update_table(smu, in smu_cmn_get_combo_pptable()
1118 int smu_cmn_set_mp1_state(struct smu_context *smu, in smu_cmn_set_mp1_state() argument
1139 ret = smu_cmn_send_smc_msg(smu, msg, NULL); in smu_cmn_set_mp1_state()
1141 dev_err(smu->adev->dev, "[PrepareMp1] Failed!\n"); in smu_cmn_set_mp1_state()
1224 void smu_cmn_get_backend_workload_mask(struct smu_context *smu, in smu_cmn_get_backend_workload_mask() argument
1238 workload_type = smu_cmn_to_asic_specific_index(smu, in smu_cmn_get_backend_workload_mask()