drm/amd/pm: add and use the SMU multi-msgs helper
Subsystems (3)
cover drm/amd/pm: add and use the SMU multi-msgs helper
SMU15 introduced driver messages that can carry multiple input parameters and return values, but callers still have to build struct smu_msg_args directly.
Add common SMU multi-msgs helpers in smu_cmn and switch the first SMU15 users over to them. This keeps multi-parameter messages and multi-return queries on one helper path while leaving the older single-parameter interface unchanged.
Patch 1 adds the common helpers and updates the shared path. Patch 2 converts the SMU15 base table address messages. Patch 3 converts the SMU15.0.0 table transfer and enabled-feature query.
Patch 4 converts the SMU15.0.8 enabled-feature query.
No functional change intended.
Yang Wang (4):
drm/amd/pm: add SMU multi-msgs helpers drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0_0 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0_8
.../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 47 ++++----- .../drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c | 38 +++----- .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 14 ++- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 96 +++++++++++++------ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++ 5 files changed, 130 insertions(+), 87 deletions(-)
Signature · 1 line
2.47.3
PATCH 1/4 drm/amd/pm: add SMU multi-msgs helpers
SMU15 driver messages can carry multiple input parameters and return values, but callers still have to build struct smu_msg_args directly.
Add common SMU multi-msgs helpers in smu_cmn and reuse them in the single-parameter wrapper and the shared table transfer path.
Keep smu_cmn_send_smc_msg() semantics unchanged for older callers.
No functional change intended.
--- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 96 ++++++++++++++++++-------- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 ++++++ 2 files changed, 88 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +66 -30
@@ -127,6 +127,61 @@ int smu_cmn_wait_for_response(struct smu_context *smu)return smu_msg_wait_response (&smu->msg_ctl,0 ); } +/** +* smu_cmn_send_smc_msg_with_params_ext - send an SMU message with 0..N args +* @smu: pointer to an SMU context +* @msg: message to send +* @params: optional input argument array +* @num_params: number of input arguments in @params +* @read_args: optional output argument array +* @num_read_args: number of output arguments to read back +* @flags: message flags (SMU_MSG_FLAG_*) +* @timeout: per-message timeout in us (0 = use default) +* +* This helper keeps the raw protocol semantics of struct smu_msg_args while +* hiding the per-call boilerplate. It is intended for true multi-parameter +* messages. Legacy wrappers such as smu_cmn_send_smc_msg() retain their +* existing single-zero-parameter behavior for compatibility. +* +* Return: 0 on success, -errno on failure. +*/ +int smu_cmn_send_smc_msg_with_params_ext (struct smu_context *smu, +enum smu_message_type msg, +const uint32_t *params, +size_t num_params, +uint32_t *read_args, +size_t num_read_args, +uint32_t flags, +uint32_t timeout) +{ +struct smu_msg_ctl *ctl = &smu->msg_ctl; +struct smu_msg_args args = { + .msg = msg, + .num_args = num_params, + .num_out_args = num_read_args, + .flags = flags, + .timeout = timeout, + }; +int ret; + +if ((num_params && !params) || (num_read_args && !read_args)) +return -EINVAL ; + +if (num_params >SMU_MSG_MAX_ARGS || num_read_args >SMU_MSG_MAX_ARGS ) +return -EINVAL ; + +if (num_params) +memcpy (args.args, params, num_params *sizeof (*params)); + + ret = ctl->ops->send_msg (ctl, &args); + +if (num_read_args) +memcpy (read_args, args.out_args, + num_read_args *sizeof (*read_args)); + +return ret; +} +/** * smu_cmn_send_smc_msg_with_param -- send a message with parameter * @smu: pointer to an SMU context
@@ -164,23 +219,9 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,uint32_t param, uint32_t *read_arg) { - struct smu_msg_ctl *ctl = &smu->msg_ctl; -struct smu_msg_args args = { - .msg = msg, - .args[0 ] = param, - .num_args =1 , - .num_out_args = read_arg ?1 :0 , - .flags =0 , - .timeout =0 , - }; -int ret; - - ret = ctl->ops->send_msg (ctl, &args); - -if (read_arg) - *read_arg = args.out_args[0 ]; - -return ret; + return smu_cmn_send_smc_msg_with_params(smu, msg, + ¶m, 1, + read_arg, read_arg ? 1 : 0); } int smu_cmn_send_smc_msg(struct smu_context *smu,
@@ -1071,13 +1112,12 @@ int smu_cmn_update_table_read_arg(struct smu_context *smu,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 ; +uint32_t param;if (!table_data || table_index >=SMU_TABLE_COUNT || table_id <0 )return -EINVAL ;
@@ -1093,18 +1133,14 @@ int smu_cmn_update_table_read_arg(struct smu_context *smu,amdgpu_hdp_flush (adev,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); + param = ((argument &0xFFFF ) <<16 ) | (table_id &0xffff ); -if (read_arg) - *read_arg = args.out_args[0 ]; + ret =smu_cmn_send_smc_msg_with_params_ext ( + smu, + drv2smu ? SMU_MSG_TransferTableDram2Smu : + SMU_MSG_TransferTableSmu2Dram, + ¶m,1 , read_arg, read_arg ?1 :0 , + read_arg ?SMU_MSG_FLAG_FORCE_READ_ARG :0 ,0 );if (ret)return ret;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +22 -0
@@ -118,6 +118,28 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,uint32_t param, uint32_t *read_arg); +int smu_cmn_send_smc_msg_with_params_ext (struct smu_context *smu, +enum smu_message_type msg, +const uint32_t *params, +size_t num_params, +uint32_t *read_args, +size_t num_read_args, +uint32_t flags, +uint32_t timeout); + +static inline int smu_cmn_send_smc_msg_with_params (struct smu_context *smu, +enum smu_message_type msg, +const uint32_t *params, +size_t num_params, +uint32_t *read_args, +size_t num_read_args) +{ +return smu_cmn_send_smc_msg_with_params_ext (smu, msg, + params, num_params, + read_args, num_read_args, +0 ,0 ); +} +int smu_cmn_send_smc_msg (struct smu_context *smu,enum smu_message_type msg,uint32_t *read_arg);
Signature · 1 line
2.47.3
PATCH 2/4 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0
In reply to Yang WangConvert the SMU15 table address messages to smu_cmn_send_smc_msg_with_params() so they use the common SMU multi-msgs helper instead of open-coding struct smu_msg_args.
No functional change intended.
--- .../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c +21 -26
@@ -590,52 +590,47 @@ int smu_v15_0_notify_memory_pool_location(struct smu_context *smu) {struct smu_table_context *smu_table = &smu->smu_table;struct smu_table *memory_pool = &smu_table->memory_pool; -struct smu_msg_args args = { - .msg = SMU_MSG_DramLogSetDramAddr, - .num_args =3 , - .num_out_args =0 , - }; +uint32_t params[3 ];if (memory_pool->size ==0 || memory_pool->cpu_addr ==NULL )return 0 ;/* SMU_MSG_DramLogSetDramAddr: ARG0=low, ARG1=high, ARG2=size */ - args.args[0 ] =lower_32_bits (memory_pool->mc_address); - args.args[1 ] =upper_32_bits (memory_pool->mc_address); - args.args[2 ] = (u32 )memory_pool->size; - -return smu->msg_ctl.ops->send_msg (&smu->msg_ctl, &args); + params[0 ] =lower_32_bits (memory_pool->mc_address); + params[1 ] =upper_32_bits (memory_pool->mc_address); + params[2 ] = (u32 )memory_pool->size; + +return smu_cmn_send_smc_msg_with_params (smu, + SMU_MSG_DramLogSetDramAddr, + params,ARRAY_SIZE (params), +NULL ,0 ); }int smu_v15_0_set_driver_table_location (struct smu_context *smu) {struct smu_table *driver_table = &smu->smu_table.driver_table; -struct smu_msg_args args = { - .msg = SMU_MSG_SetDriverDramAddr, - .num_args =2 , - .num_out_args =0 , +const uint32_t params[] = { +lower_32_bits (driver_table->mc_address), +upper_32_bits (driver_table->mc_address), }; - args.args[0 ] =lower_32_bits (driver_table->mc_address); - args.args[1 ] =upper_32_bits (driver_table->mc_address); - -return smu->msg_ctl.ops->send_msg (&smu->msg_ctl, &args); +return smu_cmn_send_smc_msg_with_params (smu, SMU_MSG_SetDriverDramAddr, + params,ARRAY_SIZE (params), +NULL ,0 ); }int smu_v15_0_set_tool_table_location (struct smu_context *smu) {struct smu_table *tool_table = &smu->smu_table.tables[SMU_TABLE_PMSTATUSLOG ]; -struct smu_msg_args args = { - .msg = SMU_MSG_SetToolsDramAddr, - .num_args =2 , - .num_out_args =0 , +const uint32_t params[] = { +lower_32_bits (tool_table->mc_address), +upper_32_bits (tool_table->mc_address), };/* SMU_MSG_SetToolsDramAddr: ARG0=low, ARG1=high */ - args.args[0 ] =lower_32_bits (tool_table->mc_address); - args.args[1 ] =upper_32_bits (tool_table->mc_address); - -return smu->msg_ctl.ops->send_msg (&smu->msg_ctl, &args); +return smu_cmn_send_smc_msg_with_params (smu, SMU_MSG_SetToolsDramAddr, + params,ARRAY_SIZE (params), +NULL ,0 ); }int smu_v15_0_set_allowed_mask (struct smu_context *smu)
Signature · 1 line
2.47.3
PATCH 3/4 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0_0
In reply to Yang WangConvert the SMU15.0.0 table transfer path and enabled-feature query to smu_cmn_send_smc_msg_with_params() so both paths use the common SMU multi-msgs helper.
No functional change intended.
--- .../drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c +15 -23
@@ -248,7 +248,7 @@ static int smu_v15_0_0_update_table(struct smu_context *smu,uint64_t address;uint32_t table_size;int ret; -struct smu_msg_ctl *ctl = &smu->msg_ctl; +uint32_t params[3 ];if (!table_data || table_index >=SMU_TABLE_COUNT || table_id <0 )return -EINVAL ;
@@ -265,20 +265,15 @@ static int smu_v15_0_0_update_table(struct smu_context *smu, } address = table->mc_address; + params[0 ] = table_id; + params[1 ] = (uint32_t )lower_32_bits (address); + params[2 ] = (uint32_t )upper_32_bits (address); -struct smu_msg_args args = { - .msg = drv2smu ? - SMU_MSG_TransferTableDram2Smu : - SMU_MSG_TransferTableSmu2Dram, - .num_args =3 , - .num_out_args =0 , - }; - - args.args[0 ] = table_id; - args.args[1 ] = (uint32_t )lower_32_bits (address); - args.args[2 ] = (uint32_t )upper_32_bits (address); - - ret = ctl->ops->send_msg (ctl, &args); + ret =smu_cmn_send_smc_msg_with_params (smu, + drv2smu ? SMU_MSG_TransferTableDram2Smu : + SMU_MSG_TransferTableSmu2Dram, + params,ARRAY_SIZE (params), +NULL ,0 );if (ret)return ret;
@@ -535,22 +530,19 @@ static int smu_v15_0_0_read_sensor(struct smu_context *smu,static int smu_v15_0_0_get_enabled_mask (struct smu_context *smu,struct smu_feature_bits *feature_mask) { +uint32_t out[2 ];int ret; -struct smu_msg_ctl *ctl = &smu->msg_ctl;if (!feature_mask)return -EINVAL ; -struct smu_msg_args args = { - .msg = SMU_MSG_GetEnabledSmuFeatures, - .num_args =0 , - .num_out_args =2 , - }; - - ret = ctl->ops->send_msg (ctl, &args); + ret =smu_cmn_send_smc_msg_with_params (smu, + SMU_MSG_GetEnabledSmuFeatures, +NULL ,0 , out, +ARRAY_SIZE (out));if (!ret) -smu_feature_bits_from_arr32 (feature_mask, args.out_args, +smu_feature_bits_from_arr32 (feature_mask, out,SMU_FEATURE_NUM_DEFAULT );return ret;
Signature · 1 line
2.47.3
PATCH 4/4 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0_8
In reply to Yang WangConvert the SMU15.0.8 enabled-feature query to smu_cmn_send_smc_msg_with_params() so it uses the common SMU multi-msgs helper.
No functional change intended.
--- .../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +6 -8
@@ -1313,23 +1313,21 @@ static int smu_v15_0_8_system_features_control(struct smu_context *smu,static int smu_v15_0_8_get_enabled_mask (struct smu_context *smu,struct smu_feature_bits *feature_mask) { -struct smu_msg_args args = { - .msg = SMU_MSG_GetEnabledSmuFeatures, - .num_args =0 , - .num_out_args =2 , - }; +uint32_t out[2 ];int ret;if (!feature_mask)return -EINVAL ; - ret = smu->msg_ctl.ops->send_msg (&smu->msg_ctl, &args); + ret =smu_cmn_send_smc_msg_with_params (smu, + SMU_MSG_GetEnabledSmuFeatures, +NULL ,0 , + out,ARRAY_SIZE (out));if (ret)return ret; -smu_feature_bits_from_arr32 (feature_mask, args.out_args, -SMU_FEATURE_NUM_DEFAULT ); +smu_feature_bits_from_arr32 (feature_mask, out,SMU_FEATURE_NUM_DEFAULT );return 0 ; }
Signature · 1 line
2.47.3
AMD General
Ping this series to enable support for upcoming SMU IP and SMU RAS interface.
Best Regards,
Kevin
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Yang Wang
Sent: Monday, April 27, 2026 15:34
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH 0/4] drm/amd/pm: add and use the SMU multi-msgs helper
SMU15 introduced driver messages that can carry multiple input parameters and return values, but callers still have to build struct smu_msg_args directly.
Add common SMU multi-msgs helpers in smu_cmn and switch the first SMU15 users over to them. This keeps multi-parameter messages and multi-return queries on one helper path while leaving the older single-parameter interface unchanged.
Patch 1 adds the common helpers and updates the shared path. Patch 2 converts the SMU15 base table address messages. Patch 3 converts the SMU15.0.0 table transfer and enabled-feature query. Patch 4 converts the SMU15.0.8 enabled-feature query.
No functional change intended.
Yang Wang (4):
drm/amd/pm: add SMU multi-msgs helpers drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0_0 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0_8
.../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 47 ++++----- .../drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c | 38 +++----- .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 14 ++- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 96 +++++++++++++------ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++ 5 files changed, 130 insertions(+), 87 deletions(-)
--
2.47.3
Feng, Kenneth
maintainerAMD General
Series is Reviewed-by: Kenneth Feng <[email protected]> Thanks.
-----Original Message-----
From: Wang, Yang(Kevin) <[email protected]>
Sent: Monday, April 27, 2026 3:34 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: [PATCH 0/4] drm/amd/pm: add and use the SMU multi-msgs helper
SMU15 introduced driver messages that can carry multiple input parameters and return values, but callers still have to build struct smu_msg_args directly.
Add common SMU multi-msgs helpers in smu_cmn and switch the first SMU15 users over to them. This keeps multi-parameter messages and multi-return queries on one helper path while leaving the older single-parameter interface unchanged.
Patch 1 adds the common helpers and updates the shared path. Patch 2 converts the SMU15 base table address messages. Patch 3 converts the SMU15.0.0 table transfer and enabled-feature query. Patch 4 converts the SMU15.0.8 enabled-feature query.
No functional change intended.
Yang Wang (4):
drm/amd/pm: add SMU multi-msgs helpers drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0_0 drm/amd/pm: use the SMU multi-msgs helper in smu_v15_0_8
.../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c | 47 ++++----- .../drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c | 38 +++----- .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c | 14 ++- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 96 +++++++++++++------ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++ 5 files changed, 130 insertions(+), 87 deletions(-)
--
2.47.3