]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables (v2)
authorMatt Coffin <mcoffin13@gmail.com>
Sat, 25 Jan 2020 18:04:05 +0000 (13:04 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:37:15 +0000 (04:37 -0800)
commit 93c5f1f66c6ad4a3b180c1644f74e1b3b4be7864 upstream.

Previously, the syfs functionality for restoring the default powerplay
table was sourcing it's information from the currently-staged powerplay
table.

This patch adds a step to cache the first overdrive table that we see on
boot, so that it can be used later to "restore" the powerplay table

v2: sqaush my original with Matt's fix

Bug: https://gitlab.freedesktop.org/drm/amd/issues/1020
Signed-off-by: Matt Coffin <mcoffin13@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org # 5.5.x
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/vega20_ppt.c

index 137a6d08bf9d9059fe068304ebf344ad81236995..d005dea4a3bfb39618e4f001cc9d6a97e6f82c68 100644 (file)
@@ -263,6 +263,7 @@ struct smu_table_context
        uint8_t                         thermal_controller_type;
 
        void                            *overdrive_table;
+       void                            *boot_overdrive_table;
 };
 
 struct smu_dpm_context {
index 706aec129cd12205b3b1601fb427cd900abeef27..e3f8c45e7467bac71df04b5ea1b60936423044d2 100644 (file)
@@ -2020,6 +2020,13 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
                        return ret;
                od_table->UclkFmax = input[1];
                break;
+       case PP_OD_RESTORE_DEFAULT_TABLE:
+               if (!(table_context->overdrive_table && table_context->boot_overdrive_table)) {
+                       pr_err("Overdrive table was not initialized!\n");
+                       return -EINVAL;
+               }
+               memcpy(table_context->overdrive_table, table_context->boot_overdrive_table, sizeof(OverDriveTable_t));
+               break;
        case PP_OD_COMMIT_DPM_TABLE:
                navi10_dump_od_table(od_table);
                ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, (void *)od_table, true);
index e4268a627effec922120236d5292803fc0c1a351..8b13d18c6414c16a8d84bdcab29569672b451d48 100644 (file)
@@ -1807,6 +1807,12 @@ int smu_v11_0_set_default_od_settings(struct smu_context *smu, bool initialize,
                        pr_err("Failed to export overdrive table!\n");
                        return ret;
                }
+               if (!table_context->boot_overdrive_table) {
+                       table_context->boot_overdrive_table = kmemdup(table_context->overdrive_table, overdrive_table_size, GFP_KERNEL);
+                       if (!table_context->boot_overdrive_table) {
+                               return -ENOMEM;
+                       }
+               }
        }
        ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, true);
        if (ret) {
index 0d3a3b0a934e9a767ebe98fa105c8ac80f39e863..a9c41cd111ce7c786b367c4efb17fe474c672a33 100644 (file)
@@ -1702,22 +1702,11 @@ static int vega20_set_default_od_settings(struct smu_context *smu,
        struct smu_table_context *table_context = &smu->smu_table;
        int ret;
 
-       if (initialize) {
-               if (table_context->overdrive_table)
-                       return -EINVAL;
-
-               table_context->overdrive_table = kzalloc(sizeof(OverDriveTable_t), GFP_KERNEL);
-
-               if (!table_context->overdrive_table)
-                       return -ENOMEM;
-
-               ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0,
-                                      table_context->overdrive_table, false);
-               if (ret) {
-                       pr_err("Failed to export over drive table!\n");
-                       return ret;
-               }
+       ret = smu_v11_0_set_default_od_settings(smu, initialize, sizeof(OverDriveTable_t));
+       if (ret)
+               return ret;
 
+       if (initialize) {
                ret = vega20_set_default_od8_setttings(smu);
                if (ret)
                        return ret;
@@ -2774,12 +2763,11 @@ static int vega20_odn_edit_dpm_table(struct smu_context *smu,
                break;
 
        case PP_OD_RESTORE_DEFAULT_TABLE:
-               ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, false);
-               if (ret) {
-                       pr_err("Failed to export over drive table!\n");
-                       return ret;
+               if (!(table_context->overdrive_table && table_context->boot_overdrive_table)) {
+                       pr_err("Overdrive table was not initialized!\n");
+                       return -EINVAL;
                }
-
+               memcpy(table_context->overdrive_table, table_context->boot_overdrive_table, sizeof(OverDriveTable_t));
                break;
 
        case PP_OD_COMMIT_DPM_TABLE: