From: James Lin <PingLei.Lin@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Harry Wentland <harry.wentland@amd.com>,
Leo Li <sunpeng.li@amd.com>,
Aurabindo Pillai <aurabindo.pillai@amd.com>,
Roman Li <roman.li@amd.com>, Wayne Lin <wayne.lin@amd.com>,
Tom Chung <chiahsuan.chung@amd.com>,
"Fangzhi Zuo" <jerry.zuo@amd.com>,
Dan Wheeler <daniel.wheeler@amd.com>, Ray Wu <Ray.Wu@amd.com>,
Ivan Lipski <ivan.lipski@amd.com>, Alex Hung <alex.hung@amd.com>,
James Lin <PingLei.Lin@amd.com>,
Chenyu Chen <Chen-Yu.Chen@amd.com>,
George Shen <george.shen@amd.com>,
Michael Strauss <michael.strauss@amd.com>,
James Lin <pinglei.lin@amd.com>
Subject: [PATCH 05/33] drm/amd/display: Refactor DP retrain link HW sequence
Date: Tue, 17 Nov 2026 05:50:42 +0800 [thread overview]
Message-ID: <20261116215641.2800595-6-PingLei.Lin@amd.com> (raw)
In-Reply-To: <20261116215641.2800595-1-PingLei.Lin@amd.com>
From: George Shen <george.shen@amd.com>
[Why]
Current implementation of DP retrain link test function contains an
issue where ODM combine is cleared and not reconfigured when we toggle
off/on OTG.
The function is also rigid and difficult to maintain when all the HW
programming logic is done directly within it.
[How]
Move HW programming calls to a hwss function and call it from the DP
retrain link function.
Additionaly, add a call to reprogram the ODM combine register that is
cleared when disabling OTG in the hwss function call.
Cc: Michael Strauss <michael.strauss@amd.com>
Signed-off-by: George Shen <george.shen@amd.com>
Signed-off-by: James Lin <pinglei.lin@amd.com>
---
.../drm/amd/display/dc/core/dc_hw_sequencer.c | 84 +++++++++++++++++++
.../drm/amd/display/dc/hwss/hw_sequencer.h | 8 ++
.../display/dc/link/accessories/link_dp_cts.c | 39 ++-------
3 files changed, 98 insertions(+), 33 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
index ecf90e3a770c..061ea11cef0e 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
@@ -3195,6 +3195,90 @@ void hwss_wait_for_odm_update_pending_complete(struct dc *dc, struct dc_state *c
hwss_wait_for_all_blank_complete(dc, context);
}
+/**
+ * hwss_restart_otg_for_dp_test_link_retrain - restart the OTGs of a link retrained
+ * by a DP test request, with the stream's planes left attached
+ *
+ * Disables the OTGs, programs the pixel clock and audio if requested, restores
+ * the ODM combine configuration cleared by disable_crtc, then re-enables the
+ * OTGs. The caller must have already turned DPMS off and updated the stream and
+ * link resources in @context for the new link settings.
+ *
+ * @dc: [in] dc reference
+ * @context: [in] hardware context in use
+ * @otg_masters: [in] OTG master pipes of the streams being retrained
+ * @otg_master_count: [in] number of entries in @otg_masters
+ * @program_pix_clk: [in] program pixel clock and audio, needed when the link encoding changes
+ * @audio_output: [in] audio output per OTG master, used if @program_pix_clk
+ */
+void hwss_restart_otg_for_dp_test_link_retrain(struct dc *dc,
+ struct dc_state *context,
+ struct pipe_ctx **otg_masters,
+ uint8_t otg_master_count,
+ bool program_pix_clk,
+ struct audio_output *audio_output)
+{
+ int i;
+
+ // TODO: Confirm with HW docs if disable/re-enable is actually required here
+ for (i = 0; i < otg_master_count; i++)
+ otg_masters[i]->stream_res.tg->funcs->disable_crtc(otg_masters[i]->stream_res.tg);
+
+ if (program_pix_clk) {
+ for (i = 0; i < otg_master_count; i++) {
+ struct pipe_ctx *pipe = otg_masters[i];
+ struct audio *audio = pipe->stream_res.audio;
+
+ if (pipe->stream_res.pix_clk_params.controller_id != CONTROLLER_ID_UNDEFINED)
+ pipe->clock_source->funcs->program_pix_clk(
+ pipe->clock_source,
+ &pipe->stream_res.pix_clk_params,
+ dc->link_srv->dp_get_encoding_format(&pipe->link_config.dp_link_settings),
+ &pipe->pll_settings);
+
+ if (audio != NULL) {
+ const struct link_hwss *link_hwss = get_link_hwss(
+ pipe->stream->link, &pipe->link_res);
+
+ link_hwss->setup_audio_output(pipe, &audio_output[i], audio->inst);
+
+ audio->funcs->az_configure(
+ audio,
+ pipe->stream->signal,
+ &audio_output[i].crtc_info,
+ &pipe->stream->audio_info,
+ &audio_output[i].dp_link_info);
+
+ if (dc->config.disable_hbr_audio_dp2 &&
+ audio->funcs->az_disable_hbr_audio &&
+ dc->link_srv->dp_is_128b_132b_signal(pipe))
+ audio->funcs->az_disable_hbr_audio(audio);
+ }
+ }
+ }
+
+ for (i = 0; i < otg_master_count; i++) {
+ struct pipe_ctx *pipe = otg_masters[i];
+
+ /* disable_crtc cleared the ODM segment config */
+ if (pipe->next_odm_pipe) {
+ struct pipe_ctx *opp_heads[MAX_PIPES];
+ int opp_inst[MAX_PIPES] = {0};
+ int opp_head_count = resource_get_opp_heads_for_otg_master(pipe, &context->res_ctx, opp_heads);
+ int j;
+
+ for (j = 0; j < opp_head_count; j++)
+ opp_inst[j] = opp_heads[j]->stream_res.opp->inst;
+
+ pipe->stream_res.tg->funcs->set_odm_combine(pipe->stream_res.tg, opp_inst, opp_head_count,
+ resource_get_odm_slice_dst_width(pipe, false),
+ resource_get_odm_slice_dst_width(pipe, true));
+ }
+
+ pipe->stream_res.tg->funcs->enable_crtc(pipe->stream_res.tg);
+ }
+}
+
void hwss_reset_unused_det(struct dc *dc, struct dc_state *context)
{
struct hubbub *hubbub = dc->res_pool->hubbub;
diff --git a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
index bfe9afb434af..c2e256a40128 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
+++ b/drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
@@ -66,6 +66,7 @@ struct link_training_settings;
struct dc_link;
struct dc_crtc_timing;
struct dmub_srv_hw_params;
+struct audio_output;
struct tg_lock_params {
struct dc *dc;
@@ -2316,6 +2317,13 @@ void hwss_wait_for_all_blank_complete(struct dc *dc,
void hwss_wait_for_odm_update_pending_complete(struct dc *dc,
struct dc_state *context);
+void hwss_restart_otg_for_dp_test_link_retrain(struct dc *dc,
+ struct dc_state *context,
+ struct pipe_ctx **otg_masters,
+ uint8_t otg_master_count,
+ bool program_pix_clk,
+ struct audio_output *audio_output);
+
void hwss_wait_for_no_pipes_pending(struct dc *dc,
struct dc_state *context);
diff --git a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
index f316337cee1b..2fe7ceff1f50 100644
--- a/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
+++ b/drivers/gpu/drm/amd/display/dc/link/accessories/link_dp_cts.c
@@ -72,6 +72,7 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
struct dc_stream_update stream_update = { 0 };
bool dpms_off = false;
bool needs_divider_update = false;
+ bool program_pix_clk = false;
bool was_hpo_acquired = resource_is_hpo_acquired(link->dc->current_state);
bool is_hpo_acquired;
uint8_t count;
@@ -97,52 +98,24 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
link->dc,
state,
pipes[i]);
-
- // Disable OTG and re-enable after updating clocks
- pipes[i]->stream_res.tg->funcs->disable_crtc(pipes[i]->stream_res.tg);
}
if (needs_divider_update && link->dc->res_pool->funcs->update_dc_state_for_encoder_switch) {
link->dc->res_pool->funcs->update_dc_state_for_encoder_switch(link,
link_setting, count,
*pipes, &audio_output[0]);
- for (i = 0; i < count; i++) {
- pipes[i]->clock_source->funcs->program_pix_clk(
- pipes[i]->clock_source,
- &pipes[i]->stream_res.pix_clk_params,
- link->dc->link_srv->dp_get_encoding_format(&pipes[i]->link_config.dp_link_settings),
- &pipes[i]->pll_settings);
-
- if (pipes[i]->stream_res.audio != NULL) {
- const struct link_hwss *link_hwss = get_link_hwss(
- link, &pipes[i]->link_res);
-
- link_hwss->setup_audio_output(pipes[i], &audio_output[i],
- pipes[i]->stream_res.audio->inst);
-
- pipes[i]->stream_res.audio->funcs->az_configure(
- pipes[i]->stream_res.audio,
- pipes[i]->stream->signal,
- &audio_output[i].crtc_info,
- &pipes[i]->stream->audio_info,
- &audio_output[i].dp_link_info);
-
- if (link->dc->config.disable_hbr_audio_dp2 &&
- pipes[i]->stream_res.audio->funcs->az_disable_hbr_audio &&
- link->dc->link_srv->dp_is_128b_132b_signal(pipes[i]))
- pipes[i]->stream_res.audio->funcs->az_disable_hbr_audio(pipes[i]->stream_res.audio);
- }
- }
+ program_pix_clk = true;
}
+ // Disable OTG, update clocks and re-enable OTG with its ODM configuration restored
+ hwss_restart_otg_for_dp_test_link_retrain(dc, state, pipes, count,
+ program_pix_clk, audio_output);
+
// Toggle on HPO I/O if necessary
is_hpo_acquired = resource_is_hpo_acquired(state);
if (was_hpo_acquired != is_hpo_acquired && link->dc->hwss.setup_hpo_hw_control)
link->dc->hwss.setup_hpo_hw_control(link->dc->hwseq, is_hpo_acquired);
- for (i = 0; i < count; i++)
- pipes[i]->stream_res.tg->funcs->enable_crtc(pipes[i]->stream_res.tg);
-
// Set DPMS on with stream update
// Cache all streams on current link since dc_update_planes_and_stream might kill current_state
for (i = 0; i < MAX_PIPES; i++) {
--
2.43.0
next prev parent reply other threads:[~2026-11-17 17:13 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 21:50 [PATCH 00/33] DC Patches November 23, 2026 James Lin
2026-11-16 21:50 ` [PATCH 01/33] drm/amd/display: Clear OTG_AUTO_FORCE_VSYNC_MODE on OTG disable James Lin
2026-11-16 21:50 ` [PATCH 02/33] drm/amd/display: Rename DPMS to DPMS_v1 James Lin
2026-11-16 21:50 ` [PATCH 03/33] drm/amd/display: Power up eDP when detect link James Lin
2026-11-16 21:50 ` [PATCH 04/33] drm/amd/display: Add DPMS-v2 files James Lin
2026-11-16 21:50 ` James Lin [this message]
2026-11-16 21:50 ` [PATCH 06/33] drm/amd/display: add extra 0.25 line reserved for TSetup/TCalc inefficiency James Lin
2026-11-16 21:50 ` [PATCH 07/33] drm/amd/display: Use panel luminance range for AUX backlight in power module James Lin
2026-11-16 21:50 ` [PATCH 08/33] drm/amd/display: Read PWM back linearly with the linear backlight curve James Lin
2026-11-16 21:50 ` [PATCH 09/33] drm/amd/display: Add API to set brightness percent James Lin
2026-11-16 21:50 ` [PATCH 10/33] drm/amd/display: Pass linear brightness percent to power module James Lin
2026-11-16 21:50 ` [PATCH 11/33] drm/amd/display: Add DPMS-v2 types James Lin
2026-11-16 21:50 ` [PATCH 12/33] drm/amd/display: Always apply 0ppm pixel clock adjustment James Lin
2026-11-16 21:50 ` [PATCH 13/33] drm/amd/display: Add otg versions of get_vblank_counter/scanoutpos James Lin
2026-11-16 21:50 ` [PATCH 14/33] drm/amd/display: Queue vblank control work to sleepable context James Lin
2026-11-16 21:50 ` [PATCH 15/33] drm/amd/display: Fix KUnit tests for vblank control rework James Lin
2026-11-16 21:50 ` [PATCH 16/33] drm/amd/display: Add urgent request and assertion probes James Lin
2026-11-16 21:50 ` [PATCH 17/33] drm/amd/display: Fix G7 P-state aperture addresses James Lin
2026-11-16 21:50 ` [PATCH 18/33] drm/amd/display: Set stream min/max refresh from VRR config James Lin
2026-11-16 21:50 ` [PATCH 19/33] drm/amd/display: Add DC2 wrapped initialization for DCN401 James Lin
2026-11-16 21:50 ` [PATCH 20/33] drm/amd/display: Honor the Replay stream regeneration wait event James Lin
2026-11-16 21:50 ` [PATCH 21/33] drm/amd/display: Disable Replay when link off frame count is below 2 James Lin
2026-11-16 21:50 ` [PATCH 22/33] drm/amd/display: Skip DSC padding borrow estimate for zero padding James Lin
2026-11-16 21:51 ` [PATCH 23/33] drm/amd/display: Drop unused DC interfaces James Lin
2026-11-16 21:51 ` [PATCH 24/33] drm/amd/display: Let the DC2 commit replace or keep a stream James Lin
2026-11-16 21:51 ` [PATCH 25/33] drm/amd/display: Support two streams in the dcn401 DC2 builders James Lin
2026-11-16 21:51 ` [PATCH 26/33] drm/amd/display: Add a plane beside a kept plane in DC2 update James Lin
2026-11-16 21:51 ` [PATCH 27/33] drm/amd/display: Keep an unchanged stream in the DC2 commit James Lin
2026-11-16 21:51 ` [PATCH 28/33] drm/amd/display: Change the ODM and MPC layout in DC2 update James Lin
2026-11-16 21:51 ` [PATCH 29/33] drm/amd/display: Give the DC2 builders State pipe facts James Lin
2026-11-16 21:51 ` [PATCH 30/33] drm/amd/display: Add RGBA8888 surface pixel format support James Lin
2026-11-16 21:51 ` [PATCH 31/33] drm/amd/display: Fix DCE crossbar for RGBA8888 surface format James Lin
2026-11-16 21:51 ` [PATCH 32/33] drm/amd/display: [FW Promotion] Release 0.1.85.0 James Lin
2026-11-16 21:51 ` [PATCH 33/33] drm/amd/display: Promote DC to 3.2.408 James Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116215641.2800595-6-PingLei.Lin@amd.com \
--to=pinglei.lin@amd.com \
--cc=Chen-Yu.Chen@amd.com \
--cc=Ray.Wu@amd.com \
--cc=alex.hung@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=aurabindo.pillai@amd.com \
--cc=chiahsuan.chung@amd.com \
--cc=daniel.wheeler@amd.com \
--cc=george.shen@amd.com \
--cc=harry.wentland@amd.com \
--cc=ivan.lipski@amd.com \
--cc=jerry.zuo@amd.com \
--cc=michael.strauss@amd.com \
--cc=roman.li@amd.com \
--cc=sunpeng.li@amd.com \
--cc=wayne.lin@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.