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

drm/amd/pm: add inst to set_powergating_by_smu

Add an instance parameter to set_powergating_by_smu() function, and
re-write all amd_pm functions accordingly. Then use the instance to
call smu_dpm_set_vcn_enable().

v2: remove duplicated functions.

remove for-loop in smu_dpm_set_power_gate(), and temporarily move it to
to amdgpu_dpm_set_powergating_by_smu(), in order to keep the exact same
logic as before, until further separation in next patch.

v3: add instance number in error message.

Signed-off-by: Boyuan Zhang <boyuan.zhang@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Boyuan Zhang and committed by
Alex Deucher
697cb5cc 15df736a

+24 -14
+3 -1
drivers/gpu/drm/amd/include/kgd_pp_interface.h
··· 421 421 int (*load_firmware)(void *handle); 422 422 int (*wait_for_fw_loading_complete)(void *handle); 423 423 int (*set_powergating_by_smu)(void *handle, 424 - uint32_t block_type, bool gate); 424 + uint32_t block_type, 425 + bool gate, 426 + int inst); 425 427 int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id); 426 428 int (*set_power_limit)(void *handle, uint32_t n); 427 429 int (*get_power_limit)(void *handle, uint32_t *limit,
+8 -2
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
··· 88 88 case AMD_IP_BLOCK_TYPE_UVD: 89 89 case AMD_IP_BLOCK_TYPE_VCE: 90 90 case AMD_IP_BLOCK_TYPE_GFX: 91 - case AMD_IP_BLOCK_TYPE_VCN: 92 91 case AMD_IP_BLOCK_TYPE_SDMA: 93 92 case AMD_IP_BLOCK_TYPE_JPEG: 94 93 case AMD_IP_BLOCK_TYPE_GMC: ··· 95 96 case AMD_IP_BLOCK_TYPE_VPE: 96 97 if (pp_funcs && pp_funcs->set_powergating_by_smu) 97 98 ret = (pp_funcs->set_powergating_by_smu( 98 - (adev)->powerplay.pp_handle, block_type, gate)); 99 + (adev)->powerplay.pp_handle, block_type, gate, 0)); 100 + break; 101 + case AMD_IP_BLOCK_TYPE_VCN: 102 + if (pp_funcs && pp_funcs->set_powergating_by_smu) { 103 + for (int i = 0; i < adev->vcn.num_vcn_inst; i++) 104 + ret = (pp_funcs->set_powergating_by_smu( 105 + (adev)->powerplay.pp_handle, block_type, gate, i)); 106 + } 99 107 break; 100 108 default: 101 109 break;
+3 -1
drivers/gpu/drm/amd/pm/legacy-dpm/kv_dpm.c
··· 3276 3276 } 3277 3277 3278 3278 static int kv_set_powergating_by_smu(void *handle, 3279 - uint32_t block_type, bool gate) 3279 + uint32_t block_type, 3280 + bool gate, 3281 + int inst) 3280 3282 { 3281 3283 switch (block_type) { 3282 3284 case AMD_IP_BLOCK_TYPE_UVD:
+3 -1
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
··· 1227 1227 } 1228 1228 1229 1229 static int pp_set_powergating_by_smu(void *handle, 1230 - uint32_t block_type, bool gate) 1230 + uint32_t block_type, 1231 + bool gate, 1232 + int inst) 1231 1233 { 1232 1234 int ret = 0; 1233 1235
+7 -9
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 358 358 */ 359 359 static int smu_dpm_set_power_gate(void *handle, 360 360 uint32_t block_type, 361 - bool gate) 361 + bool gate, 362 + int inst) 362 363 { 363 364 struct smu_context *smu = handle; 364 - struct amdgpu_device *adev = smu->adev; 365 - int i, ret = 0; 365 + int ret = 0; 366 366 367 367 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) { 368 368 dev_WARN(smu->adev->dev, ··· 378 378 */ 379 379 case AMD_IP_BLOCK_TYPE_UVD: 380 380 case AMD_IP_BLOCK_TYPE_VCN: 381 - for (i = 0; i < adev->vcn.num_vcn_inst; i++) { 382 - ret = smu_dpm_set_vcn_enable(smu, !gate, i); 383 - if (ret) 384 - dev_err(smu->adev->dev, "Failed to power %s VCN instance %d!\n", 385 - gate ? "gate" : "ungate", i); 386 - } 381 + ret = smu_dpm_set_vcn_enable(smu, !gate, inst); 382 + if (ret) 383 + dev_err(smu->adev->dev, "Failed to power %s VCN instance %d!\n", 384 + gate ? "gate" : "ungate", inst); 387 385 break; 388 386 case AMD_IP_BLOCK_TYPE_GFX: 389 387 ret = smu_gfx_off_control(smu, gate);