]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amd/powerplay: add golden dpm table to backup default DPM table (v2)
authorLikun Gao <Likun.Gao@amd.com>
Fri, 11 Jan 2019 09:42:47 +0000 (17:42 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:03:59 +0000 (15:03 -0500)
Backup default DPM table into golden dpm table.

v2: fix dpm_context and golden_dpm_context kfree two times issue.

Signed-off-by: Likun Gao <Likun.Gao@amd.com>
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
Reviewed-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index 635c8b8e6d8d7b2d4fc4908a9f8483cd759d96bd..9e376eea847d084d606d1f1a2d2fc2f16255d647 100644 (file)
@@ -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 {
index 037d900c450cce545536f39bfee7f4636dee15a5..534319f24eb0b1668a070ce6a96995805e7d3d6e 100644 (file)
@@ -272,7 +272,9 @@ static int smu_v11_0_fini_dpm_context(struct smu_context *smu)
                return -EINVAL;
 
        kfree(smu_dpm->dpm_context);
+       kfree(smu_dpm->golden_dpm_context);
        smu_dpm->dpm_context = NULL;
+       smu_dpm->golden_dpm_context = NULL;
        smu_dpm->dpm_context_size = 0;
 
        return 0;
index c398899320d1333e09ffaa2f3793521830a6bfdf..aa7f41a59e8252cb93f2b239f857b1708523302e 100644 (file)
@@ -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;
 }