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

Configure Feed

Select the types of activity you want to include in your feed.

drm/amd: Stop overloading power limit with limit type

When passed around internally the upper 8 bits of power limit include
the limit type. This is non-obvious without digging into the nuances
of each function. Instead pass the limit type as an argument to all
applicable layers.

Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Mario Limonciello and committed by
Alex Deucher
5f4f49a4 16dc933a

+10 -13
+1 -1
drivers/gpu/drm/amd/include/kgd_pp_interface.h
··· 454 454 bool gate, 455 455 int inst); 456 456 int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id); 457 - int (*set_power_limit)(void *handle, uint32_t n); 457 + int (*set_power_limit)(void *handle, uint32_t limit_type, uint32_t n); 458 458 int (*get_power_limit)(void *handle, uint32_t *limit, 459 459 enum pp_power_limit_level pp_limit_level, 460 460 enum pp_power_type power_type);
+2 -1
drivers/gpu/drm/amd/pm/amdgpu_dpm.c
··· 1616 1616 } 1617 1617 1618 1618 int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev, 1619 + uint32_t limit_type, 1619 1620 uint32_t limit) 1620 1621 { 1621 1622 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; ··· 1627 1626 1628 1627 mutex_lock(&adev->pm.mutex); 1629 1628 ret = pp_funcs->set_power_limit(adev->powerplay.pp_handle, 1630 - limit); 1629 + limit_type, limit); 1631 1630 mutex_unlock(&adev->pm.mutex); 1632 1631 1633 1632 return ret;
+1 -2
drivers/gpu/drm/amd/pm/amdgpu_pm.c
··· 3390 3390 return err; 3391 3391 3392 3392 value = value / 1000000; /* convert to Watt */ 3393 - value |= limit_type << 24; 3394 3393 3395 3394 err = amdgpu_pm_get_access(adev); 3396 3395 if (err < 0) 3397 3396 return err; 3398 3397 3399 - err = amdgpu_dpm_set_power_limit(adev, value); 3398 + err = amdgpu_dpm_set_power_limit(adev, limit_type, value); 3400 3399 3401 3400 amdgpu_pm_put_access(adev); 3402 3401
+1 -1
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h
··· 553 553 enum pp_power_limit_level pp_limit_level, 554 554 enum pp_power_type power_type); 555 555 int amdgpu_dpm_set_power_limit(struct amdgpu_device *adev, 556 - uint32_t limit); 556 + uint32_t limit_type, uint32_t limit); 557 557 int amdgpu_dpm_is_cclk_dpm_supported(struct amdgpu_device *adev); 558 558 int amdgpu_dpm_debugfs_print_current_performance_level(struct amdgpu_device *adev, 559 559 struct seq_file *m);
+1 -1
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
··· 952 952 return 0; 953 953 } 954 954 955 - static int pp_set_power_limit(void *handle, uint32_t limit) 955 + static int pp_set_power_limit(void *handle, uint32_t limit_type, uint32_t limit) 956 956 { 957 957 struct pp_hwmgr *hwmgr = handle; 958 958 uint32_t max_power_limit;
+4 -6
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 68 68 static int smu_reset(struct smu_context *smu); 69 69 static int smu_set_fan_speed_pwm(void *handle, u32 speed); 70 70 static int smu_set_fan_control_mode(void *handle, u32 value); 71 - static int smu_set_power_limit(void *handle, uint32_t limit); 71 + static int smu_set_power_limit(void *handle, uint32_t limit_type, uint32_t limit); 72 72 static int smu_set_fan_speed_rpm(void *handle, uint32_t speed); 73 73 static int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled); 74 74 static int smu_set_mp1_state(void *handle, enum pp_mp1_state mp1_state); ··· 510 510 511 511 /* set the user dpm power limit */ 512 512 if (smu->user_dpm_profile.power_limit) { 513 - ret = smu_set_power_limit(smu, smu->user_dpm_profile.power_limit); 513 + ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT, smu->current_power_limit); 514 514 if (ret) 515 515 dev_err(smu->adev->dev, "Failed to set power limit value\n"); 516 516 } ··· 2258 2258 adev->pm.dpm_enabled = true; 2259 2259 2260 2260 if (smu->current_power_limit) { 2261 - ret = smu_set_power_limit(smu, smu->current_power_limit); 2261 + ret = smu_set_power_limit(smu, SMU_DEFAULT_PPT_LIMIT, smu->current_power_limit); 2262 2262 if (ret && ret != -EOPNOTSUPP) 2263 2263 return ret; 2264 2264 } ··· 2958 2958 return ret; 2959 2959 } 2960 2960 2961 - static int smu_set_power_limit(void *handle, uint32_t limit) 2961 + static int smu_set_power_limit(void *handle, uint32_t limit_type, uint32_t limit) 2962 2962 { 2963 2963 struct smu_context *smu = handle; 2964 - uint32_t limit_type = limit >> 24; 2965 2964 int ret = 0; 2966 2965 2967 2966 if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) 2968 2967 return -EOPNOTSUPP; 2969 2968 2970 - limit &= (1<<24)-1; 2971 2969 if (limit_type != SMU_DEFAULT_PPT_LIMIT) 2972 2970 if (smu->ppt_funcs->set_power_limit) 2973 2971 return smu->ppt_funcs->set_power_limit(smu, limit_type, limit);
-1
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c
··· 2397 2397 smu->current_power_limit = ppt_limit; 2398 2398 break; 2399 2399 case SMU_FAST_PPT_LIMIT: 2400 - ppt_limit &= ~(SMU_FAST_PPT_LIMIT << 24); 2401 2400 if (ppt_limit > power_context->max_fast_ppt_limit) { 2402 2401 dev_err(smu->adev->dev, 2403 2402 "New power limit (%d) is over the max allowed %d\n",