Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Eric Huang and committed by
Alex Deucher
03609ebc 43f6d144

+67
+64
drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.c
··· 1613 1613 1614 1614 } 1615 1615 1616 + static 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 1653 * Initializes the SMC table and uploads it 1618 1654 * ··· 1868 1832 result = polaris10_populate_pm_fuses(hwmgr); 1869 1833 PP_ASSERT_WITH_CODE(0 == result, 1870 1834 "Failed to populate PM fuses to SMC memory!", return result); 1835 + 1836 + polaris10_save_default_power_profile(hwmgr); 1837 + 1871 1838 return 0; 1872 1839 } 1873 1840 ··· 2336 2297 return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device, 2337 2298 CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON)) 2338 2299 ? true : false; 2300 + } 2301 + 2302 + int polaris10_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, 2303 + struct amd_pp_profile *request) 2304 + { 2305 + struct polaris10_smumgr *smu_data = (struct polaris10_smumgr *) 2306 + (hwmgr->smumgr->backend); 2307 + struct SMU74_Discrete_GraphicsLevel *levels = 2308 + smu_data->smc_state_table.GraphicsLevel; 2309 + uint32_t array = smu_data->smu7_data.dpm_table_start + 2310 + offsetof(SMU74_Discrete_DpmTable, GraphicsLevel); 2311 + uint32_t array_size = sizeof(struct SMU74_Discrete_GraphicsLevel) * 2312 + SMU74_MAX_LEVELS_GRAPHICS; 2313 + uint32_t i; 2314 + 2315 + for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) { 2316 + levels[i].ActivityLevel = 2317 + cpu_to_be16(request->activity_threshold); 2318 + levels[i].EnabledForActivity = 1; 2319 + levels[i].UpHyst = request->up_hyst; 2320 + levels[i].DownHyst = request->down_hyst; 2321 + } 2322 + 2323 + return smu7_copy_bytes_to_smc(hwmgr->smumgr, array, (uint8_t *)levels, 2324 + array_size, SMC_RAM_END); 2339 2325 }
+2
drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smc.h
··· 37 37 uint32_t polaris10_get_mac_definition(uint32_t value); 38 38 int polaris10_process_firmware_header(struct pp_hwmgr *hwmgr); 39 39 bool polaris10_is_dpm_running(struct pp_hwmgr *hwmgr); 40 + int polaris10_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, 41 + struct amd_pp_profile *request); 40 42 41 43 #endif 42 44
+1
drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
··· 409 409 .populate_all_memory_levels = polaris10_populate_all_memory_levels, 410 410 .get_mac_definition = polaris10_get_mac_definition, 411 411 .is_dpm_running = polaris10_is_dpm_running, 412 + .populate_requested_graphic_levels = polaris10_populate_requested_graphic_levels, 412 413 };