drm/amd/pm: add read arg support to smu_cmn_update_table
Subsystems (3)
PATCH 1/2 drm/amd/pm: add read arg support to smu_cmn_update_table
Extend the smu_cmn_update_table function to support reading a 32-bit return argument from the SMU firmware during table transfer operations.
- Rename the original function to smu_cmn_update_table_read_arg
- Add a uint32_t *read_arg output parameter to capture firmware response
- Pass the read_arg pointer to the SMU message command
- Keep full backward compatibility using a macro wrapper for the old API
This allows the driver to retrieve status codes, results, or configuration feedback from the SMU firmware after table data transfer.
No functional changes for existing users of the original smu_cmn_update_table() API.
--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 1 + drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 37 +++++++++++++------ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 14 ++++--- 3 files changed, 35 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1 -0
@@ -584,6 +584,7 @@ struct cmn2asic_mapping {/* Message flags for smu_msg_args */ #define SMU_MSG_FLAG_ASYNC BIT(0)/* Async send - skip post-poll */ #define SMU_MSG_FLAG_LOCK_HELD BIT(1)/* Caller holds ctl->lock */ +#define SMU_MSG_FLAG_FORCE_READ_ARG BIT(2)/* force read smu arg from pmfw */ /* smu_msg_ctl flags */ #define SMU_MSG_CTL_DEBUG_MAILBOX BIT(0)/* Debug mailbox supported */
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +25 -12
@@ -496,7 +496,8 @@ static int smu_msg_v1_send_msg(struct smu_msg_ctl *ctl, }/* Read output args */ -if (ret ==0 && args->num_out_args >0 ) { +if ((ret ==0 || (args->flags &SMU_MSG_FLAG_FORCE_READ_ARG )) && + args->num_out_args >0 ) {__smu_msg_v1_read_out_args (ctl, args);dev_dbg (adev->dev,"smu send message: %s(%d) resp : 0x%08x" ,smu_get_message_name (smu, args->msg), index, reg);
@@ -1060,20 +1061,24 @@ int smu_cmn_check_fw_version(struct smu_context *smu)return 0 ; } -int smu_cmn_update_table (struct smu_context *smu, -enum smu_table_id table_index, -int argument, -void *table_data, -bool drv2smu) +int smu_cmn_update_table_read_arg (struct smu_context *smu, +enum smu_table_id table_index, +int argument, +void *table_data, +uint32_t *read_arg, +bool drv2smu) { -struct smu_table_context *smu_table = &smu->smu_table;struct amdgpu_device *adev = smu->adev; +struct smu_table_context *smu_table = &smu->smu_table;struct smu_table *table = &smu_table->driver_table; +struct smu_msg_ctl *ctl = &smu->msg_ctl; +struct smu_msg_args args;int table_id =smu_cmn_to_asic_specific_index (smu,CMN2ASIC_MAPPING_TABLE , table_index);uint32_t table_size;int ret =0 ; +if (!table_data || table_index >=SMU_TABLE_COUNT || table_id <0 )return -EINVAL ;
@@ -1088,11 +1093,19 @@ int smu_cmn_update_table(struct smu_context *smu,amdgpu_hdp_flush (adev,NULL ); } - ret =smu_cmn_send_smc_msg_with_param (smu, drv2smu ? - SMU_MSG_TransferTableDram2Smu : - SMU_MSG_TransferTableSmu2Dram, - table_id | ((argument &0xFFFF ) <<16 ), -NULL ); + args.msg = drv2smu ? SMU_MSG_TransferTableDram2Smu : SMU_MSG_TransferTableSmu2Dram; + args.args[0 ] = ((argument &0xFFFF ) <<16 ) | (table_id &0xffff ); + args.num_args =1 ; + args.out_args[0 ] =0 ; + args.num_out_args = read_arg ?1 :0 ; + args.flags = read_arg ?SMU_MSG_FLAG_FORCE_READ_ARG :0 ; + args.timeout =0 ; + + ret = ctl->ops->send_msg (ctl, &args); + +if (read_arg) + *read_arg = args.out_args[0 ]; +if (ret)return ret;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +9 -5
@@ -168,11 +168,15 @@ int smu_cmn_get_smc_version(struct smu_context *smu,uint32_t *if_version, uint32_t *smu_version); -int smu_cmn_update_table (struct smu_context *smu, -enum smu_table_id table_index, -int argument, -void *table_data, -bool drv2smu); +#define smu_cmn_update_table (smu, table_index, argument, table_data, drv2smu) \ + smu_cmn_update_table_read_arg((smu), (table_index), (argument), (table_data), NULL, (drv2smu)) + +int smu_cmn_update_table_read_arg (struct smu_context *smu, +enum smu_table_id table_index, +int argument, +void *table_data, +uint32_t *read_arg, +bool drv2smu);int smu_cmn_vram_cpy (struct smu_context *smu,void *dst,const void *src,size_t len);
Signature · 1 line
2.47.3
PATCH 2/2 drm/amd/pm: add od table upload failure message parsing for smu v14.0.x
parse and print detailed reasons for od table upload failures to help users understand error causes.
example:
$ echo "0 30 40" | sudo tee fan_curve $ echo "1 40 30" | sudo tee fan_curve $ echo "c" | sudo tee fan_curve
kernel log:
[ 75.040174] amdgpu 0000:0a:00.0: Failed to upload overdrive table, ret:-5 [ 75.040178] amdgpu 0000:0a:00.0: Invalid overdrive table content: OD_FAN_CURVE_PWM_ERROR (13) [ 75.040181] amdgpu 0000:0a:00.0: Failed to upload overdrive table!
--- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 60 ++++++++++++++++--- 1 file changed, 52 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +52 -8
@@ -2230,17 +2230,61 @@ static void smu_v14_0_2_dump_od_table(struct smu_context *smu, od_table->OverDriveTable.FanMode); } +#define OD_FAIL_MSG_MAP (msg) \ + [msg] = #msg + +static const char *od_failed_message[] = { +OD_FAIL_MSG_MAP (OD_REQUEST_ADVANCED_NOT_SUPPORTED ), +OD_FAIL_MSG_MAP (OD_UNSUPPORTED_FEATURE ), +OD_FAIL_MSG_MAP (OD_INVALID_FEATURE_COMBO_ERROR ), +OD_FAIL_MSG_MAP (OD_GFXCLK_VF_CURVE_OFFSET_ERROR ), +OD_FAIL_MSG_MAP (OD_VDD_GFX_VMAX_ERROR ), +OD_FAIL_MSG_MAP (OD_VDD_SOC_VMAX_ERROR ), +OD_FAIL_MSG_MAP (OD_PPT_ERROR ), +OD_FAIL_MSG_MAP (OD_FAN_MIN_PWM_ERROR ), +OD_FAIL_MSG_MAP (OD_FAN_ACOUSTIC_TARGET_ERROR ), +OD_FAIL_MSG_MAP (OD_FAN_ACOUSTIC_LIMIT_ERROR ), +OD_FAIL_MSG_MAP (OD_FAN_TARGET_TEMP_ERROR ), +OD_FAIL_MSG_MAP (OD_FAN_ZERO_RPM_STOP_TEMP_ERROR ), +OD_FAIL_MSG_MAP (OD_FAN_CURVE_PWM_ERROR ), +OD_FAIL_MSG_MAP (OD_FAN_CURVE_TEMP_ERROR ), +OD_FAIL_MSG_MAP (OD_FULL_CTRL_GFXCLK_ERROR ), +OD_FAIL_MSG_MAP (OD_FULL_CTRL_UCLK_ERROR ), +OD_FAIL_MSG_MAP (OD_FULL_CTRL_FCLK_ERROR ), +OD_FAIL_MSG_MAP (OD_FULL_CTRL_VDD_GFX_ERROR ), +OD_FAIL_MSG_MAP (OD_FULL_CTRL_VDD_SOC_ERROR ), +OD_FAIL_MSG_MAP (OD_TDC_ERROR ), +OD_FAIL_MSG_MAP (OD_GFXCLK_ERROR ), +OD_FAIL_MSG_MAP (OD_UCLK_ERROR ), +OD_FAIL_MSG_MAP (OD_FCLK_ERROR ), +OD_FAIL_MSG_MAP (OD_OP_TEMP_ERROR ), +OD_FAIL_MSG_MAP (OD_OP_GFX_EDC_ERROR ), +OD_FAIL_MSG_MAP (OD_OP_GFX_PCC_ERROR ), +OD_FAIL_MSG_MAP (OD_POWER_FEATURE_CTRL_ERROR ), +}; +static int smu_v14_0_2_upload_overdrive_table (struct smu_context *smu,OverDriveTableExternal_t *od_table) { -int ret; - ret =smu_cmn_update_table (smu, -SMU_TABLE_OVERDRIVE , -0 , - (void *)od_table, - true); -if (ret) -dev_err (smu->adev->dev,"Failed to upload overdrive table!\n" ); +uint32_t read_arg =0 ; +int ret, od_faile_type; + + ret =smu_cmn_update_table_read_arg (smu, +SMU_TABLE_OVERDRIVE , +0 , + (void *)od_table, + &read_arg, + true); +if (ret) { +dev_err (smu->adev->dev,"Failed to upload overdrive table, ret:%d\n" , ret); +if ((read_arg &0xff ) ==TABLE_TRANSFER_FAILED ) { + od_faile_type = read_arg >>16 ; +dev_err (smu->adev->dev,"Invalid overdrive table content: %s (%d)\n" , + od_faile_type <ARRAY_SIZE (od_failed_message) ? + od_failed_message[od_faile_type] :"unknown" , + od_faile_type); + } + }return ret; }
Signature · 1 line
2.47.3