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 Fiji

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
43f6d144 3ed2584f

+68 -1
+65
drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.c
··· 1721 1721 smu_data->smu7_data.arb_table_start, tmp, SMC_RAM_END); 1722 1722 } 1723 1723 1724 + static int fiji_save_default_power_profile(struct pp_hwmgr *hwmgr) 1725 + { 1726 + struct fiji_smumgr *data = (struct fiji_smumgr *)(hwmgr->smumgr->backend); 1727 + struct SMU73_Discrete_GraphicsLevel *levels = 1728 + data->smc_state_table.GraphicsLevel; 1729 + unsigned min_level = 1; 1730 + 1731 + hwmgr->default_gfx_power_profile.activity_threshold = 1732 + be16_to_cpu(levels[0].ActivityLevel); 1733 + hwmgr->default_gfx_power_profile.up_hyst = levels[0].UpHyst; 1734 + hwmgr->default_gfx_power_profile.down_hyst = levels[0].DownHyst; 1735 + hwmgr->default_gfx_power_profile.type = AMD_PP_GFX_PROFILE; 1736 + 1737 + hwmgr->default_compute_power_profile = hwmgr->default_gfx_power_profile; 1738 + hwmgr->default_compute_power_profile.type = AMD_PP_COMPUTE_PROFILE; 1739 + 1740 + /* Workaround compute SDMA instability: disable lowest SCLK 1741 + * DPM level. Optimize compute power profile: Use only highest 1742 + * 2 power levels (if more than 2 are available), Hysteresis: 1743 + * 0ms up, 5ms down 1744 + */ 1745 + if (data->smc_state_table.GraphicsDpmLevelCount > 2) 1746 + min_level = data->smc_state_table.GraphicsDpmLevelCount - 2; 1747 + else if (data->smc_state_table.GraphicsDpmLevelCount == 2) 1748 + min_level = 1; 1749 + else 1750 + min_level = 0; 1751 + hwmgr->default_compute_power_profile.min_sclk = 1752 + be32_to_cpu(levels[min_level].SclkFrequency); 1753 + hwmgr->default_compute_power_profile.up_hyst = 0; 1754 + hwmgr->default_compute_power_profile.down_hyst = 5; 1755 + 1756 + hwmgr->gfx_power_profile = hwmgr->default_gfx_power_profile; 1757 + hwmgr->compute_power_profile = hwmgr->default_compute_power_profile; 1758 + 1759 + return 0; 1760 + } 1724 1761 /** 1725 1762 * Initializes the SMC table and uploads it 1726 1763 * ··· 1971 1934 result = fiji_populate_pm_fuses(hwmgr); 1972 1935 PP_ASSERT_WITH_CODE(0 == result, 1973 1936 "Failed to populate PM fuses to SMC memory!", return result); 1937 + 1938 + fiji_save_default_power_profile(hwmgr); 1939 + 1974 1940 return 0; 1975 1941 } 1976 1942 ··· 2417 2377 return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device, 2418 2378 CGS_IND_REG__SMC, FEATURE_STATUS, VOLTAGE_CONTROLLER_ON)) 2419 2379 ? true : false; 2380 + } 2381 + 2382 + int fiji_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, 2383 + struct amd_pp_profile *request) 2384 + { 2385 + struct fiji_smumgr *smu_data = (struct fiji_smumgr *) 2386 + (hwmgr->smumgr->backend); 2387 + struct SMU73_Discrete_GraphicsLevel *levels = 2388 + smu_data->smc_state_table.GraphicsLevel; 2389 + uint32_t array = smu_data->smu7_data.dpm_table_start + 2390 + offsetof(SMU73_Discrete_DpmTable, GraphicsLevel); 2391 + uint32_t array_size = sizeof(struct SMU73_Discrete_GraphicsLevel) * 2392 + SMU73_MAX_LEVELS_GRAPHICS; 2393 + uint32_t i; 2394 + 2395 + for (i = 0; i < smu_data->smc_state_table.GraphicsDpmLevelCount; i++) { 2396 + levels[i].ActivityLevel = 2397 + cpu_to_be16(request->activity_threshold); 2398 + levels[i].EnabledForActivity = 1; 2399 + levels[i].UpHyst = request->up_hyst; 2400 + levels[i].DownHyst = request->down_hyst; 2401 + } 2402 + 2403 + return smu7_copy_bytes_to_smc(hwmgr->smumgr, array, (uint8_t *)levels, 2404 + array_size, SMC_RAM_END); 2420 2405 }
+2 -1
drivers/gpu/drm/amd/powerplay/smumgr/fiji_smc.h
··· 46 46 int fiji_process_firmware_header(struct pp_hwmgr *hwmgr); 47 47 int fiji_initialize_mc_reg_table(struct pp_hwmgr *hwmgr); 48 48 bool fiji_is_dpm_running(struct pp_hwmgr *hwmgr); 49 - 49 + int fiji_populate_requested_graphic_levels(struct pp_hwmgr *hwmgr, 50 + struct amd_pp_profile *request); 50 51 #endif 51 52
+1
drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
··· 519 519 .get_mac_definition = fiji_get_mac_definition, 520 520 .initialize_mc_reg_table = fiji_initialize_mc_reg_table, 521 521 .is_dpm_running = fiji_is_dpm_running, 522 + .populate_requested_graphic_levels = fiji_populate_requested_graphic_levels, 522 523 };