Commit 8279bb4e authored by Prike Liang's avatar Prike Liang Committed by Alex Deucher

drm/amd/pm: add gfx_state_change_set() for rn gfx power switch (v2)

The gfx_state_change_set() funtion can support set GFX power
change status to D0/D3.

v2: make sure to register callback (Alex)
Signed-off-by: default avatarPrike Liang <Prike.Liang@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 628c36d7
...@@ -828,14 +828,14 @@ int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev) ...@@ -828,14 +828,14 @@ int amdgpu_gfx_get_num_kcq(struct amdgpu_device *adev)
void amdgpu_gfx_state_change_set(struct amdgpu_device *adev, enum gfx_change_state state) void amdgpu_gfx_state_change_set(struct amdgpu_device *adev, enum gfx_change_state state)
{ {
if (is_support_sw_smu(adev)) {
mutex_lock(&adev->pm.mutex); smu_gfx_state_change_set(&adev->smu, state);
} else {
if (adev->powerplay.pp_funcs && mutex_lock(&adev->pm.mutex);
adev->powerplay.pp_funcs->gfx_state_change_set) if (adev->powerplay.pp_funcs &&
adev->powerplay.pp_funcs->gfx_state_change_set)
((adev)->powerplay.pp_funcs->gfx_state_change_set( ((adev)->powerplay.pp_funcs->gfx_state_change_set(
(adev)->powerplay.pp_handle, state)); (adev)->powerplay.pp_handle, state));
mutex_unlock(&adev->pm.mutex);
mutex_unlock(&adev->pm.mutex); }
} }
...@@ -576,6 +576,7 @@ struct pptable_funcs { ...@@ -576,6 +576,7 @@ struct pptable_funcs {
int (*post_init)(struct smu_context *smu); int (*post_init)(struct smu_context *smu);
void (*interrupt_work)(struct smu_context *smu); void (*interrupt_work)(struct smu_context *smu);
int (*gpo_control)(struct smu_context *smu, bool enablement); int (*gpo_control)(struct smu_context *smu, bool enablement);
int (*gfx_state_change_set)(struct smu_context *smu, uint32_t state);
}; };
typedef enum { typedef enum {
...@@ -764,6 +765,7 @@ int smu_get_status_gfxoff(struct amdgpu_device *adev, uint32_t *value); ...@@ -764,6 +765,7 @@ int smu_get_status_gfxoff(struct amdgpu_device *adev, uint32_t *value);
ssize_t smu_sys_get_gpu_metrics(struct smu_context *smu, void **table); ssize_t smu_sys_get_gpu_metrics(struct smu_context *smu, void **table);
int smu_enable_mgpu_fan_boost(struct smu_context *smu); int smu_enable_mgpu_fan_boost(struct smu_context *smu);
int smu_gfx_state_change_set(struct smu_context *smu, uint32_t state);
#endif #endif
#endif #endif
...@@ -2529,3 +2529,15 @@ int smu_enable_mgpu_fan_boost(struct smu_context *smu) ...@@ -2529,3 +2529,15 @@ int smu_enable_mgpu_fan_boost(struct smu_context *smu)
return ret; return ret;
} }
int smu_gfx_state_change_set(struct smu_context *smu, uint32_t state)
{
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;
}
...@@ -1136,6 +1136,12 @@ static ssize_t renoir_get_gpu_metrics(struct smu_context *smu, ...@@ -1136,6 +1136,12 @@ static ssize_t renoir_get_gpu_metrics(struct smu_context *smu,
return sizeof(struct gpu_metrics_v2_0); return sizeof(struct gpu_metrics_v2_0);
} }
static int renoir_gfx_state_change_set(struct smu_context *smu, uint32_t state)
{
return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_GpuChangeState, state, NULL);
}
static const struct pptable_funcs renoir_ppt_funcs = { static const struct pptable_funcs renoir_ppt_funcs = {
.set_power_state = NULL, .set_power_state = NULL,
.print_clk_levels = renoir_print_clk_levels, .print_clk_levels = renoir_print_clk_levels,
...@@ -1171,6 +1177,7 @@ static const struct pptable_funcs renoir_ppt_funcs = { ...@@ -1171,6 +1177,7 @@ static const struct pptable_funcs renoir_ppt_funcs = {
.get_pp_feature_mask = smu_cmn_get_pp_feature_mask, .get_pp_feature_mask = smu_cmn_get_pp_feature_mask,
.set_pp_feature_mask = smu_cmn_set_pp_feature_mask, .set_pp_feature_mask = smu_cmn_set_pp_feature_mask,
.get_gpu_metrics = renoir_get_gpu_metrics, .get_gpu_metrics = renoir_get_gpu_metrics,
.gfx_state_change_set = renoir_gfx_state_change_set,
}; };
void renoir_set_ppt_funcs(struct smu_context *smu) void renoir_set_ppt_funcs(struct smu_context *smu)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment