Skip to contentSkip to conversation

drm/amd/display: Do not set drr on pipe commit

PATCH In review Aurabindo Pillai 3 participants 7 messages Jul 5, 2023 – Jul 6, 2023

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

PATCH 1/2 drm/amd/display: Do not set drr on pipe commit

From: Wesley Chalmers <[email protected]>

[WHY]
Writing to DRR registers such as OTG_V_TOTAL_MIN on the same frame as a pipe commit can cause underflow.

[HOW]
Move DMUB p-state delegate into optimze_bandwidth; enabling FAMS sets optimized_required.

This change expects that Freesync requests are blocked when optimized_required is true.

Fixes de1da2f7fe25 ("drm/amd/display: Add monitor specific edid quirk")
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c | 6 ++++++
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 7 +++++++
 2 files changed, 13 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c +6 -0
index 4492bc2392b6..dba7eab9a2c4 100644
@@ -2123,6 +2123,12 @@ void dcn20_optimize_bandwidth(
 	if (hubbub->funcs->program_compbuf_size)
 		hubbub->funcs->program_compbuf_size(hubbub, context->bw_ctx.bw.dcn.compbuf_size_kb, true);
 
+	if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching) {
+		dc_dmub_srv_p_state_delegate(dc,
+			true, context);
+		context->bw_ctx.bw.dcn.clk.p_state_change_support = true;
+	}
+
 	dc->clk_mgr->funcs->update_clocks(
 			dc->clk_mgr,
 			context,
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +7 -0
index bf8864bc8a99..7d38977f09a6 100644
@@ -951,11 +951,18 @@ void dcn30_set_disp_pattern_generator(const struct dc *dc,
 void dcn30_prepare_bandwidth(struct dc *dc,
 			     struct dc_state *context)
 {
+	if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching) {
+		dc->optimized_required = true;
+		context->bw_ctx.bw.dcn.clk.p_state_change_support = false;
+	}
+
 	if (dc->clk_mgr->dc_mode_softmax_enabled)
 		if (dc->clk_mgr->clks.dramclk_khz <= dc->clk_mgr->bw_params->dc_mode_softmax_memclk * 1000 &&
 				context->bw_ctx.bw.dcn.clk.dramclk_khz > dc->clk_mgr->bw_params->dc_mode_softmax_memclk * 1000)
 			dc->clk_mgr->funcs->set_max_memclk(dc->clk_mgr, dc->clk_mgr->bw_params->clk_table.entries[dc->clk_mgr->bw_params->clk_table.num_entries - 1].memclk_mhz);
 
 	dcn20_prepare_bandwidth(dc, context);
+
+	dc_dmub_srv_p_state_delegate(dc, false, context);
 }
 
Signature · 1 line
2.41.0
#1 lore raw

PATCH 2/2 drm/amd/display: Block optimize on consecutive FAMS enables

From: Wesley Chalmers <[email protected]>

[WHY]
It is possible to commit state multiple times in rapid succession with FAMS enabled; if each of these commits were to set optimized_required, then the user may see latency.

[HOW]
fw_based_mclk_switching is currently not used in dc->clk_mgr; use it to track whether the current state has FAMS enabled;
if it has, then do not disable FAMS in prepare_bandwidth, and do not set optimized_required.

Fixes de1da2f7fe25 ("drm/amd/display: Add monitor specific edid quirk")
---
 .../drm/amd/display/dc/dcn20/dcn20_hwseq.c    |  3 +++
 .../drm/amd/display/dc/dcn30/dcn30_hwseq.c    | 20 +++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c +3 -0
index dba7eab9a2c4..5cfa37804d7c 100644
@@ -2127,6 +2127,9 @@ void dcn20_optimize_bandwidth(
 		dc_dmub_srv_p_state_delegate(dc,
 			true, context);
 		context->bw_ctx.bw.dcn.clk.p_state_change_support = true;
+		dc->clk_mgr->clks.fw_based_mclk_switching = true;
+	} else {
+		dc->clk_mgr->clks.fw_based_mclk_switching = false;
 	}
 
 	dc->clk_mgr->funcs->update_clocks(
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +18 -2
index 7d38977f09a6..fb66d84b2a1d 100644
@@ -951,7 +951,11 @@ void dcn30_set_disp_pattern_generator(const struct dc *dc,
 void dcn30_prepare_bandwidth(struct dc *dc,
 			     struct dc_state *context)
 {
-	if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching) {
+	bool p_state_change_support = context->bw_ctx.bw.dcn.clk.p_state_change_support;
+	/* Any transition into an FPO config should disable MCLK switching first to avoid
+	 * driver and FW P-State synchronization issues.
+	 */
+	if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching || dc->clk_mgr->clks.fw_based_mclk_switching) {
 		dc->optimized_required = true;
 		context->bw_ctx.bw.dcn.clk.p_state_change_support = false;
 	}
@@ -962,7 +966,19 @@ void dcn30_prepare_bandwidth(struct dc *dc,
 			dc->clk_mgr->funcs->set_max_memclk(dc->clk_mgr, dc->clk_mgr->bw_params->clk_table.entries[dc->clk_mgr->bw_params->clk_table.num_entries - 1].memclk_mhz);
 
 	dcn20_prepare_bandwidth(dc, context);
+	/*
+	 * enabled -> enabled: do not disable
+	 * enabled -> disabled: disable
+	 * disabled -> enabled: don't care
+	 * disabled -> disabled: don't care
+	 */
+	if (!context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching)
+		dc_dmub_srv_p_state_delegate(dc, false, context);
 
-	dc_dmub_srv_p_state_delegate(dc, false, context);
+	if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching || dc->clk_mgr->clks.fw_based_mclk_switching) {
+		/* After disabling P-State, restore the original value to ensure we get the correct P-State
+		 * on the next optimize. */
+		context->bw_ctx.bw.dcn.clk.p_state_change_support = p_state_change_support;
+	}
 }
 
Signature · 1 line
2.41.0
Acked-by on v1 1/2
#2 lore raw
In reply to Aurabindo Pillai
Quoted 10 lines · Aurabindo Pillai

From: Wesley Chalmers <[email protected]>

[WHY]
Writing to DRR registers such as OTG_V_TOTAL_MIN on the same frame as a pipe commit can cause underflow.

[HOW]
Move DMUB p-state delegate into optimze_bandwidth; enabling FAMS sets optimized_required.

Quoted 8 lines

This change expects that Freesync requests are blocked when optimized_required is true.

Fixes de1da2f7fe25 ("drm/amd/display: Add monitor specific edid quirk")

This series is:

Quoted 45 lines
---
  drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c | 6 ++++++
  drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 7 +++++++
  2 files changed, 13 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c +6 -0
index 4492bc2392b6..dba7eab9a2c4 100644
@@ -2123,6 +2123,12 @@ void dcn20_optimize_bandwidth(
  	if (hubbub->funcs->program_compbuf_size)
  		hubbub->funcs->program_compbuf_size(hubbub, context->bw_ctx.bw.dcn.compbuf_size_kb, true);
 
+	if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching) {
+		dc_dmub_srv_p_state_delegate(dc,
+			true, context);
+		context->bw_ctx.bw.dcn.clk.p_state_change_support = true;
+	}
+
  	dc->clk_mgr->funcs->update_clocks(
  			dc->clk_mgr,
  			context,
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c +7 -0
index bf8864bc8a99..7d38977f09a6 100644
@@ -951,11 +951,18 @@ void dcn30_set_disp_pattern_generator(const struct dc *dc,
  void dcn30_prepare_bandwidth(struct dc *dc,
  			     struct dc_state *context)
  {
+	if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching) {
+		dc->optimized_required = true;
+		context->bw_ctx.bw.dcn.clk.p_state_change_support = false;
+	}
+
  	if (dc->clk_mgr->dc_mode_softmax_enabled)
  		if (dc->clk_mgr->clks.dramclk_khz <= dc->clk_mgr->bw_params->dc_mode_softmax_memclk * 1000 &&
  				context->bw_ctx.bw.dcn.clk.dramclk_khz > dc->clk_mgr->bw_params->dc_mode_softmax_memclk * 1000)
  			dc->clk_mgr->funcs->set_max_memclk(dc->clk_mgr, dc->clk_mgr->bw_params->clk_table.entries[dc->clk_mgr->bw_params->clk_table.num_entries - 1].memclk_mhz);
 
  	dcn20_prepare_bandwidth(dc, context);
+
+	dc_dmub_srv_p_state_delegate(dc, false, context);
  }
 
Signature · 1 line
Hamza
#3 lore raw
In reply to Aurabindo Pillai
Quoted 6 lines · Aurabindo Pillai

From: Wesley Chalmers <[email protected]>

[WHY]
Writing to DRR registers such as OTG_V_TOTAL_MIN on the same frame as a pipe commit can cause underflow.

Quoted 8 lines

[HOW]
Move DMUB p-state delegate into optimze_bandwidth; enabling FAMS sets optimized_required.

This change expects that Freesync requests are blocked when optimized_required is true.

Fixes de1da2f7fe25 ("drm/amd/display: Add monitor specific edid quirk")

Seems like inappropriate use of Fixes:, or how does this commit "fix" the referenced commit?

(Also a bit surprised to learn about that one only now, and that it landed without my confirming it actually works)

Signature · 2 lines
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer
#4 lore raw

[Public]

Hi Michel,

You confirmed in another thread the monitor specific quirk for disabling FAMS fixed your hang. Fixes references the commit which adds such quirk:

de1da2f7fe25 drm/amd/display: Add monitor specific edid quirk

The intention is that these two patches should only be merged into stable trees after applying the monitor specific quirk.

--

Regards,
Jay
________________________________
From: Michel Dänzer <[email protected]>
Sent: Thursday, July 6, 2023 6:05 AM
To: Pillai, Aurabindo <[email protected]>; [email protected] <[email protected]>
Cc: Chalmers, Wesley <[email protected]>; Siqueira, Rodrigo <[email protected]>; Wheeler, Daniel <[email protected]>; Mahfooz, Hamza <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: Re: [PATCH 1/2] drm/amd/display: Do not set drr on pipe commit

Quoted 6 lines · Aurabindo Pillai

From: Wesley Chalmers <[email protected]>

[WHY]
Writing to DRR registers such as OTG_V_TOTAL_MIN on the same frame as a pipe commit can cause underflow.

Quoted 8 lines

[HOW]
Move DMUB p-state delegate into optimze_bandwidth; enabling FAMS sets optimized_required.

This change expects that Freesync requests are blocked when optimized_required is true.

Fixes de1da2f7fe25 ("drm/amd/display: Add monitor specific edid quirk")

Seems like inappropriate use of Fixes:, or how does this commit "fix" the referenced commit?

(Also a bit surprised to learn about that one only now, and that it landed without my confirming it actually works)

--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and Xwayland developer

#5 lore raw
Quoted 4 lines · Aurabindo

Hi Michel,

You confirmed in another thread the monitor specific quirk for disabling FAMS fixed your hang.

That's not quite accurate. I confirmed that hard-coding FAMS to be disabled works around the hangs I reported, and you asked me to test an EDID quirk patch, which I reported not to have any effect for my monitor. Then I didn't hear back anything until this patch series today, so I haven't tested the de1da2f7fe25 commit. (I expect it to work, but I can't confirm it yet)

Signature · 2 lines
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer
#6 lore raw

[Public]

From the log you provided, I extracted the panel id so I expect FAMS to get disabled on your monitor. If it doesn't work, let me know.

--

Regards,
Jay
________________________________
From: Michel Dänzer <[email protected]>
Sent: Thursday, July 6, 2023 10:11 AM
To: Pillai, Aurabindo <[email protected]>; [email protected] <[email protected]>
Cc: Chalmers, Wesley <[email protected]>; Siqueira, Rodrigo <[email protected]>; Wheeler, Daniel <[email protected]>; Mahfooz, Hamza <[email protected]>; Deucher, Alexander <[email protected]>; Wentland, Harry <[email protected]>
Subject: Re: [PATCH 1/2] drm/amd/display: Do not set drr on pipe commit

Quoted 4 lines · Aurabindo

Hi Michel,

You confirmed in another thread the monitor specific quirk for disabling FAMS fixed your hang.

That's not quite accurate. I confirmed that hard-coding FAMS to be disabled works around the hangs I reported, and you asked me to test an EDID quirk patch, which I reported not to have any effect for my monitor. Then I didn't hear back anything until this patch series today, so I haven't tested the de1da2f7fe25 commit. (I expect it to work, but I can't confirm it yet)

--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and Xwayland developer