aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Huang <JinHuiEric.Huang@amd.com>2017-01-24 10:57:22 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-03-29 23:52:51 -0400
commit03609ebc4cbdbdb32b72df2b611390d19b9a99bf (patch)
tree89d74966f6d1f839b4c469f4621612967a29b8d1
parent43f6d14455ed2a993a9f945274e8da63e087d5fa (diff)
drm/amd/powerplay: add power profile support for Polaris
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>
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c64
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c1
3 files changed, 67 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c
index 80e2329a1b9e..1eedab143aa9 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c
@@ -1613,6 +1613,42 @@ static void polaris10_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr)
1613 1613
1614} 1614}
1615 1615
1616static void polaris10_save_default_power_profile(struct pp_hwmgr *hwmgr)
1617{
1618 struct polaris10_smumgr *data = (struct polaris10_smumgr *)(hwmgr->smumgr->backend);
1619 struct SMU74_Discrete_GraphicsLevel *levels =
1620 data->smc_state_table.GraphicsLevel;
1621 unsigned min_level = 1;
1622
1623 hwmgr->default_gfx_power_profile.activity_threshold =
1624 be16_to_cpu(levels[0].ActivityLevel);
1625 hwmgr->default_gfx_power_profile.up_hyst = levels[0].UpHyst;
1626 hwmgr->default_gfx_power_profile.down_hyst = levels[0].DownHyst;
1627 hwmgr->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE;
1628
1629 hwmgr->default_compute_power_profile = hwmgr->default_gfx_power_profile;
1630 hwmgr->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE;
1631
1632 /* Workaround compute SDMA instability: disable lowest SCLK
1633 * DPM level. Optimize compute power profile: Use only highest
1634 * 2 power levels (if more than 2 are available), Hysteresis:
1635 * 0ms up, 5ms down
1636 */
1637 if (data->smc_state_table.GraphicsDpmLevelCount > 2)
1638 min_level = data->smc_state_table.GraphicsDpmLevelCount - 2;
1639 else if (data->smc_state_table.GraphicsDpmLevelCount == 2)
1640 min_level = 1;
1641 else
1642 min_level = 0;
1643 hwmgr->default_compute_power_profile.min_sclk =
1644 be32_to_cpu(levels[min_level].SclkSetting.SclkFrequency);
1645 hwmgr->default_compute_power_profile.up_hyst = 0;
1646 hwmgr->default_compute_power_profile.down_hyst = 5;
1647
1648 hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile;
1649 hwmgr->compute_power_profile = hwmgr->default_compute_power_profile;
1650}
1651
1616/** 1652/**
1617* Initializes the SMC table and uploads it 1653* Initializes the SMC table and uploads it
1618* 1654*
@@ -1832,6 +1868,9 @@ int polaris10_init_smc_table(struct pp_hwmgr *hwmgr)
1832 result = polaris10_populate_pm_fuses(hwmgr); 1868 result = polaris10_populate_pm_fuses(hwmgr);
1833 PP_ASSERT_WITH_CODE(0 == result, 1869 PP_ASSERT_WITH_CODE(0 == result,
1834 "Failed to populate PM fuses to SMC memory!", return result); 1870 "Failed to populate PM fuses to SMC memory!", return result);
1871
1872 polaris10_save_default_power_profile(hwmgr);
1873
1835 return 0; 1874 return 0;
1836} 1875}
1837 1876
@@ -2298,3 +2337,28 @@ bool polaris10_is_dpm_running(struct pp_hwmgr *hwmgr)
2298 CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON)) 2337 CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON))
2299 ? true : false; 2338 ? true : false;
2300} 2339}
2340
2341int polaris10_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
2342 struct amd_pp_profile *request)
2343{
2344 struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *)
2345 (hwmgr->smumgr->backend);
2346 struct SMU74_Discrete_GraphicsLevel *levels =
2347 smu_data->smc_state_table.GraphicsLevel;
2348 uint32_t array = smu_data->smu7_data.dpm_table_start +
2349 offsetof(SMU74_Discrete_DpmTable, GraphicsLevel);
2350 uint32_t array_size = sizeof(struct SMU74_Discrete_GraphicsLevel) *
2351 SMU74_MAX_LEVELS_GRAPHICS;
2352 uint32_t i;
2353
2354 for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) {
2355 levels[i].ActivityLevel =
2356 cpu_to_be16(request->activity_threshold);
2357 levels[i].EnabledForActivity = 1;
2358 levels[i].UpHyst = request->up_hyst;
2359 levels[i].DownHyst = request->down_hyst;
2360 }
2361
2362 return smu7_copy_bytes_to_smc(hwmgr->smumgr, array, (uint8_t *)levels,
2363 array_size, SMC_RAM_END);
2364}
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.h b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.h
index 5ade3cea8bb7..1df8154d0626 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.h
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.h
@@ -37,6 +37,8 @@ uint32_t polaris10_get_offsetof(uint32_t type, uint32_t member);
37uint32_t polaris10_get_mac_definition(uint32_t value); 37uint32_t polaris10_get_mac_definition(uint32_t value);
38int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr); 38int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr);
39bool polaris10_is_dpm_running(struct pp_hwmgr *hwmgr); 39bool polaris10_is_dpm_running(struct pp_hwmgr *hwmgr);
40int polaris10_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr,
41 struct amd_pp_profile *request);
40 42
41#endif 43#endif
42 44
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
index ce20ae2e520e..9616cedc139c 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
@@ -409,4 +409,5 @@ const struct pp_smumgr_func polaris10_smu_funcs = {
409 .populate_all_memory_levels = polaris10_populate_all_memory_levels, 409 .populate_all_memory_levels = polaris10_populate_all_memory_levels,
410 .get_mac_definition = polaris10_get_mac_definition, 410 .get_mac_definition = polaris10_get_mac_definition,
411 .is_dpm_running = polaris10_is_dpm_running, 411 .is_dpm_running = polaris10_is_dpm_running,
412 .populate_requested_graphic_levels = polaris10_populate_requested_graphic_levels,
412}; 413};