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 int __smu_cmn_send_debug_msg(struct smu_context *smu, in __smu_cmn_send_debug_msg() argument
242 struct amdgpu_device *adev = smu->adev; in __smu_cmn_send_debug_msg()
244 WREG32(smu->debug_param_reg, param); in __smu_cmn_send_debug_msg()
245 WREG32(smu->debug_msg_reg, msg); in __smu_cmn_send_debug_msg()
246 WREG32(smu->debug_resp_reg, 0); in __smu_cmn_send_debug_msg()
252 * @smu: pointer to an SMU context
254 * @param: message parameter to send to the SMU
256 * Send a message to the SMU with the parameter passed. Do not wait
263 int smu_cmn_send_msg_without_waiting(struct smu_context *smu, in smu_cmn_send_msg_without_waiting() argument
267 struct amdgpu_device *adev = smu->adev; in smu_cmn_send_msg_without_waiting()
274 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_msg_without_waiting()
275 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_msg_without_waiting()
279 __smu_cmn_send_msg(smu, msg_index, param); in smu_cmn_send_msg_without_waiting()
292 * smu_cmn_wait_for_response -- wait for response from the SMU
293 * @smu: pointer to an SMU context
295 * Wait for status from the SMU.
301 int smu_cmn_wait_for_response(struct smu_context *smu) in smu_cmn_wait_for_response() argument
306 reg = __smu_cmn_poll_stat(smu); in smu_cmn_wait_for_response()
307 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_wait_for_response()
309 if (unlikely(smu->adev->pm.smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && in smu_cmn_wait_for_response()
311 amdgpu_device_halt(smu->adev); in smu_cmn_wait_for_response()
320 * @smu: pointer to an SMU context
322 * @param: parameter to send to the SMU
323 * @read_arg: pointer to u32 to return a value from the SMU back
326 * Send the message @msg with parameter @param to the SMU, wait for
327 * completion of the command, and return back a value from the SMU in
336 * If we weren't able to send the message to the SMU, we also print
340 * -EREMOTEIO, indicating that the SMU returned back an
350 int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, in smu_cmn_send_smc_msg_with_param() argument
355 struct amdgpu_device *adev = smu->adev; in smu_cmn_send_smc_msg_with_param()
362 index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_send_smc_msg_with_param()
368 mutex_lock(&smu->message_lock); in smu_cmn_send_smc_msg_with_param()
369 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_smc_msg_with_param()
370 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_smc_msg_with_param()
373 __smu_cmn_reg_print_error(smu, reg, index, param, msg); in smu_cmn_send_smc_msg_with_param()
376 __smu_cmn_send_msg(smu, (uint16_t) index, param); in smu_cmn_send_smc_msg_with_param()
377 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_smc_msg_with_param()
378 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_smc_msg_with_param()
380 __smu_cmn_reg_print_error(smu, reg, index, param, msg); in smu_cmn_send_smc_msg_with_param()
382 smu_cmn_read_arg(smu, read_arg); in smu_cmn_send_smc_msg_with_param()
389 mutex_unlock(&smu->message_lock); in smu_cmn_send_smc_msg_with_param()
393 int smu_cmn_send_smc_msg(struct smu_context *smu, in smu_cmn_send_smc_msg() argument
397 return smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_send_smc_msg()
403 int smu_cmn_send_debug_smc_msg(struct smu_context *smu, in smu_cmn_send_debug_smc_msg() argument
406 return __smu_cmn_send_debug_msg(smu, msg, 0); in smu_cmn_send_debug_smc_msg()
409 int smu_cmn_send_debug_smc_msg_with_param(struct smu_context *smu, in smu_cmn_send_debug_smc_msg_with_param() argument
412 return __smu_cmn_send_debug_msg(smu, msg, param); in smu_cmn_send_debug_smc_msg_with_param()
415 int smu_cmn_to_asic_specific_index(struct smu_context *smu, in smu_cmn_to_asic_specific_index() argument
425 !smu->message_map) in smu_cmn_to_asic_specific_index()
428 msg_mapping = smu->message_map[index]; in smu_cmn_to_asic_specific_index()
432 if (amdgpu_sriov_vf(smu->adev) && in smu_cmn_to_asic_specific_index()
440 !smu->clock_map) in smu_cmn_to_asic_specific_index()
443 mapping = smu->clock_map[index]; in smu_cmn_to_asic_specific_index()
451 !smu->feature_map) in smu_cmn_to_asic_specific_index()
454 mapping = smu->feature_map[index]; in smu_cmn_to_asic_specific_index()
462 !smu->table_map) in smu_cmn_to_asic_specific_index()
465 mapping = smu->table_map[index]; in smu_cmn_to_asic_specific_index()
473 !smu->pwr_src_map) in smu_cmn_to_asic_specific_index()
476 mapping = smu->pwr_src_map[index]; in smu_cmn_to_asic_specific_index()
484 !smu->workload_map) in smu_cmn_to_asic_specific_index()
487 mapping = smu->workload_map[index]; in smu_cmn_to_asic_specific_index()
498 int smu_cmn_feature_is_supported(struct smu_context *smu, in smu_cmn_feature_is_supported() argument
501 struct smu_feature *feature = &smu->smu_feature; in smu_cmn_feature_is_supported()
504 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_is_supported()
515 static int __smu_get_enabled_features(struct smu_context *smu, in __smu_get_enabled_features() argument
518 return smu_cmn_call_asic_func(get_enabled_mask, smu, enabled_features); in __smu_get_enabled_features()
521 int smu_cmn_feature_is_enabled(struct smu_context *smu, in smu_cmn_feature_is_enabled() argument
524 struct amdgpu_device *adev = smu->adev; in smu_cmn_feature_is_enabled()
528 if (__smu_get_enabled_features(smu, &enabled_features)) { in smu_cmn_feature_is_enabled()
541 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_is_enabled()
550 bool smu_cmn_clk_dpm_is_enabled(struct smu_context *smu, in smu_cmn_clk_dpm_is_enabled() argument
582 if (!smu_cmn_feature_is_enabled(smu, feature_id)) in smu_cmn_clk_dpm_is_enabled()
588 int smu_cmn_get_enabled_mask(struct smu_context *smu, in smu_cmn_get_enabled_mask() argument
601 index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_get_enabled_mask()
605 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_get_enabled_mask()
612 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_get_enabled_mask()
617 ret = smu_cmn_send_smc_msg(smu, in smu_cmn_get_enabled_mask()
623 ret = smu_cmn_send_smc_msg(smu, in smu_cmn_get_enabled_mask()
644 int smu_cmn_feature_update_enable_state(struct smu_context *smu, in smu_cmn_feature_update_enable_state() argument
651 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
657 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
662 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
668 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
677 int smu_cmn_feature_set_enabled(struct smu_context *smu, in smu_cmn_feature_set_enabled() argument
683 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_set_enabled()
689 return smu_cmn_feature_update_enable_state(smu, in smu_cmn_feature_set_enabled()
700 static const char *smu_get_feature_name(struct smu_context *smu, in smu_get_feature_name() argument
704 return "unknown smu feature"; in smu_get_feature_name()
708 size_t smu_cmn_get_pp_feature_mask(struct smu_context *smu, in smu_cmn_get_pp_feature_mask() argument
717 if (__smu_get_enabled_features(smu, &feature_mask)) in smu_cmn_get_pp_feature_mask()
726 feature_index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_get_pp_feature_mask()
744 smu_get_feature_name(smu, sort_feature[feature_index]), in smu_cmn_get_pp_feature_mask()
753 int smu_cmn_set_pp_feature_mask(struct smu_context *smu, in smu_cmn_set_pp_feature_mask() argument
761 ret = __smu_get_enabled_features(smu, &feature_mask); in smu_cmn_set_pp_feature_mask()
769 ret = smu_cmn_feature_update_enable_state(smu, in smu_cmn_set_pp_feature_mask()
776 ret = smu_cmn_feature_update_enable_state(smu, in smu_cmn_set_pp_feature_mask()
791 * @smu: smu_context pointer
799 int smu_cmn_disable_all_features_with_exception(struct smu_context *smu, in smu_cmn_disable_all_features_with_exception() argument
806 skipped_feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_disable_all_features_with_exception()
815 return smu_cmn_feature_update_enable_state(smu, in smu_cmn_disable_all_features_with_exception()
820 int smu_cmn_get_smc_version(struct smu_context *smu, in smu_cmn_get_smc_version() argument
829 if (smu->smc_fw_if_version && smu->smc_fw_version) in smu_cmn_get_smc_version()
832 *if_version = smu->smc_fw_if_version; in smu_cmn_get_smc_version()
835 *smu_version = smu->smc_fw_version; in smu_cmn_get_smc_version()
841 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetDriverIfVersion, if_version); in smu_cmn_get_smc_version()
845 smu->smc_fw_if_version = *if_version; in smu_cmn_get_smc_version()
849 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetSmuVersion, smu_version); in smu_cmn_get_smc_version()
853 smu->smc_fw_version = *smu_version; in smu_cmn_get_smc_version()
859 int smu_cmn_update_table(struct smu_context *smu, in smu_cmn_update_table() argument
865 struct smu_table_context *smu_table = &smu->smu_table; in smu_cmn_update_table()
866 struct amdgpu_device *adev = smu->adev; in smu_cmn_update_table()
868 int table_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_update_table()
887 ret = smu_cmn_send_smc_msg_with_param(smu, drv2smu ? in smu_cmn_update_table()
903 int smu_cmn_write_watermarks_table(struct smu_context *smu) in smu_cmn_write_watermarks_table() argument
905 void *watermarks_table = smu->smu_table.watermarks_table; in smu_cmn_write_watermarks_table()
910 return smu_cmn_update_table(smu, in smu_cmn_write_watermarks_table()
917 int smu_cmn_write_pptable(struct smu_context *smu) in smu_cmn_write_pptable() argument
919 void *pptable = smu->smu_table.driver_pptable; in smu_cmn_write_pptable()
921 return smu_cmn_update_table(smu, in smu_cmn_write_pptable()
928 int smu_cmn_get_metrics_table(struct smu_context *smu, in smu_cmn_get_metrics_table() argument
932 struct smu_table_context *smu_table = &smu->smu_table; in smu_cmn_get_metrics_table()
940 ret = smu_cmn_update_table(smu, in smu_cmn_get_metrics_table()
946 dev_info(smu->adev->dev, "Failed to export SMU metrics table!\n"); in smu_cmn_get_metrics_table()
958 int smu_cmn_get_combo_pptable(struct smu_context *smu) in smu_cmn_get_combo_pptable() argument
960 void *pptable = smu->smu_table.combo_pptable; in smu_cmn_get_combo_pptable()
962 return smu_cmn_update_table(smu, in smu_cmn_get_combo_pptable()
1018 int smu_cmn_set_mp1_state(struct smu_context *smu, in smu_cmn_set_mp1_state() argument
1039 ret = smu_cmn_send_smc_msg(smu, msg, NULL); in smu_cmn_set_mp1_state()
1041 dev_err(smu->adev->dev, "[PrepareMp1] Failed!\n"); in smu_cmn_set_mp1_state()