size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)
{
- struct amdgpu_device *adev = smu->adev;
size_t size = 0;
int ret = 0, i = 0;
uint32_t feature_mask[2] = { 0 };
uint32_t sort_feature[SMU_FEATURE_COUNT];
uint64_t hw_feature_count = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
uint64_t feature_2_enabled = 0;
uint64_t feature_2_disabled = 0;
uint64_t feature_enables = 0;
- struct amdgpu_device *adev = smu->adev;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_dpm_set_power_gate(struct smu_context *smu, uint32_t block_type,
bool gate)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
switch (block_type) {
case AMD_IP_BLOCK_TYPE_UVD:
int smu_sys_get_pp_table(struct smu_context *smu, void **table)
{
struct smu_table_context *smu_table = &smu->smu_table;
- struct amdgpu_device *adev = smu->adev;
uint32_t powerplay_table_size;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (!smu_table->power_play_table && !smu_table->hardcode_pptable)
return -EINVAL;
int smu_sys_set_pp_table(struct smu_context *smu, void *buf, size_t size)
{
struct smu_table_context *smu_table = &smu->smu_table;
- struct amdgpu_device *adev = smu->adev;
ATOM_COMMON_TABLE_HEADER *header = (ATOM_COMMON_TABLE_HEADER *)buf;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (header->usStructureSize != size) {
pr_err("pp table size not matched !\n");
int smu_display_configuration_change(struct smu_context *smu,
const struct amd_pp_display_configuration *display_config)
{
- struct amdgpu_device *adev = smu->adev;
int index = 0;
int num_of_active_display = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
-
- if (!is_support_sw_smu(smu->adev))
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (!display_config)
return -EINVAL;
struct amd_pp_clock_info *clocks)
{
struct amd_pp_simple_clock_info simple_clocks = {0};
- struct amdgpu_device *adev = smu->adev;
struct smu_clock_info hw_clocks;
int ret = 0;
- if (!is_support_sw_smu(smu->adev))
- return -EINVAL;
-
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
enum amd_pp_task task_id,
bool lock_needed)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (lock_needed)
mutex_lock(&smu->mutex);
bool en)
{
struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
- struct amdgpu_device *adev = smu->adev;
long workload;
uint32_t index;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (!(type < PP_SMC_POWER_PROFILE_CUSTOM))
return -EINVAL;
enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu)
{
struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
- struct amdgpu_device *adev = smu->adev;
enum amd_dpm_forced_level level;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (!smu->is_apu && !smu_dpm_ctx->dpm_context)
return -EINVAL;
int smu_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_level level)
{
struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (!smu->is_apu && !smu_dpm_ctx->dpm_context)
return -EINVAL;
int smu_set_display_count(struct smu_context *smu, uint32_t count)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
ret = smu_init_display_count(smu, count);
bool lock_needed)
{
struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (smu_dpm_ctx->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) {
pr_debug("force clock level is for dpm manual mode only.\n");
uint16_t msg;
int ret;
+ if (!smu->pm_enabled)
+ return -EOPNOTSUPP;
+
mutex_lock(&smu->mutex);
switch (mp1_state) {
int smu_set_df_cstate(struct smu_context *smu,
enum pp_df_cstate state)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (!smu->ppt_funcs || !smu->ppt_funcs->set_df_cstate)
return 0;
int smu_allow_xgmi_power_down(struct smu_context *smu, bool en)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (!smu->ppt_funcs || !smu->ppt_funcs->allow_xgmi_power_down)
return 0;
struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges)
{
void *table = smu->smu_table.watermarks_table;
- struct amdgpu_device *adev = smu->adev;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (!table)
return -EINVAL;
int smu_set_ac_dc(struct smu_context *smu)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
/* controlled by firmware */
if (smu->dc_controlled_by_gpio)
int smu_load_microcode(struct smu_context *smu)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_check_fw_status(struct smu_context *smu)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_set_fan_speed_rpm(struct smu_context *smu, uint32_t speed)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
bool def,
bool lock_needed)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
if (lock_needed) {
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
}
int smu_set_power_limit(struct smu_context *smu, uint32_t limit)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_print_clk_levels(struct smu_context *smu, enum smu_clk_type clk_type, char *buf)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_get_od_percentage(struct smu_context *smu, enum smu_clk_type type)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_set_od_percentage(struct smu_context *smu, enum smu_clk_type type, uint32_t value)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
enum PP_OD_DPM_TABLE_COMMAND type,
long *input, uint32_t size)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
enum amd_pp_sensors sensor,
void *data, uint32_t *size)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_get_power_profile_mode(struct smu_context *smu, char *buf)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
uint32_t param_size,
bool lock_needed)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (lock_needed)
mutex_lock(&smu->mutex);
int smu_get_fan_control_mode(struct smu_context *smu)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_set_fan_control_mode(struct smu_context *smu, int value)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_get_fan_speed_percent(struct smu_context *smu, uint32_t *speed)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_set_fan_speed_percent(struct smu_context *smu, uint32_t speed)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_get_fan_speed_rpm(struct smu_context *smu, uint32_t *speed)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_set_deep_sleep_dcefclk(struct smu_context *smu, int clk)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_set_active_display_count(struct smu_context *smu, uint32_t count)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
if (smu->ppt_funcs->set_active_display_count)
ret = smu->ppt_funcs->set_active_display_count(smu, count);
enum amd_pp_clock_type type,
struct amd_pp_clocks *clocks)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_get_max_high_clocks(struct smu_context *smu,
struct amd_pp_simple_clock_info *clocks)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
enum smu_clk_type clk_type,
struct pp_clock_levels_with_latency *clocks)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
enum amd_pp_clock_type type,
struct pp_clock_levels_with_voltage *clocks)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_display_clock_voltage_request(struct smu_context *smu,
struct pp_display_clock_request *clock_req)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_display_disable_memory_clock_switch(struct smu_context *smu, bool disable_memory_clock_switch)
{
- struct amdgpu_device *adev = smu->adev;
int ret = -EINVAL;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_notify_smu_enable_pwe(struct smu_context *smu)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_set_xgmi_pstate(struct smu_context *smu,
uint32_t pstate)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_set_azalia_d3_pme(struct smu_context *smu)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
{
bool ret = false;
+ if (!smu->pm_enabled)
+ return false;
+
mutex_lock(&smu->mutex);
if (smu->ppt_funcs && smu->ppt_funcs->baco_is_support)
{
int ret = 0;
+ if (!smu->pm_enabled)
+ return -EOPNOTSUPP;
+
mutex_lock(&smu->mutex);
if (smu->ppt_funcs->baco_enter)
{
int ret = 0;
+ if (!smu->pm_enabled)
+ return -EOPNOTSUPP;
+
mutex_lock(&smu->mutex);
if (smu->ppt_funcs->baco_exit)
{
int ret = 0;
+ if (!smu->pm_enabled)
+ return -EOPNOTSUPP;
+
mutex_lock(&smu->mutex);
if (smu->ppt_funcs->mode2_reset)
int smu_get_max_sustainable_clocks_by_dc(struct smu_context *smu,
struct pp_smu_nv_clock_table *max_clocks)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
unsigned int *clock_values_in_khz,
unsigned int *num_states)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
enum amd_pm_state_type smu_get_current_power_state(struct smu_context *smu)
{
enum amd_pm_state_type pm_state = POWER_STATE_TYPE_DEFAULT;
- struct amdgpu_device *adev = smu->adev;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
int smu_get_dpm_clock_table(struct smu_context *smu,
struct dpm_clocks *clock_table)
{
- struct amdgpu_device *adev = smu->adev;
int ret = 0;
- if (!adev->pm.dpm_enabled)
- return -EINVAL;
+ if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
+ return -EOPNOTSUPP;
mutex_lock(&smu->mutex);