Drop unneeded power related lock protections
Subsystems (3)
cover Drop unneeded power related lock protections
As a follow-up for previous cleanup, those redundant lock protections can be dropped now. As we already adopted an unified lock(adev->pm.mutex) in amdgpu_dpm.c.
Evan Quan (7):
drm/amd/pm: drop unneeded lock protection smu->mutex drm/amd/pm: drop unneeded vcn/jpeg_gate_lock drm/amd/pm: drop unneeded smu->metrics_lock drm/amd/pm: drop unneeded smu->sensor_lock drm/amd/pm: drop unneeded smu_baco->mutex drm/amd/pm: drop unneeded feature->mutex drm/amd/pm: drop unneeded hwmgr->smu_lock
.../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 282 ++----------- drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h | 1 - drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 375 ++---------------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 - .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 18 +- .../amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 14 +- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 116 ++---- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 31 +- .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 19 +- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 30 +- .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c | 16 +- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 27 +- .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 20 +- .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c | 12 +- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 40 +- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 4 - 16 files changed, 157 insertions(+), 855 deletions(-)
Signature · 1 line
2.29.0
PATCH 1/7 drm/amd/pm: drop unneeded lock protection smu->mutex
As all those APIs are already protected either by adev->pm.mutex or smu->message_lock.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 315 ++---------------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 1 - .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 2 - .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 2 - .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 2 - .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 - 6 files changed, 25 insertions(+), 299 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +25 -290
@@ -55,8 +55,7 @@ static int smu_force_smuclk_levels(struct smu_context *smu, uint32_t mask);static int smu_handle_task (struct smu_context *smu,enum amd_dpm_forced_level level, -enum amd_pp_task task_id, -bool lock_needed); +enum amd_pp_task task_id);static int smu_reset (struct smu_context *smu);static int smu_set_fan_speed_pwm (void *handle,u32 speed);static int smu_set_fan_control_mode (struct smu_context *smu,int value);
@@ -68,36 +67,22 @@ static int smu_sys_get_pp_feature_mask(void *handle, char *buf) {struct smu_context *smu = handle; -int size =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); - - size =smu_get_pp_feature_mask (smu, buf); - -mutex_unlock (&smu->mutex); - -return size; +return smu_get_pp_feature_mask (smu, buf); }static int smu_sys_set_pp_feature_mask (void *handle,uint64_t new_mask) {struct smu_context *smu = handle; -int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); - - ret =smu_set_pp_feature_mask (smu, new_mask); - -mutex_unlock (&smu->mutex); - -return ret; +return smu_set_pp_feature_mask (smu, new_mask); }int smu_get_status_gfxoff (struct smu_context *smu,uint32_t *value)
@@ -117,16 +102,12 @@ int smu_set_soft_freq_range(struct smu_context *smu, {int ret =0 ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_soft_freq_limited_range) ret = smu->ppt_funcs->set_soft_freq_limited_range (smu, clk_type, min, max); -mutex_unlock (&smu->mutex); -return ret; }
@@ -140,16 +121,12 @@ int smu_get_dpm_freq_range(struct smu_context *smu,if (!min && !max)return -EINVAL ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_dpm_ultimate_freq) ret = smu->ppt_funcs->get_dpm_ultimate_freq (smu, clk_type, min, max); -mutex_unlock (&smu->mutex); -return ret; }
@@ -482,7 +459,6 @@ static int smu_sys_get_pp_table(void *handle, {struct smu_context *smu = handle;struct smu_table_context *smu_table = &smu->smu_table; -uint32_t powerplay_table_size;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ;
@@ -490,18 +466,12 @@ static int smu_sys_get_pp_table(void *handle,if (!smu_table->power_play_table && !smu_table->hardcode_pptable)return -EINVAL ; -mutex_lock (&smu->mutex); -if (smu_table->hardcode_pptable) *table = smu_table->hardcode_pptable;else *table = smu_table->power_play_table; - powerplay_table_size = smu_table->power_play_table_size; - -mutex_unlock (&smu->mutex); - -return powerplay_table_size; +return smu_table->power_play_table_size; } static int smu_sys_set_pp_table(void *handle,
@@ -521,13 +491,10 @@ static int smu_sys_set_pp_table(void *handle,return -EIO ; } -mutex_lock (&smu->mutex);if (!smu_table->hardcode_pptable) smu_table->hardcode_pptable =kzalloc (size,GFP_KERNEL ); -if (!smu_table->hardcode_pptable) { - ret = -ENOMEM ; - goto failed; - } +if (!smu_table->hardcode_pptable) +return -ENOMEM ;memcpy (smu_table->hardcode_pptable, buf, size); smu_table->power_play_table = smu_table->hardcode_pptable;
@@ -545,8 +512,6 @@ static int smu_sys_set_pp_table(void *handle, smu->uploading_custom_pp_table = false; -failed: -mutex_unlock (&smu->mutex);return ret; }
@@ -633,7 +598,6 @@ static int smu_early_init(void *handle) smu->adev = adev; smu->pm_enabled = !!amdgpu_dpm; smu->is_apu = false; -mutex_init (&smu->mutex);mutex_init (&smu->smu_baco.mutex); smu->smu_baco.state =SMU_BACO_STATE_EXIT ; smu->smu_baco.platform_support = false;
@@ -736,8 +700,7 @@ static int smu_late_init(void *handle)smu_handle_task (smu, smu->smu_dpm.dpm_level, -AMD_PP_TASK_COMPLETE_INIT , - false); +AMD_PP_TASK_COMPLETE_INIT );smu_restore_dpm_user_profile (smu);
@@ -1013,12 +976,8 @@ static void smu_interrupt_work_fn(struct work_struct *work) struct smu_context *smu = container_of(work, struct smu_context, interrupt_work); -mutex_lock (&smu->mutex); -if (smu->ppt_funcs && smu->ppt_funcs->interrupt_work) smu->ppt_funcs->interrupt_work (smu); - -mutex_unlock (&smu->mutex); }static int smu_sw_init (void *handle)
@@ -1634,8 +1593,6 @@ static int smu_display_configuration_change(void *handle,if (!display_config)return -EINVAL ; -mutex_lock (&smu->mutex); -smu_set_min_dcef_deep_sleep (smu, display_config->min_dcef_deep_sleep_set_clk /100 );
@@ -1644,8 +1601,6 @@ static int smu_display_configuration_change(void *handle, num_of_active_display++; } -mutex_unlock (&smu->mutex); -return 0 ; }
@@ -1768,22 +1723,18 @@ static int smu_adjust_power_state_dynamic(struct smu_context *smu,static int smu_handle_task (struct smu_context *smu,enum amd_dpm_forced_level level, -enum amd_pp_task task_id, -bool lock_needed) +enum amd_pp_task task_id) {int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -if (lock_needed) -mutex_lock (&smu->mutex); -switch (task_id) {case AMD_PP_TASK_DISPLAY_CONFIG_CHANGE : ret =smu_pre_display_config_changed (smu);if (ret) - goto out; +return ret; ret =smu_adjust_power_state_dynamic (smu, level, false);break ;case AMD_PP_TASK_COMPLETE_INIT :
@@ -1794,10 +1745,6 @@ static int smu_handle_task(struct smu_context *smu,break ; } -out: -if (lock_needed) -mutex_unlock (&smu->mutex); -return ret; }
@@ -1808,7 +1755,7 @@ static int smu_handle_dpm_task(void *handle,struct smu_context *smu = handle;struct smu_dpm_context *smu_dpm = &smu->smu_dpm; -return smu_handle_task (smu, smu_dpm->dpm_level, task_id, true); +return smu_handle_task (smu, smu_dpm->dpm_level, task_id); }
@@ -1827,8 +1774,6 @@ static int smu_switch_power_profile(void *handle,if (!(type <PP_SMC_POWER_PROFILE_CUSTOM ))return -EINVAL ; -mutex_lock (&smu->mutex); -if (!en) { smu->workload_mask &= ~(1 << smu->workload_prority[type]); index =fls (smu->workload_mask);
@@ -1845,8 +1790,6 @@ static int smu_switch_power_profile(void *handle, smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM)smu_bump_power_profile_mode (smu, &workload,0 ); -mutex_unlock (&smu->mutex); -return 0 ; }
@@ -1854,7 +1797,6 @@ static enum amd_dpm_forced_level smu_get_performance_level(void *handle) {struct smu_context *smu = handle;struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); -enum amd_dpm_forced_level level;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ;
@@ -1862,11 +1804,7 @@ static enum amd_dpm_forced_level smu_get_performance_level(void *handle)if (!smu->is_apu && !smu_dpm_ctx->dpm_context)return -EINVAL ; -mutex_lock (&(smu->mutex)); - level = smu_dpm_ctx->dpm_level; -mutex_unlock (&(smu->mutex)); - -return level; +return smu_dpm_ctx->dpm_level; } static int smu_force_performance_level(void *handle,
@@ -1882,19 +1820,12 @@ static int smu_force_performance_level(void *handle,if (!smu->is_apu && !smu_dpm_ctx->dpm_context)return -EINVAL ; -mutex_lock (&smu->mutex); - ret =smu_enable_umd_pstate (smu, &level); -if (ret) { -mutex_unlock (&smu->mutex); +if (ret)return ret; - } ret =smu_handle_task (smu, level, -AMD_PP_TASK_READJUST_POWER_STATE , - false); - -mutex_unlock (&smu->mutex); +AMD_PP_TASK_READJUST_POWER_STATE );/* reset user dpm clock state */ if (!ret && smu_dpm_ctx->dpm_level !=AMD_DPM_FORCED_LEVEL_MANUAL ) {
@@ -1908,16 +1839,11 @@ static int smu_force_performance_level(void *handle,static int smu_set_display_count (void *handle,uint32_t count) {struct smu_context *smu = handle; -int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); - ret =smu_init_display_count (smu, count); -mutex_unlock (&smu->mutex); - -return ret; +return smu_init_display_count (smu, count); } static int smu_force_smuclk_levels(struct smu_context *smu,
@@ -1935,8 +1861,6 @@ static int smu_force_smuclk_levels(struct smu_context *smu,return -EINVAL ; } -mutex_lock (&smu->mutex); -if (smu->ppt_funcs && smu->ppt_funcs->force_clk_levels) { ret = smu->ppt_funcs->force_clk_levels (smu, clk_type, mask);if (!ret && !(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) {
@@ -1945,8 +1869,6 @@ static int smu_force_smuclk_levels(struct smu_context *smu, } } -mutex_unlock (&smu->mutex); -return ret; }
@@ -2005,14 +1927,10 @@ static int smu_set_mp1_state(void *handle,if (!smu->pm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs && smu->ppt_funcs->set_mp1_state) ret = smu->ppt_funcs->set_mp1_state (smu, mp1_state); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2028,14 +1946,10 @@ static int smu_set_df_cstate(void *handle,if (!smu->ppt_funcs || !smu->ppt_funcs->set_df_cstate)return 0 ; -mutex_lock (&smu->mutex); - ret = smu->ppt_funcs->set_df_cstate (smu, state);if (ret)dev_err (smu->adev->dev,"[SetDfCstate] failed!\n" ); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2049,38 +1963,25 @@ int smu_allow_xgmi_power_down(struct smu_context *smu, bool en)if (!smu->ppt_funcs || !smu->ppt_funcs->allow_xgmi_power_down)return 0 ; -mutex_lock (&smu->mutex); - ret = smu->ppt_funcs->allow_xgmi_power_down (smu, en);if (ret)dev_err (smu->adev->dev,"[AllowXgmiPowerDown] failed!\n" ); -mutex_unlock (&smu->mutex); -return ret; }int smu_write_watermarks_table (struct smu_context *smu) { -int ret =0 ; -if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); - - ret =smu_set_watermarks_table (smu,NULL ); - -mutex_unlock (&smu->mutex); - -return ret; +return smu_set_watermarks_table (smu,NULL ); }static int smu_set_watermarks_for_clock_ranges (void *handle,struct pp_smu_wm_range_sets *clock_ranges) {struct smu_context *smu = handle; -int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ;
@@ -2088,13 +1989,7 @@ static int smu_set_watermarks_for_clock_ranges(void *handle,if (smu->disable_watermark)return 0 ; -mutex_lock (&smu->mutex); - - ret =smu_set_watermarks_table (smu, clock_ranges); - -mutex_unlock (&smu->mutex); - -return ret; +return smu_set_watermarks_table (smu, clock_ranges); }int smu_set_ac_dc (struct smu_context *smu)
@@ -2108,14 +2003,12 @@ int smu_set_ac_dc(struct smu_context *smu)if (smu->dc_controlled_by_gpio)return 0 ; -mutex_lock (&smu->mutex); ret =smu_set_power_source (smu, smu->adev->pm.ac_power ?SMU_POWER_SOURCE_AC :SMU_POWER_SOURCE_DC );if (ret)dev_err (smu->adev->dev,"Failed to switch to %s mode!\n" , smu->adev->pm.ac_power ?"AC" :"DC" ); -mutex_unlock (&smu->mutex);return ret; }
@@ -2202,13 +2095,9 @@ static int smu_set_gfx_cgpg(struct smu_context *smu, bool enabled) {int ret =0 ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_gfx_cgpg) ret = smu->ppt_funcs->set_gfx_cgpg (smu, enabled); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2220,8 +2109,6 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_rpm) { ret = smu->ppt_funcs->set_fan_speed_rpm (smu, speed);if (!ret && !(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) {
@@ -2234,8 +2121,6 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed) } } -mutex_unlock (&smu->mutex); -return ret; }
@@ -2291,8 +2176,6 @@ int smu_get_power_limit(void *handle,break ; } -mutex_lock (&smu->mutex); -if (limit_type !=SMU_DEFAULT_PPT_LIMIT ) {if (smu->ppt_funcs->get_ppt_limit) ret = smu->ppt_funcs->get_ppt_limit (smu, limit, limit_type, limit_level);
@@ -2326,8 +2209,6 @@ int smu_get_power_limit(void *handle, } } -mutex_unlock (&smu->mutex); -return ret; }
@@ -2340,21 +2221,16 @@ static int smu_set_power_limit(void *handle, uint32_t limit)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); - limit &= (1 <<24 )-1 ;if (limit_type !=SMU_DEFAULT_PPT_LIMIT ) -if (smu->ppt_funcs->set_power_limit) { - ret = smu->ppt_funcs->set_power_limit (smu, limit_type, limit); - goto out; - } +if (smu->ppt_funcs->set_power_limit) +return smu->ppt_funcs->set_power_limit (smu, limit_type, limit);if (limit > smu->max_power_limit) {dev_err (smu->adev->dev,"New power limit (%d) is over the max allowed %d\n" , limit, smu->max_power_limit); - ret = -EINVAL ; - goto out; +return -EINVAL ; }if (!limit)
@@ -2366,9 +2242,6 @@ static int smu_set_power_limit(void *handle, uint32_t limit) smu->user_dpm_profile.power_limit = limit; } -out: -mutex_unlock (&smu->mutex); -return ret; }
@@ -2379,13 +2252,9 @@ static int smu_print_smuclk_levels(struct smu_context *smu, enum smu_clk_type clif (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->print_clk_levels) ret = smu->ppt_funcs->print_clk_levels (smu, clk_type, buf); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2442,14 +2311,10 @@ static int smu_od_edit_dpm_table(void *handle,if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->od_edit_dpm_table) { ret = smu->ppt_funcs->od_edit_dpm_table (smu, type, input, size); } -mutex_unlock (&smu->mutex); -return ret; }
@@ -2473,8 +2338,6 @@ static int smu_read_sensor(void *handle, size_val = *size_arg; size = &size_val; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->read_sensor)if (!smu->ppt_funcs->read_sensor (smu, sensor, data, size)) goto unlock;
@@ -2515,8 +2378,6 @@ static int smu_read_sensor(void *handle, } unlock: -mutex_unlock (&smu->mutex); -// assign uint32_t to int *size_arg = size_val;
@@ -2526,7 +2387,6 @@ static int smu_read_sensor(void *handle,static int smu_get_power_profile_mode (void *handle,char *buf) {struct smu_context *smu = handle; -int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled || !smu->ppt_funcs->get_power_profile_mode)
@@ -2534,13 +2394,7 @@ static int smu_get_power_profile_mode(void *handle, char *buf)if (!buf)return -EINVAL ; -mutex_lock (&smu->mutex); - - ret = smu->ppt_funcs->get_power_profile_mode (smu, buf); - -mutex_unlock (&smu->mutex); - -return ret; +return smu->ppt_funcs->get_power_profile_mode (smu, buf); } static int smu_set_power_profile_mode(void *handle,
@@ -2548,19 +2402,12 @@ static int smu_set_power_profile_mode(void *handle, uint32_t param_size) {struct smu_context *smu = handle; -int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled || !smu->ppt_funcs->set_power_profile_mode)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); - -smu_bump_power_profile_mode (smu, param, param_size); - -mutex_unlock (&smu->mutex); - -return ret; +return smu_bump_power_profile_mode (smu, param, param_size); }
@@ -2572,13 +2419,9 @@ static u32 smu_get_fan_control_mode(void *handle)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return AMD_FAN_CTRL_NONE ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_control_mode) ret = smu->ppt_funcs->get_fan_control_mode (smu); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2589,16 +2432,12 @@ static int smu_set_fan_control_mode(struct smu_context *smu, int value)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_control_mode) { ret = smu->ppt_funcs->set_fan_control_mode (smu, value);if (!ret && !(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) smu->user_dpm_profile.fan_mode = value; } -mutex_unlock (&smu->mutex); -/* reset user dpm fan speed */ if (!ret && value !=AMD_FAN_CTRL_MANUAL && !(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) {
@@ -2626,13 +2465,9 @@ static int smu_get_fan_speed_pwm(void *handle, u32 *speed)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_pwm) ret = smu->ppt_funcs->get_fan_speed_pwm (smu, speed); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2644,8 +2479,6 @@ static int smu_set_fan_speed_pwm(void *handle, u32 speed)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_fan_speed_pwm) { ret = smu->ppt_funcs->set_fan_speed_pwm (smu, speed);if (!ret && !(smu->user_dpm_profile.flags &SMU_DPM_USER_PROFILE_RESTORE )) {
@@ -2658,8 +2491,6 @@ static int smu_set_fan_speed_pwm(void *handle, u32 speed) } } -mutex_unlock (&smu->mutex); -return ret; }
@@ -2671,31 +2502,20 @@ static int smu_get_fan_speed_rpm(void *handle, uint32_t *speed)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_fan_speed_rpm) ret = smu->ppt_funcs->get_fan_speed_rpm (smu, speed); -mutex_unlock (&smu->mutex); -return ret; }static int smu_set_deep_sleep_dcefclk (void *handle,uint32_t clk) {struct smu_context *smu = handle; -int ret =0 ;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); - - ret =smu_set_min_dcef_deep_sleep (smu, clk); - -mutex_unlock (&smu->mutex); - -return ret; +return smu_set_min_dcef_deep_sleep (smu, clk); } static int smu_get_clock_by_type_with_latency(void *handle,
@@ -2709,8 +2529,6 @@ static int smu_get_clock_by_type_with_latency(void *handle,if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_clock_by_type_with_latency) {switch (type) {case amd_pp_sys_clock:
@@ -2727,15 +2545,12 @@ static int smu_get_clock_by_type_with_latency(void *handle,break ;default :dev_err (smu->adev->dev,"Invalid clock type!\n" ); -mutex_unlock (&smu->mutex);return -EINVAL ; } ret = smu->ppt_funcs->get_clock_by_type_with_latency (smu, clk_type, clocks); } -mutex_unlock (&smu->mutex); -return ret; }
@@ -2748,13 +2563,9 @@ static int smu_display_clock_voltage_request(void *handle,if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->display_clock_voltage_request) ret = smu->ppt_funcs->display_clock_voltage_request (smu, clock_req); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2768,13 +2579,9 @@ static int smu_display_disable_memory_clock_switch(void *handle,if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->display_disable_memory_clock_switch) ret = smu->ppt_funcs->display_disable_memory_clock_switch (smu, disable_memory_clock_switch); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2787,13 +2594,9 @@ static int smu_set_xgmi_pstate(void *handle,if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->set_xgmi_pstate) ret = smu->ppt_funcs->set_xgmi_pstate (smu, pstate); -mutex_unlock (&smu->mutex); -if (ret)dev_err (smu->adev->dev,"Failed to set XGMI pstate!\n" );
@@ -2803,21 +2606,16 @@ static int smu_set_xgmi_pstate(void *handle,static int smu_get_baco_capability (void *handle,bool *cap) {struct smu_context *smu = handle; -int ret =0 ; *cap = false;if (!smu->pm_enabled)return 0 ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support) *cap = smu->ppt_funcs->baco_is_support (smu); -mutex_unlock (&smu->mutex); - -return ret; +return 0 ; }static int smu_baco_set_state (void *handle,int state)
@@ -2829,20 +2627,11 @@ static int smu_baco_set_state(void *handle, int state)return -EOPNOTSUPP ;if (state ==0 ) { -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->baco_exit) ret = smu->ppt_funcs->baco_exit (smu); - -mutex_unlock (&smu->mutex); }else if (state ==1 ) { -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->baco_enter) ret = smu->ppt_funcs->baco_enter (smu); - -mutex_unlock (&smu->mutex); - }else {return -EINVAL ; }
@@ -2861,13 +2650,9 @@ bool smu_mode1_reset_is_support(struct smu_context *smu)if (!smu->pm_enabled)return false; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs && smu->ppt_funcs->mode1_reset_is_support) ret = smu->ppt_funcs->mode1_reset_is_support (smu); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2878,13 +2663,9 @@ bool smu_mode2_reset_is_support(struct smu_context *smu)if (!smu->pm_enabled)return false; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs && smu->ppt_funcs->mode2_reset_is_support) ret = smu->ppt_funcs->mode2_reset_is_support (smu); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2895,13 +2676,9 @@ int smu_mode1_reset(struct smu_context *smu)if (!smu->pm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->mode1_reset) ret = smu->ppt_funcs->mode1_reset (smu); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2913,13 +2690,9 @@ static int smu_mode2_reset(void *handle)if (!smu->pm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->mode2_reset) ret = smu->ppt_funcs->mode2_reset (smu); -mutex_unlock (&smu->mutex); -if (ret)dev_err (smu->adev->dev,"Mode2 reset failed!\n" );
@@ -2935,13 +2708,9 @@ static int smu_get_max_sustainable_clocks_by_dc(void *handle,if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_max_sustainable_clocks_by_dc) ret = smu->ppt_funcs->get_max_sustainable_clocks_by_dc (smu, max_clocks); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2955,13 +2724,9 @@ static int smu_get_uclk_dpm_states(void *handle,if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_uclk_dpm_states) ret = smu->ppt_funcs->get_uclk_dpm_states (smu, clock_values_in_khz, num_states); -mutex_unlock (&smu->mutex); -return ret; }
@@ -2973,13 +2738,9 @@ static enum amd_pm_state_type smu_get_current_power_state(void *handle)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_current_power_state) pm_state = smu->ppt_funcs->get_current_power_state (smu); -mutex_unlock (&smu->mutex); -return pm_state; }
@@ -2992,20 +2753,15 @@ static int smu_get_dpm_clock_table(void *handle,if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->get_dpm_clock_table) ret = smu->ppt_funcs->get_dpm_clock_table (smu, clock_table); -mutex_unlock (&smu->mutex); -return ret; }static ssize_t smu_sys_get_gpu_metrics (void *handle,void **table) {struct smu_context *smu = handle; -ssize_t size;if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ;
@@ -3013,13 +2769,7 @@ static ssize_t smu_sys_get_gpu_metrics(void *handle, void **table)if (!smu->ppt_funcs->get_gpu_metrics)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); - - size = smu->ppt_funcs->get_gpu_metrics (smu, table); - -mutex_unlock (&smu->mutex); - -return size; +return smu->ppt_funcs->get_gpu_metrics (smu, table); }static int smu_enable_mgpu_fan_boost (void *handle)
@@ -3030,13 +2780,9 @@ static int smu_enable_mgpu_fan_boost(void *handle)if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)return -EOPNOTSUPP ; -mutex_lock (&smu->mutex); -if (smu->ppt_funcs->enable_mgpu_fan_boost) ret = smu->ppt_funcs->enable_mgpu_fan_boost (smu); -mutex_unlock (&smu->mutex); -return ret; }
@@ -3046,10 +2792,8 @@ static int smu_gfx_state_change_set(void *handle,struct smu_context *smu = handle;int ret =0 ; -mutex_lock (&smu->mutex);if (smu->ppt_funcs->gfx_state_change_set) ret = smu->ppt_funcs->gfx_state_change_set (smu, state); -mutex_unlock (&smu->mutex);return ret; }
@@ -3058,10 +2802,8 @@ int smu_set_light_sbr(struct smu_context *smu, bool enable) {int ret =0 ; -mutex_lock (&smu->mutex);if (smu->ppt_funcs->set_light_sbr) ret = smu->ppt_funcs->set_light_sbr (smu, enable); -mutex_unlock (&smu->mutex);return ret; }
@@ -3070,11 +2812,9 @@ int smu_get_ecc_info(struct smu_context *smu, void *umc_ecc) {int ret = -EOPNOTSUPP ; -mutex_lock (&smu->mutex);if (smu->ppt_funcs && smu->ppt_funcs->get_ecc_info) ret = smu->ppt_funcs->get_ecc_info (smu, umc_ecc); -mutex_unlock (&smu->mutex);return ret;
@@ -3091,12 +2831,10 @@ static int smu_get_prv_buffer_details(void *handle, void **addr, size_t *size) *addr =NULL ; *size =0 ; -mutex_lock (&smu->mutex);if (memory_pool->bo) { *addr = memory_pool->cpu_addr; *size = memory_pool->size; } -mutex_unlock (&smu->mutex);return 0 ; }
@@ -3160,11 +2898,8 @@ int smu_wait_for_event(struct smu_context *smu, enum smu_event_type event, {int ret = -EINVAL ; -if (smu->ppt_funcs->wait_for_event) { -mutex_lock (&smu->mutex); +if (smu->ppt_funcs->wait_for_event) ret = smu->ppt_funcs->wait_for_event (smu, event, event_arg); -mutex_unlock (&smu->mutex); - }return ret; }
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -1
@@ -487,7 +487,6 @@ struct smu_contextconst struct cmn2asic_mapping *table_map;const struct cmn2asic_mapping *pwr_src_map;const struct cmn2asic_mapping *workload_map; -struct mutex mutex;struct mutex sensor_lock;struct mutex metrics_lock;struct mutex message_lock;
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +0 -2
@@ -2128,9 +2128,7 @@ static int arcturus_i2c_xfer(struct i2c_adapter *i2c_adap, } } } -mutex_lock (&smu->mutex); r =smu_cmn_update_table (smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); -mutex_unlock (&smu->mutex);if (r) goto fail;
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +0 -2
@@ -2826,9 +2826,7 @@ static int navi10_i2c_xfer(struct i2c_adapter *i2c_adap, } } } -mutex_lock (&smu->mutex); r =smu_cmn_update_table (smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); -mutex_unlock (&smu->mutex);if (r) goto fail;
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -2
@@ -3483,9 +3483,7 @@ static int sienna_cichlid_i2c_xfer(struct i2c_adapter *i2c_adap, } } } -mutex_lock (&smu->mutex); r =smu_cmn_update_table (smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); -mutex_unlock (&smu->mutex);if (r) goto fail;
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -2
@@ -1530,9 +1530,7 @@ static int aldebaran_i2c_xfer(struct i2c_adapter *i2c_adap, } } } -mutex_lock (&smu->mutex); r =smu_cmn_update_table (smu,SMU_TABLE_I2C_COMMANDS ,0 , req, true); -mutex_unlock (&smu->mutex);if (r) goto fail;
Signature · 1 line
2.29.0
PATCH 2/7 drm/amd/pm: drop unneeded vcn/jpeg_gate_lock
In reply to Evan QuanAs those related APIs are already protected by adev->pm.mutex.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 56 +++---------------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 - 2 files changed, 8 insertions(+), 50 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8 -48
@@ -158,8 +158,8 @@ static u32 smu_get_sclk(void *handle, bool low)return clk_freq *100 ; } -static int smu_dpm_set_vcn_enable_locked (struct smu_context *smu, -bool enable) +static int smu_dpm_set_vcn_enable (struct smu_context *smu, +bool enable) {struct smu_power_context *smu_power = &smu->smu_power;struct smu_power_gate *power_gate = &smu_power->power_gate;
@@ -178,24 +178,8 @@ static int smu_dpm_set_vcn_enable_locked(struct smu_context *smu,return ret; } -static int smu_dpm_set_vcn_enable (struct smu_context *smu, -bool enable) -{ -struct smu_power_context *smu_power = &smu->smu_power; -struct smu_power_gate *power_gate = &smu_power->power_gate; -int ret =0 ; - -mutex_lock (&power_gate->vcn_gate_lock); - - ret =smu_dpm_set_vcn_enable_locked (smu, enable); - -mutex_unlock (&power_gate->vcn_gate_lock); - -return ret; -} - -static int smu_dpm_set_jpeg_enable_locked (struct smu_context *smu, -bool enable) +static int smu_dpm_set_jpeg_enable (struct smu_context *smu, +bool enable) {struct smu_power_context *smu_power = &smu->smu_power;struct smu_power_gate *power_gate = &smu_power->power_gate;
@@ -214,22 +198,6 @@ static int smu_dpm_set_jpeg_enable_locked(struct smu_context *smu,return ret; } -static int smu_dpm_set_jpeg_enable (struct smu_context *smu, -bool enable) -{ -struct smu_power_context *smu_power = &smu->smu_power; -struct smu_power_gate *power_gate = &smu_power->power_gate; -int ret =0 ; - -mutex_lock (&power_gate->jpeg_gate_lock); - - ret =smu_dpm_set_jpeg_enable_locked (smu, enable); - -mutex_unlock (&power_gate->jpeg_gate_lock); - -return ret; -} -/** * smu_dpm_set_power_gate - power gate/ungate the specific IP block *
@@ -619,17 +587,14 @@ static int smu_set_default_dpm_table(struct smu_context *smu)if (!smu->ppt_funcs->set_default_dpm_table)return 0 ; -mutex_lock (&power_gate->vcn_gate_lock); -mutex_lock (&power_gate->jpeg_gate_lock); - vcn_gate =atomic_read (&power_gate->vcn_gated); jpeg_gate =atomic_read (&power_gate->jpeg_gated); - ret =smu_dpm_set_vcn_enable_locked (smu, true); + ret =smu_dpm_set_vcn_enable (smu, true);if (ret) goto err0_out; - ret =smu_dpm_set_jpeg_enable_locked (smu, true); + ret =smu_dpm_set_jpeg_enable (smu, true);if (ret) goto err1_out;
@@ -638,13 +603,10 @@ static int smu_set_default_dpm_table(struct smu_context *smu)dev_err (smu->adev->dev,"Failed to setup default dpm clock tables!\n" ); -smu_dpm_set_jpeg_enable_locked (smu, !jpeg_gate); +smu_dpm_set_jpeg_enable (smu, !jpeg_gate); err1_out: -smu_dpm_set_vcn_enable_locked (smu, !vcn_gate); +smu_dpm_set_vcn_enable (smu, !vcn_gate); err0_out: -mutex_unlock (&power_gate->jpeg_gate_lock); -mutex_unlock (&power_gate->vcn_gate_lock); -return ret; }
@@ -1006,8 +968,6 @@ static int smu_sw_init(void *handle)atomic_set (&smu->smu_power.power_gate.vcn_gated,1 );atomic_set (&smu->smu_power.power_gate.jpeg_gated,1 ); -mutex_init (&smu->smu_power.power_gate.vcn_gate_lock); -mutex_init (&smu->smu_power.power_gate.jpeg_gate_lock); smu->workload_mask =1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ]; smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ] =0 ;
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -2
@@ -376,8 +376,6 @@ struct smu_power_gate {bool vce_gated;atomic_t vcn_gated;atomic_t jpeg_gated; -struct mutex vcn_gate_lock; -struct mutex jpeg_gate_lock; };struct smu_power_context {
Signature · 1 line
2.29.0
PATCH 3/7 drm/amd/pm: drop unneeded smu->metrics_lock
In reply to Evan QuanAs all those related APIs are already well protected by adev->pm.mutex and smu->message_lock.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 1 - drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 1 - .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 14 +-- .../amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 10 +- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 112 +++++------------- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 27 ++--- .../gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 28 ++--- .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c | 14 +-- .../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 23 ++-- .../drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c | 10 +- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 21 +--- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 4 - 12 files changed, 70 insertions(+), 195 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -1
@@ -956,7 +956,6 @@ static int smu_sw_init(void *handle)bitmap_zero (smu->smu_feature.allowed,SMU_FEATURE_MAX );mutex_init (&smu->sensor_lock); -mutex_init (&smu->metrics_lock);mutex_init (&smu->message_lock);INIT_WORK (&smu->throttling_logging_work, smu_throttling_logging_work_fn);
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -1
@@ -486,7 +486,6 @@ struct smu_contextconst struct cmn2asic_mapping *pwr_src_map;const struct cmn2asic_mapping *workload_map;struct mutex sensor_lock; -struct mutex metrics_lock;struct mutex message_lock;uint64_t pool_size;
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +4 -10
@@ -612,15 +612,11 @@ static int arcturus_get_smu_metrics_data(struct smu_context *smu,SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;int ret =0 ; -mutex_lock (&smu->metrics_lock); - - ret =smu_cmn_get_metrics_table_locked (smu, -NULL , - false); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu, +NULL , + false); +if (ret)return ret; - }switch (member) {case METRICS_CURR_GFXCLK :
@@ -703,8 +699,6 @@ static int arcturus_get_smu_metrics_data(struct smu_context *smu,break ; } -mutex_unlock (&smu->metrics_lock); -return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +2 -8
@@ -150,13 +150,9 @@ cyan_skillfish_get_smu_metrics_data(struct smu_context *smu,SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;int ret =0 ; -mutex_lock (&smu->metrics_lock); - - ret =smu_cmn_get_metrics_table_locked (smu,NULL , false); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu,NULL , false); +if (ret)return ret; - }switch (member) {case METRICS_CURR_GFXCLK :
@@ -200,8 +196,6 @@ cyan_skillfish_get_smu_metrics_data(struct smu_context *smu,break ; } -mutex_unlock (&smu->metrics_lock); -return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +32 -80
204 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +8 -19
@@ -525,15 +525,11 @@ static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,uint16_t average_gfx_activity;int ret =0 ; -mutex_lock (&smu->metrics_lock); - - ret =smu_cmn_get_metrics_table_locked (smu, -NULL , - false); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu, +NULL , + false); +if (ret)return ret; - }switch (member) {case METRICS_CURR_GFXCLK :
@@ -633,8 +629,6 @@ static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,break ; } -mutex_unlock (&smu->metrics_lock); -return ret; }
@@ -3564,14 +3558,11 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,uint16_t average_gfx_activity;int ret =0 ; -mutex_lock (&smu->metrics_lock); - ret =smu_cmn_get_metrics_table_locked (smu, - &metrics_external, - true); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu, + &metrics_external, + true); +if (ret)return ret; - }smu_cmn_init_soft_gpu_metrics (gpu_metrics,1 ,3 );
@@ -3661,8 +3652,6 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,smu_v11_0_get_current_pcie_link_speed (smu); } -mutex_unlock (&smu->metrics_lock); - gpu_metrics->system_clock_counter =ktime_get_boottime_ns (); *table = (void *)gpu_metrics;
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +8 -20
@@ -273,15 +273,11 @@ static int vangogh_get_legacy_smu_metrics_data(struct smu_context *smu,SmuMetrics_legacy_t *metrics = (SmuMetrics_legacy_t *)smu_table->metrics_table;int ret =0 ; -mutex_lock (&smu->metrics_lock); - - ret =smu_cmn_get_metrics_table_locked (smu, -NULL , - false); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu, +NULL , + false); +if (ret)return ret; - }switch (member) {case METRICS_CURR_GFXCLK :
@@ -335,8 +331,6 @@ static int vangogh_get_legacy_smu_metrics_data(struct smu_context *smu,break ; } -mutex_unlock (&smu->metrics_lock); -return ret; }
@@ -348,15 +342,11 @@ static int vangogh_get_smu_metrics_data(struct smu_context *smu,SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;int ret =0 ; -mutex_lock (&smu->metrics_lock); - - ret =smu_cmn_get_metrics_table_locked (smu, -NULL , - false); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu, +NULL , + false); +if (ret)return ret; - }switch (member) {case METRICS_CURR_GFXCLK :
@@ -410,8 +400,6 @@ static int vangogh_get_smu_metrics_data(struct smu_context *smu,break ; } -mutex_unlock (&smu->metrics_lock); -return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +4 -10
@@ -1128,15 +1128,11 @@ static int renoir_get_smu_metrics_data(struct smu_context *smu,SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;int ret =0 ; -mutex_lock (&smu->metrics_lock); - - ret =smu_cmn_get_metrics_table_locked (smu, -NULL , - false); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu, +NULL , + false); +if (ret)return ret; - }switch (member) {case METRICS_AVERAGE_GFXCLK :
@@ -1201,8 +1197,6 @@ static int renoir_get_smu_metrics_data(struct smu_context *smu,break ; } -mutex_unlock (&smu->metrics_lock); -return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +7 -16
@@ -580,15 +580,11 @@ static int aldebaran_get_smu_metrics_data(struct smu_context *smu,SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;int ret =0 ; -mutex_lock (&smu->metrics_lock); - - ret =smu_cmn_get_metrics_table_locked (smu, -NULL , - false); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu, +NULL , + false); +if (ret)return ret; - }switch (member) {case METRICS_CURR_GFXCLK :
@@ -662,8 +658,6 @@ static int aldebaran_get_smu_metrics_data(struct smu_context *smu,break ; } -mutex_unlock (&smu->metrics_lock); -return ret; }
@@ -1601,17 +1595,14 @@ static void aldebaran_get_unique_id(struct smu_context *smu)uint32_t upper32 =0 , lower32 =0 ;int ret; -mutex_lock (&smu->metrics_lock); - ret =smu_cmn_get_metrics_table_locked (smu,NULL , false); + ret =smu_cmn_get_metrics_table (smu,NULL , false);if (ret) - goto out_unlock; + goto out; upper32 = metrics->PublicSerialNumUpper32; lower32 = metrics->PublicSerialNumLower32; -out_unlock: -mutex_unlock (&smu->metrics_lock); - +out: adev->unique_id = ((uint64_t )upper32 <<32 ) | lower32;sprintf (adev->serial,"%016llx" , adev->unique_id); }
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +2 -8
@@ -310,13 +310,9 @@ static int yellow_carp_get_smu_metrics_data(struct smu_context *smu,SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;int ret =0 ; -mutex_lock (&smu->metrics_lock); - - ret =smu_cmn_get_metrics_table_locked (smu,NULL , false); -if (ret) { -mutex_unlock (&smu->metrics_lock); + ret =smu_cmn_get_metrics_table (smu,NULL , false); +if (ret)return ret; - }switch (member) {case METRICS_AVERAGE_GFXCLK :
@@ -387,8 +383,6 @@ static int yellow_carp_get_smu_metrics_data(struct smu_context *smu,break ; } -mutex_unlock (&smu->metrics_lock); -return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +3 -18
@@ -942,9 +942,9 @@ int smu_cmn_write_pptable(struct smu_context *smu) true); } -int smu_cmn_get_metrics_table_locked (struct smu_context *smu, -void *metrics_table, -bool bypass_cache) +int smu_cmn_get_metrics_table (struct smu_context *smu, +void *metrics_table, +bool bypass_cache) {struct smu_table_context *smu_table= &smu->smu_table; uint32_t table_size =
@@ -972,21 +972,6 @@ int smu_cmn_get_metrics_table_locked(struct smu_context *smu,return 0 ; } -int smu_cmn_get_metrics_table (struct smu_context *smu, -void *metrics_table, -bool bypass_cache) -{ -int ret =0 ; - -mutex_lock (&smu->metrics_lock); - ret =smu_cmn_get_metrics_table_locked (smu, - metrics_table, - bypass_cache); -mutex_unlock (&smu->metrics_lock); - -return ret; -} -void smu_cmn_init_soft_gpu_metrics (void *table,uint8_t frev,uint8_t crev) {struct metrics_table_header *header = (struct metrics_table_header *)table;
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -4
@@ -101,10 +101,6 @@ int smu_cmn_write_watermarks_table(struct smu_context *smu);int smu_cmn_write_pptable (struct smu_context *smu); -int smu_cmn_get_metrics_table_locked (struct smu_context *smu, -void *metrics_table, -bool bypass_cache); -int smu_cmn_get_metrics_table (struct smu_context *smu,void *metrics_table,bool bypass_cache);
Signature · 1 line
2.29.0
PATCH 4/7 drm/amd/pm: drop unneeded smu->sensor_lock
In reply to Evan QuanAs all those related APIs are already well protected by adev->pm.mutex and smu->message_lock.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 1 - drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 1 - drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 2 -- drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c | 4 ---- drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 2 -- drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 2 -- drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c | 2 -- drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c | 2 -- drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 2 -- drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c | 2 -- 10 files changed, 20 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -1
@@ -955,7 +955,6 @@ static int smu_sw_init(void *handle)bitmap_zero (smu->smu_feature.enabled,SMU_FEATURE_MAX );bitmap_zero (smu->smu_feature.allowed,SMU_FEATURE_MAX ); -mutex_init (&smu->sensor_lock);mutex_init (&smu->message_lock);INIT_WORK (&smu->throttling_logging_work, smu_throttling_logging_work_fn);
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -1
@@ -485,7 +485,6 @@ struct smu_contextconst struct cmn2asic_mapping *table_map;const struct cmn2asic_mapping *pwr_src_map;const struct cmn2asic_mapping *workload_map; -struct mutex sensor_lock;struct mutex message_lock;uint64_t pool_size;
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +0 -2
@@ -1123,7 +1123,6 @@ static int arcturus_read_sensor(struct smu_context *smu,if (!data || !size)return -EINVAL ; -mutex_lock (&smu->sensor_lock);switch (sensor) {case AMDGPU_PP_SENSOR_MAX_FAN_RPM : *(uint32_t *)data = pptable->FanMaximumRpm;
@@ -1184,7 +1183,6 @@ static int arcturus_read_sensor(struct smu_context *smu, ret = -EOPNOTSUPP ;break ; } -mutex_unlock (&smu->sensor_lock);return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu11/cyan_skillfish_ppt.c +0 -4
@@ -209,8 +209,6 @@ static int cyan_skillfish_read_sensor(struct smu_context *smu,if (!data || !size)return -EINVAL ; -mutex_lock (&smu->sensor_lock); -switch (sensor) {case AMDGPU_PP_SENSOR_GFX_SCLK : ret = cyan_skillfish_get_smu_metrics_data(smu,
@@ -261,8 +259,6 @@ static int cyan_skillfish_read_sensor(struct smu_context *smu,break ; } -mutex_unlock (&smu->sensor_lock); -return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +0 -2
@@ -1964,7 +1964,6 @@ static int navi10_read_sensor(struct smu_context *smu,if (!data || !size)return -EINVAL ; -mutex_lock (&smu->sensor_lock);switch (sensor) {case AMDGPU_PP_SENSOR_MAX_FAN_RPM : *(uint32_t *)data = pptable->FanMaximumRpm;
@@ -2024,7 +2023,6 @@ static int navi10_read_sensor(struct smu_context *smu, ret = -EOPNOTSUPP ;break ; } -mutex_unlock (&smu->sensor_lock);return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -2
@@ -1605,7 +1605,6 @@ static int sienna_cichlid_read_sensor(struct smu_context *smu,if (!data || !size)return -EINVAL ; -mutex_lock (&smu->sensor_lock);switch (sensor) {case AMDGPU_PP_SENSOR_MAX_FAN_RPM :GET_PPTABLE_MEMBER (FanMaximumRpm, &temp);
@@ -1666,7 +1665,6 @@ static int sienna_cichlid_read_sensor(struct smu_context *smu, ret = -EOPNOTSUPP ;break ; } -mutex_unlock (&smu->sensor_lock);return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.c +0 -2
@@ -1494,7 +1494,6 @@ static int vangogh_read_sensor(struct smu_context *smu,if (!data || !size)return -EINVAL ; -mutex_lock (&smu->sensor_lock);switch (sensor) {case AMDGPU_PP_SENSOR_GPU_LOAD : ret = vangogh_common_get_smu_metrics_data(smu,
@@ -1556,7 +1555,6 @@ static int vangogh_read_sensor(struct smu_context *smu, ret = -EOPNOTSUPP ;break ; } -mutex_unlock (&smu->sensor_lock);return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c +0 -2
@@ -1209,7 +1209,6 @@ static int renoir_read_sensor(struct smu_context *smu,if (!data || !size)return -EINVAL ; -mutex_lock (&smu->sensor_lock);switch (sensor) {case AMDGPU_PP_SENSOR_GPU_LOAD : ret = renoir_get_smu_metrics_data(smu,
@@ -1277,7 +1276,6 @@ static int renoir_read_sensor(struct smu_context *smu, ret = -EOPNOTSUPP ;break ; } -mutex_unlock (&smu->sensor_lock);return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c +0 -2
@@ -1150,7 +1150,6 @@ static int aldebaran_read_sensor(struct smu_context *smu,if (!data || !size)return -EINVAL ; -mutex_lock (&smu->sensor_lock);switch (sensor) {case AMDGPU_PP_SENSOR_MEM_LOAD :case AMDGPU_PP_SENSOR_GPU_LOAD :
@@ -1189,7 +1188,6 @@ static int aldebaran_read_sensor(struct smu_context *smu, ret = -EOPNOTSUPP ;break ; } -mutex_unlock (&smu->sensor_lock);return ret; }
drivers/gpu/drm/amd/pm/swsmu/smu13/yellow_carp_ppt.c +0 -2
@@ -395,7 +395,6 @@ static int yellow_carp_read_sensor(struct smu_context *smu,if (!data || !size)return -EINVAL ; -mutex_lock (&smu->sensor_lock);switch (sensor) {case AMDGPU_PP_SENSOR_GPU_LOAD : ret = yellow_carp_get_smu_metrics_data(smu,
@@ -463,7 +462,6 @@ static int yellow_carp_read_sensor(struct smu_context *smu, ret = -EOPNOTSUPP ;break ; } -mutex_unlock (&smu->sensor_lock);return ret; }
Signature · 1 line
2.29.0
PATCH 5/7 drm/amd/pm: drop unneeded smu_baco->mutex
In reply to Evan QuanAs those APIs related are already well protected by adev->pm.mutex.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 1 - drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 1 - .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 19 +++++-------------- 3 files changed, 5 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -1
@@ -566,7 +566,6 @@ static int smu_early_init(void *handle) smu->adev = adev; smu->pm_enabled = !!amdgpu_dpm; smu->is_apu = false; -mutex_init (&smu->smu_baco.mutex); smu->smu_baco.state =SMU_BACO_STATE_EXIT ; smu->smu_baco.platform_support = false; smu->user_dpm_profile.fan_mode =-1 ;
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -1
@@ -428,7 +428,6 @@ enum smu_baco_statestruct smu_baco_context { -struct mutex mutex;uint32_t state;bool platform_support; };
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +5 -14
@@ -1615,13 +1615,8 @@ bool smu_v11_0_baco_is_support(struct smu_context *smu)enum smu_baco_state smu_v11_0_baco_get_state (struct smu_context *smu) {struct smu_baco_context *smu_baco = &smu->smu_baco; -enum smu_baco_state baco_state; -mutex_lock (&smu_baco->mutex); - baco_state = smu_baco->state; -mutex_unlock (&smu_baco->mutex); - -return baco_state; +return smu_baco->state; }#define D3HOT_BACO_SEQUENCE 0
@@ -1638,8 +1633,6 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)if (smu_v11_0_baco_get_state (smu) == state)return 0 ; -mutex_lock (&smu_baco->mutex); -if (state ==SMU_BACO_STATE_ENTER ) {switch (adev->ip_versions[MP1_HWIP ][0 ]) {case IP_VERSION (11 ,0 ,7 ):
@@ -1680,18 +1673,16 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state) }else { ret =smu_cmn_send_smc_msg (smu, SMU_MSG_ExitBaco,NULL );if (ret) - goto out; +return ret;/* clear vbios scratch 6 and 7 for coming asic reinit */ WREG32 (adev->bios_scratch_reg_offset +6 ,0 );WREG32 (adev->bios_scratch_reg_offset +7 ,0 ); } -if (ret) - goto out; - smu_baco->state = state; -out: -mutex_unlock (&smu_baco->mutex); +if (!ret) + smu_baco->state = state; +return ret; }
Signature · 1 line
2.29.0
PATCH 6/7 drm/amd/pm: drop unneeded feature->mutex
In reply to Evan QuanAs all those related APIs are already well protected by adev->pm.mutex.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 1 - drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 1 - .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 20 ++++++++----------- drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 19 ++---------------- 4 files changed, 10 insertions(+), 31 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0 -1
@@ -949,7 +949,6 @@ static int smu_sw_init(void *handle) smu->pool_size = adev->pm.smu_prv_buffer_size; smu->smu_feature.feature_num =SMU_FEATURE_MAX ; -mutex_init (&smu->smu_feature.mutex);bitmap_zero (smu->smu_feature.supported,SMU_FEATURE_MAX );bitmap_zero (smu->smu_feature.enabled,SMU_FEATURE_MAX );bitmap_zero (smu->smu_feature.allowed,SMU_FEATURE_MAX );
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -1
@@ -391,7 +391,6 @@ struct smu_featureDECLARE_BITMAP (supported,SMU_FEATURE_MAX );DECLARE_BITMAP (allowed,SMU_FEATURE_MAX );DECLARE_BITMAP (enabled,SMU_FEATURE_MAX ); -struct mutex mutex; };struct smu_clocks {
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +8 -12
@@ -717,25 +717,21 @@ int smu_v13_0_set_allowed_mask(struct smu_context *smu)int ret =0 ;uint32_t feature_mask[2 ]; -mutex_lock (&feature->mutex); -if (bitmap_empty (feature->allowed,SMU_FEATURE_MAX ) || feature->feature_num <64 ) - goto failed; +if (bitmap_empty (feature->allowed,SMU_FEATURE_MAX ) || + feature->feature_num <64 ) +return -EINVAL ;bitmap_copy ((unsigned long *)feature_mask, feature->allowed,64 ); ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetAllowedFeaturesMaskHigh, feature_mask[1 ],NULL );if (ret) - goto failed; - - ret =smu_cmn_send_smc_msg_with_param (smu, SMU_MSG_SetAllowedFeaturesMaskLow, - feature_mask[0 ],NULL ); -if (ret) - goto failed; +return ret; -failed: -mutex_unlock (&feature->mutex); -return ret; +return smu_cmn_send_smc_msg_with_param (smu, + SMU_MSG_SetAllowedFeaturesMaskLow, + feature_mask[0 ], +NULL ); }int smu_v13_0_gfx_off_control (struct smu_context *smu,bool enable)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2 -17
@@ -459,7 +459,6 @@ int smu_cmn_feature_is_supported(struct smu_context *smu, {struct smu_feature *feature = &smu->smu_feature;int feature_id; -int ret =0 ; feature_id = smu_cmn_to_asic_specific_index(smu, CMN2ASIC_MAPPING_FEATURE,
@@ -469,11 +468,7 @@ int smu_cmn_feature_is_supported(struct smu_context *smu,WARN_ON (feature_id > feature->feature_num); -mutex_lock (&feature->mutex); - ret =test_bit (feature_id, feature->supported); -mutex_unlock (&feature->mutex); - -return ret; +return test_bit (feature_id, feature->supported); } int smu_cmn_feature_is_enabled(struct smu_context *smu,
@@ -482,7 +477,6 @@ int smu_cmn_feature_is_enabled(struct smu_context *smu,struct smu_feature *feature = &smu->smu_feature;struct amdgpu_device *adev = smu->adev;int feature_id; -int ret =0 ;if (smu->is_apu && adev->family <AMDGPU_FAMILY_VGH )return 1 ;
@@ -495,11 +489,7 @@ int smu_cmn_feature_is_enabled(struct smu_context *smu,WARN_ON (feature_id > feature->feature_num); -mutex_lock (&feature->mutex); - ret =test_bit (feature_id, feature->enabled); -mutex_unlock (&feature->mutex); - -return ret; +return test_bit (feature_id, feature->enabled); } bool smu_cmn_clk_dpm_is_enabled(struct smu_context *smu,
@@ -644,14 +634,12 @@ int smu_cmn_feature_update_enable_state(struct smu_context *smu,return ret; } -mutex_lock (&feature->mutex);if (enabled)bitmap_or (feature->enabled, feature->enabled, (unsigned long *)(&feature_mask),SMU_FEATURE_MAX );else bitmap_andnot (feature->enabled, feature->enabled, (unsigned long *)(&feature_mask),SMU_FEATURE_MAX ); -mutex_unlock (&feature->mutex);return ret; }
@@ -821,11 +809,8 @@ int smu_cmn_disable_all_features_with_exception(struct smu_context *smu, }if (no_hw_disablement) { -mutex_lock (&feature->mutex);bitmap_andnot (feature->enabled, feature->enabled, (unsigned long *)(&features_to_disable),SMU_FEATURE_MAX ); -mutex_unlock (&feature->mutex); -return 0 ; }else { return smu_cmn_feature_update_enable_state(smu,
Signature · 1 line
2.29.0
PATCH 7/7 drm/amd/pm: drop unneeded hwmgr->smu_lock
In reply to Evan QuanAs all those related APIs are already well protected by adev->pm.mutex.
--- .../gpu/drm/amd/pm/powerplay/amd_powerplay.c | 282 +++--------------- drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h | 1 - 2 files changed, 39 insertions(+), 244 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +39 -243
@@ -50,7 +50,6 @@ static int amd_powerplay_create(struct amdgpu_device *adev) hwmgr->adev = adev; hwmgr->not_vf = !amdgpu_sriov_vf (adev); hwmgr->device =amdgpu_cgs_create_device (adev); -mutex_init (&hwmgr->smu_lock);mutex_init (&hwmgr->msg_lock); hwmgr->chip_family = adev->family; hwmgr->chip_id = adev->asic_type;
@@ -178,12 +177,9 @@ static int pp_late_init(void *handle)struct amdgpu_device *adev = handle;struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; -if (hwmgr && hwmgr->pm_en) { -mutex_lock (&hwmgr->smu_lock); +if (hwmgr && hwmgr->pm_en)hwmgr_handle_task (hwmgr,AMD_PP_TASK_COMPLETE_INIT ,NULL ); -mutex_unlock (&hwmgr->smu_lock); - }if (adev->pm.smu_prv_buffer_size !=0 )pp_reserve_vram_for_smu (adev);
@@ -345,11 +341,9 @@ static int pp_dpm_force_performance_level(void *handle,if (level == hwmgr->dpm_level)return 0 ; -mutex_lock (&hwmgr->smu_lock);pp_dpm_en_umd_pstate (hwmgr, &level); hwmgr->request_dpm_level = level;hwmgr_handle_task (hwmgr,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -358,21 +352,16 @@ static enum amd_dpm_forced_level pp_dpm_get_performance_level( void *handle) {struct pp_hwmgr *hwmgr = handle; -enum amd_dpm_forced_level level;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - level = hwmgr->dpm_level; -mutex_unlock (&hwmgr->smu_lock); -return level; +return hwmgr->dpm_level; }static uint32_t pp_dpm_get_sclk (void *handle,bool low) {struct pp_hwmgr *hwmgr = handle; -uint32_t clk =0 ;if (!hwmgr || !hwmgr->pm_en)return 0 ;
@@ -381,16 +370,12 @@ static uint32_t pp_dpm_get_sclk(void *handle, bool low)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - clk = hwmgr->hwmgr_func->get_sclk (hwmgr, low); -mutex_unlock (&hwmgr->smu_lock); -return clk; +return hwmgr->hwmgr_func->get_sclk (hwmgr, low); }static uint32_t pp_dpm_get_mclk (void *handle,bool low) {struct pp_hwmgr *hwmgr = handle; -uint32_t clk =0 ;if (!hwmgr || !hwmgr->pm_en)return 0 ;
@@ -399,10 +384,7 @@ static uint32_t pp_dpm_get_mclk(void *handle, bool low)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - clk = hwmgr->hwmgr_func->get_mclk (hwmgr, low); -mutex_unlock (&hwmgr->smu_lock); -return clk; +return hwmgr->hwmgr_func->get_mclk (hwmgr, low); }static void pp_dpm_powergate_vce (void *handle,bool gate)
@@ -416,9 +398,7 @@ static void pp_dpm_powergate_vce(void *handle, bool gate)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return ; } -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->powergate_vce (hwmgr, gate); -mutex_unlock (&hwmgr->smu_lock); }static void pp_dpm_powergate_uvd (void *handle,bool gate)
@@ -432,25 +412,18 @@ static void pp_dpm_powergate_uvd(void *handle, bool gate)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return ; } -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->powergate_uvd (hwmgr, gate); -mutex_unlock (&hwmgr->smu_lock); }static int pp_dpm_dispatch_tasks (void *handle,enum amd_pp_task task_id,enum amd_pm_state_type *user_state) { -int ret =0 ;struct pp_hwmgr *hwmgr = handle;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret =hwmgr_handle_task (hwmgr, task_id, user_state); -mutex_unlock (&hwmgr->smu_lock); - -return ret; +return hwmgr_handle_task (hwmgr, task_id, user_state); }static enum amd_pm_state_type pp_dpm_get_current_power_state (void *handle)
@@ -462,8 +435,6 @@ static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle)if (!hwmgr || !hwmgr->pm_en || !hwmgr->current_ps)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - state = hwmgr->current_ps;switch (state->classification.ui_label) {
@@ -483,7 +454,6 @@ static enum amd_pm_state_type pp_dpm_get_current_power_state(void *handle) pm_type =POWER_STATE_TYPE_DEFAULT ;break ; } -mutex_unlock (&hwmgr->smu_lock);return pm_type; }
@@ -499,15 +469,12 @@ static void pp_dpm_set_fan_control_mode(void *handle, uint32_t mode)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return ; } -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_fan_control_mode (hwmgr, mode); -mutex_unlock (&hwmgr->smu_lock); }static uint32_t pp_dpm_get_fan_control_mode (void *handle) {struct pp_hwmgr *hwmgr = handle; -uint32_t mode =0 ;if (!hwmgr || !hwmgr->pm_en)return 0 ;
@@ -516,16 +483,12 @@ static uint32_t pp_dpm_get_fan_control_mode(void *handle)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - mode = hwmgr->hwmgr_func->get_fan_control_mode (hwmgr); -mutex_unlock (&hwmgr->smu_lock); -return mode; +return hwmgr->hwmgr_func->get_fan_control_mode (hwmgr); }static int pp_dpm_set_fan_speed_pwm (void *handle,uint32_t speed) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -534,16 +497,12 @@ static int pp_dpm_set_fan_speed_pwm(void *handle, uint32_t speed)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->set_fan_speed_pwm (hwmgr, speed); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->set_fan_speed_pwm (hwmgr, speed); }static int pp_dpm_get_fan_speed_pwm (void *handle,uint32_t *speed) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -553,16 +512,12 @@ static int pp_dpm_get_fan_speed_pwm(void *handle, uint32_t *speed)return 0 ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->get_fan_speed_pwm (hwmgr, speed); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->get_fan_speed_pwm (hwmgr, speed); }static int pp_dpm_get_fan_speed_rpm (void *handle,uint32_t *rpm) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -570,16 +525,12 @@ static int pp_dpm_get_fan_speed_rpm(void *handle, uint32_t *rpm)if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL )return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm); }static int pp_dpm_set_fan_speed_rpm (void *handle,uint32_t rpm) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -588,10 +539,7 @@ static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->set_fan_speed_rpm (hwmgr, rpm); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->set_fan_speed_rpm (hwmgr, rpm); } static int pp_dpm_get_pp_num_states(void *handle,
@@ -605,8 +553,6 @@ static int pp_dpm_get_pp_num_states(void *handle,if (!hwmgr || !hwmgr->pm_en ||!hwmgr->ps)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - data->nums = hwmgr->num_ps;for (i =0 ; i < hwmgr->num_ps; i++) {
@@ -629,23 +575,18 @@ static int pp_dpm_get_pp_num_states(void *handle, data->states[i] =POWER_STATE_TYPE_DEFAULT ; } } -mutex_unlock (&hwmgr->smu_lock);return 0 ; }static int pp_dpm_get_pp_table (void *handle,char **table) {struct pp_hwmgr *hwmgr = handle; -int size =0 ;if (!hwmgr || !hwmgr->pm_en ||!hwmgr->soft_pp_table)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); *table = (char *)hwmgr->soft_pp_table; - size = hwmgr->soft_pp_table_size; -mutex_unlock (&hwmgr->smu_lock); -return size; +return hwmgr->soft_pp_table_size; }static int amd_powerplay_reset (void *handle)
@@ -672,13 +613,12 @@ static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size)if (!hwmgr || !hwmgr->pm_en)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock);if (!hwmgr->hardcode_pp_table) { hwmgr->hardcode_pp_table =kmemdup (hwmgr->soft_pp_table, hwmgr->soft_pp_table_size,GFP_KERNEL );if (!hwmgr->hardcode_pp_table) - goto err; +return ret; }memcpy (hwmgr->hardcode_pp_table, buf, size);
@@ -687,17 +627,11 @@ static int pp_dpm_set_pp_table(void *handle, const char *buf, size_t size) ret =amd_powerplay_reset (handle);if (ret) - goto err; +return ret; -if (hwmgr->hwmgr_func->avfs_control) { +if (hwmgr->hwmgr_func->avfs_control) ret = hwmgr->hwmgr_func->avfs_control (hwmgr, false); -if (ret) - goto err; - } -mutex_unlock (&hwmgr->smu_lock); -return 0 ; -err: -mutex_unlock (&hwmgr->smu_lock); +return ret; }
@@ -705,7 +639,6 @@ static int pp_dpm_force_clock_level(void *handle, enum pp_clock_type type, uint32_t mask) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -720,17 +653,13 @@ static int pp_dpm_force_clock_level(void *handle,return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->force_clock_level (hwmgr, type, mask); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->force_clock_level (hwmgr, type, mask); }static int pp_dpm_print_clock_levels (void *handle,enum pp_clock_type type,char *buf) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -739,16 +668,12 @@ static int pp_dpm_print_clock_levels(void *handle,pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->print_clock_levels (hwmgr, type, buf); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->print_clock_levels (hwmgr, type, buf); }static int pp_dpm_get_sclk_od (void *handle) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -757,16 +682,12 @@ static int pp_dpm_get_sclk_od(void *handle)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->get_sclk_od (hwmgr); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->get_sclk_od (hwmgr); }static int pp_dpm_set_sclk_od (void *handle,uint32_t value) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -776,16 +697,12 @@ static int pp_dpm_set_sclk_od(void *handle, uint32_t value)return 0 ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->set_sclk_od (hwmgr, value); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->set_sclk_od (hwmgr, value); }static int pp_dpm_get_mclk_od (void *handle) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -794,16 +711,12 @@ static int pp_dpm_get_mclk_od(void *handle)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->get_mclk_od (hwmgr); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->get_mclk_od (hwmgr); }static int pp_dpm_set_mclk_od (void *handle,uint32_t value) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -812,17 +725,13 @@ static int pp_dpm_set_mclk_od(void *handle, uint32_t value)pr_info_ratelimited ("%s was not implemented.\n" , __func__);return 0 ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->set_mclk_od (hwmgr, value); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->set_mclk_od (hwmgr, value); }static int pp_dpm_read_sensor (void *handle,int idx,void *value,int *size) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en || !value)return -EINVAL ;
@@ -841,10 +750,7 @@ static int pp_dpm_read_sensor(void *handle, int idx, *((uint32_t *)value) = hwmgr->thermal_controller.fanInfo.ulMaxRPM;return 0 ;default : -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->read_sensor (hwmgr, idx, value, size); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->read_sensor (hwmgr, idx, value, size); } }
@@ -864,36 +770,28 @@ pp_dpm_get_vce_clock_state(void *handle, unsigned idx)static int pp_get_power_profile_mode (void *handle,char *buf) {struct pp_hwmgr *hwmgr = handle; -int ret;if (!hwmgr || !hwmgr->pm_en || !hwmgr->hwmgr_func->get_power_profile_mode)return -EOPNOTSUPP ;if (!buf)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->get_power_profile_mode (hwmgr, buf); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->get_power_profile_mode (hwmgr, buf); }static int pp_set_power_profile_mode (void *handle,long *input,uint32_t size) {struct pp_hwmgr *hwmgr = handle; -int ret = -EOPNOTSUPP ;if (!hwmgr || !hwmgr->pm_en || !hwmgr->hwmgr_func->set_power_profile_mode) -return ret; +return -EOPNOTSUPP ;if (hwmgr->dpm_level !=AMD_DPM_FORCED_LEVEL_MANUAL ) {pr_debug ("power profile setting is for manual dpm mode only.\n" );return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->set_power_profile_mode (hwmgr, input, size); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return hwmgr->hwmgr_func->set_power_profile_mode (hwmgr, input, size); }static int pp_set_fine_grain_clk_vol (void *handle,uint32_t type,long *input,uint32_t size)
@@ -958,8 +856,6 @@ static int pp_dpm_switch_power_profile(void *handle,if (!(type <PP_SMC_POWER_PROFILE_CUSTOM ))return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); -if (!en) { hwmgr->workload_mask &= ~(1 << hwmgr->workload_prority[type]); index =fls (hwmgr->workload_mask);
@@ -974,15 +870,12 @@ static int pp_dpm_switch_power_profile(void *handle,if (type ==PP_SMC_POWER_PROFILE_COMPUTE && hwmgr->hwmgr_func->disable_power_features_for_compute_performance) { -if (hwmgr->hwmgr_func->disable_power_features_for_compute_performance (hwmgr, en)) { -mutex_unlock (&hwmgr->smu_lock); +if (hwmgr->hwmgr_func->disable_power_features_for_compute_performance (hwmgr, en))return -EINVAL ; - } }if (hwmgr->dpm_level !=AMD_DPM_FORCED_LEVEL_MANUAL ) hwmgr->hwmgr_func->set_power_profile_mode (hwmgr, &workload,0 ); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1012,10 +905,8 @@ static int pp_set_power_limit(void *handle, uint32_t limit)if (limit > max_power_limit)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_power_limit (hwmgr, limit); hwmgr->power_limit = limit; -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1032,8 +923,6 @@ static int pp_get_power_limit(void *handle, uint32_t *limit,if (power_type !=PP_PWR_TYPE_SUSTAINED )return -EOPNOTSUPP ; -mutex_lock (&hwmgr->smu_lock); -switch (pp_limit_level) {case PP_PWR_LIMIT_CURRENT : *limit = hwmgr->power_limit;
@@ -1053,8 +942,6 @@ static int pp_get_power_limit(void *handle, uint32_t *limit,break ; } -mutex_unlock (&hwmgr->smu_lock); -return ret; }
@@ -1066,9 +953,7 @@ static int pp_display_configuration_change(void *handle,if (!hwmgr || !hwmgr->pm_en)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock);phm_store_dal_configuration_data (hwmgr, display_config); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1076,15 +961,11 @@ static int pp_get_display_power_level(void *handle, struct amd_pp_simple_clock_info *output) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en ||!output)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret =phm_get_dal_power_level (hwmgr, output); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return phm_get_dal_power_level (hwmgr, output); } static int pp_get_current_clocks(void *handle,
@@ -1098,8 +979,6 @@ static int pp_get_current_clocks(void *handle,if (!hwmgr || !hwmgr->pm_en)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); -phm_get_dal_power_level (hwmgr, &simple_clocks); if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
@@ -1112,7 +991,6 @@ static int pp_get_current_clocks(void *handle,if (ret) {pr_debug ("Error in phm_get_clock_info \n" ); -mutex_unlock (&hwmgr->smu_lock);return -EINVAL ; }
@@ -1135,14 +1013,12 @@ static int pp_get_current_clocks(void *handle, clocks->max_engine_clock_in_sr = hw_clocks.max_eng_clk; clocks->min_engine_clock_in_sr = hw_clocks.min_eng_clk; } -mutex_unlock (&hwmgr->smu_lock);return 0 ; }static int pp_get_clock_by_type (void *handle,enum amd_pp_clock_type type,struct amd_pp_clocks *clocks) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -1150,10 +1026,7 @@ static int pp_get_clock_by_type(void *handle, enum amd_pp_clock_type type, strucif (clocks ==NULL )return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret =phm_get_clock_by_type (hwmgr, type, clocks); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return phm_get_clock_by_type (hwmgr, type, clocks); } static int pp_get_clock_by_type_with_latency(void *handle,
@@ -1161,15 +1034,11 @@ static int pp_get_clock_by_type_with_latency(void *handle, struct pp_clock_levels_with_latency *clocks) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en ||!clocks)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret =phm_get_clock_by_type_with_latency (hwmgr, type, clocks); -mutex_unlock (&hwmgr->smu_lock); -return ret; +return phm_get_clock_by_type_with_latency (hwmgr, type, clocks); } static int pp_get_clock_by_type_with_voltage(void *handle,
@@ -1177,50 +1046,34 @@ static int pp_get_clock_by_type_with_voltage(void *handle, struct pp_clock_levels_with_voltage *clocks) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en ||!clocks)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - - ret =phm_get_clock_by_type_with_voltage (hwmgr, type, clocks); - -mutex_unlock (&hwmgr->smu_lock); -return ret; +return phm_get_clock_by_type_with_voltage (hwmgr, type, clocks); }static int pp_set_watermarks_for_clocks_ranges (void *handle,void *clock_ranges) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en || !clock_ranges)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret =phm_set_watermarks_for_clocks_ranges (hwmgr, - clock_ranges); -mutex_unlock (&hwmgr->smu_lock); - -return ret; +return phm_set_watermarks_for_clocks_ranges (hwmgr, + clock_ranges); }static int pp_display_clock_voltage_request (void *handle,struct pp_display_clock_request *clock) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en ||!clock)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret =phm_display_clock_voltage_request (hwmgr, clock); -mutex_unlock (&hwmgr->smu_lock); - -return ret; +return phm_display_clock_voltage_request (hwmgr, clock); } static int pp_get_display_mode_validation_clocks(void *handle,
@@ -1234,12 +1087,9 @@ static int pp_get_display_mode_validation_clocks(void *handle, clocks->level =PP_DAL_POWERLEVEL_7 ; -mutex_lock (&hwmgr->smu_lock); -if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_DynamicPatchPowerState)) ret =phm_get_max_high_clocks (hwmgr, clocks); -mutex_unlock (&hwmgr->smu_lock);return ret; }
@@ -1346,9 +1196,7 @@ static int pp_notify_smu_enable_pwe(void *handle)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->smus_notify_pwe (hwmgr); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1364,9 +1212,7 @@ static int pp_enable_mgpu_fan_boost(void *handle) hwmgr->hwmgr_func->enable_mgpu_fan_boost == NULL)return 0 ; -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->enable_mgpu_fan_boost (hwmgr); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1383,9 +1229,7 @@ static int pp_set_min_deep_sleep_dcefclk(void *handle, uint32_t clock)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_min_deep_sleep_dcefclk (hwmgr, clock); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1402,9 +1246,7 @@ static int pp_set_hard_min_dcefclk_by_freq(void *handle, uint32_t clock)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_hard_min_dcefclk_by_freq (hwmgr, clock); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1421,9 +1263,7 @@ static int pp_set_hard_min_fclk_by_freq(void *handle, uint32_t clock)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_hard_min_fclk_by_freq (hwmgr, clock); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1431,16 +1271,11 @@ static int pp_set_hard_min_fclk_by_freq(void *handle, uint32_t clock)static int pp_set_active_display_count (void *handle,uint32_t count) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ; -mutex_lock (&hwmgr->smu_lock); - ret =phm_set_active_display_count (hwmgr, count); -mutex_unlock (&hwmgr->smu_lock); - -return ret; +return phm_set_active_display_count (hwmgr, count); }static int pp_get_asic_baco_capability (void *handle,bool *cap)
@@ -1455,9 +1290,7 @@ static int pp_get_asic_baco_capability(void *handle, bool *cap) !hwmgr->hwmgr_func->get_asic_baco_capability)return 0 ; -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->get_asic_baco_capability (hwmgr, cap); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1472,9 +1305,7 @@ static int pp_get_asic_baco_state(void *handle, int *state)if (!hwmgr->pm_en || !hwmgr->hwmgr_func->get_asic_baco_state)return 0 ; -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->get_asic_baco_state (hwmgr, (enum BACO_STATE *)state); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1490,9 +1321,7 @@ static int pp_set_asic_baco_state(void *handle, int state) !hwmgr->hwmgr_func->set_asic_baco_state)return 0 ; -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_asic_baco_state (hwmgr, (enum BACO_STATE )state); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1500,7 +1329,6 @@ static int pp_set_asic_baco_state(void *handle, int state)static int pp_get_ppfeature_status (void *handle,char *buf) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en || !buf)return -EINVAL ;
@@ -1510,17 +1338,12 @@ static int pp_get_ppfeature_status(void *handle, char *buf)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->get_ppfeature_status (hwmgr, buf); -mutex_unlock (&hwmgr->smu_lock); - -return ret; +return hwmgr->hwmgr_func->get_ppfeature_status (hwmgr, buf); }static int pp_set_ppfeature_status (void *handle,uint64_t ppfeature_masks) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -1530,17 +1353,12 @@ static int pp_set_ppfeature_status(void *handle, uint64_t ppfeature_masks)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->set_ppfeature_status (hwmgr, ppfeature_masks); -mutex_unlock (&hwmgr->smu_lock); - -return ret; +return hwmgr->hwmgr_func->set_ppfeature_status (hwmgr, ppfeature_masks); }static int pp_asic_reset_mode_2 (void *handle) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -1550,17 +1368,12 @@ static int pp_asic_reset_mode_2(void *handle)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->asic_reset (hwmgr,SMU_ASIC_RESET_MODE_2 ); -mutex_unlock (&hwmgr->smu_lock); - -return ret; +return hwmgr->hwmgr_func->asic_reset (hwmgr,SMU_ASIC_RESET_MODE_2 ); }static int pp_smu_i2c_bus_access (void *handle,bool acquire) {struct pp_hwmgr *hwmgr = handle; -int ret =0 ;if (!hwmgr || !hwmgr->pm_en)return -EINVAL ;
@@ -1570,11 +1383,7 @@ static int pp_smu_i2c_bus_access(void *handle, bool acquire)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); - ret = hwmgr->hwmgr_func->smu_i2c_bus_access (hwmgr, acquire); -mutex_unlock (&hwmgr->smu_lock); - -return ret; +return hwmgr->hwmgr_func->smu_i2c_bus_access (hwmgr, acquire); }static int pp_set_df_cstate (void *handle,enum pp_df_cstate state)
@@ -1587,9 +1396,7 @@ static int pp_set_df_cstate(void *handle, enum pp_df_cstate state)if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_df_cstate)return 0 ; -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_df_cstate (hwmgr, state); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1604,9 +1411,7 @@ static int pp_set_xgmi_pstate(void *handle, uint32_t pstate)if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_xgmi_pstate)return 0 ; -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->set_xgmi_pstate (hwmgr, pstate); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1614,7 +1419,6 @@ static int pp_set_xgmi_pstate(void *handle, uint32_t pstate)static ssize_t pp_get_gpu_metrics (void *handle,void **table) {struct pp_hwmgr *hwmgr = handle; -ssize_t size;if (!hwmgr)return -EINVAL ;
@@ -1622,11 +1426,7 @@ static ssize_t pp_get_gpu_metrics(void *handle, void **table)if (!hwmgr->pm_en || !hwmgr->hwmgr_func->get_gpu_metrics)return -EOPNOTSUPP ; -mutex_lock (&hwmgr->smu_lock); - size = hwmgr->hwmgr_func->get_gpu_metrics (hwmgr, table); -mutex_unlock (&hwmgr->smu_lock); - -return size; +return hwmgr->hwmgr_func->get_gpu_metrics (hwmgr, table); }static int pp_gfx_state_change_set (void *handle,uint32_t state)
@@ -1641,9 +1441,7 @@ static int pp_gfx_state_change_set(void *handle, uint32_t state)return -EINVAL ; } -mutex_lock (&hwmgr->smu_lock); hwmgr->hwmgr_func->gfx_state_change (hwmgr, state); -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
@@ -1657,12 +1455,10 @@ static int pp_get_prv_buffer_details(void *handle, void **addr, size_t *size) *addr =NULL ; *size =0 ; -mutex_lock (&hwmgr->smu_lock);if (adev->pm.smu_prv_buffer) {amdgpu_bo_kmap (adev->pm.smu_prv_buffer, addr); *size = adev->pm.smu_prv_buffer_size; } -mutex_unlock (&hwmgr->smu_lock);return 0 ; }
drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h +0 -1
@@ -748,7 +748,6 @@ struct pp_hwmgr {bool not_vf;bool pm_en;bool pp_one_vf; -struct mutex smu_lock;struct mutex msg_lock;uint32_t pp_table_version;
Signature · 1 line
2.29.0