Skip to contentSkip to conversation

drm/amd: fix DCN3.2 flicker/hangs after OD_MCLK (VRAM overclock)

PATCH Superseded Ilya Shidlovskiy 3 participants 12 messages Oct 22 – Nov 2

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

v2 cover drm/amd: fix DCN3.2 flicker/hangs after OD_MCLK (VRAM overclock)

On DCN3.2 (Navi31, RX 7900 GRE here), raising the UCLK max through OD_MCLK makes the display flicker (full-width stripes) and eventually hang the whole system, if the current mode does not allow memory P-state switching. DC reads the UCLK DPM levels from PMFW only in init_hw, so after the OD commit it keeps asking for the old top level as UCLK hard min ("set UCLK min = max"). That is no longer the top level, so PMFW switches UCLK outside of vblank.

The series makes DC re-read the UCLK levels (bounding box and WM ranges included) after an OD commit/restore that changed UCLK, and on resume after the user OD settings are restored. It also refreshes the SMU driver's UCLK DPM table, so pp_dpm_mclk shows the real levels.

Bug report and review of v1: https://gitlab.freedesktop.org/drm/amd/-/issues/6009
(v1 was posted there as a comment, not to the list.)

Changes in v2:
- Only act when the user has customized UCLK (user_od_feature_mask & PP_OD_FEATURE_UCLK_BIT), instead of on every OD commit (Kenneth). PP_OD_FEATURE_UCLK_BIT is ASIC specific, so the check is done in the smu13.0.0 code, which sets a flag that the generic code reads.
- The SMU patch now comes before the DC patch, which depends on it.
- Rebased on amd-staging-drm-next.
- Added Leo's ack for the display parts.

Testing:
v2 is build-tested against amd-staging-drm-next. The hardware test is on an equivalent backport to the Ubuntu 7.3.0-9 kernel (same code, plus a small local backport of the user_od_feature_mask tracking, which Ubuntu 7.3 does not have yet).

Hardware: RX 7900 GRE (Navi31, SMU 13.0.0), 5120x1440@144 (DSC, ODM 4:1)
+ 2560x1440@100, UCLK OD max 1124 -> 1300 MHz, toggled via LACT.

v1 results:
- On OD commit, DC logs the new max UCLK (1300 MHz). pp_dpm_mclk shows 1300 as the top level, and the current level stays at 1300 (20/20 samples, no drops to 772).
- About 4 minutes of heavy window switching on the 5120x1440@144 output:
no stripes, no hang, no amdgpu errors.
- 3 OC on/off toggles: one short flash exactly at the switch (memory retraining during scanout, expected), then clean.
- Same scenario with the stock module: stripes, then a full system hang.

v2 results:
v2 hardware test (same RX 7900 GRE, 5120x1440@144 + 2560x1440@100; v2 backported to the Ubuntu 7.3.0-9 amdgpu, LACT applying power cap / voltage offset at boot):
- boot and login with stock VRAM: no "DC memclk states refreshed" at all, so non-UCLK OD commits (power cap, voltage offset) no longer touch DC; the short login flash seen with v1 is gone;
- VRAM OC on (OD_MCLK 1300): exactly one refresh, "max UCLK 1300 MHz"; pp_dpm_mclk top level 1300 and current level 1300 (12/12 samples);
- VRAM OC off: exactly one refresh, "max UCLK 1124 MHz";
- desktop stays clean, no stripes, no hangs.

Known limitations (unchanged from v1):
- The OD commit itself still happens during scanout, hence the single flash at the switch.
- Only DCN3.2/SMU 13.0.0 is handled. Other ASICs with OD_MCLK probably need the same hook in their ppt code.

Ilya Shidlovskiy (3):
drm/amd/display: dcn32: rebuild WM range table when memclk states
change
drm/amd/pm: smu13.0.0: refresh the UCLK DPM table after an OD_MCLK
change
drm/amd: let DC re-read UCLK DPM levels after an OD_MCLK change

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 ++++
 .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  |  8 ++---
 drivers/gpu/drm/amd/display/dc/core/dc.c      | 21 ++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  7 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 +++++++++++
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 33 ++++++++++++++++++-
 9 files changed, 127 insertions(+), 5 deletions(-)

base-commit: 77f548b127c6de34ce271fa09ba270cb1ef9f2da

Signature · 1 line
2.55.0
#1 lore raw

PATCH v2 1/3 drm/amd/display: dcn32: rebuild WM range table when memclk states change

dcn32_get_memclk_states_from_smu() refreshes the UCLK levels, max_memclk_mhz and the bounding box, but the watermark range table and the dummy P-state table (which are derived from the same memclk levels) are only built once in dcn32_init_clocks(). Build them at the end of dcn32_get_memclk_states_from_smu() instead, so that every caller which re-reads the memclk states from PMFW also gets matching WM ranges.

No functional change for the init path.

---

Notes:
v2:
- rebased on amd-staging-drm-next, no code changes
- added Leo's Acked-by (given in drm/amd#6009)

 .../gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c +4 -4
index 22dfca6ef..7abb13ffd 100644
@@ -256,11 +256,8 @@ void dcn32_init_clocks(struct clk_mgr *clk_mgr_base)
 		if (clk_mgr_base->bw_params->clk_table.entries[i].dppclk_mhz > 1950)
 			clk_mgr_base->bw_params->clk_table.entries[i].dppclk_mhz = 1950;
 
-	/* Get UCLK, update bounding box */
+	/* Get UCLK, update bounding box and WM range table */
 	clk_mgr_base->funcs->get_memclk_states_from_smu(clk_mgr_base);
-
-	/* WM range table */
-	dcn32_build_wm_range_table(clk_mgr);
 }
 
 static void dcn32_update_clocks_update_dtb_dto(struct clk_mgr_internal *clk_mgr,
@@ -1079,6 +1076,9 @@ static void dcn32_get_memclk_states_from_smu(struct clk_mgr *clk_mgr_base)
 	/* Refresh bounding box */
 	clk_mgr_base->ctx->dc->res_pool->funcs->update_bw_bounding_box(
 			clk_mgr->base.ctx->dc, clk_mgr_base->bw_params);
+
+	/* WM range table and dummy P-state table depend on the memclk levels */
+	dcn32_build_wm_range_table(clk_mgr);
 }
 
 static bool dcn32_are_clock_states_equal(struct dc_clocks *a,
Signature · 1 line
2.55.0
#2 lore raw

PATCH v2 2/3 drm/amd/pm: smu13.0.0: refresh the UCLK DPM table after an OD_MCLK change

In reply to Ilya Shidlovskiy

The UCLK DPM table in the driver is only populated by smu_v13_0_0_set_default_dpm_table(). After an overdrive table with a different UclkFmax is uploaded, pp_dpm_mclk keeps showing the stock top level, and the "high"/"auto" soft limits are derived from the stale table.

Re-read the UCLK levels from PMFW after a successful OD commit or restore, but only when the user has customized UCLK (PP_OD_FEATURE_UCLK_BIT in user_od_feature_mask, before or after the operation, so that restoring the defaults is covered too). Do the same when the user OD settings are restored on resume.

Also record the change in a new smu_table_context->od_uclk_changed flag, with smu_od_uclk_changed() to test and clear it. PP_OD_FEATURE_UCLK_BIT is ASIC specific (8 on SMU 13.0.x, 9 on SMU 14.0.2), so this lets the generic code tell DC to re-read the levels without knowing the OD table layout.

---

Notes:
v2:
- only refresh the UCLK table when the user has customized UCLK (user_od_feature_mask & PP_OD_FEATURE_UCLK_BIT), instead of on every OD upload (Kenneth). The mask from before the operation is checked too, so that restoring the defaults still refreshes the table.
- add the od_uclk_changed flag and smu_od_uclk_changed(), used by the DC hook in the next patch
- moved before the DC patch (was 3/3), since that patch now depends on it
- rebased on amd-staging-drm-next

 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 16 +++++++++
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 33 ++++++++++++++++++-
 3 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +16 -0
index a901f8535..490640053 100644
@@ -3665,6 +3665,22 @@ static int smu_baco_set_state(void *handle, int state)
 	return ret;
 }
 
+/**
+ * smu_od_uclk_changed - test and clear the "UCLK OD changed" flag
+ * @smu: smu context
+ *
+ * The ASIC code sets the flag when an overdrive commit or restore changed the
+ * UCLK DPM levels, so that callers can tell DC to re-read them.
+ */
+bool smu_od_uclk_changed(struct smu_context *smu)
+{
+	bool changed = smu->smu_table.od_uclk_changed;
+
+	smu->smu_table.od_uclk_changed = false;
+
+	return changed;
+}
+
 bool smu_mode1_reset_is_support(struct smu_context *smu)
 {
 	bool ret = false;
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +3 -0
index 9d47d2ab1..2a0cdc6e8 100644
@@ -434,6 +434,8 @@ struct smu_table_context {
 	void				*user_overdrive_table;
 
 	uint32_t			user_od_feature_mask;
+	/* Set when an OD commit/restore changed the UCLK levels */
+	bool				od_uclk_changed;
 
 	struct smu_driver_table driver_tables[SMU_DRIVER_TABLE_COUNT];
 };
@@ -1948,6 +1950,7 @@ int smu_get_ppt_limit(void *handle,
 		      enum pp_power_type pp_power_type);
 
 bool smu_mode1_reset_is_support(struct smu_context *smu);
+bool smu_od_uclk_changed(struct smu_context *smu);
 bool smu_link_reset_is_support(struct smu_context *smu);
 int smu_mode1_reset(struct smu_context *smu);
 int smu_link_reset(struct smu_context *smu);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +32 -1
index a9bf68678..d3b452772 100644
@@ -1198,6 +1198,28 @@ static int smu_v13_0_0_upload_overdrive_table(struct smu_context *smu,
 	return ret;
 }
 
+/*
+ * PMFW rebuilds the UCLK DPM levels from UclkFmin/UclkFmax. Re-read them, so
+ * that pp_dpm_mclk and the soft limits match, and flag the change for DC.
+ */
+static void smu_v13_0_0_od_refresh_uclk_table(struct smu_context *smu)
+{
+	struct smu_13_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context;
+	int ret;
+
+	if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_UCLK_BIT))
+		return;
+
+	ret = smu_v13_0_set_single_dpm_table(smu, SMU_UCLK,
+					     &dpm_context->dpm_tables.uclk_table);
+	if (ret) {
+		dev_err(smu->adev->dev, "Failed to refresh UCLK dpm table!\n");
+		return;
+	}
+
+	smu->smu_table.od_uclk_changed = true;
+}
+
 static int smu_v13_0_0_emit_clk_levels(struct smu_context *smu,
 				       enum smu_clk_type clk_type, char *buf,
 				       int *offset)
@@ -1567,6 +1589,7 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,
 	OverDriveTableExternal_t *od_table =
 		(OverDriveTableExternal_t *)table_context->overdrive_table;
 	struct amdgpu_device *adev = smu->adev;
+	uint32_t prev_od_feature_mask = table_context->user_od_feature_mask;
 	uint32_t offset_of_voltageoffset;
 	int32_t minimum, maximum;
 	int i, ret = 0;
@@ -1912,6 +1935,11 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,
 				return ret;
 			}
 
+			/* UCLK was customized before (restore) or is now (commit) */
+			if ((prev_od_feature_mask | table_context->user_od_feature_mask) &
+			    BIT(PP_OD_FEATURE_UCLK_BIT))
+				smu_v13_0_0_od_refresh_uclk_table(smu);
+
 			memcpy(table_context->user_overdrive_table + offset_of_voltageoffset,
 			       (u8 *)od_table + offset_of_voltageoffset,
 			       sizeof(OverDriveTableExternal_t) - offset_of_voltageoffset);
@@ -2250,8 +2278,11 @@ static int smu_v13_0_0_restore_user_od_settings(struct smu_context *smu)
 		table_context->user_od_feature_mask;
 	res = smu_v13_0_0_upload_overdrive_table(smu, user_od_table);
 	user_od_table->OverDriveTable.FeatureCtrlMask = 0;
-	if (res == 0)
+	if (res == 0) {
 		memcpy(od_table, user_od_table, sizeof(OverDriveTableExternal_t));
+		if (table_context->user_od_feature_mask & BIT(PP_OD_FEATURE_UCLK_BIT))
+			smu_v13_0_0_od_refresh_uclk_table(smu);
+	}
 
 	return res;
 }
Signature · 1 line
2.55.0
#3 lore raw

PATCH v2 3/3 drm/amd: let DC re-read UCLK DPM levels after an OD_MCLK change

In reply to Ilya Shidlovskiy

DC reads the UCLK DPM levels from PMFW only during init_hw (dcn32_init_clocks() -> dcn32_get_memclk_states_from_smu()). Committing an overdrive table with a different UCLK max (OD_MCLK) changes the top UCLK level in PMFW, but nothing tells DC about it. On resume it is even worse: DC init_hw reads the stock table and the user OD table is only restored afterwards from smu_late_init().

With a stale table, DCN3.2 keeps using the stock max_memclk_mhz as the UCLK hard min whenever the current mode does not support P-state switching ("to disable P-State switching, set UCLK min = max"). After raising the UCLK max, that value is no longer the top level, PMFW switches UCLK outside of vblank, and the display shows stripes and eventually hangs (seen on a Navi31 RX 7900 GRE driving 5120x1440@144 with ODM 4:1 + 2560x1440@100).

Add dc_refresh_memclk_states(), which re-reads the memclk states (bounding box and WM ranges included) through dc_lock_memory_clock_frequency(), re-applies the UCLK hard min/max for the current mode and re-sends the WM ranges to PMFW. Call it from a new amdgpu_dm_update_memclk_states() helper when the SMU reports that an OD commit/restore changed the UCLK levels (smu_od_uclk_changed()), after pm.mutex is dropped, and after the user OD settings are restored on resume. Limited to DCN3.2/3.21 for now.

---

Notes:
v2:
- call amdgpu_dm_update_memclk_states() only when the SMU reports a UCLK change (Kenneth), both after an OD commit/restore and on resume. The check lives in the swsmu ASIC code, since PP_OD_FEATURE_UCLK_BIT is ASIC specific and amdgpu_dpm_odn_edit_dpm_table() is shared with powerplay; amdgpu_dpm.c only reads the flag under pm.mutex
- display part unchanged from v1, added Leo's Acked-by for it
- rebased on amd-staging-drm-next

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 ++++
 drivers/gpu/drm/amd/display/dc/core/dc.c      | 21 ++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  7 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     |  3 ++
 6 files changed, 72 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +33 -0
index bdabb4bf1..9cc27d552 100644
@@ -6843,3 +6843,36 @@ void dm_acpi_process_phy_transition_interlock(
 	// Not yet implemented
 }
 EXPORT_IF_KUNIT(dm_acpi_process_phy_transition_interlock);
+
+/**
+ * amdgpu_dm_update_memclk_states() - re-read the UCLK DPM levels from PMFW
+ * @adev: amdgpu device
+ *
+ * DC reads the UCLK DPM table from PMFW only in init_hw. An overdrive commit
+ * (or restoring the user OD table on resume) can change the UCLK levels, which
+ * leaves DC with a stale max_memclk_mhz and bounding box. On DCN3.2 the stale
+ * max is then used as the UCLK hard min when P-state switching is not
+ * supported by the current mode, so PMFW is free to switch UCLK outside of
+ * vblank and the display underflows or hangs.
+ */
+void amdgpu_dm_update_memclk_states(struct amdgpu_device *adev)
+{
+	struct dc *dc = adev->dm.dc;
+	unsigned int max_memclk_mhz;
+
+	if (!dc)
+		return;
+
+	if (dc->ctx->dce_version != DCN_VERSION_3_2 &&
+	    dc->ctx->dce_version != DCN_VERSION_3_21)
+		return;
+
+	mutex_lock(&adev->dm.dc_lock);
+	max_memclk_mhz = dc_refresh_memclk_states(dc);
+	mutex_unlock(&adev->dm.dc_lock);
+
+	if (max_memclk_mhz)
+		drm_info(adev_to_drm(adev),
+			 "DC memclk states refreshed, max UCLK %u MHz\n",
+			 max_memclk_mhz);
+}
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +6 -0
index 594d27591..f5137c15a 100644
@@ -1175,6 +1175,12 @@ void dm_free_gpu_mem(struct amdgpu_device *adev,
 
 bool amdgpu_dm_is_headless(struct amdgpu_device *adev);
 
+#if defined(CONFIG_DRM_AMD_DC)
+void amdgpu_dm_update_memclk_states(struct amdgpu_device *adev);
+#else
+static inline void amdgpu_dm_update_memclk_states(struct amdgpu_device *adev) {}
+#endif
+
 bool amdgpu_dm_crtc_complete_writeback(struct amdgpu_crtc *acrtc);
 
 void retrieve_dmi_info(struct amdgpu_display_manager *dm);
drivers/gpu/drm/amd/display/dc/core/dc.c +21 -0
index f84f659c1..ddb84cc48 100644
@@ -6587,6 +6587,27 @@ void dc_lock_memory_clock_frequency(struct dc *dc)
 		dc->clk_mgr->funcs->set_hard_max_memclk(dc->clk_mgr);
 }
 
+/*
+ * Re-read the memclk DPM levels from PMFW (e.g. after an overdrive change),
+ * refresh the bounding box and WM ranges, and re-apply the UCLK hard min/max
+ * for the current mode. Returns the new max memclk in MHz, 0 if unsupported.
+ */
+unsigned int dc_refresh_memclk_states(struct dc *dc)
+{
+	if (!dc->clk_mgr || !dc->clk_mgr->bw_params ||
+	    !dc->clk_mgr->funcs->get_memclk_states_from_smu)
+		return 0;
+
+	dc_exit_ips_for_hw_access(dc);
+
+	dc_lock_memory_clock_frequency(dc);
+
+	if (dc->clk_mgr->funcs->notify_wm_ranges)
+		dc->clk_mgr->funcs->notify_wm_ranges(dc->clk_mgr);
+
+	return dc->clk_mgr->bw_params->max_memclk_mhz;
+}
+
 static void blank_and_force_memclk(struct dc *dc, bool apply, unsigned int memclk_mhz)
 {
 	(void)apply;
drivers/gpu/drm/amd/display/dc/dc.h +2 -0
index f4fefa7c9..fd82d2d33 100644
@@ -3244,6 +3244,8 @@ void dc_unlock_memory_clock_frequency(struct dc *dc);
 /* set min memory clock to the min required for current mode, max to maxDPM */
 void dc_lock_memory_clock_frequency(struct dc *dc);
 
+unsigned int dc_refresh_memclk_states(struct dc *dc);
+
 /* set soft max for memclk, to be used for AC/DC switching clock limitations */
 void dc_enable_dcmode_clk_limit(struct dc *dc, bool enable);
 
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +7 -0
index 75d8bb486..afa3d9c7e 100644
@@ -1329,6 +1329,7 @@ int amdgpu_dpm_odn_edit_dpm_table(struct amdgpu_device *adev,
 				  uint32_t size)
 {
 	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+	bool uclk_changed = false;
 	int ret = 0;
 
 	if (!pp_funcs->odn_edit_dpm_table)
@@ -1339,8 +1340,14 @@ int amdgpu_dpm_odn_edit_dpm_table(struct amdgpu_device *adev,
 					   type,
 					   input,
 					   size);
+	if (is_support_sw_smu(adev))
+		uclk_changed = smu_od_uclk_changed(adev->powerplay.pp_handle);
 	mutex_unlock(&adev->pm.mutex);
 
+	/* The OD commit changed the UCLK levels, let DC re-read them */
+	if (!ret && uclk_changed)
+		amdgpu_dm_update_memclk_states(adev);
+
 	return ret;
 }
 
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -0
index 490640053..5fa7dd570 100644
@@ -601,6 +601,9 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)
 			ret = smu->ppt_funcs->restore_user_od_settings(smu);
 			if (ret)
 				dev_err(smu->adev->dev, "Failed to upload customized OD settings\n");
+			else if (smu_od_uclk_changed(smu))
+				/* DC read the stock UCLK levels in its init_hw */
+				amdgpu_dm_update_memclk_states(smu->adev);
 		}
 	}
 
Signature · 1 line
2.55.0
maintainer
#4 lore raw
In reply to Ilya Shidlovskiy

AMD General

Could you also please confirm this series is rebased on the below two commits? commit 5cd40ce699014025614140294b8e3b7a847e6472

Author: Kevin Wang <[email protected]>
Date:   Thu Oct 15 14:02:09 2026 +0800

drm/amd/pm: preserve committed OD features for SMU 13.0.0/13.0.7

commit 5a3833e7dd532ac02b4747d1b0d717dd49e87aa6

Author: Kevin Wang <[email protected]>
Date:   Thu Oct 15 14:02:31 2026 +0800

drm/amd/pm: preserve committed OD features for SMU 14.0.2

These two commits have the related code modified for another issue.

With this confirmed, Series is Reviewed-by: Kenneth Feng <[email protected]>

Thanks.

-----Original Message-----
From: Ilya Shidlovskiy <[email protected]>
Sent: Thursday, October 22, 2026 4:09 PM
To: [email protected]
Cc: Ilya Shidlovskiy <[email protected]>; Feng, Kenneth <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: [PATCH v2 0/3] drm/amd: fix DCN3.2 flicker/hangs after OD_MCLK (VRAM overclock)

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

On DCN3.2 (Navi31, RX 7900 GRE here), raising the UCLK max through OD_MCLK makes the display flicker (full-width stripes) and eventually hang the whole system, if the current mode does not allow memory P-state switching. DC reads the UCLK DPM levels from PMFW only in init_hw, so after the OD commit it keeps asking for the old top level as UCLK hard min ("set UCLK min = max"). That is no longer the top level, so PMFW switches UCLK outside of vblank.

The series makes DC re-read the UCLK levels (bounding box and WM ranges
included) after an OD commit/restore that changed UCLK, and on resume after the user OD settings are restored. It also refreshes the SMU driver's UCLK DPM table, so pp_dpm_mclk shows the real levels.

Bug report and review of v1: https://gitlab.freedesktop.org/drm/amd/-/issues/6009
(v1 was posted there as a comment, not to the list.)

Changes in v2:
- Only act when the user has customized UCLK (user_od_feature_mask & PP_OD_FEATURE_UCLK_BIT), instead of on every OD commit (Kenneth). PP_OD_FEATURE_UCLK_BIT is ASIC specific, so the check is done in the smu13.0.0 code, which sets a flag that the generic code reads.
- The SMU patch now comes before the DC patch, which depends on it.
- Rebased on amd-staging-drm-next.
- Added Leo's ack for the display parts.

Testing:
v2 is build-tested against amd-staging-drm-next. The hardware test is on an equivalent backport to the Ubuntu 7.3.0-9 kernel (same code, plus a small local backport of the user_od_feature_mask tracking, which Ubuntu 7.3 does not have yet).

Hardware: RX 7900 GRE (Navi31, SMU 13.0.0), 5120x1440@144 (DSC, ODM 4:1)
+ 2560x1440@100, UCLK OD max 1124 -> 1300 MHz, toggled via LACT.

v1 results:
- On OD commit, DC logs the new max UCLK (1300 MHz). pp_dpm_mclk shows 1300 as the top level, and the current level stays at 1300 (20/20 samples, no drops to 772).
- About 4 minutes of heavy window switching on the 5120x1440@144 output:
no stripes, no hang, no amdgpu errors.
- 3 OC on/off toggles: one short flash exactly at the switch (memory retraining during scanout, expected), then clean.
- Same scenario with the stock module: stripes, then a full system hang.

v2 results:
v2 hardware test (same RX 7900 GRE, 5120x1440@144 + 2560x1440@100; v2 backported to the Ubuntu 7.3.0-9 amdgpu, LACT applying power cap / voltage offset at boot):
- boot and login with stock VRAM: no "DC memclk states refreshed" at all, so
non-UCLK OD commits (power cap, voltage offset) no longer touch DC; the
short login flash seen with v1 is gone;
- VRAM OC on (OD_MCLK 1300): exactly one refresh, "max UCLK 1300 MHz";
pp_dpm_mclk top level 1300 and current level 1300 (12/12 samples);
- VRAM OC off: exactly one refresh, "max UCLK 1124 MHz";
- desktop stays clean, no stripes, no hangs.

Known limitations (unchanged from v1):
- The OD commit itself still happens during scanout, hence the single flash at the switch.
- Only DCN3.2/SMU 13.0.0 is handled. Other ASICs with OD_MCLK probably need the same hook in their ppt code.

Ilya Shidlovskiy (3):
drm/amd/display: dcn32: rebuild WM range table when memclk states
change
drm/amd/pm: smu13.0.0: refresh the UCLK DPM table after an OD_MCLK
change
drm/amd: let DC re-read UCLK DPM levels after an OD_MCLK change

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++++++++++++++++++  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 ++++  .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  |  8 ++---
 drivers/gpu/drm/amd/display/dc/core/dc.c      | 21 ++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  7 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 +++++++++++
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++  .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 33 ++++++++++++++++++-
 9 files changed, 127 insertions(+), 5 deletions(-)

base-commit: 77f548b127c6de34ce271fa09ba270cb1ef9f2da --
2.55.0

#5 lore raw

Hi Kenneth,

Yes, confirmed. The v2 series is based on amd-staging-drm-next at 77f548b12 (“drm/amdgpu: keep PRT mappings off the VM state lists again”, 2026-10-20), which already contains Kevin’s “preserve committed OD features” changes for SMU 13.0.0/13.0.7 and 14.0.2 (the user_od_feature_mask handling that patch 2/3 relies on). The commit hashes in the public branch differ from the ones you quoted, but the code is the same.

Thanks for the review!

Ilya

пт, 23 окт. 2026 г. в 05:31, Feng, Kenneth <[email protected]>:

Quoted 100 lines

AMD General

Could you also please confirm this series is rebased on the below two commits? commit 5cd40ce699014025614140294b8e3b7a847e6472

Author: Kevin Wang <[email protected]>
Date:   Thu Oct 15 14:02:09 2026 +0800

drm/amd/pm: preserve committed OD features for SMU 13.0.0/13.0.7

commit 5a3833e7dd532ac02b4747d1b0d717dd49e87aa6

Author: Kevin Wang <[email protected]>
Date:   Thu Oct 15 14:02:31 2026 +0800

drm/amd/pm: preserve committed OD features for SMU 14.0.2

These two commits have the related code modified for another issue.

With this confirmed, Series is Reviewed-by: Kenneth Feng <[email protected]>

Thanks.

-----Original Message-----
From: Ilya Shidlovskiy <[email protected]>
Sent: Thursday, October 22, 2026 4:09 PM
To: [email protected]
Cc: Ilya Shidlovskiy <[email protected]>; Feng, Kenneth <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: [PATCH v2 0/3] drm/amd: fix DCN3.2 flicker/hangs after OD_MCLK (VRAM overclock)

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

On DCN3.2 (Navi31, RX 7900 GRE here), raising the UCLK max through OD_MCLK makes the display flicker (full-width stripes) and eventually hang the whole system, if the current mode does not allow memory P-state switching. DC reads the UCLK DPM levels from PMFW only in init_hw, so after the OD commit it keeps asking for the old top level as UCLK hard min ("set UCLK min = max"). That is no longer the top level, so PMFW switches UCLK outside of vblank.

The series makes DC re-read the UCLK levels (bounding box and WM ranges
included) after an OD commit/restore that changed UCLK, and on resume after the user OD settings are restored. It also refreshes the SMU driver's UCLK DPM table, so pp_dpm_mclk shows the real levels.

Bug report and review of v1: https://gitlab.freedesktop.org/drm/amd/-/issues/6009
(v1 was posted there as a comment, not to the list.)

Changes in v2:
- Only act when the user has customized UCLK (user_od_feature_mask & PP_OD_FEATURE_UCLK_BIT), instead of on every OD commit (Kenneth). PP_OD_FEATURE_UCLK_BIT is ASIC specific, so the check is done in the smu13.0.0 code, which sets a flag that the generic code reads.
- The SMU patch now comes before the DC patch, which depends on it.
- Rebased on amd-staging-drm-next.
- Added Leo's ack for the display parts.

Testing:
v2 is build-tested against amd-staging-drm-next. The hardware test is on an equivalent backport to the Ubuntu 7.3.0-9 kernel (same code, plus a small local backport of the user_od_feature_mask tracking, which Ubuntu 7.3 does not have yet).

Hardware: RX 7900 GRE (Navi31, SMU 13.0.0), 5120x1440@144 (DSC, ODM 4:1)
+ 2560x1440@100, UCLK OD max 1124 -> 1300 MHz, toggled via LACT.

v1 results:
- On OD commit, DC logs the new max UCLK (1300 MHz). pp_dpm_mclk shows 1300 as the top level, and the current level stays at 1300 (20/20 samples, no drops to 772).
- About 4 minutes of heavy window switching on the 5120x1440@144 output:
no stripes, no hang, no amdgpu errors.
- 3 OC on/off toggles: one short flash exactly at the switch (memory retraining during scanout, expected), then clean.
- Same scenario with the stock module: stripes, then a full system hang.

v2 results:
v2 hardware test (same RX 7900 GRE, 5120x1440@144 + 2560x1440@100; v2 backported to the Ubuntu 7.3.0-9 amdgpu, LACT applying power cap / voltage offset at boot):
- boot and login with stock VRAM: no "DC memclk states refreshed" at all, so
non-UCLK OD commits (power cap, voltage offset) no longer touch DC; the
short login flash seen with v1 is gone;
- VRAM OC on (OD_MCLK 1300): exactly one refresh, "max UCLK 1300 MHz";
pp_dpm_mclk top level 1300 and current level 1300 (12/12 samples);
- VRAM OC off: exactly one refresh, "max UCLK 1124 MHz";
- desktop stays clean, no stripes, no hangs.

Known limitations (unchanged from v1):
- The OD commit itself still happens during scanout, hence the single flash at the switch.
- Only DCN3.2/SMU 13.0.0 is handled. Other ASICs with OD_MCLK probably need the same hook in their ppt code.

Ilya Shidlovskiy (3):
drm/amd/display: dcn32: rebuild WM range table when memclk states
change
drm/amd/pm: smu13.0.0: refresh the UCLK DPM table after an OD_MCLK
change
drm/amd: let DC re-read UCLK DPM levels after an OD_MCLK change

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++++++++++++++++++  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 ++++  .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  |  8 ++---
 drivers/gpu/drm/amd/display/dc/core/dc.c      | 21 ++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  7 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 +++++++++++
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++  .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 33 ++++++++++++++++++-
 9 files changed, 127 insertions(+), 5 deletions(-)

base-commit: 77f548b127c6de34ce271fa09ba270cb1ef9f2da --
2.55.0

#6 lore raw
Quoted 11 lines · Илья Шидловский

Hi Kenneth,

Yes, confirmed. The v2 series is based on amd-staging-drm-next at 77f548b12 (“drm/amdgpu: keep PRT mappings off the VM state lists again”, 2026-10-20), which already contains Kevin’s “preserve committed OD features” changes for SMU 13.0.0/13.0.7 and 14.0.2 (the user_od_feature_mask handling that patch 2/3 relies on). The commit hashes in the public branch differ from the ones you quoted, but the code is the same.

Quoted 1 line

Thanks for the review!

Can you double check that you sent out the right patches? This series doesn't seem to apply with the aforementioned patches in place.

Thanks!

Alex

Quoted 104 lines

Ilya

пт, 23 окт. 2026 г. в 05:31, Feng, Kenneth <[email protected]>:

Quoted 100 lines

AMD General

Could you also please confirm this series is rebased on the below two commits? commit 5cd40ce699014025614140294b8e3b7a847e6472

Author: Kevin Wang <[email protected]>
Date:   Thu Oct 15 14:02:09 2026 +0800

drm/amd/pm: preserve committed OD features for SMU 13.0.0/13.0.7

commit 5a3833e7dd532ac02b4747d1b0d717dd49e87aa6

Author: Kevin Wang <[email protected]>
Date:   Thu Oct 15 14:02:31 2026 +0800

drm/amd/pm: preserve committed OD features for SMU 14.0.2

These two commits have the related code modified for another issue.

With this confirmed, Series is Reviewed-by: Kenneth Feng <[email protected]>

Thanks.

-----Original Message-----
From: Ilya Shidlovskiy <[email protected]>
Sent: Thursday, October 22, 2026 4:09 PM
To: [email protected]
Cc: Ilya Shidlovskiy <[email protected]>; Feng, Kenneth <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: [PATCH v2 0/3] drm/amd: fix DCN3.2 flicker/hangs after OD_MCLK (VRAM overclock)

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

On DCN3.2 (Navi31, RX 7900 GRE here), raising the UCLK max through OD_MCLK makes the display flicker (full-width stripes) and eventually hang the whole system, if the current mode does not allow memory P-state switching. DC reads the UCLK DPM levels from PMFW only in init_hw, so after the OD commit it keeps asking for the old top level as UCLK hard min ("set UCLK min = max"). That is no longer the top level, so PMFW switches UCLK outside of vblank.

The series makes DC re-read the UCLK levels (bounding box and WM ranges
included) after an OD commit/restore that changed UCLK, and on resume after the user OD settings are restored. It also refreshes the SMU driver's UCLK DPM table, so pp_dpm_mclk shows the real levels.

Bug report and review of v1: https://gitlab.freedesktop.org/drm/amd/-/issues/6009
(v1 was posted there as a comment, not to the list.)

Changes in v2:
- Only act when the user has customized UCLK (user_od_feature_mask & PP_OD_FEATURE_UCLK_BIT), instead of on every OD commit (Kenneth). PP_OD_FEATURE_UCLK_BIT is ASIC specific, so the check is done in the smu13.0.0 code, which sets a flag that the generic code reads.
- The SMU patch now comes before the DC patch, which depends on it.
- Rebased on amd-staging-drm-next.
- Added Leo's ack for the display parts.

Testing:
v2 is build-tested against amd-staging-drm-next. The hardware test is on an equivalent backport to the Ubuntu 7.3.0-9 kernel (same code, plus a small local backport of the user_od_feature_mask tracking, which Ubuntu 7.3 does not have yet).

Hardware: RX 7900 GRE (Navi31, SMU 13.0.0), 5120x1440@144 (DSC, ODM 4:1)
+ 2560x1440@100, UCLK OD max 1124 -> 1300 MHz, toggled via LACT.

v1 results:
- On OD commit, DC logs the new max UCLK (1300 MHz). pp_dpm_mclk shows 1300 as the top level, and the current level stays at 1300 (20/20 samples, no drops to 772).
- About 4 minutes of heavy window switching on the 5120x1440@144 output:
no stripes, no hang, no amdgpu errors.
- 3 OC on/off toggles: one short flash exactly at the switch (memory retraining during scanout, expected), then clean.
- Same scenario with the stock module: stripes, then a full system hang.

v2 results:
v2 hardware test (same RX 7900 GRE, 5120x1440@144 + 2560x1440@100; v2 backported to the Ubuntu 7.3.0-9 amdgpu, LACT applying power cap / voltage offset at boot):
- boot and login with stock VRAM: no "DC memclk states refreshed" at all, so
non-UCLK OD commits (power cap, voltage offset) no longer touch DC; the
short login flash seen with v1 is gone;
- VRAM OC on (OD_MCLK 1300): exactly one refresh, "max UCLK 1300 MHz";
pp_dpm_mclk top level 1300 and current level 1300 (12/12 samples);
- VRAM OC off: exactly one refresh, "max UCLK 1124 MHz";
- desktop stays clean, no stripes, no hangs.

Known limitations (unchanged from v1):
- The OD commit itself still happens during scanout, hence the single flash at the switch.
- Only DCN3.2/SMU 13.0.0 is handled. Other ASICs with OD_MCLK probably need the same hook in their ppt code.

Ilya Shidlovskiy (3):
drm/amd/display: dcn32: rebuild WM range table when memclk states
change
drm/amd/pm: smu13.0.0: refresh the UCLK DPM table after an OD_MCLK
change
drm/amd: let DC re-read UCLK DPM levels after an OD_MCLK change

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++++++++++++++++++  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 ++++  .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  |  8 ++---
 drivers/gpu/drm/amd/display/dc/core/dc.c      | 21 ++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  7 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 +++++++++++
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++  .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 33 ++++++++++++++++++-
 9 files changed, 127 insertions(+), 5 deletions(-)

base-commit: 77f548b127c6de34ce271fa09ba270cb1ef9f2da --
2.55.0

#7 lore raw

v3 cover drm/amd: fix DCN3.2 flicker/hangs after OD_MCLK (VRAM overclock)

On DCN3.2 (Navi31, RX 7900 GRE here), raising the UCLK max through OD_MCLK makes the display flicker (full-width stripes) and eventually hang the whole system, if the current mode does not allow memory P-state switching. DC reads the UCLK DPM levels from PMFW only in init_hw, so after the OD commit it keeps asking for the old top level as UCLK hard min ("set UCLK min = max"). That is no longer the top level, so PMFW switches UCLK outside of vblank.

The series makes DC re-read the UCLK levels (bounding box and WM ranges included) after an OD commit/restore that changed UCLK, and on resume after the user OD settings are restored. It also refreshes the SMU driver's UCLK DPM table, so pp_dpm_mclk shows the real levels.

Bug report and review of v1: https://gitlab.freedesktop.org/drm/amd/-/issues/6009
(v1 was posted there as a comment, not to the list.)

Changes in v3:
- Rebased on top of Kevin Wang's "preserve committed OD features" patches for SMU 13.0.0/13.0.7 and 14.0.2. v2 was based on an older amd-staging-drm-next that did not have them yet, so it did not apply; sorry about the wrong confirmation earlier. Only patch 2/3 needed a conflict resolution: the UCLK check now uses Kevin's next_mask, with the same logic as before (details in the patch notes). Kenneth, please double-check that your Reviewed-by still holds for it.
- Added Kenneth's Reviewed-by.

Changes in v2:
- Only act when the user has customized UCLK (user_od_feature_mask & PP_OD_FEATURE_UCLK_BIT), instead of on every OD commit (Kenneth). PP_OD_FEATURE_UCLK_BIT is ASIC specific, so the check is done in the smu13.0.0 code, which sets a flag that the generic code reads.
- The SMU patch now comes before the DC patch, which depends on it.
- Rebased on amd-staging-drm-next.
- Added Leo's ack for the display parts.

Testing:
v3 is build-tested (W=1, no new warnings) against amd-staging-drm-next ba496bb83, which includes Kevin's patches. The hardware test is on an equivalent backport to the Ubuntu 7.3.0-9 kernel (same code, plus a small local backport of the user_od_feature_mask tracking, which Ubuntu 7.3 does not have yet).

Hardware: RX 7900 GRE (Navi31, SMU 13.0.0), 5120x1440@144 (DSC, ODM 4:1)
+ 2560x1440@100, UCLK OD max 1124 -> 1300 MHz, toggled via LACT.

v1 results:
- On OD commit, DC logs the new max UCLK (1300 MHz). pp_dpm_mclk shows 1300 as the top level, and the current level stays at 1300 (20/20 samples, no drops to 772).
- About 4 minutes of heavy window switching on the 5120x1440@144 output:
no stripes, no hang, no amdgpu errors.
- 3 OC on/off toggles: one short flash exactly at the switch (memory retraining during scanout, expected), then clean.
- Same scenario with the stock module: stripes, then a full system hang.

v2 results:
v2 hardware test (same RX 7900 GRE, 5120x1440@144 + 2560x1440@100; v2 backported to the Ubuntu 7.3.0-9 amdgpu, LACT applying power cap / voltage offset at boot):
- boot and login with stock VRAM: no "DC memclk states refreshed" at all, so non-UCLK OD commits (power cap, voltage offset) no longer touch DC; the short login flash seen with v1 is gone;
- VRAM OC on (OD_MCLK 1300): exactly one refresh, "max UCLK 1300 MHz"; pp_dpm_mclk top level 1300 and current level 1300 (12/12 samples);
- VRAM OC off: exactly one refresh, "max UCLK 1124 MHz";
- desktop stays clean, no stripes, no hangs.

Known limitations (unchanged from v1):
- The OD commit itself still happens during scanout, hence the single flash at the switch.
- Only DCN3.2/SMU 13.0.0 is handled. Other ASICs with OD_MCLK probably need the same hook in their ppt code.

Ilya Shidlovskiy (3):
drm/amd/display: dcn32: rebuild WM range table when memclk states
change
drm/amd/pm: smu13.0.0: refresh the UCLK DPM table after an OD_MCLK
change
drm/amd: let DC re-read UCLK DPM levels after an OD_MCLK change

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 ++++
 .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  |  8 ++---
 drivers/gpu/drm/amd/display/dc/core/dc.c      | 21 ++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  7 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 +++++++++++
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 30 +++++++++++++++++
 9 files changed, 125 insertions(+), 4 deletions(-)

base-commit: ba496bb837882eb1af58f41572fc289e46c77b8c

Signature · 1 line
2.55.0
#8 lore raw

PATCH v3 1/3 drm/amd/display: dcn32: rebuild WM range table when memclk states change

dcn32_get_memclk_states_from_smu() refreshes the UCLK levels, max_memclk_mhz and the bounding box, but the watermark range table and the dummy P-state table (which are derived from the same memclk levels) are only built once in dcn32_init_clocks(). Build them at the end of dcn32_get_memclk_states_from_smu() instead, so that every caller which re-reads the memclk states from PMFW also gets matching WM ranges.

No functional change for the init path.

---

Notes:
v3:
- rebased on top of Kevin Wang's "preserve committed OD features" patches, no changes
v2:
- rebased on amd-staging-drm-next, no code changes
- added Leo's Acked-by (given in drm/amd#6009)

 .../gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c +4 -4
index 22dfca6ef..7abb13ffd 100644
@@ -256,11 +256,8 @@ void dcn32_init_clocks(struct clk_mgr *clk_mgr_base)
 		if (clk_mgr_base->bw_params->clk_table.entries[i].dppclk_mhz > 1950)
 			clk_mgr_base->bw_params->clk_table.entries[i].dppclk_mhz = 1950;
 
-	/* Get UCLK, update bounding box */
+	/* Get UCLK, update bounding box and WM range table */
 	clk_mgr_base->funcs->get_memclk_states_from_smu(clk_mgr_base);
-
-	/* WM range table */
-	dcn32_build_wm_range_table(clk_mgr);
 }
 
 static void dcn32_update_clocks_update_dtb_dto(struct clk_mgr_internal *clk_mgr,
@@ -1079,6 +1076,9 @@ static void dcn32_get_memclk_states_from_smu(struct clk_mgr *clk_mgr_base)
 	/* Refresh bounding box */
 	clk_mgr_base->ctx->dc->res_pool->funcs->update_bw_bounding_box(
 			clk_mgr->base.ctx->dc, clk_mgr_base->bw_params);
+
+	/* WM range table and dummy P-state table depend on the memclk levels */
+	dcn32_build_wm_range_table(clk_mgr);
 }
 
 static bool dcn32_are_clock_states_equal(struct dc_clocks *a,
Signature · 1 line
2.55.0
#9 lore raw

PATCH v3 2/3 drm/amd/pm: smu13.0.0: refresh the UCLK DPM table after an OD_MCLK change

In reply to Ilya Shidlovskiy

The UCLK DPM table in the driver is only populated by smu_v13_0_0_set_default_dpm_table(). After an overdrive table with a different UclkFmax is uploaded, pp_dpm_mclk keeps showing the stock top level, and the "high"/"auto" soft limits are derived from the stale table.

Re-read the UCLK levels from PMFW after a successful OD commit or restore, but only when the user has customized UCLK (PP_OD_FEATURE_UCLK_BIT in user_od_feature_mask, before or after the operation, so that restoring the defaults is covered too). Do the same when the user OD settings are restored on resume.

Also record the change in a new smu_table_context->od_uclk_changed flag, with smu_od_uclk_changed() to test and clear it. PP_OD_FEATURE_UCLK_BIT is ASIC specific (8 on SMU 13.0.x, 9 on SMU 14.0.2), so this lets the generic code tell DC to re-read the levels without knowing the OD table layout.

---

Notes:
v3:
- rebased on top of Kevin Wang's "preserve committed OD features" patches. The commit and resume paths now upload a copy with next_mask; the UCLK check uses (prev_od_feature_mask | next_mask) on commit and next_mask on resume. Same logic as v2: normalize clears the UCLK bit when UCLK is back at boot values, and the previous mask still catches that.
- prev_od_feature_mask is u32, like the surrounding code
v2:
- only refresh the UCLK table when the user has customized UCLK (user_od_feature_mask & PP_OD_FEATURE_UCLK_BIT), instead of on every OD upload (Kenneth)
- add the od_uclk_changed flag and smu_od_uclk_changed(), used by the DC hook in the next patch
- moved before the DC patch (was 3/3)

 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 16 ++++++++++
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 30 +++++++++++++++++++
 3 files changed, 49 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +16 -0
index a901f8535..490640053 100644
@@ -3665,6 +3665,22 @@ static int smu_baco_set_state(void *handle, int state)
 	return ret;
 }
 
+/**
+ * smu_od_uclk_changed - test and clear the "UCLK OD changed" flag
+ * @smu: smu context
+ *
+ * The ASIC code sets the flag when an overdrive commit or restore changed the
+ * UCLK DPM levels, so that callers can tell DC to re-read them.
+ */
+bool smu_od_uclk_changed(struct smu_context *smu)
+{
+	bool changed = smu->smu_table.od_uclk_changed;
+
+	smu->smu_table.od_uclk_changed = false;
+
+	return changed;
+}
+
 bool smu_mode1_reset_is_support(struct smu_context *smu)
 {
 	bool ret = false;
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +3 -0
index 9d47d2ab1..2a0cdc6e8 100644
@@ -434,6 +434,8 @@ struct smu_table_context {
 	void				*user_overdrive_table;
 
 	uint32_t			user_od_feature_mask;
+	/* Set when an OD commit/restore changed the UCLK levels */
+	bool				od_uclk_changed;
 
 	struct smu_driver_table driver_tables[SMU_DRIVER_TABLE_COUNT];
 };
@@ -1948,6 +1950,7 @@ int smu_get_ppt_limit(void *handle,
 		      enum pp_power_type pp_power_type);
 
 bool smu_mode1_reset_is_support(struct smu_context *smu);
+bool smu_od_uclk_changed(struct smu_context *smu);
 bool smu_link_reset_is_support(struct smu_context *smu);
 int smu_mode1_reset(struct smu_context *smu);
 int smu_link_reset(struct smu_context *smu);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +30 -0
index 14b2acd36..1a02ba70d 100644
@@ -1288,6 +1288,28 @@ static int smu_v13_0_0_upload_overdrive_table(struct smu_context *smu,
 	return ret;
 }
 
+/*
+ * PMFW rebuilds the UCLK DPM levels from UclkFmin/UclkFmax. Re-read them, so
+ * that pp_dpm_mclk and the soft limits match, and flag the change for DC.
+ */
+static void smu_v13_0_0_od_refresh_uclk_table(struct smu_context *smu)
+{
+	struct smu_13_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context;
+	int ret;
+
+	if (!smu_cmn_feature_is_enabled(smu, SMU_FEATURE_DPM_UCLK_BIT))
+		return;
+
+	ret = smu_v13_0_set_single_dpm_table(smu, SMU_UCLK,
+					     &dpm_context->dpm_tables.uclk_table);
+	if (ret) {
+		dev_err(smu->adev->dev, "Failed to refresh UCLK dpm table!\n");
+		return;
+	}
+
+	smu->smu_table.od_uclk_changed = true;
+}
+
 static int smu_v13_0_0_emit_clk_levels(struct smu_context *smu,
 				       enum smu_clk_type clk_type, char *buf,
 				       int *offset)
@@ -1653,6 +1675,7 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,
 	OverDriveTable_t *od = &od_table->OverDriveTable;
 	OverDriveTable_t *boot = &boot_od_table->OverDriveTable;
 	struct amdgpu_device *adev = smu->adev;
+	u32 prev_od_feature_mask = table_context->user_od_feature_mask;
 	uint32_t offset_of_voltageoffset;
 	int32_t minimum, maximum;
 	u32 next_mask;
@@ -2007,6 +2030,11 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,
 
 			table_context->user_od_feature_mask = next_mask;
 			od_table->OverDriveTable.FeatureCtrlMask = 0;
+
+			/* UCLK was customized before (restore) or is now (commit) */
+			if ((prev_od_feature_mask | next_mask) & BIT(PP_OD_FEATURE_UCLK_BIT))
+				smu_v13_0_0_od_refresh_uclk_table(smu);
+
 			memcpy((u8 *)user_od_table + offset_of_voltageoffset,
 			       (u8 *)od_table + offset_of_voltageoffset,
 			       sizeof(OverDriveTableExternal_t) - offset_of_voltageoffset);
@@ -2362,6 +2390,8 @@ static int smu_v13_0_0_restore_user_od_settings(struct smu_context *smu)
 			!!(next_mask & ~BIT(PP_OD_FEATURE_PPT_BIT));
 		memcpy(od_table, user_od_table, sizeof(OverDriveTableExternal_t));
 		od_table->OverDriveTable.FeatureCtrlMask = 0;
+		if (next_mask & BIT(PP_OD_FEATURE_UCLK_BIT))
+			smu_v13_0_0_od_refresh_uclk_table(smu);
 	}
 
 	return res;
Signature · 1 line
2.55.0
#10 lore raw

PATCH v3 3/3 drm/amd: let DC re-read UCLK DPM levels after an OD_MCLK change

In reply to Ilya Shidlovskiy

DC reads the UCLK DPM levels from PMFW only during init_hw (dcn32_init_clocks() -> dcn32_get_memclk_states_from_smu()). Committing an overdrive table with a different UCLK max (OD_MCLK) changes the top UCLK level in PMFW, but nothing tells DC about it. On resume it is even worse: DC init_hw reads the stock table and the user OD table is only restored afterwards from smu_late_init().

With a stale table, DCN3.2 keeps using the stock max_memclk_mhz as the UCLK hard min whenever the current mode does not support P-state switching ("to disable P-State switching, set UCLK min = max"). After raising the UCLK max, that value is no longer the top level, PMFW switches UCLK outside of vblank, and the display shows stripes and eventually hangs (seen on a Navi31 RX 7900 GRE driving 5120x1440@144 with ODM 4:1 + 2560x1440@100).

Add dc_refresh_memclk_states(), which re-reads the memclk states (bounding box and WM ranges included) through dc_lock_memory_clock_frequency(), re-applies the UCLK hard min/max for the current mode and re-sends the WM ranges to PMFW. Call it from a new amdgpu_dm_update_memclk_states() helper when the SMU reports that an OD commit/restore changed the UCLK levels (smu_od_uclk_changed()), after pm.mutex is dropped, and after the user OD settings are restored on resume. Limited to DCN3.2/3.21 for now.

---

Notes:
v3:
- rebased on top of Kevin Wang's "preserve committed OD features" patches, no changes
v2:
- call amdgpu_dm_update_memclk_states() only when the SMU reports a UCLK change (Kenneth); the check lives in the swsmu ASIC code, since PP_OD_FEATURE_UCLK_BIT is ASIC specific
- display part unchanged from v1, added Leo's Acked-by for it

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 ++++
 drivers/gpu/drm/amd/display/dc/core/dc.c      | 21 ++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  7 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     |  3 ++
 6 files changed, 72 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +33 -0
index dfbc384fb..370d349cd 100644
@@ -6837,3 +6837,36 @@ void dm_acpi_process_phy_transition_interlock(
 	// Not yet implemented
 }
 EXPORT_IF_KUNIT(dm_acpi_process_phy_transition_interlock);
+
+/**
+ * amdgpu_dm_update_memclk_states() - re-read the UCLK DPM levels from PMFW
+ * @adev: amdgpu device
+ *
+ * DC reads the UCLK DPM table from PMFW only in init_hw. An overdrive commit
+ * (or restoring the user OD table on resume) can change the UCLK levels, which
+ * leaves DC with a stale max_memclk_mhz and bounding box. On DCN3.2 the stale
+ * max is then used as the UCLK hard min when P-state switching is not
+ * supported by the current mode, so PMFW is free to switch UCLK outside of
+ * vblank and the display underflows or hangs.
+ */
+void amdgpu_dm_update_memclk_states(struct amdgpu_device *adev)
+{
+	struct dc *dc = adev->dm.dc;
+	unsigned int max_memclk_mhz;
+
+	if (!dc)
+		return;
+
+	if (dc->ctx->dce_version != DCN_VERSION_3_2 &&
+	    dc->ctx->dce_version != DCN_VERSION_3_21)
+		return;
+
+	mutex_lock(&adev->dm.dc_lock);
+	max_memclk_mhz = dc_refresh_memclk_states(dc);
+	mutex_unlock(&adev->dm.dc_lock);
+
+	if (max_memclk_mhz)
+		drm_info(adev_to_drm(adev),
+			 "DC memclk states refreshed, max UCLK %u MHz\n",
+			 max_memclk_mhz);
+}
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +6 -0
index 656aa0e46..95a4b0d50 100644
@@ -1179,6 +1179,12 @@ void dm_free_gpu_mem(struct amdgpu_device *adev,
 
 bool amdgpu_dm_is_headless(struct amdgpu_device *adev);
 
+#if defined(CONFIG_DRM_AMD_DC)
+void amdgpu_dm_update_memclk_states(struct amdgpu_device *adev);
+#else
+static inline void amdgpu_dm_update_memclk_states(struct amdgpu_device *adev) {}
+#endif
+
 bool amdgpu_dm_crtc_complete_writeback(struct amdgpu_crtc *acrtc);
 
 void retrieve_dmi_info(struct amdgpu_display_manager *dm);
drivers/gpu/drm/amd/display/dc/core/dc.c +21 -0
index ae5f03a73..471cb99a1 100644
@@ -6628,6 +6628,27 @@ void dc_lock_memory_clock_frequency(struct dc *dc)
 		dc->clk_mgr->funcs->set_hard_max_memclk(dc->clk_mgr);
 }
 
+/*
+ * Re-read the memclk DPM levels from PMFW (e.g. after an overdrive change),
+ * refresh the bounding box and WM ranges, and re-apply the UCLK hard min/max
+ * for the current mode. Returns the new max memclk in MHz, 0 if unsupported.
+ */
+unsigned int dc_refresh_memclk_states(struct dc *dc)
+{
+	if (!dc->clk_mgr || !dc->clk_mgr->bw_params ||
+	    !dc->clk_mgr->funcs->get_memclk_states_from_smu)
+		return 0;
+
+	dc_exit_ips_for_hw_access(dc);
+
+	dc_lock_memory_clock_frequency(dc);
+
+	if (dc->clk_mgr->funcs->notify_wm_ranges)
+		dc->clk_mgr->funcs->notify_wm_ranges(dc->clk_mgr);
+
+	return dc->clk_mgr->bw_params->max_memclk_mhz;
+}
+
 static void blank_and_force_memclk(struct dc *dc, bool apply, unsigned int memclk_mhz)
 {
 	(void)apply;
drivers/gpu/drm/amd/display/dc/dc.h +2 -0
index d983bab7e..bf8e1aba3 100644
@@ -3263,6 +3263,8 @@ void dc_unlock_memory_clock_frequency(struct dc *dc);
 /* set min memory clock to the min required for current mode, max to maxDPM */
 void dc_lock_memory_clock_frequency(struct dc *dc);
 
+unsigned int dc_refresh_memclk_states(struct dc *dc);
+
 /* set soft max for memclk, to be used for AC/DC switching clock limitations */
 void dc_enable_dcmode_clk_limit(struct dc *dc, bool enable);
 
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +7 -0
index 75d8bb486..afa3d9c7e 100644
@@ -1329,6 +1329,7 @@ int amdgpu_dpm_odn_edit_dpm_table(struct amdgpu_device *adev,
 				  uint32_t size)
 {
 	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+	bool uclk_changed = false;
 	int ret = 0;
 
 	if (!pp_funcs->odn_edit_dpm_table)
@@ -1339,8 +1340,14 @@ int amdgpu_dpm_odn_edit_dpm_table(struct amdgpu_device *adev,
 					   type,
 					   input,
 					   size);
+	if (is_support_sw_smu(adev))
+		uclk_changed = smu_od_uclk_changed(adev->powerplay.pp_handle);
 	mutex_unlock(&adev->pm.mutex);
 
+	/* The OD commit changed the UCLK levels, let DC re-read them */
+	if (!ret && uclk_changed)
+		amdgpu_dm_update_memclk_states(adev);
+
 	return ret;
 }
 
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -0
index 490640053..5fa7dd570 100644
@@ -601,6 +601,9 @@ static void smu_restore_dpm_user_profile(struct smu_context *smu)
 			ret = smu->ppt_funcs->restore_user_od_settings(smu);
 			if (ret)
 				dev_err(smu->adev->dev, "Failed to upload customized OD settings\n");
+			else if (smu_od_uclk_changed(smu))
+				/* DC read the stock UCLK levels in its init_hw */
+				amdgpu_dm_update_memclk_states(smu->adev);
 		}
 	}
 
Signature · 1 line
2.55.0
Applied
#11 lore raw
In reply to Ilya Shidlovskiy

Applied the series. Thanks!

Alex

Quoted 96 lines · Ilya Shidlovskiy

On DCN3.2 (Navi31, RX 7900 GRE here), raising the UCLK max through OD_MCLK makes the display flicker (full-width stripes) and eventually hang the whole system, if the current mode does not allow memory P-state switching. DC reads the UCLK DPM levels from PMFW only in init_hw, so after the OD commit it keeps asking for the old top level as UCLK hard min ("set UCLK min = max"). That is no longer the top level, so PMFW switches UCLK outside of vblank.

The series makes DC re-read the UCLK levels (bounding box and WM ranges included) after an OD commit/restore that changed UCLK, and on resume after the user OD settings are restored. It also refreshes the SMU driver's UCLK DPM table, so pp_dpm_mclk shows the real levels.

Bug report and review of v1: https://gitlab.freedesktop.org/drm/amd/-/issues/6009
(v1 was posted there as a comment, not to the list.)

Changes in v3:
- Rebased on top of Kevin Wang's "preserve committed OD features" patches for SMU 13.0.0/13.0.7 and 14.0.2. v2 was based on an older amd-staging-drm-next that did not have them yet, so it did not apply; sorry about the wrong confirmation earlier. Only patch 2/3 needed a conflict resolution: the UCLK check now uses Kevin's next_mask, with the same logic as before (details in the patch notes). Kenneth, please double-check that your Reviewed-by still holds for it.
- Added Kenneth's Reviewed-by.

Changes in v2:
- Only act when the user has customized UCLK (user_od_feature_mask & PP_OD_FEATURE_UCLK_BIT), instead of on every OD commit (Kenneth). PP_OD_FEATURE_UCLK_BIT is ASIC specific, so the check is done in the smu13.0.0 code, which sets a flag that the generic code reads.
- The SMU patch now comes before the DC patch, which depends on it.
- Rebased on amd-staging-drm-next.
- Added Leo's ack for the display parts.

Testing:
v3 is build-tested (W=1, no new warnings) against amd-staging-drm-next ba496bb83, which includes Kevin's patches. The hardware test is on an equivalent backport to the Ubuntu 7.3.0-9 kernel (same code, plus a small local backport of the user_od_feature_mask tracking, which Ubuntu 7.3 does not have yet).

Hardware: RX 7900 GRE (Navi31, SMU 13.0.0), 5120x1440@144 (DSC, ODM 4:1)
+ 2560x1440@100, UCLK OD max 1124 -> 1300 MHz, toggled via LACT.

v1 results:
- On OD commit, DC logs the new max UCLK (1300 MHz). pp_dpm_mclk shows 1300 as the top level, and the current level stays at 1300 (20/20 samples, no drops to 772).
- About 4 minutes of heavy window switching on the 5120x1440@144 output:
no stripes, no hang, no amdgpu errors.
- 3 OC on/off toggles: one short flash exactly at the switch (memory retraining during scanout, expected), then clean.
- Same scenario with the stock module: stripes, then a full system hang.

v2 results:
v2 hardware test (same RX 7900 GRE, 5120x1440@144 + 2560x1440@100; v2 backported to the Ubuntu 7.3.0-9 amdgpu, LACT applying power cap / voltage offset at boot):
- boot and login with stock VRAM: no "DC memclk states refreshed" at all, so non-UCLK OD commits (power cap, voltage offset) no longer touch DC; the short login flash seen with v1 is gone;
- VRAM OC on (OD_MCLK 1300): exactly one refresh, "max UCLK 1300 MHz"; pp_dpm_mclk top level 1300 and current level 1300 (12/12 samples);
- VRAM OC off: exactly one refresh, "max UCLK 1124 MHz";
- desktop stays clean, no stripes, no hangs.

Known limitations (unchanged from v1):
- The OD commit itself still happens during scanout, hence the single flash at the switch.
- Only DCN3.2/SMU 13.0.0 is handled. Other ASICs with OD_MCLK probably need the same hook in their ppt code.

Ilya Shidlovskiy (3):
drm/amd/display: dcn32: rebuild WM range table when memclk states
change
drm/amd/pm: smu13.0.0: refresh the UCLK DPM table after an OD_MCLK
change
drm/amd: let DC re-read UCLK DPM levels after an OD_MCLK change

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++++++++++++++++++
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |  6 ++++
 .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  |  8 ++---
 drivers/gpu/drm/amd/display/dc/core/dc.c      | 21 ++++++++++++
 drivers/gpu/drm/amd/display/dc/dc.h           |  2 ++
 drivers/gpu/drm/amd/pm/amdgpu_dpm.c           |  7 ++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 +++++++++++
 drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h |  3 ++
 .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c  | 30 +++++++++++++++++
 9 files changed, 125 insertions(+), 4 deletions(-)

base-commit: ba496bb837882eb1af58f41572fc289e46c77b8c --
2.55.0