[PATCH 03/18] drm/amd/pm: enable vcn by instance for smu v14

boyuan.zhang at amd.com boyuan.zhang at amd.com
Wed Oct 2 04:36:12 UTC 2024


From: Boyuan Zhang <boyuan.zhang at amd.com>

For smu v14, set vcn enable or disable by the given instance instead of
setting it for all vcn instances.

Signed-off-by: Boyuan Zhang <boyuan.zhang at amd.com>
---
 drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h  |  5 ++-
 .../gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c    | 40 +++++++++----------
 .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c  |  2 +-
 .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c  |  2 +-
 4 files changed, 23 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h
index 46b456590a08..7d697f585443 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h
+++ b/drivers/gpu/drm/amd/pm/swsmu/inc/smu_v14_0.h
@@ -209,8 +209,9 @@ int smu_v14_0_gfx_ulv_control(struct smu_context *smu,
 int smu_v14_0_wait_for_event(struct smu_context *smu, enum smu_event_type event,
 			     uint64_t event_arg);
 
-int smu_v14_0_set_vcn_enable(struct smu_context *smu,
-			     bool enable);
+int smu_v14_0_set_vcn_enable_instance(struct smu_context *smu,
+			     bool enable,
+			     int inst);
 
 int smu_v14_0_set_jpeg_enable(struct smu_context *smu,
 			      bool enable);
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c
index 865e916fc425..bb521d3bedf7 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0.c
@@ -1491,33 +1491,29 @@ int smu_v14_0_set_single_dpm_table(struct smu_context *smu,
 	return 0;
 }
 
-int smu_v14_0_set_vcn_enable(struct smu_context *smu,
-			     bool enable)
+int smu_v14_0_set_vcn_enable_instance(struct smu_context *smu,
+			     bool enable,
+			     int inst)
 {
 	struct amdgpu_device *adev = smu->adev;
-	int i, ret = 0;
+	int ret = 0;
 
-	for (i = 0; i < adev->vcn.num_vcn_inst; i++) {
-		if (adev->vcn.harvest_config & (1 << i))
-			continue;
+	if (adev->vcn.harvest_config & (1 << inst))
+		return ret;
 
-		if (smu->is_apu) {
-			if (i == 0)
-				ret = smu_cmn_send_smc_msg_with_param(smu, enable ?
-								      SMU_MSG_PowerUpVcn0 : SMU_MSG_PowerDownVcn0,
-								      i << 16U, NULL);
-			else if (i == 1)
-				ret = smu_cmn_send_smc_msg_with_param(smu, enable ?
-								      SMU_MSG_PowerUpVcn1 : SMU_MSG_PowerDownVcn1,
-								      i << 16U, NULL);
-		} else {
+	if (smu->is_apu) {
+		if (inst == 0)
 			ret = smu_cmn_send_smc_msg_with_param(smu, enable ?
-							      SMU_MSG_PowerUpVcn : SMU_MSG_PowerDownVcn,
-							      i << 16U, NULL);
-		}
-
-		if (ret)
-			return ret;
+							      SMU_MSG_PowerUpVcn0 : SMU_MSG_PowerDownVcn0,
+							      inst << 16U, NULL);
+		else if (inst == 1)
+			ret = smu_cmn_send_smc_msg_with_param(smu, enable ?
+							      SMU_MSG_PowerUpVcn1 : SMU_MSG_PowerDownVcn1,
+							      inst << 16U, NULL);
+	} else {
+		ret = smu_cmn_send_smc_msg_with_param(smu, enable ?
+						      SMU_MSG_PowerUpVcn : SMU_MSG_PowerDownVcn,
+						      inst << 16U, NULL);
 	}
 
 	return ret;
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c
index 8798ebfcea83..9e4fadb8024a 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c
@@ -1648,7 +1648,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = {
 	.system_features_control = smu_v14_0_0_system_features_control,
 	.send_smc_msg_with_param = smu_cmn_send_smc_msg_with_param,
 	.send_smc_msg = smu_cmn_send_smc_msg,
-	.dpm_set_vcn_enable = smu_v14_0_set_vcn_enable,
+	.dpm_set_vcn_enable_instance = smu_v14_0_set_vcn_enable_instance,
 	.dpm_set_jpeg_enable = smu_v14_0_set_jpeg_enable,
 	.set_default_dpm_table = smu_v14_0_set_default_dpm_tables,
 	.read_sensor = smu_v14_0_0_read_sensor,
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
index ade3ee398e3d..00f1f1bc2652 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
@@ -2808,7 +2808,7 @@ static const struct pptable_funcs smu_v14_0_2_ppt_funcs = {
 	.system_features_control = smu_v14_0_system_features_control,
 	.set_allowed_mask = smu_v14_0_set_allowed_mask,
 	.get_enabled_mask = smu_cmn_get_enabled_mask,
-	.dpm_set_vcn_enable = smu_v14_0_set_vcn_enable,
+	.dpm_set_vcn_enable_instance = smu_v14_0_set_vcn_enable_instance,
 	.dpm_set_jpeg_enable = smu_v14_0_set_jpeg_enable,
 	.get_dpm_ultimate_freq = smu_v14_0_2_get_dpm_ultimate_freq,
 	.get_vbios_bootup_values = smu_v14_0_get_vbios_bootup_values,
-- 
2.34.1



More information about the amd-gfx mailing list