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 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>

authored by

Eric Huang and committed by
Alex Deucher
3ed2584f ff3953d4

+66
+63
drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.c
··· 2219 2219 smu_data->power_tune_defaults = &tonga_power_tune_data_set_array[0]; 2220 2220 } 2221 2221 2222 + static 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 2259 * Initializes the SMC table and uploads it 2224 2260 * ··· 2503 2467 result = tonga_populate_initial_mc_reg_table(hwmgr); 2504 2468 PP_ASSERT_WITH_CODE((!result), 2505 2469 "Failed to populate initialize MC Reg table !", return result); 2470 + 2471 + tonga_save_default_power_profile(hwmgr); 2506 2472 2507 2473 return 0; 2508 2474 } ··· 3247 3209 return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device, 3248 3210 CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON)) 3249 3211 ? true : false; 3212 + } 3213 + 3214 + int tonga_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, 3215 + struct amd_pp_profile *request) 3216 + { 3217 + struct tonga_smumgr *smu_data = (struct tonga_smumgr *) 3218 + (hwmgr->smumgr->backend); 3219 + struct SMU72_Discrete_GraphicsLevel *levels = 3220 + smu_data->smc_state_table.GraphicsLevel; 3221 + uint32_t array = smu_data->smu7_data.dpm_table_start + 3222 + offsetof(SMU72_Discrete_DpmTable, GraphicsLevel); 3223 + uint32_t array_size = sizeof(struct SMU72_Discrete_GraphicsLevel) * 3224 + SMU72_MAX_LEVELS_GRAPHICS; 3225 + uint32_t i; 3226 + 3227 + for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) { 3228 + levels[i].ActivityLevel = 3229 + cpu_to_be16(request->activity_threshold); 3230 + levels[i].EnabledForActivity = 1; 3231 + levels[i].UpHyst = request->up_hyst; 3232 + levels[i].DownHyst = request->down_hyst; 3233 + } 3234 + 3235 + return smu7_copy_bytes_to_smc(hwmgr->smumgr, array, (uint8_t *)levels, 3236 + array_size, SMC_RAM_END); 3250 3237 }
+2
drivers/gpu/drm/amd/powerplay/smumgr/tonga_smc.h
··· 56 56 int tonga_process_firmware_header(struct pp_hwmgr *hwmgr); 57 57 int tonga_initialize_mc_reg_table(struct pp_hwmgr *hwmgr); 58 58 bool tonga_is_dpm_running(struct pp_hwmgr *hwmgr); 59 + int tonga_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, 60 + struct amd_pp_profile *request); 59 61 #endif 60 62
+1
drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c
··· 209 209 .get_mac_definition = tonga_get_mac_definition, 210 210 .initialize_mc_reg_table = tonga_initialize_mc_reg_table, 211 211 .is_dpm_running = tonga_is_dpm_running, 212 + .populate_requested_graphic_levels = tonga_populate_requested_graphic_levels, 212 213 };