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

drm/amd/powerplay: support xgmi pstate setting on powerplay routine V2

Add xgmi pstate setting on powerplay routine.

V2: split the change of is_support_sw_smu_xgmi into a separate patch

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Evan Quan and committed by
Alex Deucher
3e454860 086e1c56

+44 -4
+5
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
··· 285 285 286 286 if (is_support_sw_smu_xgmi(adev)) 287 287 ret = smu_set_xgmi_pstate(&adev->smu, pstate); 288 + else if (adev->powerplay.pp_funcs && 289 + adev->powerplay.pp_funcs->set_xgmi_pstate) 290 + ret = adev->powerplay.pp_funcs->set_xgmi_pstate(adev->powerplay.pp_handle, 291 + pstate); 292 + 288 293 if (ret) 289 294 dev_err(adev->dev, 290 295 "XGMI: Set pstate failure on device %llx, hive %llx, ret %d",
+4
drivers/gpu/drm/amd/include/kgd_pp_interface.h
··· 220 220 ((group) << PP_GROUP_SHIFT | (block) << PP_BLOCK_SHIFT | \ 221 221 (support) << PP_STATE_SUPPORT_SHIFT | (state) << PP_STATE_SHIFT) 222 222 223 + #define XGMI_MODE_PSTATE_D3 0 224 + #define XGMI_MODE_PSTATE_D0 1 225 + 223 226 struct seq_file; 224 227 enum amd_pp_clock_type; 225 228 struct amd_pp_simple_clock_info; ··· 321 318 int (*set_ppfeature_status)(void *handle, uint64_t ppfeature_masks); 322 319 int (*asic_reset_mode_2)(void *handle); 323 320 int (*set_df_cstate)(void *handle, enum pp_df_cstate state); 321 + int (*set_xgmi_pstate)(void *handle, uint32_t pstate); 324 322 }; 325 323 326 324 #endif
+18
drivers/gpu/drm/amd/powerplay/amd_powerplay.c
··· 1566 1566 return 0; 1567 1567 } 1568 1568 1569 + static int pp_set_xgmi_pstate(void *handle, uint32_t pstate) 1570 + { 1571 + struct pp_hwmgr *hwmgr = handle; 1572 + 1573 + if (!hwmgr) 1574 + return -EINVAL; 1575 + 1576 + if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_xgmi_pstate) 1577 + return 0; 1578 + 1579 + mutex_lock(&hwmgr->smu_lock); 1580 + hwmgr->hwmgr_func->set_xgmi_pstate(hwmgr, pstate); 1581 + mutex_unlock(&hwmgr->smu_lock); 1582 + 1583 + return 0; 1584 + } 1585 + 1569 1586 static const struct amd_pm_funcs pp_dpm_funcs = { 1570 1587 .load_firmware = pp_dpm_load_fw, 1571 1588 .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete, ··· 1642 1625 .asic_reset_mode_2 = pp_asic_reset_mode_2, 1643 1626 .smu_i2c_bus_access = pp_smu_i2c_bus_access, 1644 1627 .set_df_cstate = pp_set_df_cstate, 1628 + .set_xgmi_pstate = pp_set_xgmi_pstate, 1645 1629 };
+15
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
··· 4176 4176 return ret; 4177 4177 } 4178 4178 4179 + static int vega20_set_xgmi_pstate(struct pp_hwmgr *hwmgr, 4180 + uint32_t pstate) 4181 + { 4182 + int ret; 4183 + 4184 + ret = smum_send_msg_to_smc_with_parameter(hwmgr, 4185 + PPSMC_MSG_SetXgmiMode, 4186 + pstate ? XGMI_MODE_PSTATE_D0 : XGMI_MODE_PSTATE_D3); 4187 + if (ret) 4188 + pr_err("SetXgmiPstate failed!\n"); 4189 + 4190 + return ret; 4191 + } 4192 + 4179 4193 static const struct pp_hwmgr_func vega20_hwmgr_funcs = { 4180 4194 /* init/fini related */ 4181 4195 .backend_init = vega20_hwmgr_backend_init, ··· 4259 4245 .set_mp1_state = vega20_set_mp1_state, 4260 4246 .smu_i2c_bus_access = vega20_smu_i2c_bus_access, 4261 4247 .set_df_cstate = vega20_set_df_cstate, 4248 + .set_xgmi_pstate = vega20_set_xgmi_pstate, 4262 4249 }; 4263 4250 4264 4251 int vega20_hwmgr_init(struct pp_hwmgr *hwmgr)
+1
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
··· 356 356 int (*asic_reset)(struct pp_hwmgr *hwmgr, enum SMU_ASIC_RESET_MODE mode); 357 357 int (*smu_i2c_bus_access)(struct pp_hwmgr *hwmgr, bool aquire); 358 358 int (*set_df_cstate)(struct pp_hwmgr *hwmgr, enum pp_df_cstate state); 359 + int (*set_xgmi_pstate)(struct pp_hwmgr *hwmgr, uint32_t pstate); 359 360 }; 360 361 361 362 struct pp_table_func {
+1 -4
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
··· 1463 1463 return ret; 1464 1464 } 1465 1465 1466 - #define XGMI_STATE_D0 1 1467 - #define XGMI_STATE_D3 0 1468 - 1469 1466 int smu_v11_0_set_xgmi_pstate(struct smu_context *smu, 1470 1467 uint32_t pstate) 1471 1468 { 1472 1469 int ret = 0; 1473 1470 ret = smu_send_smc_msg_with_param(smu, 1474 1471 SMU_MSG_SetXgmiMode, 1475 - pstate ? XGMI_STATE_D0 : XGMI_STATE_D3); 1472 + pstate ? XGMI_MODE_PSTATE_D0 : XGMI_MODE_PSTATE_D3); 1476 1473 return ret; 1477 1474 } 1478 1475