As smu->pm_enabled is a prerequisite for adev->pm.dpm_enabled. So, with adev->pm.dpm_enabled set, it can be guarded that smu->pm_enabled is also set. Thus the extra check for "!smu->pm_enabled" is totally unnecessary. Signed-off-by: Evan Quan <evan.quan@xxxxxxx> Change-Id: I6ff67137d447e6a3d8cc627b397428fed22753f3 --- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 84 +++++++++++------------ 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c index 1c3a5ccd100c..96a3388c2cb7 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c @@ -68,7 +68,7 @@ static int smu_sys_get_pp_feature_mask(void *handle, { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; return smu_get_pp_feature_mask(smu, buf); @@ -79,7 +79,7 @@ static int smu_sys_set_pp_feature_mask(void *handle, { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; return smu_set_pp_feature_mask(smu, new_mask); @@ -219,7 +219,7 @@ static int smu_dpm_set_power_gate(void *handle, struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) { + if (!smu->adev->pm.dpm_enabled) { dev_WARN(smu->adev->dev, "SMU uninitialized but power %s requested for %u!\n", gate ? "gate" : "ungate", block_type); @@ -315,7 +315,7 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu) if (!smu->adev->in_suspend) return; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return; /* Enable restore flag */ @@ -428,7 +428,7 @@ static int smu_sys_get_pp_table(void *handle, struct smu_context *smu = handle; struct smu_table_context *smu_table = &smu->smu_table; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu_table->power_play_table && !smu_table->hardcode_pptable) @@ -451,7 +451,7 @@ static int smu_sys_set_pp_table(void *handle, ATOM_COMMON_TABLE_HEADER *header = (ATOM_COMMON_TABLE_HEADER *)buf; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (header->usStructureSize != size) { @@ -1564,7 +1564,7 @@ static int smu_display_configuration_change(void *handle, int index = 0; int num_of_active_display = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!display_config) @@ -1704,7 +1704,7 @@ static int smu_handle_task(struct smu_context *smu, { int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; switch (task_id) { @@ -1745,7 +1745,7 @@ static int smu_switch_power_profile(void *handle, long workload; uint32_t index; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!(type < PP_SMC_POWER_PROFILE_CUSTOM)) @@ -1775,7 +1775,7 @@ 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); - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->is_apu && !smu_dpm_ctx->dpm_context) @@ -1791,7 +1791,7 @@ static int smu_force_performance_level(void *handle, struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->is_apu && !smu_dpm_ctx->dpm_context) @@ -1817,7 +1817,7 @@ static int smu_set_display_count(void *handle, uint32_t count) { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; return smu_init_display_count(smu, count); @@ -1830,7 +1830,7 @@ static int smu_force_smuclk_levels(struct smu_context *smu, struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) { @@ -1917,7 +1917,7 @@ static int smu_set_df_cstate(void *handle, struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs || !smu->ppt_funcs->set_df_cstate) @@ -1934,7 +1934,7 @@ int smu_allow_xgmi_power_down(struct smu_context *smu, bool en) { int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs || !smu->ppt_funcs->allow_xgmi_power_down) @@ -1949,7 +1949,7 @@ int smu_allow_xgmi_power_down(struct smu_context *smu, bool en) int smu_write_watermarks_table(struct smu_context *smu) { - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; return smu_set_watermarks_table(smu, NULL); @@ -1960,7 +1960,7 @@ static int smu_set_watermarks_for_clock_ranges(void *handle, { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->disable_watermark) @@ -1973,7 +1973,7 @@ int smu_set_ac_dc(struct smu_context *smu) { int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; /* controlled by firmware */ @@ -2083,7 +2083,7 @@ static int smu_set_fan_speed_rpm(void *handle, uint32_t speed) struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs->set_fan_speed_rpm) @@ -2126,7 +2126,7 @@ int smu_get_power_limit(void *handle, uint32_t limit_type; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; switch(pp_power_type) { @@ -2199,7 +2199,7 @@ static int smu_set_power_limit(void *handle, uint32_t limit) uint32_t limit_type = limit >> 24; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; limit &= (1<<24)-1; @@ -2230,7 +2230,7 @@ static int smu_print_smuclk_levels(struct smu_context *smu, enum smu_clk_type cl { int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->print_clk_levels) @@ -2319,7 +2319,7 @@ static int smu_od_edit_dpm_table(void *handle, struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->od_edit_dpm_table) { @@ -2340,7 +2340,7 @@ static int smu_read_sensor(void *handle, int ret = 0; uint32_t *size, size_val; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!data || !size_arg) @@ -2399,7 +2399,7 @@ static int smu_get_power_profile_mode(void *handle, char *buf) { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled || + if (!smu->adev->pm.dpm_enabled || !smu->ppt_funcs->get_power_profile_mode) return -EOPNOTSUPP; if (!buf) @@ -2414,7 +2414,7 @@ static int smu_set_power_profile_mode(void *handle, { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled || + if (!smu->adev->pm.dpm_enabled || !smu->ppt_funcs->set_power_profile_mode) return -EOPNOTSUPP; @@ -2426,7 +2426,7 @@ static int smu_get_fan_control_mode(void *handle, u32 *fan_mode) { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs->get_fan_control_mode) @@ -2445,7 +2445,7 @@ static int smu_set_fan_control_mode(void *handle, u32 value) struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs->set_fan_control_mode) @@ -2478,7 +2478,7 @@ static int smu_get_fan_speed_pwm(void *handle, u32 *speed) struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs->get_fan_speed_pwm) @@ -2497,7 +2497,7 @@ static int smu_set_fan_speed_pwm(void *handle, u32 speed) struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs->set_fan_speed_pwm) @@ -2524,7 +2524,7 @@ static int smu_get_fan_speed_rpm(void *handle, uint32_t *speed) struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs->get_fan_speed_rpm) @@ -2542,7 +2542,7 @@ static int smu_set_deep_sleep_dcefclk(void *handle, uint32_t clk) { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; return smu_set_min_dcef_deep_sleep(smu, clk); @@ -2556,7 +2556,7 @@ static int smu_get_clock_by_type_with_latency(void *handle, enum smu_clk_type clk_type; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->get_clock_by_type_with_latency) { @@ -2590,7 +2590,7 @@ static int smu_display_clock_voltage_request(void *handle, struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->display_clock_voltage_request) @@ -2606,7 +2606,7 @@ static int smu_display_disable_memory_clock_switch(void *handle, struct smu_context *smu = handle; int ret = -EINVAL; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->display_disable_memory_clock_switch) @@ -2621,7 +2621,7 @@ static int smu_set_xgmi_pstate(void *handle, struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->set_xgmi_pstate) @@ -2722,7 +2722,7 @@ static int smu_get_max_sustainable_clocks_by_dc(void *handle, struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->get_max_sustainable_clocks_by_dc) @@ -2738,7 +2738,7 @@ static int smu_get_uclk_dpm_states(void *handle, struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->get_uclk_dpm_states) @@ -2752,7 +2752,7 @@ static enum amd_pm_state_type smu_get_current_power_state(void *handle) struct smu_context *smu = handle; enum amd_pm_state_type pm_state = POWER_STATE_TYPE_DEFAULT; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->get_current_power_state) @@ -2767,7 +2767,7 @@ static int smu_get_dpm_clock_table(void *handle, struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->get_dpm_clock_table) @@ -2780,7 +2780,7 @@ static ssize_t smu_sys_get_gpu_metrics(void *handle, void **table) { struct smu_context *smu = handle; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (!smu->ppt_funcs->get_gpu_metrics) @@ -2794,7 +2794,7 @@ static int smu_enable_mgpu_fan_boost(void *handle) struct smu_context *smu = handle; int ret = 0; - if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled) + if (!smu->adev->pm.dpm_enabled) return -EOPNOTSUPP; if (smu->ppt_funcs->enable_mgpu_fan_boost) -- 2.29.0