Skip to contentSkip to conversation

drm/amd/pm: Skip redundant UCLK restore in smu_v13_0_6

PATCH In review Asad Kamal 2 participants 7 messages Mar 18

Subsystems (3)
lore
Share & tools
lore

Asad Kamal

author
#0 lore raw

PATCH v3 1/4 drm/amd/pm: Skip redundant UCLK restore in smu_v13_0_6

Only reapply UCLK soft limits during PP_OD_RESTORE_DEFAULT when the current max differs from the DPM table max. This avoids redundant SMC updates and prevents -EINVAL on restore when no change is needed.

Fixes b7a900344546 ("drm/amd/pm: Allow setting max UCLK on SMU v13.0.6")
---
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +11 -8
index 5b9580034641..dcc447e5044f 100644
@@ -2125,6 +2125,7 @@ static int smu_v13_0_6_usr_edit_dpm_table(struct smu_context *smu,
 {
 	struct smu_dpm_context *smu_dpm = &(smu->smu_dpm);
 	struct smu_13_0_dpm_context *dpm_context = smu_dpm->dpm_context;
+	struct smu_dpm_table *uclk_table = &dpm_context->dpm_tables.uclk_table;
 	struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
 	uint32_t min_clk;
 	uint32_t max_clk;
@@ -2224,14 +2225,16 @@ static int smu_v13_0_6_usr_edit_dpm_table(struct smu_context *smu,
 			if (ret)
 				return ret;
 
-			min_clk = SMU_DPM_TABLE_MIN(
-				&dpm_context->dpm_tables.uclk_table);
-			max_clk = SMU_DPM_TABLE_MAX(
-				&dpm_context->dpm_tables.uclk_table);
-			ret = smu_v13_0_6_set_soft_freq_limited_range(
-				smu, SMU_UCLK, min_clk, max_clk, false);
-			if (ret)
-				return ret;
+			if (SMU_DPM_TABLE_MAX(uclk_table) !=
+			    pstate_table->uclk_pstate.curr.max) {
+				min_clk = SMU_DPM_TABLE_MIN(&dpm_context->dpm_tables.uclk_table);
+				max_clk = SMU_DPM_TABLE_MAX(&dpm_context->dpm_tables.uclk_table);
+				ret = smu_v13_0_6_set_soft_freq_limited_range(smu,
+									      SMU_UCLK, min_clk,
+									      max_clk, false);
+				if (ret)
+					return ret;
+			}
 			smu_v13_0_reset_custom_level(smu);
 		}
 		break;
Signature · 1 line
2.46.0
author
#1 lore raw

PATCH v3 2/4 drm/amd/pm: Return -EOPNOTSUPP for unsupported OD_MCLK on smu_v13_0_6

When SET_UCLK_MAX capability is absent, return -EOPNOTSUPP from smu_v13_0_6_emit_clk_levels() for OD_MCLK instead of 0. This makes unsupported OD_MCLK reporting consistent with other clock types and allows callers to skip the entry cleanly.

---
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +1 -1
index dcc447e5044f..bcf8921bf1c7 100644
@@ -1394,7 +1394,7 @@ static int smu_v13_0_6_emit_clk_levels(struct smu_context *smu,
 		break;
 	case SMU_OD_MCLK:
 		if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(SET_UCLK_MAX)))
-			return 0;
+			return -EOPNOTSUPP;
 
 		size += sysfs_emit_at(buf, size, "%s:\n", "OD_MCLK");
 		size += sysfs_emit_at(buf, size, "0: %uMhz\n1: %uMhz\n",
Signature · 1 line
2.46.0
Reviewed-by on v3 2/4
#2 lore raw

Re: [PATCH v3 2/4] drm/amd/pm: Return -EOPNOTSUPP for unsupported OD_MCLK on smu_v13_0_6

Quoted 6 lines · Asad Kamal

When SET_UCLK_MAX capability is absent, return -EOPNOTSUPP from smu_v13_0_6_emit_clk_levels() for OD_MCLK instead of 0. This makes unsupported OD_MCLK reporting consistent with other clock types and allows callers to skip the entry cleanly.

Thanks,
Lijo

Quoted 17 lines
---
  drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +1 -1
index dcc447e5044f..bcf8921bf1c7 100644
@@ -1394,7 +1394,7 @@ static int smu_v13_0_6_emit_clk_levels(struct smu_context *smu,
  		break;
  	case SMU_OD_MCLK:
  		if (!smu_v13_0_6_cap_supported(smu, SMU_CAP(SET_UCLK_MAX)))
-			return 0;
+			return -EOPNOTSUPP;
 
  		size += sysfs_emit_at(buf, size, "%s:\n", "OD_MCLK");
  		size += sysfs_emit_at(buf, size, "0: %uMhz\n1: %uMhz\n",
author
#3 lore raw

PATCH v3 3/4 drm/amd/pm: Add OD_FCLK interface

In reply to Asad Kamal

Add OD_FCLK interface to set customa fclk max

v2: Merge patch1 & 3, check EOPNOTSUPP for all clks (Lijo)

v3: Remove redundant check (Lijo)

---
 drivers/gpu/drm/amd/include/kgd_pp_interface.h |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_pm.c             | 18 +++++++++++-------
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c      |  2 ++
 drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h   |  1 +
 4 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -0
index a9b73f4fd466..33a1404bb666 100644
@@ -119,6 +119,7 @@ enum pp_clock_type {
 	PP_ISPXCLK,
 	OD_SCLK,
 	OD_MCLK,
+	OD_FCLK,
 	OD_VDDC_CURVE,
 	OD_RANGE,
 	OD_VDDGFX_OFFSET,
@@ -208,6 +209,7 @@ enum {
 enum PP_OD_DPM_TABLE_COMMAND {
 	PP_OD_EDIT_SCLK_VDDC_TABLE,
 	PP_OD_EDIT_MCLK_VDDC_TABLE,
+	PP_OD_EDIT_FCLK_TABLE,
 	PP_OD_EDIT_CCLK_VDDC_TABLE,
 	PP_OD_EDIT_VDDC_CURVE,
 	PP_OD_RESTORE_DEFAULT_TABLE,
drivers/gpu/drm/amd/pm/amdgpu_pm.c +11 -7
index 938361ecae05..01ff24880fe2 100644
@@ -680,6 +680,8 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,
  * - minimum(not available for Vega20 and Navi1x) and maximum memory
  *   clock labeled OD_MCLK
  *
+ * - minimum and maximum fabric clock labeled OD_FCLK (SMU13)
+ *
  * - three <frequency, voltage> points labeled OD_VDDC_CURVE.
  *   They can be used to calibrate the sclk voltage curve. This is
  *   available for Vega20 and NV1X.
@@ -715,10 +717,11 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,
  * - First select manual using power_dpm_force_performance_level
  *
  * - For clock frequency setting, enter a new value by writing a
- *   string that contains "s/m index clock" to the file. The index
+ *   string that contains "s/m/f index clock" to the file. The index
  *   should be 0 if to set minimum clock. And 1 if to set maximum
  *   clock. E.g., "s 0 500" will update minimum sclk to be 500 MHz.
- *   "m 1 800" will update maximum mclk to be 800Mhz. For core
+ *   "m 1 800" will update maximum mclk to be 800Mhz. "f 1 1600" will
+ *   update maximum fabric clock to be 1600Mhz. For core
  *   clocks on VanGogh, the string contains "p core index clock".
  *   E.g., "p 2 0 800" would set the minimum core clock on core
  *   2 to 800Mhz.
@@ -768,6 +771,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
 		type = PP_OD_EDIT_CCLK_VDDC_TABLE;
 	else if (*buf == 'm')
 		type = PP_OD_EDIT_MCLK_VDDC_TABLE;
+	else if (*buf == 'f')
+		type = PP_OD_EDIT_FCLK_TABLE;
 	else if (*buf == 'r')
 		type = PP_OD_RESTORE_DEFAULT_TABLE;
 	else if (*buf == 'c')
@@ -843,9 +848,10 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
 	struct amdgpu_device *adev = drm_to_adev(ddev);
 	int size = 0;
 	int ret;
-	enum pp_clock_type od_clocks[6] = {
+	enum pp_clock_type od_clocks[] = {
 		OD_SCLK,
 		OD_MCLK,
+		OD_FCLK,
 		OD_VDDC_CURVE,
 		OD_RANGE,
 		OD_VDDGFX_OFFSET,
@@ -857,10 +863,8 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
 	if (ret)
 		return ret;
 
-	for (clk_index = 0 ; clk_index < 6 ; clk_index++) {
-		ret = amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size);
-		if (ret)
-			break;
+	for (clk_index = 0 ; clk_index < ARRAY_SIZE(od_clocks) ; clk_index++) {
+		amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size);
 	}
 
 	if (size == 0)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -0
index 3dc917194154..a2bc1c753e0e 100644
@@ -3056,6 +3056,8 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type)
 		clk_type = SMU_OD_SCLK; break;
 	case OD_MCLK:
 		clk_type = SMU_OD_MCLK; break;
+	case OD_FCLK:
+		clk_type = SMU_OD_FCLK; break;
 	case OD_VDDC_CURVE:
 		clk_type = SMU_OD_VDDC_CURVE; break;
 	case OD_RANGE:
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +1 -0
index 584c4cfd0c16..8cdbaf32492e 100644
@@ -324,6 +324,7 @@ enum smu_clk_type {
 	SMU_OD_CCLK,
 	SMU_OD_SCLK,
 	SMU_OD_MCLK,
+	SMU_OD_FCLK,
 	SMU_OD_VDDC_CURVE,
 	SMU_OD_RANGE,
 	SMU_OD_VDDGFX_OFFSET,
Signature · 1 line
2.46.0
Reviewed-by on v3 3/4
#4 lore raw

Re: [PATCH v3 3/4] drm/amd/pm: Add OD_FCLK interface

Quoted 7 lines · Asad Kamal

Add OD_FCLK interface to set customa fclk max

v2: Merge patch1 & 3, check EOPNOTSUPP for all clks (Lijo)

v3: Remove redundant check (Lijo)

Thanks,
Lijo

Quoted 113 lines
---
  drivers/gpu/drm/amd/include/kgd_pp_interface.h |  2 ++
  drivers/gpu/drm/amd/pm/amdgpu_pm.c             | 18 +++++++++++-------
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c      |  2 ++
  drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h   |  1 +
  4 files changed, 16 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -0
index a9b73f4fd466..33a1404bb666 100644
@@ -119,6 +119,7 @@ enum pp_clock_type {
  	PP_ISPXCLK,
  	OD_SCLK,
  	OD_MCLK,
+	OD_FCLK,
  	OD_VDDC_CURVE,
  	OD_RANGE,
  	OD_VDDGFX_OFFSET,
@@ -208,6 +209,7 @@ enum {
  enum PP_OD_DPM_TABLE_COMMAND {
  	PP_OD_EDIT_SCLK_VDDC_TABLE,
  	PP_OD_EDIT_MCLK_VDDC_TABLE,
+	PP_OD_EDIT_FCLK_TABLE,
  	PP_OD_EDIT_CCLK_VDDC_TABLE,
  	PP_OD_EDIT_VDDC_CURVE,
  	PP_OD_RESTORE_DEFAULT_TABLE,
drivers/gpu/drm/amd/pm/amdgpu_pm.c +11 -7
index 938361ecae05..01ff24880fe2 100644
@@ -680,6 +680,8 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,
   * - minimum(not available for Vega20 and Navi1x) and maximum memory
   *   clock labeled OD_MCLK
   *
+ * - minimum and maximum fabric clock labeled OD_FCLK (SMU13)
+ *
   * - three <frequency, voltage> points labeled OD_VDDC_CURVE.
   *   They can be used to calibrate the sclk voltage curve. This is
   *   available for Vega20 and NV1X.
@@ -715,10 +717,11 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,
   * - First select manual using power_dpm_force_performance_level
   *
   * - For clock frequency setting, enter a new value by writing a
- *   string that contains "s/m index clock" to the file. The index
+ *   string that contains "s/m/f index clock" to the file. The index
   *   should be 0 if to set minimum clock. And 1 if to set maximum
   *   clock. E.g., "s 0 500" will update minimum sclk to be 500 MHz.
- *   "m 1 800" will update maximum mclk to be 800Mhz. For core
+ *   "m 1 800" will update maximum mclk to be 800Mhz. "f 1 1600" will
+ *   update maximum fabric clock to be 1600Mhz. For core
   *   clocks on VanGogh, the string contains "p core index clock".
   *   E.g., "p 2 0 800" would set the minimum core clock on core
   *   2 to 800Mhz.
@@ -768,6 +771,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,
  		type = PP_OD_EDIT_CCLK_VDDC_TABLE;
  	else if (*buf == 'm')
  		type = PP_OD_EDIT_MCLK_VDDC_TABLE;
+	else if (*buf == 'f')
+		type = PP_OD_EDIT_FCLK_TABLE;
  	else if (*buf == 'r')
  		type = PP_OD_RESTORE_DEFAULT_TABLE;
  	else if (*buf == 'c')
@@ -843,9 +848,10 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
  	struct amdgpu_device *adev = drm_to_adev(ddev);
  	int size = 0;
  	int ret;
-	enum pp_clock_type od_clocks[6] = {
+	enum pp_clock_type od_clocks[] = {
  		OD_SCLK,
  		OD_MCLK,
+		OD_FCLK,
  		OD_VDDC_CURVE,
  		OD_RANGE,
  		OD_VDDGFX_OFFSET,
@@ -857,10 +863,8 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,
  	if (ret)
  		return ret;
 
-	for (clk_index = 0 ; clk_index < 6 ; clk_index++) {
-		ret = amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size);
-		if (ret)
-			break;
+	for (clk_index = 0 ; clk_index < ARRAY_SIZE(od_clocks) ; clk_index++) {
+		amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size);
  	}
 
  	if (size == 0)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -0
index 3dc917194154..a2bc1c753e0e 100644
@@ -3056,6 +3056,8 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type)
  		clk_type = SMU_OD_SCLK; break;
  	case OD_MCLK:
  		clk_type = SMU_OD_MCLK; break;
+	case OD_FCLK:
+		clk_type = SMU_OD_FCLK; break;
  	case OD_VDDC_CURVE:
  		clk_type = SMU_OD_VDDC_CURVE; break;
  	case OD_RANGE:
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +1 -0
index 584c4cfd0c16..8cdbaf32492e 100644
@@ -324,6 +324,7 @@ enum smu_clk_type {
  	SMU_OD_CCLK,
  	SMU_OD_SCLK,
  	SMU_OD_MCLK,
+	SMU_OD_FCLK,
  	SMU_OD_VDDC_CURVE,
  	SMU_OD_RANGE,
  	SMU_OD_VDDGFX_OFFSET,
author
#5 lore raw

PATCH v3 4/4 drm/amd/pm: Add custom fclk setting support

In reply to Asad Kamal

Add custom fclk setting support for smu_v13_x_x

v2: Move uclk fix to separate patch, return EOPNOTSUPP in case of dpm disabled (Lijo)

v3: remove dpm check for filling fclk pstate table (Lijo)

---
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  2 +
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 82 ++++++++++++++++++-
 2 files changed, 83 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
index cf3781aba02a..d8a1c402a624 100644
@@ -2467,4 +2467,6 @@ void smu_v13_0_reset_custom_level(struct smu_context *smu)
 	pstate_table->uclk_pstate.custom.max = 0;
 	pstate_table->gfxclk_pstate.custom.min = 0;
 	pstate_table->gfxclk_pstate.custom.max = 0;
+	pstate_table->fclk_pstate.custom.min = 0;
+	pstate_table->fclk_pstate.custom.max = 0;
 }
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +81 -1

137 lines not on this page · raw message

Signature · 1 line
2.46.0
Reviewed-by on v3 4/4
#6 lore raw

Re: [PATCH v3 4/4] drm/amd/pm: Add custom fclk setting support

Quoted 8 lines · Asad Kamal

Add custom fclk setting support for smu_v13_x_x

v2: Move uclk fix to separate patch, return EOPNOTSUPP in case of dpm disabled (Lijo)

v3: remove dpm check for filling fclk pstate table (Lijo)

Thanks,
Lijo

Quoted 166 lines
---
  .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  2 +
  .../drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c  | 82 ++++++++++++++++++-
  2 files changed, 83 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -0
index cf3781aba02a..d8a1c402a624 100644
@@ -2467,4 +2467,6 @@ void smu_v13_0_reset_custom_level(struct smu_context *smu)
  	pstate_table->uclk_pstate.custom.max = 0;
  	pstate_table->gfxclk_pstate.custom.min = 0;
  	pstate_table->gfxclk_pstate.custom.max = 0;
+	pstate_table->fclk_pstate.custom.min = 0;
+	pstate_table->fclk_pstate.custom.max = 0;
  }
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c +81 -1
index bcf8921bf1c7..f76665c85bc3 100644
@@ -1199,6 +1199,7 @@ static int smu_v13_0_6_populate_umd_state_clk(struct smu_context *smu)
  	struct smu_dpm_table *gfx_table = &dpm_context->dpm_tables.gfx_table;
  	struct smu_dpm_table *mem_table = &dpm_context->dpm_tables.uclk_table;
  	struct smu_dpm_table *soc_table = &dpm_context->dpm_tables.soc_table;
+	struct smu_dpm_table *fclk_table = &dpm_context->dpm_tables.fclk_table;
  	struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
 
  	pstate_table->gfxclk_pstate.min = SMU_DPM_TABLE_MIN(gfx_table);
@@ -1216,6 +1217,12 @@ static int smu_v13_0_6_populate_umd_state_clk(struct smu_context *smu)
  	pstate_table->socclk_pstate.curr.min = SMU_DPM_TABLE_MIN(soc_table);
  	pstate_table->socclk_pstate.curr.max = SMU_DPM_TABLE_MAX(soc_table);
 
+	pstate_table->fclk_pstate.min = SMU_DPM_TABLE_MIN(fclk_table);
+	pstate_table->fclk_pstate.peak = SMU_DPM_TABLE_MAX(fclk_table);
+	pstate_table->fclk_pstate.curr.min = SMU_DPM_TABLE_MIN(fclk_table);
+	pstate_table->fclk_pstate.curr.max = SMU_DPM_TABLE_MAX(fclk_table);
+	pstate_table->fclk_pstate.standard = SMU_DPM_TABLE_MIN(fclk_table);
+
  	if (gfx_table->count > SMU_13_0_6_UMD_PSTATE_GFXCLK_LEVEL &&
  	    mem_table->count > SMU_13_0_6_UMD_PSTATE_MCLK_LEVEL &&
  	    soc_table->count > SMU_13_0_6_UMD_PSTATE_SOCCLK_LEVEL) {
@@ -1401,7 +1408,15 @@ static int smu_v13_0_6_emit_clk_levels(struct smu_context *smu,
  				      pstate_table->uclk_pstate.curr.min,
  				      pstate_table->uclk_pstate.curr.max);
  		break;
+	case SMU_OD_FCLK:
+		if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_FCLK_BIT))
+			return -EOPNOTSUPP;
 
+		size += sysfs_emit_at(buf, size, "%s:\n", "OD_FCLK");
+		size += sysfs_emit_at(buf, size, "0: %uMhz\n1: %uMhz\n",
+				      pstate_table->fclk_pstate.curr.min,
+				      pstate_table->fclk_pstate.curr.max);
+		break;
  	case SMU_SCLK:
  	case SMU_GFXCLK:
  		single_dpm_table = &(dpm_context->dpm_tables.gfx_table);
@@ -2043,7 +2058,7 @@ static int smu_v13_0_6_set_soft_freq_limited_range(struct smu_context *smu,
  	int ret = 0;
 
  	if (clk_type != SMU_GFXCLK && clk_type != SMU_SCLK &&
-	    clk_type != SMU_UCLK)
+	    clk_type != SMU_UCLK && clk_type != SMU_FCLK)
  		return -EINVAL;
 
  	if ((smu_dpm->dpm_level != AMD_DPM_FORCED_LEVEL_MANUAL) &&
@@ -2084,6 +2099,15 @@ static int smu_v13_0_6_set_soft_freq_limited_range(struct smu_context *smu,
  				pstate_table->uclk_pstate.curr.max = max;
  		}
 
+		if (clk_type == SMU_FCLK) {
+			if (max == pstate_table->fclk_pstate.curr.max)
+				return 0;
+
+			ret = smu_v13_0_set_soft_freq_limited_range(smu, SMU_FCLK, 0, max, false);
+			if (!ret)
+				pstate_table->fclk_pstate.curr.max = max;
+		}
+
  		return ret;
  	}
 
@@ -2126,6 +2150,7 @@ static int smu_v13_0_6_usr_edit_dpm_table(struct smu_context *smu,
  	struct smu_dpm_context *smu_dpm = &(smu->smu_dpm);
  	struct smu_13_0_dpm_context *dpm_context = smu_dpm->dpm_context;
  	struct smu_dpm_table *uclk_table = &dpm_context->dpm_tables.uclk_table;
+	struct smu_dpm_table *fclk_table = &dpm_context->dpm_tables.fclk_table;
  	struct smu_umd_pstate_table *pstate_table = &smu->pstate_table;
  	uint32_t min_clk;
  	uint32_t max_clk;
@@ -2206,6 +2231,40 @@ static int smu_v13_0_6_usr_edit_dpm_table(struct smu_context *smu,
  			pstate_table->uclk_pstate.custom.max = input[1];
  		}
  		break;
+	case PP_OD_EDIT_FCLK_TABLE:
+		if (size != 2) {
+			dev_err(smu->adev->dev,
+				"Input parameter number not correct\n");
+			return -EINVAL;
+		}
+
+		if (!smu_cmn_feature_is_enabled(smu,
+						SMU_FEATURE_DPM_FCLK_BIT)) {
+			dev_warn(smu->adev->dev,
+				 "FCLK limits setting not supported!\n");
+			return -EOPNOTSUPP;
+		}
+
+		max_clk = SMU_DPM_TABLE_MAX(&dpm_context->dpm_tables.fclk_table);
+		if (input[0] == 0) {
+			dev_info(smu->adev->dev,
+				 "Setting min FCLK level is not supported\n");
+			return -EOPNOTSUPP;
+		} else if (input[0] == 1) {
+			if (input[1] > max_clk) {
+				dev_warn(smu->adev->dev,
+					 "Maximum FCLK (%ld) MHz specified is greater than the maximum allowed (%d) MHz\n",
+					 input[1], max_clk);
+				pstate_table->fclk_pstate.custom.max =
+					pstate_table->fclk_pstate.curr.max;
+				return -EINVAL;
+			}
+
+			pstate_table->fclk_pstate.custom.max = input[1];
+		} else {
+			return -EINVAL;
+		}
+		break;
 
  	case PP_OD_RESTORE_DEFAULT_TABLE:
  		if (size != 0) {
@@ -2235,6 +2294,17 @@ static int smu_v13_0_6_usr_edit_dpm_table(struct smu_context *smu,
  				if (ret)
  					return ret;
  			}
+
+			if (SMU_DPM_TABLE_MAX(fclk_table) !=
+			    pstate_table->fclk_pstate.curr.max) {
+				max_clk = SMU_DPM_TABLE_MAX(&dpm_context->dpm_tables.fclk_table);
+				min_clk = SMU_DPM_TABLE_MIN(&dpm_context->dpm_tables.fclk_table);
+				ret = smu_v13_0_6_set_soft_freq_limited_range(smu,
+									      SMU_FCLK, min_clk,
+									      max_clk, false);
+				if (ret)
+					return ret;
+			}
  			smu_v13_0_reset_custom_level(smu);
  		}
  		break;
@@ -2261,6 +2331,16 @@ static int smu_v13_0_6_usr_edit_dpm_table(struct smu_context *smu,
  			if (ret)
  				return ret;
 
+			if (pstate_table->fclk_pstate.custom.max) {
+				min_clk = pstate_table->fclk_pstate.curr.min;
+				max_clk = pstate_table->fclk_pstate.custom.max;
+				ret = smu_v13_0_6_set_soft_freq_limited_range(smu,
+									      SMU_FCLK, min_clk,
+									      max_clk, false);
+				if (ret)
+					return ret;
+			}
+
  			if (!pstate_table->uclk_pstate.custom.max)
  				return 0;