Skip to contentSkip to conversation

drm/amd/pm: add variant func smu_cmn_send_msg() to unify msg sending logic

PATCH In review Yang Wang 2 participants 9 messages Mar 23 – Mar 24

Subsystems (3)
lore
Share & tools
lore

Yang Wang

author
#0 lore raw

PATCH 1/4 drm/amd/pm: add variant func smu_cmn_send_msg() to unify msg sending logic

add variant func smu_cmn_send_msg() to unify smu message sending logic, and enabling support for newer ASIC interfaces such as SMU v15 and upcoming devices. (support multi-param/multi-response, standardize code across all smu code layers)

The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters. e.g:
1. r = smu_cmn_send_msg(smu, msg_id);
2. r = smu_cmn_send_msg(smu, msg_id, &read_arg);
3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg);
4. r = smu_cmn_send_msg(smu, msg_id,

			num_param, [param0, param1, ...],
			num_response, [arg0, arg1, ...]
---
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 79 ++++++++++++++++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++++
 2 files changed, 101 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +79 -0
index 7bd8c435466a..480d91d88957 100644
@@ -193,6 +193,85 @@ int smu_cmn_send_smc_msg(struct smu_context *smu,
 					       read_arg);
 }
 
+static inline int smu_cmn_send_msg_internal(struct smu_context *smu, enum smu_message_type msg,
+					    int num_in_args, u32 *in_args,
+					    int num_out_args, u32 *out_args)
+{
+	struct smu_msg_ctl *ctl = &smu->msg_ctl;
+	struct smu_msg_args args = { 0 };
+	int ret;
+
+	if (msg >= SMU_MSG_MAX_COUNT)
+		return -EINVAL;
+
+	if ((num_in_args >= ARRAY_SIZE(args.args) || num_in_args < 0) ||
+	    (num_out_args >= ARRAY_SIZE(args.out_args) || num_out_args < 0))
+		return -EINVAL;
+
+	if ((num_in_args > 0 && !in_args) || (num_out_args > 0 && !out_args))
+		return -EINVAL;
+
+	if (!ctl->ops || !ctl->ops->send_msg)
+		return -EOPNOTSUPP;
+
+	args.msg = msg;
+	args.num_args = num_in_args;
+	args.num_out_args = num_out_args;
+	args.flags = 0;
+	args.timeout = 0;
+
+	if (num_in_args)
+		memcpy(&args.args[0], in_args, num_in_args * sizeof(u32));
+
+	ret = ctl->ops->send_msg(ctl, &args);
+	if (ret)
+		return ret;
+
+	if (num_out_args)
+		memcpy(out_args, &args.out_args[0], num_out_args * sizeof(u32));
+
+	return ret;
+}
+
+/*
+ * NOTE: To ensure compatibility with the behavioral logic of the legacy API,
+ * it is required to explicitly set the parameter "param" to 0 when invoking
+ * the msg_0 and msg_1 functions.
+ * */
+
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum smu_message_type msg)
+{
+	return __smu_cmn_send_msg_2(smu, msg, 0, NULL);
+}
+
+int __smu_cmn_send_msg_1(struct smu_context *smu, enum smu_message_type msg,
+			 u32 *read_arg)
+{
+	return __smu_cmn_send_msg_2(smu, msg, 0, read_arg);
+}
+
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum smu_message_type msg,
+			 u32 param, u32 *read_arg)
+{
+	int ret;
+
+	if (read_arg)
+		ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 1, read_arg);
+	else
+		ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 0, NULL);
+
+	return ret;
+}
+
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum smu_message_type msg,
+			 int num_in_args, u32 *in_args,
+			 int num_out_args, u32 *out_args)
+{
+	return smu_cmn_send_msg_internal(smu, msg,
+					 num_in_args, in_args,
+					 num_out_args, out_args);
+}
+
 int smu_cmn_send_debug_smc_msg(struct smu_context *smu,
 			 uint32_t msg)
 {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +22 -0
index b76e86df5da7..5c14ed9ed9b4 100644
@@ -210,6 +210,28 @@ int smu_cmn_dpm_pcie_gen_idx(int gen);
 int smu_cmn_dpm_pcie_width_idx(int width);
 int smu_cmn_check_fw_version(struct smu_context *smu);
 
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum smu_message_type msg);
+int __smu_cmn_send_msg_1(struct smu_context *smu, enum smu_message_type msg,
+			 u32 *read_arg);
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum smu_message_type msg,
+			 u32 param, u32 *read_arg);
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum smu_message_type msg,
+			 int num_in_args, u32 *in_args,
+			 int num_out_args, u32 *out_args);
+
+/*
+* The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters.
+* e.g:
+* 1. r = smu_cmn_send_msg(smu, msg_id);
+* 2. r = smu_cmn_send_msg(smu, msg_id, &read_arg);
+* 3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg);
+* 4. r = smu_cmn_send_msg(smu, msg_id,
+*			  num_param, [param0, param1, ...],
+*			  num_response, [arg0, arg1, ...]
+*/
+#define smu_cmn_send_msg(smu, msg, ...) \
+	CONCATENATE(__smu_cmn_send_msg_, COUNT_ARGS(__VA_ARGS__))(smu, msg, ##__VA_ARGS__)
+
 /*SMU gpu metrics */
 
 /* Attribute ID mapping */
Signature · 1 line
2.47.3
author
#1 lore raw

PATCH 2/4 drm/amd/pm: replace legacy smu_cmn_send_smc_msg() with smu_cmn_send_msg()

Retire the legacy smu_cmn_send_smc_msg() API and replace it with the unified smu_cmn_send_msg(). This patch streamlines the change to the following sed command and standardizes code formatting:
'sed -i 's/smu_cmn_send_smc_msg/smu_cmn_send_msg/g'

---
 .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c |  8 ++---
 .../amd/pm/swsmu/smu11/cyan_skillfish_ppt.c   |  2 +-
 .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 10 +++---
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  2 +-
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    | 19 +++++------
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  |  8 ++---
 .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c   |  6 ++--
 .../gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c    |  8 ++---
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    | 12 +++----
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    | 30 +++++++----------
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  |  4 +--
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c |  6 ++--
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c  |  2 +-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_5_ppt.c  |  2 +-
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 33 +++++++++----------
 .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c  |  4 +--
 .../gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c    | 20 +++++------
 .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c  |  2 +-
 .../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c    | 14 ++++----
 .../drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c  |  2 +-
 .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c  | 18 +++++-----
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 20 +++--------
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  4 ---
 23 files changed, 105 insertions(+), 131 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +4 -4
index 0c4afd1e1aab..220027596937 100644
@@ -550,13 +550,13 @@ static int arcturus_run_btc(struct smu_context *smu)
 {
 	int ret = 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_RunAfllBtc, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_RunAfllBtc);
 	if (ret) {
 		dev_err(smu->adev->dev, "RunAfllBtc failed!\n");
 		return ret;
 	}
 
-	return smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);
+	return smu_cmn_send_msg(smu, SMU_MSG_RunDcBtc);
 }
 
 static int arcturus_populate_umd_state_clk(struct smu_context *smu)
@@ -1716,8 +1716,8 @@ static void arcturus_get_unique_id(struct smu_context *smu)
 	}
 
 	/* Get the SN to turn into a Unique ID */
-	smu_cmn_send_smc_msg(smu, SMU_MSG_ReadSerialNumTop32, &top32);
-	smu_cmn_send_smc_msg(smu, SMU_MSG_ReadSerialNumBottom32, &bottom32);
+	smu_cmn_send_msg(smu, SMU_MSG_ReadSerialNumTop32, &top32);
+	smu_cmn_send_msg(smu, SMU_MSG_ReadSerialNumBottom32, &bottom32);
 
 	id = ((uint64_t)bottom32 << 32) | top32;
 	adev->unique_id = id;
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +1 -1
index 87953a4d0a43..e37e2388a231 100644
@@ -512,7 +512,7 @@ static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,
 		}
 
 		if (cyan_skillfish_user_settings.vddc == CYAN_SKILLFISH_VDDC_MAGIC) {
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_UnforceGfxVid, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_UnforceGfxVid);
 			if (ret) {
 				dev_err(smu->adev->dev, "Unforce vddc failed!\n");
 				return ret;
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +5 -5
index 737bfdfb814c..1b95fa7e1a46 100644
@@ -1138,7 +1138,7 @@ static int navi10_dpm_set_vcn_enable(struct smu_context *smu,
 		}
 	} else {
 		if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) {
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PowerDownVcn, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_PowerDownVcn);
 			if (ret)
 				return ret;
 		}
@@ -1153,13 +1153,13 @@ static int navi10_dpm_set_jpeg_enable(struct smu_context *smu, bool enable)
 
 	if (enable) {
 		if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_JPEG_PG_BIT)) {
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PowerUpJpeg, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_PowerUpJpeg);
 			if (ret)
 				return ret;
 		}
 	} else {
 		if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_JPEG_PG_BIT)) {
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PowerDownJpeg, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_PowerDownJpeg);
 			if (ret)
 				return ret;
 		}
@@ -2553,7 +2553,7 @@ static int navi10_run_btc(struct smu_context *smu)
 {
 	int ret = 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_RunBtc, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_RunBtc);
 	if (ret)
 		dev_err(smu->adev->dev, "RunBtc failed!\n");
 
@@ -2617,7 +2617,7 @@ static int navi10_umc_hybrid_cdr_workaround(struct smu_context *smu)
 	 * In this case, SMU already disabled dummy pstate during enablement
 	 * of UCLK DPM, we have to re-enabled it.
 	 */
-	return smu_cmn_send_smc_msg(smu, SMU_MSG_DAL_ENABLE_DUMMY_PSTATE_CHANGE, NULL);
+	return smu_cmn_send_msg(smu, SMU_MSG_DAL_ENABLE_DUMMY_PSTATE_CHANGE);
 }
 
 static int navi10_set_dummy_pstates_table_location(struct smu_context *smu)
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +1 -1
index 6268bc5ed3e6..39000c053203 100644
@@ -2436,7 +2436,7 @@ static int sienna_cichlid_run_btc(struct smu_context *smu)
 {
 	int res;
 
-	res = smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);
+	res = smu_cmn_send_msg(smu, SMU_MSG_RunDcBtc);
 	if (res)
 		dev_err(smu->adev->dev, "RunDcBtc failed!\n");
 
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +9 -10
index 1eec1a88e05f..210134ee1437 100644
@@ -774,8 +774,8 @@ int smu_v11_0_set_allowed_mask(struct smu_context *smu)
 int smu_v11_0_system_features_control(struct smu_context *smu,
 					     bool en)
 {
-	return smu_cmn_send_smc_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
-					  SMU_MSG_DisableAllSmuFeatures), NULL);
+	return smu_cmn_send_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
+					  SMU_MSG_DisableAllSmuFeatures));
 }
 
 int smu_v11_0_notify_display_change(struct smu_context *smu)
@@ -980,9 +980,8 @@ int smu_v11_0_set_power_limit(struct smu_context *smu,
 
 static int smu_v11_0_ack_ac_dc_interrupt(struct smu_context *smu)
 {
-	return smu_cmn_send_smc_msg(smu,
-				SMU_MSG_ReenableAcDcInterrupt,
-				NULL);
+	return smu_cmn_send_msg(smu,
+				SMU_MSG_ReenableAcDcInterrupt);
 }
 
 static int smu_v11_0_process_pending_interrupt(struct smu_context *smu)
@@ -1121,9 +1120,9 @@ int smu_v11_0_gfx_off_control(struct smu_context *smu, bool enable)
 		if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
 			return 0;
 		if (enable)
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_AllowGfxOff, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_AllowGfxOff);
 		else
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_DisallowGfxOff, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_DisallowGfxOff);
 		break;
 	default:
 		break;
@@ -1553,7 +1552,7 @@ int smu_v11_0_get_max_sustainable_clocks_by_dc(struct smu_context *smu,
 
 int smu_v11_0_set_azalia_d3_pme(struct smu_context *smu)
 {
-	return smu_cmn_send_smc_msg(smu, SMU_MSG_BacoAudioD3PME, NULL);
+	return smu_cmn_send_msg(smu, SMU_MSG_BacoAudioD3PME);
 }
 
 int smu_v11_0_baco_set_armd3_sequence(struct smu_context *smu,
@@ -1646,7 +1645,7 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)
 		}
 
 	} else {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_ExitBaco, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_ExitBaco);
 		if (ret)
 			return ret;
 
@@ -1694,7 +1693,7 @@ int smu_v11_0_mode1_reset(struct smu_context *smu)
 {
 	int ret = 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_Mode1Reset);
 	if (!ret)
 		msleep(SMU11_MODE1_RESET_WAIT_TIME_IN_MS);
 
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +4 -4
index 08179840697e..d67104f52496 100644
@@ -2241,7 +2241,7 @@ static int vangogh_post_smu_init(struct smu_context *smu)
 	/* allow message will be sent after enable message on Vangogh*/
 	if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_GFXCLK_BIT) &&
 			(adev->pg_flags & AMD_PG_SUPPORT_GFX_PG)) {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_EnableGfxOff, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_EnableGfxOff);
 		if (ret) {
 			dev_err(adev->dev, "Failed to Enable GfxOff!\n");
 			return ret;
@@ -2330,7 +2330,7 @@ static int vangogh_get_power_limit(struct smu_context *smu,
 	if (smu->adev->pm.fw_version < 0x43f1e00)
 		return ret;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetSlowPPTLimit, &ppt_limit);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetSlowPPTLimit, &ppt_limit);
 	if (ret) {
 		dev_err(smu->adev->dev, "Get slow PPT limit failed!\n");
 		return ret;
@@ -2345,7 +2345,7 @@ static int vangogh_get_power_limit(struct smu_context *smu,
 	if (min_power_limit)
 		*min_power_limit = 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetFastPPTLimit, &ppt_limit);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetFastPPTLimit, &ppt_limit);
 	if (ret) {
 		dev_err(smu->adev->dev, "Get fast PPT limit failed!\n");
 		return ret;
@@ -2503,7 +2503,7 @@ static u32 vangogh_get_gfxoff_entrycount(struct smu_context *smu, uint64_t *entr
 	if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
 		return 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetGfxOffEntryCount, &value);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetGfxOffEntryCount, &value);
 	*entrycount = value + adev->gfx.gfx_off_entrycount;
 
 	return ret;
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +3 -3
index 31e21ff8859a..f46269075ee2 100644
@@ -318,7 +318,7 @@ static int renoir_get_dpm_ultimate_freq(struct smu_context *smu,
 		switch (clk_type) {
 		case SMU_GFXCLK:
 		case SMU_SCLK:
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetMaxGfxclkFrequency, max);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_GetMaxGfxclkFrequency, max);
 			if (ret) {
 				dev_err(smu->adev->dev, "Attempt to get max GX frequency from SMC Failed !\n");
 				goto failed;
@@ -346,7 +346,7 @@ static int renoir_get_dpm_ultimate_freq(struct smu_context *smu,
 		switch (clk_type) {
 		case SMU_GFXCLK:
 		case SMU_SCLK:
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetMinGfxclkFrequency, min);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_GetMinGfxclkFrequency, min);
 			if (ret) {
 				dev_err(smu->adev->dev, "Attempt to get min GX frequency from SMC Failed !\n");
 				goto failed;
@@ -649,7 +649,7 @@ static int renoir_dpm_set_vcn_enable(struct smu_context *smu,
 		}
 	} else {
 		if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) {
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PowerDownVcn, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_PowerDownVcn);
 			if (ret)
 				return ret;
 		}
drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c +4 -4
index ac5e44dff6c9..0bd36b465cae 100644
@@ -112,9 +112,9 @@ int smu_v12_0_powergate_sdma(struct smu_context *smu, bool gate)
 		return 0;
 
 	if (gate)
-		return smu_cmn_send_smc_msg(smu, SMU_MSG_PowerDownSdma, NULL);
+		return smu_cmn_send_msg(smu, SMU_MSG_PowerDownSdma);
 	else
-		return smu_cmn_send_smc_msg(smu, SMU_MSG_PowerUpSdma, NULL);
+		return smu_cmn_send_msg(smu, SMU_MSG_PowerUpSdma);
 }
 
 int smu_v12_0_set_gfx_cgpg(struct smu_context *smu, bool enable)
@@ -159,10 +159,10 @@ int smu_v12_0_gfx_off_control(struct smu_context *smu, bool enable)
 	int ret = 0, timeout = 500;
 
 	if (enable) {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_AllowGfxOff, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_AllowGfxOff);
 
 	} else {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_DisallowGfxOff, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_DisallowGfxOff);
 
 		/* confirm gfx is back to "on" state, timeout is 0.5 second */
 		while (!(smu_v12_0_get_gfxoff_status(smu) == 2)) {
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +6 -6
index 259e5a13c1bd..5ffd4ca69499 100644
@@ -560,7 +560,7 @@ static int aldebaran_run_board_btc(struct smu_context *smu)
 	if (smu->smc_fw_version <= 0x00441d00)
 		return 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_BoardPowerCalibration, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_BoardPowerCalibration);
 	if (ret)
 		dev_err(smu->adev->dev, "Board power calibration failed!\n");
 
@@ -571,7 +571,7 @@ static int aldebaran_run_btc(struct smu_context *smu)
 {
 	int ret;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_RunDcBtc);
 	if (ret)
 		dev_err(smu->adev->dev, "RunDcBtc failed!\n");
 	else
@@ -1139,8 +1139,8 @@ static int aldebaran_get_power_limit(struct smu_context *smu,
 	 * For secondary die show the value as 0.
 	 */
 	if (aldebaran_is_primary(smu)) {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetPptLimit,
-					   &power_limit);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_GetPptLimit,
+				       &power_limit);
 
 		if (ret) {
 			/* the last hope to figure out the ppt limit */
@@ -1203,7 +1203,7 @@ static int aldebaran_set_performance_level(struct smu_context *smu,
 	/* Disable determinism if switching to another mode */
 	if ((smu_dpm->dpm_level == AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM) &&
 	    (level != AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM)) {
-		smu_cmn_send_smc_msg(smu, SMU_MSG_DisableDeterminism, NULL);
+		smu_cmn_send_msg(smu, SMU_MSG_DisableDeterminism);
 		pstate_table->gfxclk_pstate.curr.max =
 			SMU_DPM_TABLE_MAX(gfx_table);
 	}
@@ -1806,7 +1806,7 @@ static int aldebaran_mode1_reset(struct smu_context *smu)
 	* PM FW support SMU_MSG_GfxDeviceDriverReset from 68.07
 	*/
 	if (smu->smc_fw_version < 0x00440700) {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_Mode1Reset);
 	} else {
 		/* fatal error triggered by ras, PMFW supports the flag
 		   from 68.44.0 */
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +12 -18
index d8a1c402a624..4cce12f3d783 100644
@@ -754,9 +754,9 @@ int smu_v13_0_gfx_off_control(struct smu_context *smu, bool enable)
 		if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
 			return 0;
 		if (enable)
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_AllowGfxOff, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_AllowGfxOff);
 		else
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_DisallowGfxOff, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_DisallowGfxOff);
 		break;
 	default:
 		break;
@@ -768,8 +768,8 @@ int smu_v13_0_gfx_off_control(struct smu_context *smu, bool enable)
 int smu_v13_0_system_features_control(struct smu_context *smu,
 				      bool en)
 {
-	return smu_cmn_send_smc_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
-					  SMU_MSG_DisableAllSmuFeatures), NULL);
+	return smu_cmn_send_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
+					  SMU_MSG_DisableAllSmuFeatures));
 }
 
 int smu_v13_0_notify_display_change(struct smu_context *smu)
@@ -777,7 +777,7 @@ int smu_v13_0_notify_display_change(struct smu_context *smu)
 	int ret = 0;
 
 	if (!amdgpu_device_has_dc_support(smu->adev))
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_DALNotPresent, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_DALNotPresent);
 
 	return ret;
 }
@@ -951,9 +951,7 @@ int smu_v13_0_set_power_limit(struct smu_context *smu,
 
 static int smu_v13_0_allow_ih_interrupt(struct smu_context *smu)
 {
-	return smu_cmn_send_smc_msg(smu,
-				    SMU_MSG_AllowIHHostInterrupt,
-				    NULL);
+	return smu_cmn_send_msg(smu, SMU_MSG_AllowIHHostInterrupt);
 }
 
 static int smu_v13_0_process_pending_interrupt(struct smu_context *smu)
@@ -1210,9 +1208,7 @@ static int smu_v13_0_set_irq_state(struct amdgpu_device *adev,
 
 void smu_v13_0_interrupt_work(struct smu_context *smu)
 {
-	smu_cmn_send_smc_msg(smu,
-			     SMU_MSG_ReenableAcDcInterrupt,
-			     NULL);
+	smu_cmn_send_msg(smu, SMU_MSG_ReenableAcDcInterrupt);
 }
 
 #define THM_11_0__SRCID__THM_DIG_THERM_L2H		0		/* ASIC_TEMP > CG_THERMAL_INT.DIG_THERM_INTH  */
@@ -1406,7 +1402,7 @@ int smu_v13_0_set_azalia_d3_pme(struct smu_context *smu)
 {
 	int ret = 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_BacoAudioD3PME, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_BacoAudioD3PME);
 
 	return ret;
 }
@@ -1417,7 +1413,7 @@ static int smu_v13_0_wait_for_reset_complete(struct smu_context *smu,
 	int ret = 0;
 
 	dev_dbg(smu->adev->dev, "waiting for smu reset complete\n");
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GfxDriverResetRecovery, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GfxDriverResetRecovery);
 
 	return ret;
 }
@@ -1973,7 +1969,7 @@ int smu_v13_0_run_btc(struct smu_context *smu)
 {
 	int res;
 
-	res = smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);
+	res = smu_cmn_send_msg(smu, SMU_MSG_RunDcBtc);
 	if (res)
 		dev_err(smu->adev->dev, "RunDcBtc failed!\n");
 
@@ -2125,9 +2121,7 @@ static int smu_v13_0_baco_set_state(struct smu_context *smu,
 						      BACO_SEQ_BAMACO : BACO_SEQ_BACO,
 						      NULL);
 	} else {
-		ret = smu_cmn_send_smc_msg(smu,
-					   SMU_MSG_ExitBaco,
-					   NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_ExitBaco);
 		if (ret)
 			return ret;
 
@@ -2332,7 +2326,7 @@ int smu_v13_0_mode1_reset(struct smu_context *smu)
 {
 	int ret = 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_Mode1Reset);
 	if (!ret)
 		msleep(SMU13_MODE1_RESET_WAIT_TIME_IN_MS);
 
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +2 -2
index ab81582e46aa..e8f8917654eb 100644
@@ -2864,7 +2864,7 @@ static int smu_v13_0_0_mode1_reset(struct smu_context *smu)
 		break;
 
 	default:
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode1Reset, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_Mode1Reset);
 		break;
 	}
 
@@ -2885,7 +2885,7 @@ static int smu_v13_0_0_mode2_reset(struct smu_context *smu)
 	struct amdgpu_device *adev = smu->adev;
 
 	if (amdgpu_ip_version(adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 10))
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_Mode2Reset, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_Mode2Reset);
 	else
 		return -EOPNOTSUPP;
 
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c +3 -3
index 67cd186bd263..834e7ef8079f 100644
@@ -301,8 +301,8 @@ int smu_v13_0_12_setup_driver_pptable(struct smu_context *smu)
 		if (ret)
 			return ret;
 
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetMetricsVersion,
-					   &table_version);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_GetMetricsVersion,
+				       &table_version);
 		if (ret)
 			return ret;
 		smu_table->tables[SMU_TABLE_SMU_METRICS].version =
@@ -471,7 +471,7 @@ static int smu_v13_0_12_get_system_metrics_table(struct smu_context *smu)
 	if (smu_table_cache_is_valid(sys_table))
 		return 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetSystemMetricsTable, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetSystemMetricsTable);
 	if (ret) {
 		dev_info(smu->adev->dev,
 			 "Failed to export system metrics table!\n");
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c +1 -1
index 167b3499f7f1..85e34c890672 100644
@@ -241,7 +241,7 @@ static int smu_v13_0_4_system_features_control(struct smu_context *smu, bool en)
 				return ret;
 		}
 
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PrepareMp1ForUnload);
 	}
 
 	return ret;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_5_ppt.c +1 -1
index 141e778333c5..ed6fa13f3119 100644
@@ -191,7 +191,7 @@ static int smu_v13_0_5_system_features_control(struct smu_context *smu, bool en)
 	int ret = 0;
 
 	if (!en && !adev->in_s0ix)
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PrepareMp1ForUnload);
 
 	return ret;
 }
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +16 -17
index f76665c85bc3..1266867108e5 100644
@@ -769,7 +769,7 @@ int smu_v13_0_6_get_metrics_table(struct smu_context *smu, void *metrics_table,
 	if (bypass_cache || !smu_table->metrics_time ||
 	    time_after(jiffies,
 		       smu_table->metrics_time + msecs_to_jiffies(1))) {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetMetricsTable, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_GetMetricsTable);
 		if (ret) {
 			dev_info(smu->adev->dev,
 				 "Failed to export SMU metrics table!\n");
@@ -848,7 +848,7 @@ int smu_v13_0_6_get_static_metrics_table(struct smu_context *smu)
 	struct smu_table *table = &smu_table->driver_table;
 	int ret;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetStaticMetricsTable, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetStaticMetricsTable);
 	if (ret) {
 		dev_info(smu->adev->dev,
 				"Failed to export static metrics table!\n");
@@ -912,8 +912,8 @@ static int smu_v13_0_6_setup_driver_pptable(struct smu_context *smu)
 		if (!retry)
 			return -ETIME;
 
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetMetricsVersion,
-					   &table_version);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_GetMetricsVersion,
+				       &table_version);
 		if (ret)
 			return ret;
 		smu_table->tables[SMU_TABLE_SMU_METRICS].version =
@@ -1040,8 +1040,8 @@ static int smu_v13_0_6_get_dpm_ultimate_freq(struct smu_context *smu,
 
 	if (max) {
 		if (clk_type == SMU_GFXCLK || clk_type == SMU_SCLK)
-			ret = smu_cmn_send_smc_msg(
-				smu, SMU_MSG_GetMaxGfxclkFrequency, max);
+			ret = smu_cmn_send_msg(smu,
+					       SMU_MSG_GetMaxGfxclkFrequency, max);
 		else
 			ret = smu_cmn_send_smc_msg_with_param(
 				smu, SMU_MSG_GetMaxDpmFreq, param, max);
@@ -1051,8 +1051,8 @@ static int smu_v13_0_6_get_dpm_ultimate_freq(struct smu_context *smu,
 
 	if (min) {
 		if (clk_type == SMU_GFXCLK || clk_type == SMU_SCLK)
-			ret = smu_cmn_send_smc_msg(
-				smu, SMU_MSG_GetMinGfxclkFrequency, min);
+			ret = smu_cmn_send_msg(smu,
+					       SMU_MSG_GetMinGfxclkFrequency, min);
 		else
 			ret = smu_cmn_send_smc_msg_with_param(
 				smu, SMU_MSG_GetMinDpmFreq, param, min);
@@ -1722,7 +1722,7 @@ static int smu_v13_0_6_get_power_limit(struct smu_context *smu,
 	uint32_t power_limit = 0;
 	int ret;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetPptLimit, &power_limit);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetPptLimit, &power_limit);
 
 	if (ret) {
 		dev_err(smu->adev->dev, "Couldn't get PPT limit");
@@ -1789,7 +1789,7 @@ static int smu_v13_0_6_get_ppt_limit(struct smu_context *smu,
 			*ppt_limit = pptable->PPT1Max;
 			break;
 		case SMU_PPT_LIMIT_CURRENT:
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetFastPptLimit, ppt_limit);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_GetFastPptLimit, ppt_limit);
 			if (ret)
 				dev_err(smu->adev->dev, "Get fast PPT limit failed!\n");
 			break;
@@ -1929,7 +1929,7 @@ static int smu_v13_0_6_notify_unload(struct smu_context *smu)
 
 	dev_dbg(smu->adev->dev, "Notify PMFW about driver unload");
 	/* Ignore return, just intimate FW that driver is not going to be there */
-	smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);
+	smu_cmn_send_msg(smu, SMU_MSG_PrepareMp1ForUnload);
 
 	return 0;
 }
@@ -1995,7 +1995,7 @@ static int smu_v13_0_6_set_performance_level(struct smu_context *smu,
 	/* Disable determinism if switching to another mode */
 	if ((smu_dpm->dpm_level == AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM) &&
 	    (level != AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM)) {
-		smu_cmn_send_smc_msg(smu, SMU_MSG_DisableDeterminism, NULL);
+		smu_cmn_send_msg(smu, SMU_MSG_DisableDeterminism);
 		pstate_table->gfxclk_pstate.curr.max =
 			SMU_DPM_TABLE_MAX(gfx_table);
 	}
@@ -2406,8 +2406,7 @@ static int smu_v13_0_6_request_i2c_xfer(struct smu_context *smu,
 	memcpy(table->cpu_addr, table_data, table_size);
 	/* Flush hdp cache */
 	amdgpu_hdp_flush(adev, NULL);
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_RequestI2cTransaction,
-					  NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_RequestI2cTransaction);
 
 	return ret;
 }
@@ -3181,7 +3180,7 @@ static int smu_v13_0_6_send_rma_reason(struct smu_context *smu)
 	if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(RMA_MSG)))
 		return 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_RmaDueToBadPageThreshold, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_RmaDueToBadPageThreshold);
 	if (ret)
 		dev_err(smu->adev->dev,
 			"[%s] failed to send BadPageThreshold event to SMU\n",
@@ -3314,7 +3313,7 @@ static int smu_v13_0_6_get_valid_mca_count(struct smu_context *smu, enum amdgpu_
 		return -EINVAL;
 	}
 
-	ret = smu_cmn_send_smc_msg(smu, msg, count);
+	ret = smu_cmn_send_msg(smu, msg, count);
 	if (ret) {
 		*count = 0;
 		return ret;
@@ -3779,7 +3778,7 @@ static int smu_v13_0_6_get_valid_aca_count(struct smu_context *smu, enum aca_smu
 		return -EINVAL;
 	}
 
-	ret = smu_cmn_send_smc_msg(smu, msg, count);
+	ret = smu_cmn_send_msg(smu, msg, count);
 	if (ret) {
 		*count = 0;
 		return ret;
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +2 -2
index 748b5b074fff..bcf472e5b415 100644
@@ -218,7 +218,7 @@ static int yellow_carp_system_features_control(struct smu_context *smu, bool en)
 	int ret = 0;
 
 	if (!en && !adev->in_s0ix)
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PrepareMp1ForUnload);
 
 	return ret;
 }
@@ -276,7 +276,7 @@ static int yellow_carp_post_smu_init(struct smu_context *smu)
 	int ret = 0;
 
 	/* allow message will be sent after enable message on Yellow Carp*/
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_EnableGfxOff, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_EnableGfxOff);
 	if (ret)
 		dev_err(adev->dev, "Failed to Enable GfxOff!\n");
 	return ret;
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c +8 -12
index 9f01bed3970e..395626e4732c 100644
@@ -777,9 +777,9 @@ int smu_v14_0_gfx_off_control(struct smu_context *smu, bool enable)
 		if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
 			return 0;
 		if (enable)
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_AllowGfxOff, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_AllowGfxOff);
 		else
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_DisallowGfxOff, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_DisallowGfxOff);
 		break;
 	default:
 		break;
@@ -791,8 +791,8 @@ int smu_v14_0_gfx_off_control(struct smu_context *smu, bool enable)
 int smu_v14_0_system_features_control(struct smu_context *smu,
 				      bool en)
 {
-	return smu_cmn_send_smc_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
-					  SMU_MSG_DisableAllSmuFeatures), NULL);
+	return smu_cmn_send_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
+					  SMU_MSG_DisableAllSmuFeatures));
 }
 
 int smu_v14_0_notify_display_change(struct smu_context *smu)
@@ -1068,7 +1068,7 @@ static int smu_v14_0_wait_for_reset_complete(struct smu_context *smu,
 	int ret = 0;
 
 	dev_dbg(smu->adev->dev, "waiting for smu reset complete\n");
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GfxDriverResetRecovery, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GfxDriverResetRecovery);
 
 	return ret;
 }
@@ -1620,7 +1620,7 @@ int smu_v14_0_run_btc(struct smu_context *smu)
 {
 	int res;
 
-	res = smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);
+	res = smu_cmn_send_msg(smu, SMU_MSG_RunDcBtc);
 	if (res)
 		dev_err(smu->adev->dev, "RunDcBtc failed!\n");
 
@@ -1795,9 +1795,7 @@ int smu_v14_0_baco_set_state(struct smu_context *smu,
 						      BACO_SEQ_BAMACO : BACO_SEQ_BACO,
 						      NULL);
 	} else {
-		ret = smu_cmn_send_smc_msg(smu,
-					   SMU_MSG_ExitBaco,
-					   NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_ExitBaco);
 		if (ret)
 			return ret;
 
@@ -1948,9 +1946,7 @@ int smu_v14_0_od_edit_dpm_table(struct smu_context *smu,
 
 static int smu_v14_0_allow_ih_interrupt(struct smu_context *smu)
 {
-	return smu_cmn_send_smc_msg(smu,
-				    SMU_MSG_AllowIHHostInterrupt,
-				    NULL);
+	return smu_cmn_send_msg(smu, SMU_MSG_AllowIHHostInterrupt);
 }
 
 int smu_v14_0_enable_thermal_alert(struct smu_context *smu)
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c +1 -1
index dbdf7653cc53..0be0b11be79a 100644
@@ -252,7 +252,7 @@ static int smu_v14_0_0_system_features_control(struct smu_context *smu, bool en)
 	int ret = 0;
 
 	if (!en && !adev->in_s0ix)
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PrepareMp1ForUnload);
 
 	return ret;
 }
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c +7 -7
index 5649f2e71ac6..878dc26927f4 100644
@@ -671,9 +671,9 @@ int smu_v15_0_gfx_off_control(struct smu_context *smu, bool enable)
 		if (!(adev->pm.pp_feature & PP_GFXOFF_MASK))
 			return 0;
 		if (enable)
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_AllowGfxOff, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_AllowGfxOff);
 		else
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_DisallowGfxOff, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_DisallowGfxOff);
 		break;
 	default:
 		break;
@@ -684,7 +684,7 @@ int smu_v15_0_gfx_off_control(struct smu_context *smu, bool enable)
 
 int smu_v15_0_system_features_control(struct smu_context *smu, bool en)
 {
-	return smu_cmn_send_smc_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
+	return smu_cmn_send_msg(smu, (en ? SMU_MSG_EnableAllSmuFeatures :
 					  SMU_MSG_DisableAllSmuFeatures), NULL);
 }
 
@@ -881,7 +881,7 @@ static int smu_v15_0_wait_for_reset_complete(struct smu_context *smu,
 	int ret = 0;
 
 	dev_dbg(smu->adev->dev, "waiting for smu reset complete\n");
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GfxDriverResetRecovery, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GfxDriverResetRecovery, NULL);
 
 	return ret;
 }
@@ -1417,7 +1417,7 @@ int smu_v15_0_run_btc(struct smu_context *smu)
 {
 	int res;
 
-	res = smu_cmn_send_smc_msg(smu, SMU_MSG_RunDcBtc, NULL);
+	res = smu_cmn_send_msg(smu, SMU_MSG_RunDcBtc);
 	if (res)
 		dev_err(smu->adev->dev, "RunDcBtc failed!\n");
 
@@ -1592,7 +1592,7 @@ int smu_v15_0_baco_set_state(struct smu_context *smu,
 						      BACO_SEQ_BAMACO : BACO_SEQ_BACO,
 						      NULL);
 	} else {
-		ret = smu_cmn_send_smc_msg(smu,
+		ret = smu_cmn_send_msg(smu,
 					   SMU_MSG_ExitBaco,
 					   NULL);
 		if (ret)
@@ -1732,7 +1732,7 @@ int smu_v15_0_od_edit_dpm_table(struct smu_context *smu,
 
 static int smu_v15_0_allow_ih_interrupt(struct smu_context *smu)
 {
-	return smu_cmn_send_smc_msg(smu,
+	return smu_cmn_send_msg(smu,
 				    SMU_MSG_AllowIHHostInterrupt,
 				    NULL);
 }
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c +1 -1
index 9a4a5f482e75..80ba197664f1 100644
@@ -228,7 +228,7 @@ static int smu_v15_0_0_system_features_control(struct smu_context *smu, bool en)
 	int ret = 0;
 
 	if (!en && !adev->in_s0ix)
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PrepareMp1ForUnload);
 
 	return ret;
 }
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +9 -9
index cc2babc6a341..672f243ea0fe 100644
@@ -335,7 +335,7 @@ static int smu_v15_0_8_get_metrics_table_internal(struct smu_context *smu, uint3
 
 	if (!tmo || !smu_table->metrics_time ||
 	    time_after(jiffies, smu_table->metrics_time + msecs_to_jiffies(tmo))) {
-		int ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetMetricsTable, NULL);
+		int ret = smu_cmn_send_msg(smu, SMU_MSG_GetMetricsTable);
 		if (ret) {
 			dev_info(adev->dev,
 				 "Failed to export SMU metrics table!\n");
@@ -543,7 +543,7 @@ static int smu_v15_0_8_get_system_metrics_table(struct smu_context *smu)
 	if (smu_table_cache_is_valid(sys_table))
 		return 0;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetSystemMetricsTable, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetSystemMetricsTable);
 	if (ret) {
 		dev_info(smu->adev->dev,
 			 "Failed to export system metrics table!\n");
@@ -980,7 +980,7 @@ static int smu_v15_0_8_get_static_metrics_table(struct smu_context *smu)
 	struct smu_table *table = &smu_table->driver_table;
 	int ret;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetStaticMetricsTable, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetStaticMetricsTable);
 	if (ret) {
 		dev_err(smu->adev->dev,
 			 "Failed to export static metrics table!\n");
@@ -1045,8 +1045,8 @@ static int smu_v15_0_8_set_driver_pptable(struct smu_context *smu)
 		if (ret)
 			return ret;
 
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetMetricsVersion,
-					   &table_version);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_GetMetricsVersion,
+				       &table_version);
 		if (ret)
 			return ret;
 		smu_table->tables[SMU_TABLE_SMU_METRICS].version =
@@ -1266,7 +1266,7 @@ static int smu_v15_0_8_notify_unload(struct smu_context *smu)
 
 	dev_dbg(smu->adev->dev, "Notify PMFW about driver unload");
 	/* Ignore return, just intimate FW that driver is not going to be there */
-	smu_cmn_send_smc_msg(smu, SMU_MSG_PrepareMp1ForUnload, NULL);
+	smu_cmn_send_msg(smu, SMU_MSG_PrepareMp1ForUnload);
 
 	return 0;
 }
@@ -1765,7 +1765,7 @@ static int smu_v15_0_8_get_power_limit(struct smu_context *smu,
 	uint32_t power_limit = 0;
 	int ret;
 
-	ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetPptLimit, &power_limit);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GetPptLimit, &power_limit);
 	if (ret) {
 		dev_err(smu->adev->dev, "Couldn't get PPT limit");
 		return -EINVAL;
@@ -2176,8 +2176,8 @@ static int smu_v15_0_8_get_ppt_limit(struct smu_context *smu,
 			*ppt_limit = pptable->PPT1Max;
 			break;
 		case SMU_PPT_LIMIT_CURRENT:
-			ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetFastPptLimit,
-						   ppt_limit);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_GetFastPptLimit,
+					       ppt_limit);
 			if (ret)
 				dev_err(smu->adev->dev,
 					"Get fast PPT limit failed!\n");
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -15
index 480d91d88957..0c95d904b5f1 100644
@@ -183,16 +183,6 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
 	return ret;
 }
 
-int smu_cmn_send_smc_msg(struct smu_context *smu,
-			 enum smu_message_type msg,
-			 uint32_t *read_arg)
-{
-	return smu_cmn_send_smc_msg_with_param(smu,
-					       msg,
-					       0,
-					       read_arg);
-}
-
 static inline int smu_cmn_send_msg_internal(struct smu_context *smu, enum smu_message_type msg,
 					    int num_in_args, u32 *in_args,
 					    int num_out_args, u32 *out_args)
@@ -863,12 +853,12 @@ int smu_cmn_get_enabled_mask(struct smu_context *smu,
 		ret = smu_cmn_send_smc_msg_with_param(
 			smu, SMU_MSG_GetEnabledSmuFeatures, 1, &features[1]);
 	} else {
-		ret = smu_cmn_send_smc_msg(
+		ret = smu_cmn_send_msg(
 			smu, SMU_MSG_GetEnabledSmuFeaturesHigh, &features[1]);
 		if (ret)
 			return ret;
 
-		ret = smu_cmn_send_smc_msg(
+		ret = smu_cmn_send_msg(
 			smu, SMU_MSG_GetEnabledSmuFeaturesLow, &features[0]);
 	}
 
@@ -1096,7 +1086,7 @@ int smu_cmn_get_smc_version(struct smu_context *smu,
 	}
 
 	if (if_version) {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetDriverIfVersion, if_version);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_GetDriverIfVersion, if_version);
 		if (ret)
 			return ret;
 
@@ -1104,7 +1094,7 @@ int smu_cmn_get_smc_version(struct smu_context *smu,
 	}
 
 	if (smu_version) {
-		ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetSmuVersion, smu_version);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_GetSmuVersion, smu_version);
 		if (ret)
 			return ret;
 
@@ -1270,7 +1260,7 @@ int smu_cmn_set_mp1_state(struct smu_context *smu,
 		return 0;
 	}
 
-	ret = smu_cmn_send_smc_msg(smu, msg, NULL);
+	ret = smu_cmn_send_msg(smu, msg);
 	if (ret)
 		dev_err(smu->adev->dev, "[PrepareMp1] Failed!\n");
 
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -4
index 5c14ed9ed9b4..ee3f53a6a0c8 100644
@@ -115,10 +115,6 @@ 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(struct smu_context *smu,
-			 enum smu_message_type msg,
-			 uint32_t *read_arg);
-
 int smu_cmn_send_debug_smc_msg(struct smu_context *smu,
 			 uint32_t msg);
 
Signature · 1 line
2.47.3
author
#2 lore raw

PATCH 3/4 drm/amd/pm: replace legacy smu_cmn_send_smc_msg_with_param() with smu_cmn_send_msg()

In reply to Yang Wang

Retire the legacy smu_cmn_send_smc_msg_with_param() API and replace it with the unified smu_cmn_send_msg(). This patch streamlines the change to the following sed command and standardizes code formatting:
sed -i 's/smu_cmn_send_smc_msg_with_param/smu_cmn_send_msg/g'

---
 .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c |  22 +-
 .../amd/pm/swsmu/smu11/cyan_skillfish_ppt.c   |   6 +-
 .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   |  60 +++---
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  86 ++++----
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    | 170 +++++++--------
 .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c  |  96 ++++-----
 .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c   | 140 ++++++------
 .../gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c    |  41 ++--
 .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c    |  48 ++---
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    | 198 ++++++++---------
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  |  56 ++---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c |  36 ++--
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c  |  26 +--
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_5_ppt.c  |  36 ++--
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 112 +++++-----
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c  |  36 ++--
 .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c  |  40 ++--
 .../gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c    | 200 +++++++++---------
 .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c  |  54 ++---
 .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c  |  26 +--
 .../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c    | 142 ++++++-------
 .../drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c  |  21 +-
 .../drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c  |  12 +-
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 102 ++-------
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |   5 -
 25 files changed, 848 insertions(+), 923 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +10 -12
index 220027596937..e28a2c9bf430 100644
@@ -293,11 +293,9 @@ static int arcturus_select_plpd_policy(struct smu_context *smu, int level)
 	}
 
 	if (level == XGMI_PLPD_DEFAULT)
-		return smu_cmn_send_smc_msg_with_param(
-			smu, SMU_MSG_GmiPwrDnControl, 1, NULL);
+		return smu_cmn_send_msg(smu, SMU_MSG_GmiPwrDnControl, 1, NULL);
 	else if (level == XGMI_PLPD_DISALLOW)
-		return smu_cmn_send_smc_msg_with_param(
-			smu, SMU_MSG_GmiPwrDnControl, 0, NULL);
+		return smu_cmn_send_msg(smu, SMU_MSG_GmiPwrDnControl, 0, NULL);
 	else
 		return -EINVAL;
 }
@@ -893,7 +891,7 @@ static int arcturus_upload_dpm_level(struct smu_context *smu,
 	if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_GFXCLK_BIT) &&
 	    (feature_mask & FEATURE_DPM_GFXCLK_MASK)) {
 		freq = dpm_context->dpm_tables.gfx_table.dpm_levels[level].value;
-		ret = smu_cmn_send_smc_msg_with_param(smu,
+		ret = smu_cmn_send_msg(smu,
 			(max ? SMU_MSG_SetSoftMaxByFreq : SMU_MSG_SetSoftMinByFreq),
 			(PPCLK_GFXCLK << 16) | (freq & 0xffff),
 			NULL);
@@ -907,7 +905,7 @@ static int arcturus_upload_dpm_level(struct smu_context *smu,
 	if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_UCLK_BIT) &&
 	    (feature_mask & FEATURE_DPM_UCLK_MASK)) {
 		freq = dpm_context->dpm_tables.uclk_table.dpm_levels[level].value;
-		ret = smu_cmn_send_smc_msg_with_param(smu,
+		ret = smu_cmn_send_msg(smu,
 			(max ? SMU_MSG_SetSoftMaxByFreq : SMU_MSG_SetSoftMinByFreq),
 			(PPCLK_UCLK << 16) | (freq & 0xffff),
 			NULL);
@@ -921,7 +919,7 @@ static int arcturus_upload_dpm_level(struct smu_context *smu,
 	if (smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT) &&
 	    (feature_mask & FEATURE_DPM_SOCCLK_MASK)) {
 		freq = dpm_context->dpm_tables.soc_table.dpm_levels[level].value;
-		ret = smu_cmn_send_smc_msg_with_param(smu,
+		ret = smu_cmn_send_msg(smu,
 			(max ? SMU_MSG_SetSoftMaxByFreq : SMU_MSG_SetSoftMinByFreq),
 			(PPCLK_SOCCLK << 16) | (freq & 0xffff),
 			NULL);
@@ -1485,10 +1483,10 @@ static int arcturus_set_power_profile_mode(struct smu_context *smu,
 		memset(smu->custom_profile_params, 0, ARCTURUS_CUSTOM_PARAMS_SIZE);
 	}
 
-	ret = smu_cmn_send_smc_msg_with_param(smu,
-					      SMU_MSG_SetWorkloadMask,
-					      backend_workload_mask,
-					      NULL);
+	ret = smu_cmn_send_msg(smu,
+			       SMU_MSG_SetWorkloadMask,
+			       backend_workload_mask,
+			       NULL);
 	if (ret) {
 		dev_err(smu->adev->dev, "Failed to set workload mask 0x%08x\n",
 			workload_mask);
@@ -1741,7 +1739,7 @@ static int arcturus_set_df_cstate(struct smu_context *smu,
 		return -EINVAL;
 	}
 
-	return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_DFCstateControl, state, NULL);
+	return smu_cmn_send_msg(smu, SMU_MSG_DFCstateControl, state, NULL);
 }
 
 static const struct throttling_logging_label {
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +3 -3
index e37e2388a231..3ab3491c7a39 100644
@@ -504,8 +504,8 @@ static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,
 			return -EINVAL;
 		}
 
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_RequestGfxclk,
-					cyan_skillfish_user_settings.sclk, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_RequestGfxclk,
+				       cyan_skillfish_user_settings.sclk, NULL);
 		if (ret) {
 			dev_err(smu->adev->dev, "Set sclk failed!\n");
 			return ret;
@@ -523,7 +523,7 @@ static int cyan_skillfish_od_edit_dpm_table(struct smu_context *smu,
 			 * vid = (uint32_t)((1.55 - voltage) * 160.0 + 0.00001)
 			 */
 			vid = (1550 - cyan_skillfish_user_settings.vddc) * 160 / 1000;
-			ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_ForceGfxVid, vid, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_ForceGfxVid, vid, NULL);
 			if (ret) {
 				dev_err(smu->adev->dev, "Force vddc failed!\n");
 				return ret;
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +30 -30

123 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +43 -43

162 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +85 -85

338 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +48 -48

320 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +70 -70

235 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c +20 -21

92 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +23 -25

109 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +99 -99

368 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +28 -28

104 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_12_ppt.c +18 -18
index 834e7ef8079f..650aa7b15c84 100644
@@ -1018,8 +1018,8 @@ static int smu_v13_0_12_get_ras_table_version(struct amdgpu_device *adev,
 {
 	struct smu_context *smu = adev->powerplay.pp_handle;
 
-	return smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_GetRASTableVersion, 0, table_version);
+	return smu_cmn_send_msg(smu,
+				SMU_MSG_GetRASTableVersion, 0, table_version);
 }
 
 static int smu_v13_0_12_get_badpage_count(struct amdgpu_device *adev, uint32_t *count,
@@ -1032,8 +1032,8 @@ static int smu_v13_0_12_get_badpage_count(struct amdgpu_device *adev, uint32_t *
 	now = (uint64_t)ktime_to_ms(ktime_get());
 	end = now + timeout;
 	do {
-		ret = smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_GetBadPageCount, 0, count);
+		ret = smu_cmn_send_msg(smu,
+				       SMU_MSG_GetBadPageCount, 0, count);
 		/* eeprom is not ready */
 		if (ret != -EBUSY)
 			return ret;
@@ -1050,8 +1050,8 @@ static int smu_v13_0_12_set_timestamp(struct amdgpu_device *adev, uint64_t times
 {
 	struct smu_context *smu = adev->powerplay.pp_handle;
 
-	return smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_SetTimestamp, (uint32_t)timestamp, 0);
+	return smu_cmn_send_msg(smu,
+				SMU_MSG_SetTimestamp, (uint32_t)timestamp, 0);
 }
 
 static int smu_v13_0_12_get_timestamp(struct amdgpu_device *adev,
@@ -1061,8 +1061,8 @@ static int smu_v13_0_12_get_timestamp(struct amdgpu_device *adev,
 	uint32_t temp;
 	int ret;
 
-	ret = smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_GetTimestamp, index, &temp);
+	ret = smu_cmn_send_msg(smu,
+			       SMU_MSG_GetTimestamp, index, &temp);
 	if (!ret)
 		*timestamp = temp;
 
@@ -1077,14 +1077,14 @@ static int smu_v13_0_12_get_badpage_ipid(struct amdgpu_device *adev,
 	int ret;
 
 	temp_arg = index | (1 << 16);
-	ret = smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_GetBadPageIpid, temp_arg, &temp_ipid_lo);
+	ret = smu_cmn_send_msg(smu,
+			       SMU_MSG_GetBadPageIpid, temp_arg, &temp_ipid_lo);
 	if (ret)
 		return ret;
 
 	temp_arg = index | (2 << 16);
-	ret = smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_GetBadPageIpid, temp_arg, &temp_ipid_high);
+	ret = smu_cmn_send_msg(smu,
+			       SMU_MSG_GetBadPageIpid, temp_arg, &temp_ipid_high);
 	if (!ret)
 		*ipid = (uint64_t)temp_ipid_high << 32 | temp_ipid_lo;
 	return ret;
@@ -1095,8 +1095,8 @@ static int smu_v13_0_12_erase_ras_table(struct amdgpu_device *adev,
 {
 	struct smu_context *smu = adev->powerplay.pp_handle;
 
-	return smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_EraseRasTable, 0, result);
+	return smu_cmn_send_msg(smu,
+				SMU_MSG_EraseRasTable, 0, result);
 }
 
 static int smu_v13_0_12_get_badpage_mca_addr(struct amdgpu_device *adev,
@@ -1107,14 +1107,14 @@ static int smu_v13_0_12_get_badpage_mca_addr(struct amdgpu_device *adev,
 	int ret;
 
 	temp_arg = index | (1 << 16);
-	ret = smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_GetBadPageMcaAddr, temp_arg, &temp_addr_lo);
+	ret = smu_cmn_send_msg(smu,
+			       SMU_MSG_GetBadPageMcaAddr, temp_arg, &temp_addr_lo);
 	if (ret)
 		return ret;
 
 	temp_arg = index | (2 << 16);
-	ret = smu_cmn_send_smc_msg_with_param(smu,
-			SMU_MSG_GetBadPageMcaAddr, temp_arg, &temp_addr_high);
+	ret = smu_cmn_send_msg(smu,
+			       SMU_MSG_GetBadPageMcaAddr, temp_arg, &temp_addr_high);
 	if (!ret)
 		*mca_addr = (uint64_t)temp_addr_high << 32 | temp_addr_lo;
 	return ret;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_4_ppt.c +13 -13
index 85e34c890672..07a0a624b631 100644
@@ -235,8 +235,8 @@ static int smu_v13_0_4_system_features_control(struct smu_context *smu, bool en)
 			 * MP1_UNLOAD message to prevent GC/RLC/PMFW from entering
 			 * an invalid state.
 			 */
-			ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset,
-							      SMU_RESET_MODE_2, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_GfxDeviceDriverReset,
+					       SMU_RESET_MODE_2, NULL);
 			if (ret)
 				return ret;
 		}
@@ -410,14 +410,14 @@ static int smu_v13_0_4_get_current_clk_freq(struct smu_context *smu,
 		member_type = METRICS_AVERAGE_UCLK;
 		break;
 	case SMU_FCLK:
-		return smu_cmn_send_smc_msg_with_param(smu,
-						       SMU_MSG_GetFclkFrequency,
-						       0, value);
+		return smu_cmn_send_msg(smu,
+					SMU_MSG_GetFclkFrequency,
+					0, value);
 	case SMU_GFXCLK:
 	case SMU_SCLK:
-		return smu_cmn_send_smc_msg_with_param(smu,
-						       SMU_MSG_GetGfxclkFrequency,
-						       0, value);
+		return smu_cmn_send_msg(smu,
+					SMU_MSG_GetGfxclkFrequency,
+					0, value);
 		break;
 	default:
 		return -EINVAL;
@@ -881,12 +881,12 @@ static int smu_v13_0_4_set_soft_freq_limited_range(struct smu_context *smu,
 		max_clk = max << SMU_13_VCLK_SHIFT;
 	}
 
-	ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_min, min_clk, NULL);
+	ret = smu_cmn_send_msg(smu, msg_set_min, min_clk, NULL);
 	if (ret)
 		return ret;
 
-	return smu_cmn_send_smc_msg_with_param(smu, msg_set_max,
-					       max_clk, NULL);
+	return smu_cmn_send_msg(smu, msg_set_max,
+				max_clk, NULL);
 }
 
 static int smu_v13_0_4_force_clk_levels(struct smu_context *smu,
@@ -1080,8 +1080,8 @@ static int smu_v13_0_4_set_performance_level(struct smu_context *smu,
 
 static int smu_v13_0_4_mode2_reset(struct smu_context *smu)
 {
-	return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset,
-					       SMU_RESET_MODE_2, NULL);
+	return smu_cmn_send_msg(smu, SMU_MSG_GfxDeviceDriverReset,
+				SMU_RESET_MODE_2, NULL);
 }
 
 static int smu_v13_0_4_set_fine_grain_gfx_freq_parameters(struct smu_context *smu)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_5_ppt.c +18 -18
index ed6fa13f3119..2b9136dcf10c 100644
@@ -204,11 +204,11 @@ static int smu_v13_0_5_dpm_set_vcn_enable(struct smu_context *smu,
 
 	/* vcn dpm on is a prerequisite for vcn power gate messages */
 	if (enable)
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerUpVcn,
-						      0, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PowerUpVcn,
+				       0, NULL);
 	else
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerDownVcn,
-						      0, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PowerDownVcn,
+				       0, NULL);
 
 	return ret;
 }
@@ -218,12 +218,12 @@ static int smu_v13_0_5_dpm_set_jpeg_enable(struct smu_context *smu, bool enable)
 	int ret = 0;
 
 	if (enable)
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerUpJpeg,
-						      0, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PowerUpJpeg,
+				       0, NULL);
 	else
-		ret = smu_cmn_send_smc_msg_with_param(smu,
-						      SMU_MSG_PowerDownJpeg, 0,
-						      NULL);
+		ret = smu_cmn_send_msg(smu,
+				       SMU_MSG_PowerDownJpeg, 0,
+				       NULL);
 
 	return ret;
 }
@@ -247,7 +247,7 @@ static int smu_v13_0_5_mode_reset(struct smu_context *smu, int type)
 {
 	int ret = 0;
 
-	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset, type, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GfxDeviceDriverReset, type, NULL);
 	if (ret)
 		dev_err(smu->adev->dev, "Failed to mode reset!\n");
 
@@ -575,15 +575,15 @@ static int smu_v13_0_5_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM
 				return -EINVAL;
 			}
 
-			ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinGfxClk,
-									smu->gfx_actual_hard_min_freq, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_SetHardMinGfxClk,
+					       smu->gfx_actual_hard_min_freq, NULL);
 			if (ret) {
 				dev_err(smu->adev->dev, "Set hard min sclk failed!");
 				return ret;
 			}
 
-			ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxGfxClk,
-									smu->gfx_actual_soft_max_freq, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_SetSoftMaxGfxClk,
+					       smu->gfx_actual_soft_max_freq, NULL);
 			if (ret) {
 				dev_err(smu->adev->dev, "Set soft max sclk failed!");
 				return ret;
@@ -618,8 +618,8 @@ static int smu_v13_0_5_get_current_clk_freq(struct smu_context *smu,
 		break;
 	case SMU_GFXCLK:
 	case SMU_SCLK:
-		return smu_cmn_send_smc_msg_with_param(smu,
-				SMU_MSG_GetGfxclkFrequency, 0, value);
+		return smu_cmn_send_msg(smu,
+					SMU_MSG_GetGfxclkFrequency, 0, value);
 		break;
 	default:
 		return -EINVAL;
@@ -852,11 +852,11 @@ static int smu_v13_0_5_set_soft_freq_limited_range(struct smu_context *smu,
 		max_clk = max << SMU_13_VCLK_SHIFT;
 	}
 
-	ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_min, min_clk, NULL);
+	ret = smu_cmn_send_msg(smu, msg_set_min, min_clk, NULL);
 	if (ret)
 		goto out;
 
-	ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_max, max_clk, NULL);
+	ret = smu_cmn_send_msg(smu, msg_set_max, max_clk, NULL);
 	if (ret)
 		goto out;
 
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +52 -60

261 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +18 -18
index 3ad756e14174..5cc15545da6e 100644
@@ -2366,10 +2366,10 @@ static int smu_v13_0_7_enable_mgpu_fan_boost(struct smu_context *smu)
 	if (skutable->MGpuAcousticLimitRpmThreshold == 0)
 		return 0;
 
-	return smu_cmn_send_smc_msg_with_param(smu,
-					       SMU_MSG_SetMGpuFanBoostLimitRpm,
-					       0,
-					       NULL);
+	return smu_cmn_send_msg(smu,
+				SMU_MSG_SetMGpuFanBoostLimitRpm,
+				0,
+				NULL);
 }
 
 static int smu_v13_0_7_get_power_limit(struct smu_context *smu,
@@ -2591,8 +2591,8 @@ static int smu_v13_0_7_set_power_profile_mode(struct smu_context *smu,
 		memset(smu->custom_profile_params, 0, SMU_13_0_7_CUSTOM_PARAMS_SIZE);
 	}
 
-	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetWorkloadMask,
-					      backend_workload_mask, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_SetWorkloadMask,
+			       backend_workload_mask, NULL);
 
 	if (ret) {
 		dev_err(smu->adev->dev, "Failed to set workload mask 0x%08x\n",
@@ -2636,10 +2636,10 @@ static bool smu_v13_0_7_is_mode1_reset_supported(struct smu_context *smu)
 static int smu_v13_0_7_set_df_cstate(struct smu_context *smu,
 				     enum pp_df_cstate state)
 {
-	return smu_cmn_send_smc_msg_with_param(smu,
-					       SMU_MSG_DFCstateControl,
-					       state,
-					       NULL);
+	return smu_cmn_send_msg(smu,
+				SMU_MSG_DFCstateControl,
+				state,
+				NULL);
 }
 
 static bool smu_v13_0_7_wbrf_support_check(struct smu_context *smu)
@@ -2746,10 +2746,10 @@ static int smu_v13_0_7_update_pcie_parameters(struct smu_context *smu,
 			smu_pcie_arg |= pcie_table->pcie_gen[i] << 8;
 			smu_pcie_arg |= pcie_table->pcie_lane[i];
 
-			ret = smu_cmn_send_smc_msg_with_param(smu,
-								SMU_MSG_OverridePcieParameters,
-								smu_pcie_arg,
-								NULL);
+			ret = smu_cmn_send_msg(smu,
+					       SMU_MSG_OverridePcieParameters,
+					       smu_pcie_arg,
+					       NULL);
 			if (ret)
 				break;
 		}
@@ -2765,10 +2765,10 @@ static int smu_v13_0_7_update_pcie_parameters(struct smu_context *smu,
 				smu_pcie_arg |= pcie_table->pcie_gen[i] << 8;
 				smu_pcie_arg |= pcie_table->pcie_lane[i];
 
-				ret = smu_cmn_send_smc_msg_with_param(smu,
-									SMU_MSG_OverridePcieParameters,
-									smu_pcie_arg,
-									NULL);
+				ret = smu_cmn_send_msg(smu,
+						       SMU_MSG_OverridePcieParameters,
+						       smu_pcie_arg,
+						       NULL);
 				if (ret)
 					break;
 			}
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +20 -20
index bcf472e5b415..7fbf2b111d38 100644
@@ -231,11 +231,11 @@ static int yellow_carp_dpm_set_vcn_enable(struct smu_context *smu,
 
 	/* vcn dpm on is a prerequisite for vcn power gate messages */
 	if (enable)
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerUpVcn,
-						      0, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PowerUpVcn,
+				       0, NULL);
 	else
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerDownVcn,
-						      0, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PowerDownVcn,
+				       0, NULL);
 
 	return ret;
 }
@@ -245,12 +245,12 @@ static int yellow_carp_dpm_set_jpeg_enable(struct smu_context *smu, bool enable)
 	int ret = 0;
 
 	if (enable)
-		ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_PowerUpJpeg,
-						      0, NULL);
+		ret = smu_cmn_send_msg(smu, SMU_MSG_PowerUpJpeg,
+				       0, NULL);
 	else
-		ret = smu_cmn_send_smc_msg_with_param(smu,
-						      SMU_MSG_PowerDownJpeg, 0,
-						      NULL);
+		ret = smu_cmn_send_msg(smu,
+				       SMU_MSG_PowerDownJpeg, 0,
+				       NULL);
 
 	return ret;
 }
@@ -286,7 +286,7 @@ static int yellow_carp_mode_reset(struct smu_context *smu, int type)
 {
 	int ret = 0;
 
-	ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GfxDeviceDriverReset, type, NULL);
+	ret = smu_cmn_send_msg(smu, SMU_MSG_GfxDeviceDriverReset, type, NULL);
 	if (ret)
 		dev_err(smu->adev->dev, "Failed to mode reset!\n");
 
@@ -706,15 +706,15 @@ static int yellow_carp_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM
 				return -EINVAL;
 			}
 
-			ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetHardMinGfxClk,
-									smu->gfx_actual_hard_min_freq, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_SetHardMinGfxClk,
+					       smu->gfx_actual_hard_min_freq, NULL);
 			if (ret) {
 				dev_err(smu->adev->dev, "Set hard min sclk failed!");
 				return ret;
 			}
 
-			ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetSoftMaxGfxClk,
-									smu->gfx_actual_soft_max_freq, NULL);
+			ret = smu_cmn_send_msg(smu, SMU_MSG_SetSoftMaxGfxClk,
+					       smu->gfx_actual_soft_max_freq, NULL);
 			if (ret) {
 				dev_err(smu->adev->dev, "Set soft max sclk failed!");
 				return ret;
@@ -748,12 +748,12 @@ static int yellow_carp_get_current_clk_freq(struct smu_context *smu,
 		member_type = METRICS_AVERAGE_UCLK;
 		break;
 	case SMU_FCLK:
-		return smu_cmn_send_smc_msg_with_param(smu,
-				SMU_MSG_GetFclkFrequency, 0, value);
+		return smu_cmn_send_msg(smu,
+					SMU_MSG_GetFclkFrequency, 0, value);
 	case SMU_GFXCLK:
 	case SMU_SCLK:
-		return smu_cmn_send_smc_msg_with_param(smu,
-				SMU_MSG_GetGfxclkFrequency, 0, value);
+		return smu_cmn_send_msg(smu,
+					SMU_MSG_GetGfxclkFrequency, 0, value);
 		break;
 	default:
 		return -EINVAL;
@@ -995,12 +995,12 @@ static int yellow_carp_set_soft_freq_limited_range(struct smu_context *smu,
 		max_clk = max << SMU_13_VCLK_SHIFT;
 	}
 
-	ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_min, min_clk, NULL);
+	ret = smu_cmn_send_msg(smu, msg_set_min, min_clk, NULL);
 
 	if (ret)
 		goto out;
 
-	ret = smu_cmn_send_smc_msg_with_param(smu, msg_set_max, max_clk, NULL);
+	ret = smu_cmn_send_msg(smu, msg_set_max, max_clk, NULL);
 	if (ret)
 		goto out;
 
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c +100 -100

362 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c +27 -27

71 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +13 -13
index baf6866477e7..28c1b084fe62 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c +71 -71

142 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_0_ppt.c +10 -11
index 80ba197664f1..ec517abedb9a 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c +6 -6
index 672f243ea0fe..89a44b456e8a 100644

Lines of this file are not shown. View the raw message.

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +23 -79

102 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -5
index ee3f53a6a0c8..ed9196ba3c7a 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.47.3

Part of the diff is not shown here. View the raw message.

author
#3 lore raw

PATCH 4/4 drm/amd/pm: use helper smu_cmn_send_msg() to simplify smu v15 code logic

In reply to Yang Wang

use helper smu_cmn_send_msg API to simplify smu v15 code logic.

---
 .../gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c    | 41 ++++++++-----------
 1 file changed, 16 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c +16 -25
index 8e95a62e186c..51246a098335 100644
@@ -590,52 +590,43 @@ 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,
-	};
+	u32 param[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;
+	param[0] = lower_32_bits(memory_pool->mc_address);
+	param[1] = upper_32_bits(memory_pool->mc_address);
+	param[2] = (u32)memory_pool->size;
 
-	return smu->msg_ctl.ops->send_msg(&smu->msg_ctl, &args);
+	return smu_cmn_send_msg(smu, SMU_MSG_DramLogSetDramAddr,
+				3, param, 0, NULL);
 }
 
 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,
-	};
+	u32 param[2];
 
-	args.args[0] = lower_32_bits(driver_table->mc_address);
-	args.args[1] = upper_32_bits(driver_table->mc_address);
+	param[0] = lower_32_bits(driver_table->mc_address);
+	param[1] = upper_32_bits(driver_table->mc_address);
 
-	return smu->msg_ctl.ops->send_msg(&smu->msg_ctl, &args);
+	return smu_cmn_send_msg(smu, SMU_MSG_SetDriverDramAddr,
+				2, param, 0, NULL);
 }
 
 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,
-	};
+	u32 param[2];
 
 	/* 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);
+	param[0] = lower_32_bits(tool_table->mc_address);
+	param[1] = upper_32_bits(tool_table->mc_address);
 
-	return smu->msg_ctl.ops->send_msg(&smu->msg_ctl, &args);
+	return smu_cmn_send_msg(smu, SMU_MSG_SetToolsDramAddr,
+				2, param, 0, NULL);
 }
 
 int smu_v15_0_set_allowed_mask(struct smu_context *smu)
Signature · 1 line
2.47.3
#4 lore raw
In reply to Yang Wang
Quoted 4 lines · Yang Wang

add variant func smu_cmn_send_msg() to unify smu message sending logic, and enabling support for newer ASIC interfaces such as SMU v15 and upcoming devices. (support multi-param/multi-response, standardize code across all smu code layers)

Quoted 8 lines

The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters. e.g:
1. r = smu_cmn_send_msg(smu, msg_id);
2. r = smu_cmn_send_msg(smu, msg_id, &read_arg);
3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg);
4. r = smu_cmn_send_msg(smu, msg_id,

			num_param, [param0, param1, ...],
			num_response, [arg0, arg1, ...]

As mentioned earlier, I don't think this helps with readability of the code. This commit message has to be referred always regarding usage. For ex: if I want to send a message which has only one output argument and no input argument, it takes a while to figure out which form to use.

Instead, it's better to expose args structure directly to user. I don't think it's so complicated to use like this.

https://gitlab.freedesktop.org/agd5f/linux/-/blob/drm-next/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c#L627

Maybe I've a biased view, I feel like it's easier to read this way about what is being done.

Thanks,
Lijo

Quoted 130 lines
---
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 79 ++++++++++++++++++++++++++
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++++
  2 files changed, 101 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +79 -0
index 7bd8c435466a..480d91d88957 100644
@@ -193,6 +193,85 @@ int smu_cmn_send_smc_msg(struct smu_context *smu,
  					       read_arg);
  }
 
+static inline int smu_cmn_send_msg_internal(struct smu_context *smu, enum smu_message_type msg,
+					    int num_in_args, u32 *in_args,
+					    int num_out_args, u32 *out_args)
+{
+	struct smu_msg_ctl *ctl = &smu->msg_ctl;
+	struct smu_msg_args args = { 0 };
+	int ret;
+
+	if (msg >= SMU_MSG_MAX_COUNT)
+		return -EINVAL;
+
+	if ((num_in_args >= ARRAY_SIZE(args.args) || num_in_args < 0) ||
+	    (num_out_args >= ARRAY_SIZE(args.out_args) || num_out_args < 0))
+		return -EINVAL;
+
+	if ((num_in_args > 0 && !in_args) || (num_out_args > 0 && !out_args))
+		return -EINVAL;
+
+	if (!ctl->ops || !ctl->ops->send_msg)
+		return -EOPNOTSUPP;
+
+	args.msg = msg;
+	args.num_args = num_in_args;
+	args.num_out_args = num_out_args;
+	args.flags = 0;
+	args.timeout = 0;
+
+	if (num_in_args)
+		memcpy(&args.args[0], in_args, num_in_args * sizeof(u32));
+
+	ret = ctl->ops->send_msg(ctl, &args);
+	if (ret)
+		return ret;
+
+	if (num_out_args)
+		memcpy(out_args, &args.out_args[0], num_out_args * sizeof(u32));
+
+	return ret;
+}
+
+/*
+ * NOTE: To ensure compatibility with the behavioral logic of the legacy API,
+ * it is required to explicitly set the parameter "param" to 0 when invoking
+ * the msg_0 and msg_1 functions.
+ * */
+
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum smu_message_type msg)
+{
+	return __smu_cmn_send_msg_2(smu, msg, 0, NULL);
+}
+
+int __smu_cmn_send_msg_1(struct smu_context *smu, enum smu_message_type msg,
+			 u32 *read_arg)
+{
+	return __smu_cmn_send_msg_2(smu, msg, 0, read_arg);
+}
+
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum smu_message_type msg,
+			 u32 param, u32 *read_arg)
+{
+	int ret;
+
+	if (read_arg)
+		ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 1, read_arg);
+	else
+		ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 0, NULL);
+
+	return ret;
+}
+
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum smu_message_type msg,
+			 int num_in_args, u32 *in_args,
+			 int num_out_args, u32 *out_args)
+{
+	return smu_cmn_send_msg_internal(smu, msg,
+					 num_in_args, in_args,
+					 num_out_args, out_args);
+}
+
  int smu_cmn_send_debug_smc_msg(struct smu_context *smu,
  			 uint32_t msg)
  {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +22 -0
index b76e86df5da7..5c14ed9ed9b4 100644
@@ -210,6 +210,28 @@ int smu_cmn_dpm_pcie_gen_idx(int gen);
  int smu_cmn_dpm_pcie_width_idx(int width);
  int smu_cmn_check_fw_version(struct smu_context *smu);
 
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum smu_message_type msg);
+int __smu_cmn_send_msg_1(struct smu_context *smu, enum smu_message_type msg,
+			 u32 *read_arg);
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum smu_message_type msg,
+			 u32 param, u32 *read_arg);
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum smu_message_type msg,
+			 int num_in_args, u32 *in_args,
+			 int num_out_args, u32 *out_args);
+
+/*
+* The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters.
+* e.g:
+* 1. r = smu_cmn_send_msg(smu, msg_id);
+* 2. r = smu_cmn_send_msg(smu, msg_id, &read_arg);
+* 3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg);
+* 4. r = smu_cmn_send_msg(smu, msg_id,
+*			  num_param, [param0, param1, ...],
+*			  num_response, [arg0, arg1, ...]
+*/
+#define smu_cmn_send_msg(smu, msg, ...) \
+	CONCATENATE(__smu_cmn_send_msg_, COUNT_ARGS(__VA_ARGS__))(smu, msg, ##__VA_ARGS__)
+
  /*SMU gpu metrics */
 
  /* Attribute ID mapping */
#5 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Your comments rely on subjective assumptions ("I don't think") lacking technical justification. this increases review cost and slows progress without clear technical basis.

my approach stays simple: this patch optimizes common message paths and hides unnecessary low-level details. And the original low‑level APIs remain available, so, developers can still use them whenever fine‑grained control is required.

Best Regards,
Kevin

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, March 24, 2026 2:12 PM
To: Wang, Yang(Kevin) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/4] drm/amd/pm: add variant func smu_cmn_send_msg() to unify msg sending logic

Quoted 5 lines · Yang Wang

add variant func smu_cmn_send_msg() to unify smu message sending
logic, and enabling support for newer ASIC interfaces such as SMU v15 and upcoming devices. (support multi-param/multi-response, standardize code across all smu
code layers)

Quoted 8 lines

The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters. e.g:
1. r = smu_cmn_send_msg(smu, msg_id);
2. r = smu_cmn_send_msg(smu, msg_id, &read_arg); 3. r =
smu_cmn_send_msg(smu, msg_id, param, &read_arg); 4. r =
smu_cmn_send_msg(smu, msg_id,

                      num_param, [param0, param1, ...],
                      num_response, [arg0, arg1, ...]

As mentioned earlier, I don't think this helps with readability of the code. This commit message has to be referred always regarding usage. For
ex: if I want to send a message which has only one output argument and no input argument, it takes a while to figure out which form to use.

Instead, it's better to expose args structure directly to user. I don't think it's so complicated to use like this.

https://gitlab.freedesktop.org/agd5f/linux/-/blob/drm-next/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c#L627

Maybe I've a biased view, I feel like it's easier to read this way about what is being done.

Thanks,
Lijo

Quoted 132 lines
---
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 79 ++++++++++++++++++++++++++
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++++
  2 files changed, 101 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +78 -0
index 7bd8c435466a..480d91d88957 100644
@@ -193,6 +193,85 @@ int smu_cmn_send_smc_msg(struct smu_context *smu,
                                             read_arg);
  }
 
+static inline int smu_cmn_send_msg_internal(struct smu_context *smu, enum smu_message_type msg,
+                                         int num_in_args, u32 *in_args,
+                                         int num_out_args, u32 *out_args) {
+     struct smu_msg_ctl *ctl = &smu->msg_ctl;
+     struct smu_msg_args args = { 0 };
+     int ret;
+
+     if (msg >= SMU_MSG_MAX_COUNT)
+             return -EINVAL;
+
+     if ((num_in_args >= ARRAY_SIZE(args.args) || num_in_args < 0) ||
+         (num_out_args >= ARRAY_SIZE(args.out_args) || num_out_args < 0))
+             return -EINVAL;
+
+     if ((num_in_args > 0 && !in_args) || (num_out_args > 0 && !out_args))
+             return -EINVAL;
+
+     if (!ctl->ops || !ctl->ops->send_msg)
+             return -EOPNOTSUPP;
+
+     args.msg = msg;
+     args.num_args = num_in_args;
+     args.num_out_args = num_out_args;
+     args.flags = 0;
+     args.timeout = 0;
+
+     if (num_in_args)
+             memcpy(&args.args[0], in_args, num_in_args * sizeof(u32));
+
+     ret = ctl->ops->send_msg(ctl, &args);
+     if (ret)
+             return ret;
+
+     if (num_out_args)
+             memcpy(out_args, &args.out_args[0], num_out_args * sizeof(u32));
+
+     return ret;
+}
+
+/*
+ * NOTE: To ensure compatibility with the behavioral logic of the
+legacy API,
+ * it is required to explicitly set the parameter "param" to 0 when
+invoking
+ * the msg_0 and msg_1 functions.
+ * */
+
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum
+smu_message_type msg) {
+     return __smu_cmn_send_msg_2(smu, msg, 0, NULL); }
+
+int __smu_cmn_send_msg_1(struct smu_context *smu, enum smu_message_type msg,
+                      u32 *read_arg)
+{
+     return __smu_cmn_send_msg_2(smu, msg, 0, read_arg); }
+
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum smu_message_type msg,
+                      u32 param, u32 *read_arg)
+{
+     int ret;
+
+     if (read_arg)
+             ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 1, read_arg);
+     else
+             ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 0, NULL);
+
+     return ret;
+}
+
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum smu_message_type msg,
+                      int num_in_args, u32 *in_args,
+                      int num_out_args, u32 *out_args)
+{
+     return smu_cmn_send_msg_internal(smu, msg,
+                                      num_in_args, in_args,
+                                      num_out_args, out_args);
+}
+
  int smu_cmn_send_debug_smc_msg(struct smu_context *smu,
                       uint32_t msg)
  {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +23 -0
index b76e86df5da7..5c14ed9ed9b4 100644
@@ -210,6 +210,28 @@ int smu_cmn_dpm_pcie_gen_idx(int gen);
  int smu_cmn_dpm_pcie_width_idx(int width);
  int smu_cmn_check_fw_version(struct smu_context *smu);
 
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum
+smu_message_type msg); int __smu_cmn_send_msg_1(struct smu_context *smu, enum smu_message_type msg,
+                      u32 *read_arg);
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum smu_message_type msg,
+                      u32 param, u32 *read_arg);
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum smu_message_type msg,
+                      int num_in_args, u32 *in_args,
+                      int num_out_args, u32 *out_args);
+
+/*
+* The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters.
+* e.g:
+* 1. r = smu_cmn_send_msg(smu, msg_id);
+* 2. r = smu_cmn_send_msg(smu, msg_id, &read_arg);
+* 3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg);
+* 4. r = smu_cmn_send_msg(smu, msg_id,
+*                      num_param, [param0, param1, ...],
+*                      num_response, [arg0, arg1, ...]
+*/
+#define smu_cmn_send_msg(smu, msg, ...) \
+     CONCATENATE(__smu_cmn_send_msg_, COUNT_ARGS(__VA_ARGS__))(smu, msg,
+##__VA_ARGS__)
+
  /*SMU gpu metrics */
 
  /* Attribute ID mapping */
#6 lore raw
Quoted 7 lines · Yang(Kevin)

[AMD Official Use Only - AMD Internal Distribution Only]

Your comments rely on subjective assumptions ("I don't think") lacking technical justification. this increases review cost and slows progress without clear technical basis.

my approach stays simple: this patch optimizes common message paths and hides unnecessary low-level details. And the original low‑level APIs remain available, so, developers can still use them whenever fine‑grained control is required.

These are the ones in case you missed -

1) This uses same function with multiple variants and it is difficult to figure out which form to use.

2) It also becomes reading coding the difficult. Refer back the same message to figure out which form is being used.

3) The existing implementation is not complicated, there is nothing lowlevel in that. It's just a form of API which takes a struct instead of 11 parameters for in/out (at it fullest level it can have 12 parameters in this form). It's much clearer to read the code in that usage and it presents a uniform API rather than multiple forms of usage.

Thanks,
Lijo

Quoted 174 lines

Best Regards,
Kevin

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, March 24, 2026 2:12 PM
To: Wang, Yang(Kevin) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/4] drm/amd/pm: add variant func smu_cmn_send_msg() to unify msg sending logic

Quoted 5 lines · Yang Wang

add variant func smu_cmn_send_msg() to unify smu message sending
logic, and enabling support for newer ASIC interfaces such as SMU v15 and upcoming devices. (support multi-param/multi-response, standardize code across all smu
code layers)

Quoted 8 lines

The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters. e.g:
1. r = smu_cmn_send_msg(smu, msg_id);
2. r = smu_cmn_send_msg(smu, msg_id, &read_arg); 3. r =
smu_cmn_send_msg(smu, msg_id, param, &read_arg); 4. r =
smu_cmn_send_msg(smu, msg_id,

                       num_param, [param0, param1, ...],
                       num_response, [arg0, arg1, ...]

As mentioned earlier, I don't think this helps with readability of the code. This commit message has to be referred always regarding usage. For
ex: if I want to send a message which has only one output argument and no input argument, it takes a while to figure out which form to use.

Instead, it's better to expose args structure directly to user. I don't think it's so complicated to use like this.

https://gitlab.freedesktop.org/agd5f/linux/-/blob/drm-next/drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c#L627

Maybe I've a biased view, I feel like it's easier to read this way about what is being done.

Thanks,
Lijo

Quoted 132 lines
---
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 79 ++++++++++++++++++++++++++
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++++
   2 files changed, 101 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +78 -0
index 7bd8c435466a..480d91d88957 100644
@@ -193,6 +193,85 @@ int smu_cmn_send_smc_msg(struct smu_context *smu,
                                              read_arg);
   }
 
+static inline int smu_cmn_send_msg_internal(struct smu_context *smu, enum smu_message_type msg,
+                                         int num_in_args, u32 *in_args,
+                                         int num_out_args, u32 *out_args) {
+     struct smu_msg_ctl *ctl = &smu->msg_ctl;
+     struct smu_msg_args args = { 0 };
+     int ret;
+
+     if (msg >= SMU_MSG_MAX_COUNT)
+             return -EINVAL;
+
+     if ((num_in_args >= ARRAY_SIZE(args.args) || num_in_args < 0) ||
+         (num_out_args >= ARRAY_SIZE(args.out_args) || num_out_args < 0))
+             return -EINVAL;
+
+     if ((num_in_args > 0 && !in_args) || (num_out_args > 0 && !out_args))
+             return -EINVAL;
+
+     if (!ctl->ops || !ctl->ops->send_msg)
+             return -EOPNOTSUPP;
+
+     args.msg = msg;
+     args.num_args = num_in_args;
+     args.num_out_args = num_out_args;
+     args.flags = 0;
+     args.timeout = 0;
+
+     if (num_in_args)
+             memcpy(&args.args[0], in_args, num_in_args * sizeof(u32));
+
+     ret = ctl->ops->send_msg(ctl, &args);
+     if (ret)
+             return ret;
+
+     if (num_out_args)
+             memcpy(out_args, &args.out_args[0], num_out_args * sizeof(u32));
+
+     return ret;
+}
+
+/*
+ * NOTE: To ensure compatibility with the behavioral logic of the
+legacy API,
+ * it is required to explicitly set the parameter "param" to 0 when
+invoking
+ * the msg_0 and msg_1 functions.
+ * */
+
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum
+smu_message_type msg) {
+     return __smu_cmn_send_msg_2(smu, msg, 0, NULL); }
+
+int __smu_cmn_send_msg_1(struct smu_context *smu, enum smu_message_type msg,
+                      u32 *read_arg)
+{
+     return __smu_cmn_send_msg_2(smu, msg, 0, read_arg); }
+
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum smu_message_type msg,
+                      u32 param, u32 *read_arg)
+{
+     int ret;
+
+     if (read_arg)
+             ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 1, read_arg);
+     else
+             ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 0, NULL);
+
+     return ret;
+}
+
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum smu_message_type msg,
+                      int num_in_args, u32 *in_args,
+                      int num_out_args, u32 *out_args)
+{
+     return smu_cmn_send_msg_internal(smu, msg,
+                                      num_in_args, in_args,
+                                      num_out_args, out_args);
+}
+
   int smu_cmn_send_debug_smc_msg(struct smu_context *smu,
                        uint32_t msg)
   {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +23 -0
index b76e86df5da7..5c14ed9ed9b4 100644
@@ -210,6 +210,28 @@ int smu_cmn_dpm_pcie_gen_idx(int gen);
   int smu_cmn_dpm_pcie_width_idx(int width);
   int smu_cmn_check_fw_version(struct smu_context *smu);
 
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum
+smu_message_type msg); int __smu_cmn_send_msg_1(struct smu_context *smu, enum smu_message_type msg,
+                      u32 *read_arg);
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum smu_message_type msg,
+                      u32 param, u32 *read_arg);
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum smu_message_type msg,
+                      int num_in_args, u32 *in_args,
+                      int num_out_args, u32 *out_args);
+
+/*
+* The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters.
+* e.g:
+* 1. r = smu_cmn_send_msg(smu, msg_id);
+* 2. r = smu_cmn_send_msg(smu, msg_id, &read_arg);
+* 3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg);
+* 4. r = smu_cmn_send_msg(smu, msg_id,
+*                      num_param, [param0, param1, ...],
+*                      num_response, [arg0, arg1, ...]
+*/
+#define smu_cmn_send_msg(smu, msg, ...) \
+     CONCATENATE(__smu_cmn_send_msg_, COUNT_ARGS(__VA_ARGS__))(smu, msg,
+##__VA_ARGS__)
+
   /*SMU gpu metrics */
 
   /* Attribute ID mapping */
#7 lore raw

To add - the existing usage also avoids redundant memory copies of in/out arguments which is there with the new series.

Quoted 213 lines · Lijo
Quoted 7 lines · Yang(Kevin)

[AMD Official Use Only - AMD Internal Distribution Only]

Your comments rely on subjective assumptions ("I don't think") lacking technical justification. this increases review cost and slows progress without clear technical basis.

my approach stays simple: this patch optimizes common message paths and hides unnecessary low-level details. And the original low‑level APIs remain available, so, developers can still use them whenever fine‑grained control is required.

These are the ones in case you missed -

1) This uses same function with multiple variants and it is difficult to figure out which form to use.

2) It also becomes reading coding the difficult. Refer back the same message to figure out which form is being used.

3) The existing implementation is not complicated, there is nothing lowlevel in that. It's just a form of API which takes a struct instead of 11 parameters for in/out (at it fullest level it can have 12 parameters in this form). It's much clearer to read the code in that usage and it presents a uniform API rather than multiple forms of usage.

Thanks,
Lijo

Quoted 190 lines

Best Regards,
Kevin

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, March 24, 2026 2:12 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/4] drm/amd/pm: add variant func smu_cmn_send_msg() to unify msg sending logic

Quoted 5 lines · Yang Wang

add variant func smu_cmn_send_msg() to unify smu message sending
logic, and enabling support for newer ASIC interfaces such as SMU v15 and upcoming devices. (support multi-param/multi-response, standardize code across all smu
code layers)

Quoted 8 lines

The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters. e.g:
1. r = smu_cmn_send_msg(smu, msg_id);
2. r = smu_cmn_send_msg(smu, msg_id, &read_arg); 3. r =
smu_cmn_send_msg(smu, msg_id, param, &read_arg); 4. r =
smu_cmn_send_msg(smu, msg_id,
                       num_param, [param0, param1, ...],
                       num_response, [arg0, arg1, ...]

As mentioned earlier, I don't think this helps with readability of the code. This commit message has to be referred always regarding usage. For
ex: if I want to send a message which has only one output argument and no input argument, it takes a while to figure out which form to use.

Instead, it's better to expose args structure directly to user. I don't think it's so complicated to use like this.

https://gitlab.freedesktop.org/agd5f/linux/-/blob/drm-next/drivers/ gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c#L627

Maybe I've a biased view, I feel like it's easier to read this way about what is being done.

Thanks,
Lijo

Quoted 148 lines

---
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 79 ++++++++++++++++++++++
++++
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++++

   2 files changed, 101 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +15 -0
index 7bd8c435466a..480d91d88957 100644
@@ -193,6 +193,85 @@ int smu_cmn_send_smc_msg(struct smu_context *smu,
                                               read_arg);
    }
 
+static inline int smu_cmn_send_msg_internal(struct smu_context *smu, 
 enum smu_message_type msg,
+                                         int num_in_args, u32 *in_args,
+                                         int num_out_args, u32 
 *out_args) {
+     struct smu_msg_ctl *ctl = &smu->msg_ctl;
+     struct smu_msg_args args = { 0 };
+     int ret;
+
+     if (msg >= SMU_MSG_MAX_COUNT)
+             return -EINVAL;
+
+     if ((num_in_args >= ARRAY_SIZE(args.args) || num_in_args < 0) ||
+         (num_out_args >= ARRAY_SIZE(args.out_args) || num_out_args 
 < 0))
+             return -EINVAL;
+
+     if ((num_in_args > 0 && !in_args) || (num_out_args > 0 && ! 

out_args))
+             return -EINVAL;

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +19 -0
+
+     if (!ctl->ops || !ctl->ops->send_msg)
+             return -EOPNOTSUPP;
+
+     args.msg = msg;
+     args.num_args = num_in_args;
+     args.num_out_args = num_out_args;
+     args.flags = 0;
+     args.timeout = 0;
+
+     if (num_in_args)
+             memcpy(&args.args[0], in_args, num_in_args * sizeof(u32));
+
+     ret = ctl->ops->send_msg(ctl, &args);
+     if (ret)
+             return ret;
+
+     if (num_out_args)
+             memcpy(out_args, &args.out_args[0], num_out_args * 

sizeof(u32));

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +17 -0
+
+     return ret;
+}
+
+/*
+ * NOTE: To ensure compatibility with the behavioral logic of the
+legacy API,
+ * it is required to explicitly set the parameter "param" to 0 when
+invoking
+ * the msg_0 and msg_1 functions.
+ * */
+
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum
+smu_message_type msg) {
+     return __smu_cmn_send_msg_2(smu, msg, 0, NULL); }
+
+int __smu_cmn_send_msg_1(struct smu_context *smu, enum 

smu_message_type msg,
+                      u32 *read_arg)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4 -0
+{
+     return __smu_cmn_send_msg_2(smu, msg, 0, read_arg); }
+
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum 

smu_message_type msg,
+                      u32 param, u32 *read_arg)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+{
+     int ret;
+
+     if (read_arg)
+             ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 1, 

read_arg);
+     else
+             ret = smu_cmn_send_msg_internal(smu, msg, 1, &param, 0, NULL);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+
+     return ret;
+}
+
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum 

smu_message_type msg,
+                      int num_in_args, u32 *in_args, +                      int num_out_args, u32 *out_args)

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6 -0
+{
+     return smu_cmn_send_msg_internal(smu, msg,
+                                      num_in_args, in_args,
+                                      num_out_args, out_args);
+}
+

   int smu_cmn_send_debug_smc_msg(struct smu_context *smu, uint32_t msg)
   {

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +11 -0
index b76e86df5da7..5c14ed9ed9b4 100644
@@ -210,6 +210,28 @@ int smu_cmn_dpm_pcie_gen_idx(int gen);
    int smu_cmn_dpm_pcie_width_idx(int width);
    int smu_cmn_check_fw_version(struct smu_context *smu);
 
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum
+smu_message_type msg); int __smu_cmn_send_msg_1(struct smu_context 
 *smu, enum smu_message_type msg,
+                      u32 *read_arg);
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum 
 smu_message_type msg,
+                      u32 param, u32 *read_arg);
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum 
 smu_message_type msg,
+                      int num_in_args, u32 *in_args,
+                      int num_out_args, u32 *out_args);
+
+/*
+* The smu_cmn_send_msg() API will expand to the following prototypes 

based on the number of input parameters.

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +10 -0
+* e.g:
+* 1. r = smu_cmn_send_msg(smu, msg_id);
+* 2. r = smu_cmn_send_msg(smu, msg_id, &read_arg);
+* 3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg);
+* 4. r = smu_cmn_send_msg(smu, msg_id,
+*                      num_param, [param0, param1, ...],
+*                      num_response, [arg0, arg1, ...]
+*/
+#define smu_cmn_send_msg(smu, msg, ...) \
+     CONCATENATE(__smu_cmn_send_msg_, COUNT_ARGS(__VA_ARGS__))(smu, 

msg,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +2 -0
+##__VA_ARGS__)
+

   /*SMU gpu metrics */

   /* Attribute ID mapping */

#8 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

I strongly disagree with your viewpoint that variable parameters can lead to complexity,
The goal of variable parameters is to solve problems in complex scenarios, which is a very common programming technique on Linux, e.g.: printk()/open()/err()/exec()/... , even bpf_trace_run<1...12>() api in kernel side.
which all adopt this design to meet the needs of complex scenarios.

Btw,
without further technical concerns, I will stop this thread to reduce unnecessary review noise.

Best Regards,
Kevin

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, March 24, 2026 6:04 PM
To: Wang, Yang(Kevin) <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/4] drm/amd/pm: add variant func smu_cmn_send_msg() to unify msg sending logic

To add - the existing usage also avoids redundant memory copies of in/out arguments which is there with the new series.

Quoted 237 lines · Lijo
Quoted 11 lines · Yang(Kevin)

[AMD Official Use Only - AMD Internal Distribution Only]

Your comments rely on subjective assumptions ("I don't think") lacking technical justification.
this increases review cost and slows progress without clear technical basis.

my approach stays simple: this patch optimizes common message paths and hides unnecessary low-level details.
And the original low‑level APIs remain available, so, developers can still use them whenever fine‑grained control is required.

These are the ones in case you missed -

1) This uses same function with multiple variants and it is difficult to figure out which form to use.

2) It also becomes reading coding the difficult. Refer back the same message to figure out which form is being used.

3) The existing implementation is not complicated, there is nothing lowlevel in that. It's just a form of API which takes a struct instead of 11 parameters for in/out (at it fullest level it can have 12 parameters in this form). It's much clearer to read the code in that usage and it presents a uniform API rather than multiple forms of usage.

Thanks,
Lijo

Quoted 204 lines

Best Regards,
Kevin

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, March 24, 2026 2:12 PM
To: Wang, Yang(Kevin) <[email protected]>; amd- [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Feng, Kenneth <[email protected]>
Subject: Re: [PATCH 1/4] drm/amd/pm: add variant func smu_cmn_send_msg() to unify msg sending logic

Quoted 6 lines · Yang Wang

add variant func smu_cmn_send_msg() to unify smu message sending logic, and enabling support for newer ASIC interfaces such as SMU v15 and upcoming devices.
(support multi-param/multi-response, standardize code across all smu code layers)

Quoted 8 lines

The smu_cmn_send_msg() API will expand to the following prototypes based on the number of input parameters.
e.g:
1. r = smu_cmn_send_msg(smu, msg_id); 2. r = smu_cmn_send_msg(smu, msg_id, &read_arg); 3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg); 4. r = smu_cmn_send_msg(smu, msg_id,

                       num_param, [param0, param1, ...],
                       num_response, [arg0, arg1, ...]

As mentioned earlier, I don't think this helps with readability of the code. This commit message has to be referred always regarding usage. For
ex: if I want to send a message which has only one output argument and no input argument, it takes a while to figure out which form to use.

Instead, it's better to expose args structure directly to user. I don't think it's so complicated to use like this.

https://gitlab.freedesktop.org/agd5f/linux/-/blob/drm-next/drivers/
gpu/drm/amd/pm/swsmu/smu15/smu_v15_0.c#L627

Maybe I've a biased view, I feel like it's easier to read this way about what is being done.

Thanks,
Lijo

Quoted 152 lines
---
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 79
++++++++++++++++++++++
++++
   drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 22 +++++++
   2 files changed, 101 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +15 -0
index 7bd8c435466a..480d91d88957 100644
@@ -193,6 +193,85 @@ int smu_cmn_send_smc_msg(struct smu_context
 *smu,
                                              read_arg);
   }
 
+static inline int smu_cmn_send_msg_internal(struct smu_context
+*smu,
 enum smu_message_type msg,
+                                         int num_in_args, u32
+*in_args,
+                                         int num_out_args, u32
 *out_args) {
+     struct smu_msg_ctl *ctl = &smu->msg_ctl;
+     struct smu_msg_args args = { 0 };
+     int ret;
+
+     if (msg >= SMU_MSG_MAX_COUNT)
+             return -EINVAL;
+
+     if ((num_in_args >= ARRAY_SIZE(args.args) || num_in_args < 0)
+||
+         (num_out_args >= ARRAY_SIZE(args.out_args) || num_out_args

< 0))

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3 -0
+             return -EINVAL;
+
+     if ((num_in_args > 0 && !in_args) || (num_out_args > 0 && !

out_args))

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +21 -0
+             return -EINVAL;
+
+     if (!ctl->ops || !ctl->ops->send_msg)
+             return -EOPNOTSUPP;
+
+     args.msg = msg;
+     args.num_args = num_in_args;
+     args.num_out_args = num_out_args;
+     args.flags = 0;
+     args.timeout = 0;
+
+     if (num_in_args)
+             memcpy(&args.args[0], in_args, num_in_args *
+sizeof(u32));
+
+     ret = ctl->ops->send_msg(ctl, &args);
+     if (ret)
+             return ret;
+
+     if (num_out_args)
+             memcpy(out_args, &args.out_args[0], num_out_args *

sizeof(u32));

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +17 -0
+
+     return ret;
+}
+
+/*
+ * NOTE: To ensure compatibility with the behavioral logic of the
+legacy API,
+ * it is required to explicitly set the parameter "param" to 0 when
+invoking
+ * the msg_0 and msg_1 functions.
+ * */
+
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum
+smu_message_type msg) {
+     return __smu_cmn_send_msg_2(smu, msg, 0, NULL); }
+
+int __smu_cmn_send_msg_1(struct smu_context *smu, enum

smu_message_type msg,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +4 -0
+                      u32 *read_arg) {
+     return __smu_cmn_send_msg_2(smu, msg, 0, read_arg); }
+
+int __smu_cmn_send_msg_2(struct smu_context *smu, enum

smu_message_type msg,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6 -0
+                      u32 param, u32 *read_arg) {
+     int ret;
+
+     if (read_arg)
+             ret = smu_cmn_send_msg_internal(smu, msg, 1, &param,
+1,

read_arg);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3 -0
+     else
+             ret = smu_cmn_send_msg_internal(smu, msg, 1, &param,
+0,

NULL);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+
+     return ret;
+}
+
+int __smu_cmn_send_msg_4(struct smu_context *smu, enum

smu_message_type msg,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6 -0
+                      int num_in_args, u32 *in_args,
+                      int num_out_args, u32 *out_args) {
+     return smu_cmn_send_msg_internal(smu, msg,
+                                      num_in_args, in_args,
+                                      num_out_args, out_args); }
+
   int smu_cmn_send_debug_smc_msg(struct smu_context *smu,
                        uint32_t msg)
   {
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +12 -0
index b76e86df5da7..5c14ed9ed9b4 100644
@@ -210,6 +210,28 @@ int smu_cmn_dpm_pcie_gen_idx(int gen);
   int smu_cmn_dpm_pcie_width_idx(int width);
   int smu_cmn_check_fw_version(struct smu_context *smu);
 
+int __smu_cmn_send_msg_0(struct smu_context *smu, enum
+smu_message_type msg); int __smu_cmn_send_msg_1(struct smu_context
 *smu, enum smu_message_type msg,
+                      u32 *read_arg); int
+__smu_cmn_send_msg_2(struct smu_context *smu, enum
 smu_message_type msg,
+                      u32 param, u32 *read_arg); int
+__smu_cmn_send_msg_4(struct smu_context *smu, enum
 smu_message_type msg,
+                      int num_in_args, u32 *in_args,
+                      int num_out_args, u32 *out_args);
+
+/*
+* The smu_cmn_send_msg() API will expand to the following
+prototypes

based on the number of input parameters.

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +9 -0
+* e.g:
+* 1. r = smu_cmn_send_msg(smu, msg_id);
+* 2. r = smu_cmn_send_msg(smu, msg_id, &read_arg);
+* 3. r = smu_cmn_send_msg(smu, msg_id, param, &read_arg);
+* 4. r = smu_cmn_send_msg(smu, msg_id,
+*                      num_param, [param0, param1, ...],
+*                      num_response, [arg0, arg1, ...] */ #define
+smu_cmn_send_msg(smu, msg, ...) \
+     CONCATENATE(__smu_cmn_send_msg_, COUNT_ARGS(__VA_ARGS__))(smu,

msg,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +2 -0
+##__VA_ARGS__)
+
   /*SMU gpu metrics */
 
   /* Attribute ID mapping */