aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorEric Huang <JinHuiEric.Huang@amd.com>2017-01-24 10:53:39 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-03-29 23:52:50 -0400
commit3ed2584f0b165dcdfdccc0514c476f901b62b4d9 (patch)
treed12a08bf3fd40eb2110ae60b85aec958a7c09ab7 /drivers/gpu/drm/amd
parentff3953d49c0acafab527ec97a665df87ab6bbc70 (diff)
drm/amd/powerplay: add power profile support for tonga
Signed-off-by: Eric Huang <JinHuiEric.Huang@amd.com> Acked-by: Rex Zhu <Rex.Zhu@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.c63
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c1
3 files changed, 66 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.c b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.c
index 331b0aba4a13..3491d1ae53cf 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.c
@@ -2219,6 +2219,42 @@ static void tonga_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
2219 smu_data->power_tune_defaults = &tonga_power_tune_data_set_array[0]; 2219 smu_data->power_tune_defaults = &tonga_power_tune_data_set_array[0];
2220} 2220}
2221 2221
2222static void tonga_save_default_power_profile(struct pp_hwmgr *hwmgr)
2223{
2224 struct tonga_smumgr *data = (struct tonga_smumgr *)(hwmgr->smumgr->backend);
2225 struct SMU72_Discrete_GraphicsLevel *levels =
2226 data->smc_state_table.GraphicsLevel;
2227 unsigned min_level = 1;
2228
2229 hwmgr->default_gfx_power_profile.activity_threshold =
2230 be16_to_cpu(levels[0].ActivityLevel);
2231 hwmgr->default_gfx_power_profile.up_hyst = levels[0].UpHyst;
2232 hwmgr->default_gfx_power_profile.down_hyst = levels[0].DownHyst;
2233 hwmgr->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE;
2234
2235 hwmgr->default_compute_power_profile = hwmgr->default_gfx_power_profile;
2236 hwmgr->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE;
2237
2238 /* Workaround compute SDMA instability: disable lowest SCLK
2239 * DPM level. Optimize compute power profile: Use only highest
2240 * 2 power levels (if more than 2 are available), Hysteresis:
2241 * 0ms up, 5ms down
2242 */
2243 if (data->smc_state_table.GraphicsDpmLevelCount > 2)
2244 min_level = data->smc_state_table.GraphicsDpmLevelCount - 2;
2245 else if (data->smc_state_table.GraphicsDpmLevelCount == 2)
2246 min_level = 1;
2247 else
2248 min_level = 0;
2249 hwmgr->default_compute_power_profile.min_sclk =
2250 be32_to_cpu(levels[min_level].SclkFrequency);
2251 hwmgr->default_compute_power_profile.up_hyst = 0;
2252 hwmgr->default_compute_power_profile.down_hyst = 5;
2253
2254 hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile;
2255 hwmgr->compute_power_profile = hwmgr->default_compute_power_profile;
2256}
2257
2222/** 2258/**
2223 * Initializes the SMC table and uploads it 2259 * Initializes the SMC table and uploads it
2224 * 2260 *
@@ -2468,6 +2504,8 @@ int tonga_init_smc_table(struct pp_hwmgr *hwmgr)
2468 PP_ASSERT_WITH_CODE((!result), 2504 PP_ASSERT_WITH_CODE((!result),
2469 "Failed to populate initialize MC Reg table !", return result); 2505 "Failed to populate initialize MC Reg table !", return result);
2470 2506
2507 tonga_save_default_power_profile(hwmgr);
2508
2471 return 0; 2509 return 0;
2472} 2510}
2473 2511
@@ -3210,3 +3248,28 @@ bool tonga_is_dpm_running(struct pp_hwmgr *hwmgr)
3210 CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON)) 3248 CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON))
3211 ? true : false; 3249 ? true : false;
3212} 3250}
3251
3252int tonga_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
3253 struct amd_pp_profile *request)
3254{
3255 struct tonga_smumgr *smu_data = (struct tonga_smumgr *)
3256 (hwmgr->smumgr->backend);
3257 struct SMU72_Discrete_GraphicsLevel *levels =
3258 smu_data->smc_state_table.GraphicsLevel;
3259 uint32_t array = smu_data->smu7_data.dpm_table_start +
3260 offsetof(SMU72_Discrete_DpmTable, GraphicsLevel);
3261 uint32_t array_size = sizeof(struct SMU72_Discrete_GraphicsLevel) *
3262 SMU72_MAX_LEVELS_GRAPHICS;
3263 uint32_t i;
3264
3265 for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) {
3266 levels[i].ActivityLevel =
3267 cpu_to_be16(request->activity_threshold);
3268 levels[i].EnabledForActivity = 1;
3269 levels[i].UpHyst = request->up_hyst;
3270 levels[i].DownHyst = request->down_hyst;
3271 }
3272
3273 return smu7_copy_bytes_to_smc(hwmgr->smumgr, array, (uint8_t *)levels,
3274 array_size, SMC_RAM_END);
3275}
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.h b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.h
index 8ae169ff541d..962860f13f24 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.h
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.h
@@ -56,5 +56,7 @@ uint32_t tonga_get_mac_definition(uint32_t value);
56int tonga_process_firmware_header(struct pp_hwmgr *hwmgr); 56int tonga_process_firmware_header(struct pp_hwmgr *hwmgr);
57int tonga_initialize_mc_reg_table(struct pp_hwmgr *hwmgr); 57int tonga_initialize_mc_reg_table(struct pp_hwmgr *hwmgr);
58bool tonga_is_dpm_running(struct pp_hwmgr *hwmgr); 58bool tonga_is_dpm_running(struct pp_hwmgr *hwmgr);
59int tonga_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
60 struct amd_pp_profile *request);
59#endif 61#endif
60 62
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
index a7d55366f2d2..c35f4c35c9ca 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
@@ -209,4 +209,5 @@ const struct pp_smumgr_func tonga_smu_funcs = {
209 .get_mac_definition = tonga_get_mac_definition, 209 .get_mac_definition = tonga_get_mac_definition,
210 .initialize_mc_reg_table = tonga_initialize_mc_reg_table, 210 .initialize_mc_reg_table = tonga_initialize_mc_reg_table,
211 .is_dpm_running = tonga_is_dpm_running, 211 .is_dpm_running = tonga_is_dpm_running,
212 .populate_requested_graphic_levels = tonga_populate_requested_graphic_levels,
212}; 213};