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

drm/amdgpu: add amdgpu_gfx_state_change_set() set gfx power change entry (v2)

The new amdgpu_gfx_state_change_set() funtion can support set GFX power
change status to D0/D3.

v2: squash in warning fix (Alex)

Signed-off-by: Prike Liang <Prike.Liang@amd.com>
Acked-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Prike Liang and committed by
Alex Deucher
d90a53d6 4cd078dc

+58 -1
+20
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
··· 819 819 } 820 820 return amdgpu_num_kcq; 821 821 } 822 + 823 + /* amdgpu_gfx_state_change_set - Handle gfx power state change set 824 + * @adev: amdgpu_device pointer 825 + * @state: gfx power state(1 -sGpuChangeState_D0Entry and 2 -sGpuChangeState_D3Entry) 826 + * 827 + */ 828 + 829 + void amdgpu_gfx_state_change_set(struct amdgpu_device *adev, enum gfx_change_state state) 830 + { 831 + 832 + mutex_lock(&adev->pm.mutex); 833 + 834 + if (adev->powerplay.pp_funcs && 835 + adev->powerplay.pp_funcs->gfx_state_change_set) 836 + ((adev)->powerplay.pp_funcs->gfx_state_change_set( 837 + (adev)->powerplay.pp_handle, state)); 838 + 839 + mutex_unlock(&adev->pm.mutex); 840 + 841 + }
+7
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
··· 47 47 AMDGPU_GFX_PIPE_PRIO_MAX 48 48 }; 49 49 50 + /* Argument for PPSMC_MSG_GpuChangeState */ 51 + enum gfx_change_state { 52 + sGpuChangeState_D0Entry = 1, 53 + sGpuChangeState_D3Entry, 54 + }; 55 + 50 56 #define AMDGPU_GFX_QUEUE_PRIORITY_MINIMUM 0 51 57 #define AMDGPU_GFX_QUEUE_PRIORITY_MAXIMUM 15 52 58 ··· 400 394 uint32_t amdgpu_kiq_rreg(struct amdgpu_device *adev, uint32_t reg); 401 395 void amdgpu_kiq_wreg(struct amdgpu_device *adev, uint32_t reg, uint32_t v); 402 396 int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev); 397 + void amdgpu_gfx_state_change_set(struct amdgpu_device *adev, enum gfx_change_state state); 403 398 #endif
+1
drivers/gpu/drm/amd/include/kgd_pp_interface.h
··· 285 285 int (*odn_edit_dpm_table)(void *handle, uint32_t type, long *input, uint32_t size); 286 286 int (*set_mp1_state)(void *handle, enum pp_mp1_state mp1_state); 287 287 int (*smu_i2c_bus_access)(void *handle, bool acquire); 288 + int (*gfx_state_change_set)(void *handle, uint32_t state); 288 289 /* export to DC */ 289 290 u32 (*get_sclk)(void *handle, bool low); 290 291 u32 (*get_mclk)(void *handle, bool low);
+1
drivers/gpu/drm/amd/pm/inc/hwmgr.h
··· 366 366 int (*disable_power_features_for_compute_performance)(struct pp_hwmgr *hwmgr, 367 367 bool disable); 368 368 ssize_t (*get_gpu_metrics)(struct pp_hwmgr *hwmgr, void **table); 369 + int (*gfx_state_change)(struct pp_hwmgr *hwmgr, uint32_t state); 369 370 }; 370 371 371 372 struct pp_table_func {
+2 -1
drivers/gpu/drm/amd/pm/inc/rv_ppsmc.h
··· 83 83 #define PPSMC_MSG_SetSoftMaxVcn 0x34 84 84 #define PPSMC_MSG_PowerGateMmHub 0x35 85 85 #define PPSMC_MSG_SetRccPfcPmeRestoreRegister 0x36 86 - #define PPSMC_Message_Count 0x37 86 + #define PPSMC_MSG_GpuChangeState 0x37 87 + #define PPSMC_Message_Count 0x42 87 88 88 89 typedef uint16_t PPSMC_Result; 89 90 typedef int PPSMC_Msg;
+19
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
··· 1629 1629 return size; 1630 1630 } 1631 1631 1632 + static int pp_gfx_state_change_set(void *handle, uint32_t state) 1633 + { 1634 + struct pp_hwmgr *hwmgr = handle; 1635 + 1636 + if (!hwmgr || !hwmgr->pm_en) 1637 + return -EINVAL; 1638 + 1639 + if (hwmgr->hwmgr_func->gfx_state_change == NULL) { 1640 + pr_info_ratelimited("%s was not implemented.\n", __func__); 1641 + return -EINVAL; 1642 + } 1643 + 1644 + mutex_lock(&hwmgr->smu_lock); 1645 + hwmgr->hwmgr_func->gfx_state_change(hwmgr, state); 1646 + mutex_unlock(&hwmgr->smu_lock); 1647 + return 0; 1648 + } 1649 + 1632 1650 static const struct amd_pm_funcs pp_dpm_funcs = { 1633 1651 .load_firmware = pp_dpm_load_fw, 1634 1652 .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete, ··· 1709 1691 .set_df_cstate = pp_set_df_cstate, 1710 1692 .set_xgmi_pstate = pp_set_xgmi_pstate, 1711 1693 .get_gpu_metrics = pp_get_gpu_metrics, 1694 + .gfx_state_change_set = pp_gfx_state_change_set, 1712 1695 };
+8
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.c
··· 1439 1439 return 0; 1440 1440 } 1441 1441 1442 + static int smu10_gfx_state_change(struct pp_hwmgr *hwmgr, uint32_t state) 1443 + { 1444 + smum_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_GpuChangeState, state, NULL); 1445 + 1446 + return 0; 1447 + } 1448 + 1442 1449 static const struct pp_hwmgr_func smu10_hwmgr_funcs = { 1443 1450 .backend_init = smu10_hwmgr_backend_init, 1444 1451 .backend_fini = smu10_hwmgr_backend_fini, ··· 1492 1485 .set_power_profile_mode = smu10_set_power_profile_mode, 1493 1486 .asic_reset = smu10_asic_reset, 1494 1487 .set_fine_grain_clk_vol = smu10_set_fine_grain_clk_vol, 1488 + .gfx_state_change = smu10_gfx_state_change, 1495 1489 }; 1496 1490 1497 1491 int smu10_init_function_pointers(struct pp_hwmgr *hwmgr)