From: Likun Gao <Likun.Gao@xxxxxxx> Backup default DPM table into golden dpm table. Signed-off-by: Likun Gao <Likun.Gao@xxxxxxx> Reviewed-by: Kevin Wang <kevin1.wang@xxxxxxx> Reviewed-by: Evan Quan <evan.quan@xxxxxxx> --- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 11 +++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 ++- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c index f4b6ae2..2e3e084 100644 --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c @@ -671,11 +671,22 @@ static int smu_hw_fini(void *handle) struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct smu_context *smu = &adev->smu; struct smu_table_context *table_context = &smu->smu_table; + struct smu_dpm_context *smu_dpm = &smu->smu_dpm; int ret = 0; if (!is_support_sw_smu(adev)) return -EINVAL; + if (smu_dpm->dpm_context) { + kfree(smu_dpm->dpm_context); + smu_dpm->dpm_context = NULL; + } + + if (smu_dpm->golden_dpm_context) { + kfree(smu_dpm->golden_dpm_context); + smu_dpm->golden_dpm_context = NULL; + } + if (table_context->driver_pptable) { kfree(table_context->driver_pptable); table_context->driver_pptable = NULL; diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h index ef8e301..3ef752f 100644 --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h @@ -201,8 +201,9 @@ struct smu_table_context }; struct smu_dpm_context { - void *dpm_context; uint32_t dpm_context_size; + void *dpm_context; + void *golden_dpm_context; }; struct smu_power_context { diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c index c398899..aa7f41a 100644 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c @@ -136,11 +136,22 @@ static int vega20_allocate_dpm_context(struct smu_context *smu) { struct smu_dpm_context *smu_dpm = &smu->smu_dpm; + if (smu_dpm->dpm_context) + return -EINVAL; + smu_dpm->dpm_context = kzalloc(sizeof(struct vega20_dpm_table), GFP_KERNEL); if (!smu_dpm->dpm_context) return -ENOMEM; + if (smu_dpm->golden_dpm_context) + return -EINVAL; + + smu_dpm->golden_dpm_context = kzalloc(sizeof(struct vega20_dpm_table), + GFP_KERNEL); + if (!smu_dpm->golden_dpm_context) + return -ENOMEM; + smu_dpm->dpm_context_size = sizeof(struct vega20_dpm_table); return 0; @@ -610,6 +621,9 @@ static int vega20_set_default_dpm_table(struct smu_context *smu) } vega20_init_single_dpm_state(&(single_dpm_table->dpm_state)); + memcpy(smu_dpm->golden_dpm_context, dpm_table, + sizeof(struct vega20_dpm_table)); + return 0; } -- 2.7.4 _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx