Messaging functions are now moved to message control block. Remove unused legacy functions around messaging.
Signed-off-by: Lijo Lazar <[email protected]> --- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 271 +------------------------ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 3 - 2 files changed, 2 insertions(+), 272 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c index 03cd724a0bf8..177643df1aab 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c @@ -65,14 +65,6 @@ static const char *smu_get_message_name(struct smu_context *smu, return __smu_message_names[type]; } -static void smu_cmn_read_arg(struct smu_context *smu, - uint32_t *arg) -{ - struct amdgpu_device *adev = smu->adev; - - *arg = RREG32(smu->param_reg); -} - /* Redefine the SMU error codes here. * * Note that these definitions are redundant and should be removed @@ -90,215 +82,6 @@ static void smu_cmn_read_arg(struct smu_context *smu, #define SMU_RESP_DEBUG_END 0xFB #define SMU_RESP_UNEXP (~0U) -/** - * __smu_cmn_poll_stat -- poll for a status from the SMU - * @smu: a pointer to SMU context - * - * Returns the status of the SMU, which could be, - * 0, the SMU is busy with your command; - * 1, execution status: success, execution result: success; - * 0xFF, execution status: success, execution result: failure; - * 0xFE, unknown command; - * 0xFD, valid command, but bad (command) prerequisites; - * 0xFC, the command was rejected as the SMU is busy; - * 0xFB, "SMC_Result_DebugDataDumpEnd". - * - * The values here are not defined by macros, because I'd rather we - * include a single header file which defines them, which is - * maintained by the SMU FW team, so that we're impervious to firmware - * changes. At the moment those values are defined in various header - * files, one for each ASIC, yet here we're a single ASIC-agnostic - * interface. Such a change can be followed-up by a subsequent patch. - */ -static u32 __smu_cmn_poll_stat(struct smu_context *smu) -{ - struct amdgpu_device *adev = smu->adev; - int timeout = adev->usec_timeout * 20; - u32 reg; - - for ( ; timeout > 0; timeout--) { - reg = RREG32(smu->resp_reg); - if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0) - break; - - udelay(1); - } - - return reg; -} - -static void __smu_cmn_reg_print_error(struct smu_context *smu, - u32 reg_c2pmsg_90, - int msg_index, - u32 param, - enum smu_message_type msg) -{ - struct amdgpu_device *adev = smu->adev; - const char *message = smu_get_message_name(smu, msg); - u32 msg_idx, prm; - - switch (reg_c2pmsg_90) { - case SMU_RESP_NONE: { - msg_idx = RREG32(smu->msg_reg); - prm = RREG32(smu->param_reg); - dev_err_ratelimited(adev->dev, - "SMU: I'm not done with your previous command: SMN_C2PMSG_66:0x%08X SMN_C2PMSG_82:0x%08X", - msg_idx, prm); - } - break; - case SMU_RESP_OK: - /* The SMU executed the command. It completed with a - * successful result. - */ - break; - case SMU_RESP_CMD_FAIL: - /* The SMU executed the command. It completed with an - * unsuccessful result. - */ - break; - case SMU_RESP_CMD_UNKNOWN: - dev_err_ratelimited(adev->dev, - "SMU: unknown command: index:%d param:0x%08X message:%s", - msg_index, param, message); - break; - case SMU_RESP_CMD_BAD_PREREQ: - dev_err_ratelimited(adev->dev, - "SMU: valid command, bad prerequisites: index:%d param:0x%08X message:%s", - msg_index, param, message); - break; - case SMU_RESP_BUSY_OTHER: - /* It is normal for SMU_MSG_GetBadPageCount to return busy - * so don't print error at this case. - */ - if (msg != SMU_MSG_GetBadPageCount) - dev_err_ratelimited(adev->dev, - "SMU: I'm very busy for your command: index:%d param:0x%08X message:%s", - msg_index, param, message); - break; - case SMU_RESP_DEBUG_END: - dev_err_ratelimited(adev->dev, - "SMU: I'm debugging!"); - break; - case SMU_RESP_UNEXP: - if (amdgpu_device_bus_status_check(smu->adev)) { - /* print error immediately if device is off the bus */ - dev_err(adev->dev, - "SMU: response:0x%08X for index:%d param:0x%08X message:%s?", - reg_c2pmsg_90, msg_index, param, message); - break; - } - fallthrough; - default: - dev_err_ratelimited(adev->dev, - "SMU: response:0x%08X for index:%d param:0x%08X message:%s?", - reg_c2pmsg_90, msg_index, param, message); - break; - } -} - -static int __smu_cmn_reg2errno(struct smu_context *smu, u32 reg_c2pmsg_90) -{ - int res; - - switch (reg_c2pmsg_90) { - case SMU_RESP_NONE: - /* The SMU is busy--still executing your command. - */ - res = -ETIME; - break; - case SMU_RESP_OK: - res = 0; - break; - case SMU_RESP_CMD_FAIL: - /* Command completed successfully, but the command - * status was failure. - */ - res = -EIO; - break; - case SMU_RESP_CMD_UNKNOWN: - /* Unknown command--ignored by the SMU. - */ - res = -EOPNOTSUPP; - break; - case SMU_RESP_CMD_BAD_PREREQ: - /* Valid command--bad prerequisites. - */ - res = -EINVAL; - break; - case SMU_RESP_BUSY_OTHER: - /* The SMU is busy with other commands. The client - * should retry in 10 us. - */ - res = -EBUSY; - break; - default: - /* Unknown or debug response from the SMU. - */ - res = -EREMOTEIO; - break; - } - - return res; -} - -static void __smu_cmn_send_msg(struct smu_context *smu, - u16 msg, - u32 param) -{ - struct amdgpu_device *adev = smu->adev; - - WREG32(smu->resp_reg, 0); - WREG32(smu->param_reg, param); - WREG32(smu->msg_reg, msg); -} - -static inline uint32_t __smu_cmn_get_msg_flags(struct smu_context *smu, - enum smu_message_type msg) -{ - return smu->message_map[msg].flags; -} - -static int __smu_cmn_ras_filter_msg(struct smu_context *smu, - enum smu_message_type msg, bool *poll) -{ - struct amdgpu_device *adev = smu->adev; - uint32_t flags, resp; - bool fed_status, pri; - - flags = __smu_cmn_get_msg_flags(smu, msg); - *poll = true; - - pri = !!(flags & SMU_MSG_NO_PRECHECK); - /* When there is RAS fatal error, FW won't process non-RAS priority - * messages. Don't allow any messages other than RAS priority messages. - */ - fed_status = amdgpu_ras_get_fed_status(adev); - if (fed_status) { - if (!(flags & SMU_MSG_RAS_PRI)) { - dev_dbg(adev->dev, - "RAS error detected, skip sending %s", - smu_get_message_name(smu, msg)); - return -EACCES; - } - } - - if (pri || fed_status) { - /* FW will ignore non-priority messages when a RAS fatal error - * or reset condition is detected. Hence it is possible that a - * previous message wouldn't have got response. Allow to - * continue without polling for response status for priority - * messages. - */ - resp = RREG32(smu->resp_reg); - dev_dbg(adev->dev, - "Sending priority message %s response status: %x", - smu_get_message_name(smu, msg), resp); - if (resp == 0) - *poll = false; - } - - return 0; -} static int __smu_cmn_send_debug_msg(struct smu_context *smu, u32 msg, @@ -312,56 +95,6 @@ static int __smu_cmn_send_debug_msg(struct smu_context *smu, return 0; } -/** - * smu_cmn_send_msg_without_waiting -- send the message; don't wait for status - * @smu: pointer to an SMU context - * @msg_index: message index - * @param: message parameter to send to the SMU - * - * Send a message to the SMU with the parameter passed. Do not wait - * for status/result of the message, thus the "without_waiting". - * - * Return 0 on success, -errno on error if we weren't able to _send_ - * the message for some reason. See __smu_cmn_reg2errno() for details - * of the -errno. - */ -int smu_cmn_send_msg_without_waiting(struct smu_context *smu, - uint16_t msg_index, - uint32_t param) -{ - struct amdgpu_device *adev = smu->adev; - u32 reg; - int res; - - if (adev->no_hw_access) - return 0; - - if (smu->smc_fw_state == SMU_FW_HANG) { - dev_err(adev->dev, "SMU is in hanged state, failed to send smu message!\n"); - res = -EREMOTEIO; - goto Out; - } - - if (smu->smc_fw_state == SMU_FW_INIT) { - smu->smc_fw_state = SMU_FW_RUNTIME; - } else { - reg = __smu_cmn_poll_stat(smu); - res = __smu_cmn_reg2errno(smu, reg); - if (reg == SMU_RESP_NONE || res == -EREMOTEIO) - goto Out; - } - - __smu_cmn_send_msg(smu, msg_index, param); - res = 0; -Out: - if (unlikely(adev->pm.smu_debug_mask & SMU_DEBUG_HALT_ON_ERROR) && - res && (res != -ETIME)) { - amdgpu_device_halt(adev); - WARN_ON(1); - } - - return res; -} /** * smu_cmn_wait_for_response -- wait for response from the SMU @@ -371,7 +104,7 @@ int smu_cmn_send_msg_without_waiting(struct smu_context *smu, * * Return 0 on success, -errno on error, indicating the execution * status and result of the message being waited for. See - * __smu_cmn_reg2errno() for details of the -errno. + * smu_msg_v1_decode_response() for details of the -errno. */ int smu_cmn_wait_for_response(struct smu_context *smu) { @@ -394,7 +127,7 @@ int smu_cmn_wait_for_response(struct smu_context *smu) * message or receiving reply. If there is a PCI bus recovery or * the destination is a virtual GPU which does not allow this message * type, the message is simply dropped and success is also returned. - * See __smu_cmn_reg2errno() for details of the -errno. + * See smu_msg_v1_decode_response() for details of the -errno. * * If we weren't able to send the message to the SMU, we also print * the error to the standard log. diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h index 13a5c1320874..4af587b42dda 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h @@ -110,9 +110,6 @@ static inline int pcie_gen_to_speed(uint32_t gen) return ((gen == 0) ? link_speed[0] : link_speed[gen - 1]); } -int smu_cmn_send_msg_without_waiting(struct smu_context *smu, - uint16_t msg_index, - uint32_t param); int smu_cmn_send_smc_msg_with_param(struct smu_context *smu, enum smu_message_type msg, uint32_t param, -- 2.49.0
