Skip to contentSkip to conversation

drm/amdgpu/navi: fix index for OD MCLK

PATCH In review Alex Deucher 2 participants 10 messages Jan 25, 2020 – Jan 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/amdgpu/navi: fix index for OD MCLK

You can only adjust the max mclk, not the min.

---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +1 -1
index f1b27fc20c19..c8f09874c2ec 100644
@@ -843,7 +843,7 @@ static int navi10_print_clk_levels(struct smu_context *smu,
 		if (!navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_UCLK_MAX))
 			break;
 		size += sprintf(buf + size, "OD_MCLK:\n");
-		size += sprintf(buf + size, "0: %uMHz\n", od_table->UclkFmax);
+		size += sprintf(buf + size, "1: %uMHz\n", od_table->UclkFmax);
 		break;
 	case SMU_OD_VDDC_CURVE:
 		if (!smu->od_enabled || !od_table || !od_settings)
Signature · 6 lines
2.24.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

PATCH 2/3 drm/amdgpu/navi10: add OD_RANGE for navi overclocking

So users can see the range of valid values.

---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +59 -0
index c8f09874c2ec..d2d45181ae23 100644
@@ -737,6 +737,15 @@ static inline bool navi10_od_feature_is_supported(struct smu_11_0_overdrive_tabl
 	return od_table->cap[feature];
 }
 
+static void navi10_od_setting_get_range(struct smu_11_0_overdrive_table *od_table,
+					enum SMU_11_0_ODSETTING_ID setting,
+					uint32_t *min, uint32_t *max)
+{
+	if (min)
+		*min = od_table->min[setting];
+	if (max)
+		*max = od_table->max[setting];
+}
 
 static int navi10_print_clk_levels(struct smu_context *smu,
 			enum smu_clk_type clk_type, char *buf)
@@ -755,6 +764,7 @@ static int navi10_print_clk_levels(struct smu_context *smu,
 	OverDriveTable_t *od_table =
 		(OverDriveTable_t *)table_context->overdrive_table;
 	struct smu_11_0_overdrive_table *od_settings = smu->od_settings;
+	uint32_t min_value, max_value;
 
 	switch (clk_type) {
 	case SMU_GFXCLK:
@@ -867,6 +877,55 @@ static int navi10_print_clk_levels(struct smu_context *smu,
 			}
 			size += sprintf(buf + size, "%d: %uMHz @ %umV\n", i, curve_settings[0], curve_settings[1] / NAVI10_VOLTAGE_SCALE);
 		}
+		break;
+	case SMU_OD_RANGE:
+		if (!smu->od_enabled || !od_table || !od_settings)
+			break;
+		size = sprintf(buf, "%s:\n", "OD_RANGE");
+
+		if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_LIMITS)) {
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_GFXCLKFMIN,
+						    &min_value, NULL);
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_GFXCLKFMAX,
+						    NULL, &max_value);
+			size += sprintf(buf + size, "SCLK: %7uMhz %10uMhz\n",
+					min_value, max_value);
+		}
+
+		if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_UCLK_MAX)) {
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_UCLKFMAX,
+						    &min_value, &max_value);
+			size += sprintf(buf + size, "MCLK: %7uMhz %10uMhz\n",
+					min_value, max_value);
+		}
+
+		if (navi10_od_feature_is_supported(od_settings, SMU_11_0_ODFEATURE_GFXCLK_CURVE)) {
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P1,
+						    &min_value, &max_value);
+			size += sprintf(buf + size, "VDDC_CURVE_SCLK[0]: %7uMhz %10uMhz\n",
+					min_value, max_value);
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P1,
+						    &min_value, &max_value);
+			size += sprintf(buf + size, "VDDC_CURVE_VOLT[0]: %7dmV %11dmV\n",
+					min_value, max_value);
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P2,
+						    &min_value, &max_value);
+			size += sprintf(buf + size, "VDDC_CURVE_SCLK[1]: %7uMhz %10uMhz\n",
+					min_value, max_value);
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P2,
+						    &min_value, &max_value);
+			size += sprintf(buf + size, "VDDC_CURVE_VOLT[1]: %7dmV %11dmV\n",
+					min_value, max_value);
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P3,
+						    &min_value, &max_value);
+			size += sprintf(buf + size, "VDDC_CURVE_SCLK[2]: %7uMhz %10uMhz\n",
+					min_value, max_value);
+			navi10_od_setting_get_range(od_settings, SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P3,
+						    &min_value, &max_value);
+			size += sprintf(buf + size, "VDDC_CURVE_VOLT[2]: %7dmV %11dmV\n",
+					min_value, max_value);
+		}
+
 		break;
 	default:
 		break;
Signature · 6 lines
2.24.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#2 lore raw

PATCH 3/3 drm/amdgpu/navi10: add OD support for restoring default table

In reply to Alex Deucher

Was missing before.

---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +8 -0
index d2d45181ae23..f60762f9b143 100644
@@ -2062,6 +2062,14 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
 		if (ret)
 			return ret;
 		od_table->UclkFmax = input[1];
+		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;
+		}
+
 		break;
 	case PP_OD_COMMIT_DPM_TABLE:
 		navi10_dump_od_table(od_table);
Signature · 6 lines
2.24.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

Re: [PATCH 3/3] drm/amdgpu/navi10: add OD support for restoring default table

For this, I believe we're updating table_context->overdrive_table with the values set by the user, wouldn't the intended behavior here be to restore the settings that were there on boot?

If so, I think we'd have to cache the overdrive table that was there on boot, and use that in the response for PP_OD_RESTORE_DEFAULT_TABLE, no?

I'm doing some testing on this patchset, but on initial lookover that's the only thing I saw. I could be mistaken, but I think this just writes the overdrive table that we are currently using over again instead of writing the default one.

Quoted 18 lines · Alex Deucher

Was missing before.

---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +1 -0
index d2d45181ae23..f60762f9b143 100644
@@ -2062,6 +2062,14 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
 		if (ret)
 			return ret;
 		od_table->UclkFmax = input[1];
+		break;

drivers/gpu/drm/amd/powerplay/navi10_ppt.c static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL · line 2075

Quoted 10 lines
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +7 -0
+	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;
+		}
+
 		break;
 	case PP_OD_COMMIT_DPM_TABLE:
 		navi10_dump_od_table(od_table);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw

Re: [PATCH 3/3] drm/amdgpu/navi10: add OD support for restoring default table

Quoted 5 lines · Matt Coffin

For this, I believe we're updating table_context->overdrive_table with the values set by the user, wouldn't the intended behavior here be to restore the settings that were there on boot?

Correct.

Quoted 11 lines

If so, I think we'd have to cache the overdrive table that was there on boot, and use that in the response for PP_OD_RESTORE_DEFAULT_TABLE, no?

I'm doing some testing on this patchset, but on initial lookover that's the only thing I saw. I could be mistaken, but I think this just writes the overdrive table that we are currently using over again instead of writing the default one.

I just copied that vega20 did. You may be right. I haven't paged the recent SMU interface stuff into my head in a while. If so, we should also fix the vega20_ppt.c code.

Thanks!

Alex

Quoted 22 lines · Alex Deucher
Quoted 20 lines

Was missing before.

---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -0
index d2d45181ae23..f60762f9b143 100644
@@ -2062,6 +2062,14 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
              if (ret)
                      return ret;
              od_table->UclkFmax = input[1];
+             break;
+     case PP_OD_RESTORE_DEFAULT_TABLE:
+             ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, false);
+             if (ret) {
Quoted 8 lines

drivers/gpu/drm/amd/powerplay/navi10_ppt.c static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL · line 2075

Quoted 8 lines
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -0
+                     pr_err("Failed to export over drive table!\n");
+                     return ret;
+             }
+
              break;
      case PP_OD_COMMIT_DPM_TABLE:
              navi10_dump_od_table(od_table);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw

Re: [PATCH 3/3] drm/amdgpu/navi10: add OD support for restoring default table

Quoted 5 lines · Alex Deucher

On Tue, Jan 28, 2020 at 11:44 AM Matt Coffin <[email protected]> wrote:

I just copied that vega20 did. You may be right. I haven't paged the recent SMU interface stuff into my head in a while. If so, we should also fix the vega20_ppt.c code.

The vega20_ppt code was correct, until we implemented the ability for the user to write to that overdrive table, which will land in 5.5.

Not entirely sure about the canonical way to distribute changes to someone else's series, but I can take a crack at fixing this.

Quoted 22 lines
Quoted 22 lines · Alex Deucher
Quoted 20 lines

Was missing before.

---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -0
index d2d45181ae23..f60762f9b143 100644
@@ -2062,6 +2062,14 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
              if (ret)
                      return ret;
              od_table->UclkFmax = input[1];
+             break;
+     case PP_OD_RESTORE_DEFAULT_TABLE:
+             ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, false);
+             if (ret) {
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/powerplay/navi10_ppt.c static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL · line 2075

Quoted 8 lines
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -0
+                     pr_err("Failed to export over drive table!\n");
+                     return ret;
+             }
+
              break;
      case PP_OD_COMMIT_DPM_TABLE:
              navi10_dump_od_table(od_table);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#6 lore raw

Re: [PATCH 3/3] drm/amdgpu/navi10: add OD support for restoring default table

Quoted 10 lines · Matt Coffin
Quoted 5 lines · Alex Deucher

On Tue, Jan 28, 2020 at 11:44 AM Matt Coffin <[email protected]> wrote:

I just copied that vega20 did. You may be right. I haven't paged the recent SMU interface stuff into my head in a while. If so, we should also fix the vega20_ppt.c code.

Quoted 6 lines

The vega20_ppt code was correct, until we implemented the ability for the user to write to that overdrive table, which will land in 5.5.

Not entirely sure about the canonical way to distribute changes to someone else's series, but I can take a crack at fixing this.

Thanks. Just go ahead and send patches.

Alex

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines · Alex Deucher
Quoted 20 lines

Was missing before.

---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -0
index d2d45181ae23..f60762f9b143 100644
@@ -2062,6 +2062,14 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
              if (ret)
                      return ret;
              od_table->UclkFmax = input[1];
+             break;
+     case PP_OD_RESTORE_DEFAULT_TABLE:
+             ret = smu_update_table(smu, SMU_TABLE_OVERDRIVE, 0, table_context->overdrive_table, false);
+             if (ret) {
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/powerplay/navi10_ppt.c static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL · line 2075

Quoted 8 lines
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -0
+                     pr_err("Failed to export over drive table!\n");
+                     return ret;
+             }
+
              break;
      case PP_OD_COMMIT_DPM_TABLE:
              navi10_dump_od_table(od_table);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#7 lore raw

PATCH 1/1 drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables

In reply to Matt Coffin

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

---
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  1 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  9 +++---
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     |  6 ++++
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c    | 28 ++++++-------------
 4 files changed, 19 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
index b0591a8dda41..1e33c3e9b98d 100644
@@ -273,6 +273,7 @@ struct smu_table_context
 	uint8_t                         thermal_controller_type;
 
 	void				*overdrive_table;
+	void                            *boot_overdrive_table;
 };
 
 struct smu_dpm_context {
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -5
index f60762f9b143..26cfccc57331 100644
@@ -2064,12 +2064,11 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
 		od_table->UclkFmax = input[1];
 		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:
 		navi10_dump_od_table(od_table);
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +6 -0
index 02f8c9cb89d9..0dc49479a7eb 100644
@@ -1882,6 +1882,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) {
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +8 -20
index 38febd5ca4da..4ad8d6c14ee5 100644
@@ -1706,22 +1706,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;
@@ -2778,12 +2767,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:
Signature · 6 lines
2.25.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author Reviewed-by on v1 1/1
#8 lore raw

Re: [PATCH] drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables

Quoted 7 lines · Matt Coffin

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

Missing your signed-off by. With that fixed, patch is:

Quoted 106 lines
---
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  1 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  9 +++---
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     |  6 ++++
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c    | 28 ++++++-------------
 4 files changed, 19 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
index b0591a8dda41..1e33c3e9b98d 100644
@@ -273,6 +273,7 @@ struct smu_table_context
        uint8_t                         thermal_controller_type;
 
        void                            *overdrive_table;
+       void                            *boot_overdrive_table;
 };
 
 struct smu_dpm_context {
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -5
index f60762f9b143..26cfccc57331 100644
@@ -2064,12 +2064,11 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
                od_table->UclkFmax = input[1];
                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:
                navi10_dump_od_table(od_table);
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +6 -0
index 02f8c9cb89d9..0dc49479a7eb 100644
@@ -1882,6 +1882,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) {
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +8 -21
index 38febd5ca4da..4ad8d6c14ee5 100644
@@ -1706,22 +1706,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;
@@ -2778,12 +2767,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:
--
Quoted 2 lines

2.25.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#9 lore raw

PATCH 1/1 drm/amdgpu/smu_v11_0: Correct behavior of restoring default tables

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

---
 .../gpu/drm/amd/powerplay/inc/amdgpu_smu.h    |  1 +
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c    |  9 +++---
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c     |  6 ++++
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c    | 28 ++++++-------------
 4 files changed, 19 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
index b0591a8dda41..1e33c3e9b98d 100644
@@ -273,6 +273,7 @@ struct smu_table_context
 	uint8_t                         thermal_controller_type;
 
 	void				*overdrive_table;
+	void                            *boot_overdrive_table;
 };
 
 struct smu_dpm_context {
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +4 -5
index f60762f9b143..26cfccc57331 100644
@@ -2064,12 +2064,11 @@ static int navi10_od_edit_dpm_table(struct smu_context *smu, enum PP_OD_DPM_TABL
 		od_table->UclkFmax = input[1];
 		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:
 		navi10_dump_od_table(od_table);
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +6 -0
index 02f8c9cb89d9..0dc49479a7eb 100644
@@ -1882,6 +1882,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) {
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +8 -20
index 38febd5ca4da..4ad8d6c14ee5 100644
@@ -1706,22 +1706,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;
@@ -2778,12 +2767,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:
Signature · 6 lines
2.25.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx