diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2017-06-14 18:46:14 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-08-15 14:46:11 -0400 |
commit | d45aec0536d4180bc6e9a79f5342bcf0e4f9b660 (patch) | |
tree | e9b9865cb6c3f816fbe194d86a94e71aa4ba531b /drivers/gpu/drm/amd | |
parent | becdaf3f4aff560adc1263a505408a2f73f9a5d2 (diff) |
drm/amd/powerplay: add CZ profile support
Support the profiling modes for sclk.
v2: delete profileing mode for mclk.
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
Tested-and-Reviewed-by Rex Zhu <Rex.Zhu@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 82 |
1 files changed, 80 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c index 22b7d12ffff8..bc839ff0bdd0 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | |||
@@ -1312,33 +1312,111 @@ static int cz_phm_force_dpm_lowest(struct pp_hwmgr *hwmgr) | |||
1312 | return 0; | 1312 | return 0; |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | static int cz_phm_force_dpm_sclk(struct pp_hwmgr *hwmgr, uint32_t sclk) | ||
1316 | { | ||
1317 | smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, | ||
1318 | PPSMC_MSG_SetSclkSoftMin, | ||
1319 | cz_get_sclk_level(hwmgr, | ||
1320 | sclk, | ||
1321 | PPSMC_MSG_SetSclkSoftMin)); | ||
1322 | |||
1323 | smum_send_msg_to_smc_with_parameter(hwmgr->smumgr, | ||
1324 | PPSMC_MSG_SetSclkSoftMax, | ||
1325 | cz_get_sclk_level(hwmgr, | ||
1326 | sclk, | ||
1327 | PPSMC_MSG_SetSclkSoftMax)); | ||
1328 | return 0; | ||
1329 | } | ||
1330 | |||
1331 | static int cz_get_profiling_clk(struct pp_hwmgr *hwmgr, uint32_t *sclk) | ||
1332 | { | ||
1333 | struct phm_clock_voltage_dependency_table *table = | ||
1334 | hwmgr->dyn_state.vddc_dependency_on_sclk; | ||
1335 | int32_t tmp_sclk; | ||
1336 | int32_t count; | ||
1337 | |||
1338 | tmp_sclk = table->entries[table->count-1].clk * 70 / 100; | ||
1339 | |||
1340 | for (count = table->count-1; count >= 0; count--) { | ||
1341 | if (tmp_sclk >= table->entries[count].clk) { | ||
1342 | tmp_sclk = table->entries[count].clk; | ||
1343 | *sclk = tmp_sclk; | ||
1344 | break; | ||
1345 | } | ||
1346 | } | ||
1347 | if (count < 0) | ||
1348 | *sclk = table->entries[0].clk; | ||
1349 | |||
1350 | return 0; | ||
1351 | } | ||
1352 | |||
1315 | static int cz_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, | 1353 | static int cz_dpm_force_dpm_level(struct pp_hwmgr *hwmgr, |
1316 | enum amd_dpm_forced_level level) | 1354 | enum amd_dpm_forced_level level) |
1317 | { | 1355 | { |
1356 | uint32_t sclk = 0; | ||
1318 | int ret = 0; | 1357 | int ret = 0; |
1358 | uint32_t profile_mode_mask = AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD | | ||
1359 | AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK | | ||
1360 | AMD_DPM_FORCED_LEVEL_PROFILE_PEAK; | ||
1361 | |||
1362 | if (level == hwmgr->dpm_level) | ||
1363 | return ret; | ||
1364 | |||
1365 | if (!(hwmgr->dpm_level & profile_mode_mask)) { | ||
1366 | /* enter profile mode, save current level, disable gfx cg*/ | ||
1367 | if (level & profile_mode_mask) { | ||
1368 | hwmgr->saved_dpm_level = hwmgr->dpm_level; | ||
1369 | cgs_set_clockgating_state(hwmgr->device, | ||
1370 | AMD_IP_BLOCK_TYPE_GFX, | ||
1371 | AMD_CG_STATE_UNGATE); | ||
1372 | } | ||
1373 | } else { | ||
1374 | /* exit profile mode, restore level, enable gfx cg*/ | ||
1375 | if (!(level & profile_mode_mask)) { | ||
1376 | if (level == AMD_DPM_FORCED_LEVEL_PROFILE_EXIT) | ||
1377 | level = hwmgr->saved_dpm_level; | ||
1378 | cgs_set_clockgating_state(hwmgr->device, | ||
1379 | AMD_IP_BLOCK_TYPE_GFX, | ||
1380 | AMD_CG_STATE_GATE); | ||
1381 | } | ||
1382 | } | ||
1319 | 1383 | ||
1320 | switch (level) { | 1384 | switch (level) { |
1321 | case AMD_DPM_FORCED_LEVEL_HIGH: | 1385 | case AMD_DPM_FORCED_LEVEL_HIGH: |
1386 | case AMD_DPM_FORCED_LEVEL_PROFILE_PEAK: | ||
1322 | ret = cz_phm_force_dpm_highest(hwmgr); | 1387 | ret = cz_phm_force_dpm_highest(hwmgr); |
1323 | if (ret) | 1388 | if (ret) |
1324 | return ret; | 1389 | return ret; |
1390 | hwmgr->dpm_level = level; | ||
1325 | break; | 1391 | break; |
1326 | case AMD_DPM_FORCED_LEVEL_LOW: | 1392 | case AMD_DPM_FORCED_LEVEL_LOW: |
1393 | case AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK: | ||
1327 | ret = cz_phm_force_dpm_lowest(hwmgr); | 1394 | ret = cz_phm_force_dpm_lowest(hwmgr); |
1328 | if (ret) | 1395 | if (ret) |
1329 | return ret; | 1396 | return ret; |
1397 | hwmgr->dpm_level = level; | ||
1330 | break; | 1398 | break; |
1331 | case AMD_DPM_FORCED_LEVEL_AUTO: | 1399 | case AMD_DPM_FORCED_LEVEL_AUTO: |
1332 | ret = cz_phm_unforce_dpm_levels(hwmgr); | 1400 | ret = cz_phm_unforce_dpm_levels(hwmgr); |
1333 | if (ret) | 1401 | if (ret) |
1334 | return ret; | 1402 | return ret; |
1403 | hwmgr->dpm_level = level; | ||
1404 | break; | ||
1405 | case AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD: | ||
1406 | ret = cz_get_profiling_clk(hwmgr, &sclk); | ||
1407 | if (ret) | ||
1408 | return ret; | ||
1409 | hwmgr->dpm_level = level; | ||
1410 | cz_phm_force_dpm_sclk(hwmgr, sclk); | ||
1335 | break; | 1411 | break; |
1412 | case AMD_DPM_FORCED_LEVEL_MANUAL: | ||
1413 | hwmgr->dpm_level = level; | ||
1414 | break; | ||
1415 | case AMD_DPM_FORCED_LEVEL_PROFILE_EXIT: | ||
1336 | default: | 1416 | default: |
1337 | break; | 1417 | break; |
1338 | } | 1418 | } |
1339 | 1419 | ||
1340 | hwmgr->dpm_level = level; | ||
1341 | |||
1342 | return ret; | 1420 | return ret; |
1343 | } | 1421 | } |
1344 | 1422 | ||