Lines Matching full:smu

48 #define smu_cmn_call_asic_func(intf, smu, args...)                             \  argument
49 ((smu)->ppt_funcs ? ((smu)->ppt_funcs->intf ? \
50 (smu)->ppt_funcs->intf(smu, ##args) : \
54 static const char *smu_get_message_name(struct smu_context *smu, in smu_get_message_name() argument
58 return "unknown smu message"; in smu_get_message_name()
63 static void smu_cmn_read_arg(struct smu_context *smu, in smu_cmn_read_arg() argument
66 struct amdgpu_device *adev = smu->adev; in smu_cmn_read_arg()
68 *arg = RREG32(smu->param_reg); in smu_cmn_read_arg()
71 /* Redefine the SMU error codes here.
74 * when the SMU has exported a unified header file containing these
75 * macros, which header file we can just include and use the SMU's
76 * macros. At the moment, these error codes are defined by the SMU
88 * __smu_cmn_poll_stat -- poll for a status from the SMU
89 * @smu: a pointer to SMU context
91 * Returns the status of the SMU, which could be,
92 * 0, the SMU is busy with your command;
97 * 0xFC, the command was rejected as the SMU is busy;
102 * maintained by the SMU FW team, so that we're impervious to firmware
107 static u32 __smu_cmn_poll_stat(struct smu_context *smu) in __smu_cmn_poll_stat() argument
109 struct amdgpu_device *adev = smu->adev; in __smu_cmn_poll_stat()
114 reg = RREG32(smu->resp_reg); in __smu_cmn_poll_stat()
124 static void __smu_cmn_reg_print_error(struct smu_context *smu, in __smu_cmn_reg_print_error() argument
130 struct amdgpu_device *adev = smu->adev; in __smu_cmn_reg_print_error()
131 const char *message = smu_get_message_name(smu, msg); in __smu_cmn_reg_print_error()
136 msg_idx = RREG32(smu->msg_reg); in __smu_cmn_reg_print_error()
137 prm = RREG32(smu->param_reg); in __smu_cmn_reg_print_error()
139 "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()
144 /* The SMU executed the command. It completed with a in __smu_cmn_reg_print_error()
149 /* The SMU executed the command. It completed with an in __smu_cmn_reg_print_error()
155 "SMU: unknown command: index:%d param:0x%08X message:%s", in __smu_cmn_reg_print_error()
160 "SMU: valid command, bad prerequisites: index:%d param:0x%08X message:%s", in __smu_cmn_reg_print_error()
165 "SMU: I'm very busy for your command: index:%d param:0x%08X message:%s", in __smu_cmn_reg_print_error()
170 "SMU: I'm debugging!"); in __smu_cmn_reg_print_error()
174 "SMU: response:0x%08X for index:%d param:0x%08X message:%s?", in __smu_cmn_reg_print_error()
180 static int __smu_cmn_reg2errno(struct smu_context *smu, u32 reg_c2pmsg_90) in __smu_cmn_reg2errno() argument
186 /* The SMU is busy--still executing your command. in __smu_cmn_reg2errno()
200 /* Unknown command--ignored by the SMU. in __smu_cmn_reg2errno()
210 /* The SMU is busy with other commands. The client in __smu_cmn_reg2errno()
216 /* Unknown or debug response from the SMU. in __smu_cmn_reg2errno()
225 static void __smu_cmn_send_msg(struct smu_context *smu, in __smu_cmn_send_msg() argument
229 struct amdgpu_device *adev = smu->adev; in __smu_cmn_send_msg()
231 WREG32(smu->resp_reg, 0); in __smu_cmn_send_msg()
232 WREG32(smu->param_reg, param); in __smu_cmn_send_msg()
233 WREG32(smu->msg_reg, msg); in __smu_cmn_send_msg()
238 * @smu: pointer to an SMU context
240 * @param: message parameter to send to the SMU
242 * Send a message to the SMU with the parameter passed. Do not wait
249 int smu_cmn_send_msg_without_waiting(struct smu_context *smu, in smu_cmn_send_msg_without_waiting() argument
253 struct amdgpu_device *adev = smu->adev; in smu_cmn_send_msg_without_waiting()
260 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_msg_without_waiting()
261 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_msg_without_waiting()
265 __smu_cmn_send_msg(smu, msg_index, param); in smu_cmn_send_msg_without_waiting()
278 * smu_cmn_wait_for_response -- wait for response from the SMU
279 * @smu: pointer to an SMU context
281 * Wait for status from the SMU.
287 int smu_cmn_wait_for_response(struct smu_context *smu) in smu_cmn_wait_for_response() argument
292 reg = __smu_cmn_poll_stat(smu); in smu_cmn_wait_for_response()
293 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_wait_for_response()
295 if (unlikely(smu->adev->pm.smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && in smu_cmn_wait_for_response()
297 amdgpu_device_halt(smu->adev); in smu_cmn_wait_for_response()
306 * @smu: pointer to an SMU context
308 * @param: parameter to send to the SMU
309 * @read_arg: pointer to u32 to return a value from the SMU back
312 * Send the message @msg with parameter @param to the SMU, wait for
313 * completion of the command, and return back a value from the SMU in
322 * If we weren't able to send the message to the SMU, we also print
326 * -EREMOTEIO, indicating that the SMU returned back an
336 int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, in smu_cmn_send_smc_msg_with_param() argument
341 struct amdgpu_device *adev = smu->adev; in smu_cmn_send_smc_msg_with_param()
348 index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_send_smc_msg_with_param()
354 mutex_lock(&smu->message_lock); in smu_cmn_send_smc_msg_with_param()
355 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_smc_msg_with_param()
356 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_smc_msg_with_param()
359 __smu_cmn_reg_print_error(smu, reg, index, param, msg); in smu_cmn_send_smc_msg_with_param()
362 __smu_cmn_send_msg(smu, (uint16_t) index, param); in smu_cmn_send_smc_msg_with_param()
363 reg = __smu_cmn_poll_stat(smu); in smu_cmn_send_smc_msg_with_param()
364 res = __smu_cmn_reg2errno(smu, reg); in smu_cmn_send_smc_msg_with_param()
366 __smu_cmn_reg_print_error(smu, reg, index, param, msg); in smu_cmn_send_smc_msg_with_param()
368 smu_cmn_read_arg(smu, read_arg); in smu_cmn_send_smc_msg_with_param()
375 mutex_unlock(&smu->message_lock); in smu_cmn_send_smc_msg_with_param()
379 int smu_cmn_send_smc_msg(struct smu_context *smu, in smu_cmn_send_smc_msg() argument
383 return smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_send_smc_msg()
389 int smu_cmn_to_asic_specific_index(struct smu_context *smu, in smu_cmn_to_asic_specific_index() argument
399 !smu->message_map) in smu_cmn_to_asic_specific_index()
402 msg_mapping = smu->message_map[index]; in smu_cmn_to_asic_specific_index()
406 if (amdgpu_sriov_vf(smu->adev) && in smu_cmn_to_asic_specific_index()
414 !smu->clock_map) in smu_cmn_to_asic_specific_index()
417 mapping = smu->clock_map[index]; in smu_cmn_to_asic_specific_index()
425 !smu->feature_map) in smu_cmn_to_asic_specific_index()
428 mapping = smu->feature_map[index]; in smu_cmn_to_asic_specific_index()
436 !smu->table_map) in smu_cmn_to_asic_specific_index()
439 mapping = smu->table_map[index]; in smu_cmn_to_asic_specific_index()
447 !smu->pwr_src_map) in smu_cmn_to_asic_specific_index()
450 mapping = smu->pwr_src_map[index]; in smu_cmn_to_asic_specific_index()
458 !smu->workload_map) in smu_cmn_to_asic_specific_index()
461 mapping = smu->workload_map[index]; in smu_cmn_to_asic_specific_index()
472 int smu_cmn_feature_is_supported(struct smu_context *smu, in smu_cmn_feature_is_supported() argument
475 struct smu_feature *feature = &smu->smu_feature; in smu_cmn_feature_is_supported()
478 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_is_supported()
489 static int __smu_get_enabled_features(struct smu_context *smu, in __smu_get_enabled_features() argument
492 return smu_cmn_call_asic_func(get_enabled_mask, smu, enabled_features); in __smu_get_enabled_features()
495 int smu_cmn_feature_is_enabled(struct smu_context *smu, in smu_cmn_feature_is_enabled() argument
498 struct amdgpu_device *adev = smu->adev; in smu_cmn_feature_is_enabled()
502 if (__smu_get_enabled_features(smu, &enabled_features)) { in smu_cmn_feature_is_enabled()
515 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_is_enabled()
524 bool smu_cmn_clk_dpm_is_enabled(struct smu_context *smu, in smu_cmn_clk_dpm_is_enabled() argument
556 if (!smu_cmn_feature_is_enabled(smu, feature_id)) in smu_cmn_clk_dpm_is_enabled()
562 int smu_cmn_get_enabled_mask(struct smu_context *smu, in smu_cmn_get_enabled_mask() argument
575 index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_get_enabled_mask()
579 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_get_enabled_mask()
586 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_get_enabled_mask()
591 ret = smu_cmn_send_smc_msg(smu, in smu_cmn_get_enabled_mask()
597 ret = smu_cmn_send_smc_msg(smu, in smu_cmn_get_enabled_mask()
618 int smu_cmn_feature_update_enable_state(struct smu_context *smu, in smu_cmn_feature_update_enable_state() argument
625 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
631 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
636 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
642 ret = smu_cmn_send_smc_msg_with_param(smu, in smu_cmn_feature_update_enable_state()
651 int smu_cmn_feature_set_enabled(struct smu_context *smu, in smu_cmn_feature_set_enabled() argument
657 feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_feature_set_enabled()
663 return smu_cmn_feature_update_enable_state(smu, in smu_cmn_feature_set_enabled()
674 static const char *smu_get_feature_name(struct smu_context *smu, in smu_get_feature_name() argument
678 return "unknown smu feature"; in smu_get_feature_name()
682 size_t smu_cmn_get_pp_feature_mask(struct smu_context *smu, in smu_cmn_get_pp_feature_mask() argument
691 if (__smu_get_enabled_features(smu, &feature_mask)) in smu_cmn_get_pp_feature_mask()
700 feature_index = smu_cmn_to_asic_specific_index(smu, in smu_cmn_get_pp_feature_mask()
718 smu_get_feature_name(smu, sort_feature[feature_index]), in smu_cmn_get_pp_feature_mask()
727 int smu_cmn_set_pp_feature_mask(struct smu_context *smu, in smu_cmn_set_pp_feature_mask() argument
735 ret = __smu_get_enabled_features(smu, &feature_mask); in smu_cmn_set_pp_feature_mask()
743 ret = smu_cmn_feature_update_enable_state(smu, in smu_cmn_set_pp_feature_mask()
750 ret = smu_cmn_feature_update_enable_state(smu, in smu_cmn_set_pp_feature_mask()
765 * @smu: smu_context pointer
773 int smu_cmn_disable_all_features_with_exception(struct smu_context *smu, in smu_cmn_disable_all_features_with_exception() argument
780 skipped_feature_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_disable_all_features_with_exception()
789 return smu_cmn_feature_update_enable_state(smu, in smu_cmn_disable_all_features_with_exception()
794 int smu_cmn_get_smc_version(struct smu_context *smu, in smu_cmn_get_smc_version() argument
803 if (smu->smc_fw_if_version && smu->smc_fw_version) in smu_cmn_get_smc_version()
806 *if_version = smu->smc_fw_if_version; in smu_cmn_get_smc_version()
809 *smu_version = smu->smc_fw_version; in smu_cmn_get_smc_version()
815 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetDriverIfVersion, if_version); in smu_cmn_get_smc_version()
819 smu->smc_fw_if_version = *if_version; in smu_cmn_get_smc_version()
823 ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetSmuVersion, smu_version); in smu_cmn_get_smc_version()
827 smu->smc_fw_version = *smu_version; in smu_cmn_get_smc_version()
833 int smu_cmn_update_table(struct smu_context *smu, in smu_cmn_update_table() argument
839 struct smu_table_context *smu_table = &smu->smu_table; in smu_cmn_update_table()
840 struct amdgpu_device *adev = smu->adev; in smu_cmn_update_table()
842 int table_id = smu_cmn_to_asic_specific_index(smu, in smu_cmn_update_table()
861 ret = smu_cmn_send_smc_msg_with_param(smu, drv2smu ? in smu_cmn_update_table()
877 int smu_cmn_write_watermarks_table(struct smu_context *smu) in smu_cmn_write_watermarks_table() argument
879 void *watermarks_table = smu->smu_table.watermarks_table; in smu_cmn_write_watermarks_table()
884 return smu_cmn_update_table(smu, in smu_cmn_write_watermarks_table()
891 int smu_cmn_write_pptable(struct smu_context *smu) in smu_cmn_write_pptable() argument
893 void *pptable = smu->smu_table.driver_pptable; in smu_cmn_write_pptable()
895 return smu_cmn_update_table(smu, in smu_cmn_write_pptable()
902 int smu_cmn_get_metrics_table(struct smu_context *smu, in smu_cmn_get_metrics_table() argument
906 struct smu_table_context *smu_table= &smu->smu_table; in smu_cmn_get_metrics_table()
914 ret = smu_cmn_update_table(smu, in smu_cmn_get_metrics_table()
920 dev_info(smu->adev->dev, "Failed to export SMU metrics table!\n"); in smu_cmn_get_metrics_table()
932 int smu_cmn_get_combo_pptable(struct smu_context *smu) in smu_cmn_get_combo_pptable() argument
934 void *pptable = smu->smu_table.combo_pptable; in smu_cmn_get_combo_pptable()
936 return smu_cmn_update_table(smu, in smu_cmn_get_combo_pptable()
989 int smu_cmn_set_mp1_state(struct smu_context *smu, in smu_cmn_set_mp1_state() argument
1010 ret = smu_cmn_send_smc_msg(smu, msg, NULL); in smu_cmn_set_mp1_state()
1012 dev_err(smu->adev->dev, "[PrepareMp1] Failed!\n"); in smu_cmn_set_mp1_state()