Skip to contentSkip to conversation

FAILED: patch "[PATCH] drm/amd/display: Seed boot clocks to avoid lowering pre-OS" failed to apply to 7.3-stable tree

PATCH New [email protected] 2 participants 2 messages Dec 2 – Dec 4

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 7.3-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.3.y
git checkout FETCH_HEAD
git cherry-pick -x eaf4ff850d97eb608482fa3497f1b89b2e628781
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026120251-strength-outrank-ea4c@gregkh' --subject-prefix 'PATCH 7.3.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From eaf4ff850d97eb608482fa3497f1b89b2e628781 Mon Sep 17 00:00:00 2001
From: Jing Zhou <[email protected]>
Date: Thu, 5 Nov 2026 23:20:58 +0800
Subject: [PATCH] drm/amd/display: Seed boot clocks to avoid lowering pre-OS
display clocks

[WHY]
USB4 DPIA HPD can arrive early in boot, before the first stream commit. Its link detection runs prepare_phy_clocks(), which goes through clk_mgr_exit_optimized_pwr_state() and clk_mgr_optimize_pwr_state() and calls update_clocks(dc->current_state).

At that point both dc->current_state->bw_ctx.bw.dcn.clk and clk_mgr->clks are still zero, because init_clocks() memsets them. On the safe_to_lower path, dcn42_update_clocks() clamps the requested DPPCLK to the 100MHz floor and programs it. This drops DPPCLK below what the GOP-lit eDP pipe needs, and the panel flashes white.

[HOW]
1. In dcn42_init_clocks() and dcn42b_init_clocks(), seed clk_mgr->clks dispclk/dppclk from the boot snapshot(10kHz units, x10).
2. Add a DC core helper, sync_current_state_clocks_from_clk_mgr(). After every hwss.init_hw() call (legacy_hardware_init, D0 entry in dc_set_power_state, and dc_reinitialize_hardware), it copies clk_mgr->clks into dc->current_state->bw_ctx.bw.dcn.clk for DCN. A later update_clocks() before the first commit then sees the real pre-OS clocks and does not lower them. Raising clocks is still allowed and does not cause a flash.

Cc Nicholas Kazlauskas <[email protected]>
Cc Charlene Liu <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Alex Deucher <[email protected]>
(cherry picked from commit 2f289740a04f08a5ce4b5e3c69af6e32ab4a540e)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42/dcn42_clk_mgr.c +3 -0
index 405145889ba2..ae3d762955a9 100644
@@ -643,6 +643,9 @@ DC_LOGGER_INIT(clk_mgr_base->ctx->logger);
 	DC_LOG_SMU("dp_dto_source_clock %d, dprefclk %d\n", clk_mgr_base->dp_dto_source_clock_in_khz, clk_mgr_base->dprefclk_khz);
 	dcn42_dump_clk_registers(&clk_mgr_base->boot_snapshot, clk_mgr);
 
+	/* Snapshot is in 10kHz units; seed clks so update_clocks() does not lower the pre-OS clocks */
+	clk_mgr_base->clks.dispclk_khz = clk_mgr_base->boot_snapshot.dispclk * 10;
+	clk_mgr_base->clks.dppclk_khz = clk_mgr_base->boot_snapshot.dppclk * 10;
 	clk_mgr_base->clks.ref_dtbclk_khz =  clk_mgr_base->boot_snapshot.dtbclk * 10;
 	clk_mgr_base->clks.dtbclk_en = clk_mgr_base->boot_snapshot.dtbclk > 59000;
 }
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42b/dcn42b_clk_mgr.c +4 -0
index d500a3210eed..6aacc4f77ae7 100644
@@ -242,6 +242,10 @@ DC_LOGGER_INIT(clk_mgr_base->ctx->logger);
 
 	DC_LOG_SMU("dp_dto_source_clock %d, dprefclk %d\n", clk_mgr_base->dp_dto_source_clock_in_khz, clk_mgr_base->dprefclk_khz);
 	dcn42b_dump_clk_registers(&clk_mgr_base->boot_snapshot, clk_mgr);
+
+	/* Snapshot is in 10kHz units; seed clks so update_clocks() does not lower the pre-OS clocks */
+	clk_mgr_base->clks.dispclk_khz = clk_mgr_base->boot_snapshot.dispclk * 10;
+	clk_mgr_base->clks.dppclk_khz = clk_mgr_base->boot_snapshot.dppclk * 10;
 }
 
 static struct clk_bw_params dcn42b_bw_params = {
drivers/gpu/drm/amd/display/dc/core/dc.c +15 -1
index 348e8991f870..422612da44d3 100644
@@ -1663,12 +1663,25 @@ static void detect_edp_presence(struct dc *dc)
 	}
 }
 
+static void sync_current_state_clocks_from_clk_mgr(struct dc *dc)
+{
+	if (!dc->current_state || !dc->clk_mgr)
+		return;
+
+	if (!(dc->ctx->dce_version == DCN_VERSION_4_2 || dc->ctx->dce_version == DCN_VERSION_4_2B))
+		return;
+
+	dc->current_state->bw_ctx.bw.dcn.clk = dc->clk_mgr->clks;
+}
+
 void legacy_hardware_init(struct dc *dc)
 {
 
 	detect_edp_presence(dc);
-	if (dc->ctx->dce_environment != DCE_ENV_VIRTUAL_HW)
+	if (dc->ctx->dce_environment != DCE_ENV_VIRTUAL_HW) {
 		dc->hwss.init_hw(dc);
+		sync_current_state_clocks_from_clk_mgr(dc);
+	}
 	dc_dmub_srv_notify_fw_dc_power_state(dc->ctx->dmub_srv, DC_ACPI_CM_POWER_STATE_D0);
 }
 
@@ -6312,6 +6325,7 @@ void dc_set_power_state(struct dc *dc, enum dc_acpi_cm_power_state power_state)
 		dc_dmub_srv_notify_fw_dc_power_state(dc->ctx->dmub_srv, power_state);
 
 		dc->hwss.init_hw(dc);
+		sync_current_state_clocks_from_clk_mgr(dc);
 
 		if (dc->hwss.init_sys_ctx != NULL &&
 			dc->vm_pa_config.valid) {
maintainer
#1 lore raw

PATCH 1/1 drm/amd/display: Seed boot clocks to avoid lowering pre-OS display clocks

From: Jing Zhou <[email protected]>

[ Upstream commit eaf4ff850d97eb608482fa3497f1b89b2e628781 ]

[WHY]
USB4 DPIA HPD can arrive early in boot, before the first stream commit. Its link detection runs prepare_phy_clocks(), which goes through clk_mgr_exit_optimized_pwr_state() and clk_mgr_optimize_pwr_state() and calls update_clocks(dc->current_state).

At that point both dc->current_state->bw_ctx.bw.dcn.clk and clk_mgr->clks are still zero, because init_clocks() memsets them. On the safe_to_lower path, dcn42_update_clocks() clamps the requested DPPCLK to the 100MHz floor and programs it. This drops DPPCLK below what the GOP-lit eDP pipe needs, and the panel flashes white.

[HOW]
1. In dcn42_init_clocks() and dcn42b_init_clocks(), seed clk_mgr->clks dispclk/dppclk from the boot snapshot(10kHz units, x10).
2. Add a DC core helper, sync_current_state_clocks_from_clk_mgr(). After every hwss.init_hw() call (legacy_hardware_init, D0 entry in dc_set_power_state, and dc_reinitialize_hardware), it copies clk_mgr->clks into dc->current_state->bw_ctx.bw.dcn.clk for DCN. A later update_clocks() before the first commit then sees the real pre-OS clocks and does not lower them. Raising clocks is still allowed and does not cause a flash.

Cc Nicholas Kazlauskas <[email protected]>
Cc Charlene Liu <[email protected]>
Cc Mario Limonciello <[email protected]>
Cc Alex Deucher <[email protected]>
(cherry picked from commit 2f289740a04f08a5ce4b5e3c69af6e32ab4a540e)
[ sashal: Renamed legacy_hardware_init() to dc_hardware_init() in the dc.c hunk context and function header, since this tree already uses the new name. ]
---
 .../amd/display/dc/clk_mgr/dcn42/dcn42_clk_mgr.c |  3 +++
 .../display/dc/clk_mgr/dcn42b/dcn42b_clk_mgr.c   |  4 ++++
 drivers/gpu/drm/amd/display/dc/core/dc.c         | 16 +++++++++++++++-
 3 files changed, 22 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42/dcn42_clk_mgr.c +3 -0
index 19ef0b92e8e60..bb44501a9ed2e 100644
@@ -632,6 +632,9 @@ void dcn42_init_clocks(struct clk_mgr *clk_mgr_base)
 	DC_LOG_SMU("dp_dto_source_clock %d, dprefclk %d\n", clk_mgr_base->dp_dto_source_clock_in_khz, clk_mgr_base->dprefclk_khz);
 	dcn42_dump_clk_registers(&clk_mgr_base->boot_snapshot, clk_mgr);
 
+	/* Snapshot is in 10kHz units; seed clks so update_clocks() does not lower the pre-OS clocks */
+	clk_mgr_base->clks.dispclk_khz = clk_mgr_base->boot_snapshot.dispclk * 10;
+	clk_mgr_base->clks.dppclk_khz = clk_mgr_base->boot_snapshot.dppclk * 10;
 	clk_mgr_base->clks.ref_dtbclk_khz =  clk_mgr_base->boot_snapshot.dtbclk * 10;
 	clk_mgr_base->clks.dtbclk_en = clk_mgr_base->boot_snapshot.dtbclk > 59000;
 }
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn42b/dcn42b_clk_mgr.c +4 -0
index 2c2ba09221e4d..5b391cea12f02 100644
@@ -240,6 +240,10 @@ void dcn42b_init_clocks(struct clk_mgr *clk_mgr_base)
 
 	DC_LOG_SMU("dp_dto_source_clock %d, dprefclk %d\n", clk_mgr_base->dp_dto_source_clock_in_khz, clk_mgr_base->dprefclk_khz);
 	dcn42b_dump_clk_registers(&clk_mgr_base->boot_snapshot, clk_mgr);
+
+	/* Snapshot is in 10kHz units; seed clks so update_clocks() does not lower the pre-OS clocks */
+	clk_mgr_base->clks.dispclk_khz = clk_mgr_base->boot_snapshot.dispclk * 10;
+	clk_mgr_base->clks.dppclk_khz = clk_mgr_base->boot_snapshot.dppclk * 10;
 }
 
 static struct clk_bw_params dcn42b_bw_params = {
drivers/gpu/drm/amd/display/dc/core/dc.c +15 -1
index 58d9a4378dbf0..95110dd65ae32 100644
@@ -1640,12 +1640,25 @@ static void detect_edp_presence(struct dc *dc)
 	}
 }
 
+static void sync_current_state_clocks_from_clk_mgr(struct dc *dc)
+{
+	if (!dc->current_state || !dc->clk_mgr)
+		return;
+
+	if (!(dc->ctx->dce_version == DCN_VERSION_4_2 || dc->ctx->dce_version == DCN_VERSION_4_2B))
+		return;
+
+	dc->current_state->bw_ctx.bw.dcn.clk = dc->clk_mgr->clks;
+}
+
 void dc_hardware_init(struct dc *dc)
 {
 
 	detect_edp_presence(dc);
-	if (dc->ctx->dce_environment != DCE_ENV_VIRTUAL_HW)
+	if (dc->ctx->dce_environment != DCE_ENV_VIRTUAL_HW) {
 		dc->hwss.init_hw(dc);
+		sync_current_state_clocks_from_clk_mgr(dc);
+	}
 	dc_dmub_srv_notify_fw_dc_power_state(dc->ctx->dmub_srv, DC_ACPI_CM_POWER_STATE_D0);
 }
 
@@ -6521,6 +6534,7 @@ void dc_set_power_state(struct dc *dc, enum dc_acpi_cm_power_state power_state)
 		dc_dmub_srv_notify_fw_dc_power_state(dc->ctx->dmub_srv, power_state);
 
 		dc->hwss.init_hw(dc);
+		sync_current_state_clocks_from_clk_mgr(dc);
 
 		if (dc->hwss.init_sys_ctx != NULL &&
 			dc->vm_pa_config.valid) {
Signature · 1 line
2.53.0