Blob Blame History Raw
From: Rex Zhu <Rex.Zhu@amd.com>
Date: Fri, 2 Feb 2018 17:13:02 +0800
Subject: drm/amd/pp: Restore power profile mode in auto dpm level on Vega10
Git-commit: 9ac870c7775824322be7ea2d265b0f2408c910c6
Patch-mainline: v4.17-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166

As auto power profile mode still not support on vega10, so
just restore default profile mode in auto dpm level.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |   10 +++++++---
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |    1 +
 2 files changed, 8 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
@@ -761,6 +761,7 @@ static int vega10_hwmgr_backend_init(str
 	hwmgr->backend = data;
 
 	hwmgr->power_profile_mode = PP_SMC_POWER_PROFILE_VIDEO;
+	hwmgr->default_power_profile_mode = PP_SMC_POWER_PROFILE_VIDEO;
 
 	vega10_set_default_registry_data(hwmgr);
 
@@ -4235,6 +4236,11 @@ static int vega10_dpm_force_dpm_level(st
 		break;
 	case AMD_DPM_FORCED_LEVEL_AUTO:
 		ret = vega10_unforce_dpm_levels(hwmgr);
+		if (hwmgr->default_power_profile_mode != hwmgr->power_profile_mode) {
+				smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetWorkloadMask,
+						1 << hwmgr->default_power_profile_mode);
+				hwmgr->power_profile_mode = hwmgr->default_power_profile_mode;
+		}
 		break;
 	case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD:
 	case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK:
@@ -4258,6 +4264,7 @@ static int vega10_dpm_force_dpm_level(st
 		else if (level != AMD_DPM_FORCED_LEVEL_PROFILE_PEAK && hwmgr->dpm_level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK)
 			vega10_set_fan_control_mode(hwmgr, AMD_FAN_CTRL_AUTO);
 	}
+
 	return ret;
 }
 
@@ -5075,9 +5082,6 @@ static int vega10_set_power_profile_mode
 	uint8_t use_rlc_busy;
 	uint8_t min_active_level;
 
-	if (input[size] == PP_SMC_POWER_PROFILE_AUTO)
-		return 0; /* TO DO auto wattman feature not enabled */
-
 	hwmgr->power_profile_mode = input[size];
 
 	smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_SetWorkloadMask,
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -757,6 +757,7 @@ struct pp_hwmgr {
 	enum amd_pp_profile_type current_power_profile;
 	bool en_umd_pstate;
 	uint32_t power_profile_mode;
+	uint32_t default_power_profile_mode;
 	uint32_t pstate_sclk;
 	uint32_t pstate_mclk;
 	bool od_enabled;