From: Chenyu Chen <chen-yu.chen@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>,
Gabe Teeger <gabe.teeger@amd.com>,
Charlene Liu <charlene.liu@amd.com>,
Chenyu Chen <chen-yu.chen@amd.com>
Subject: [PATCH 24/27] drm/amd/display: Fix two streams sharing one OTG
Date: Wed, 25 Nov 2026 14:55:13 +0800 [thread overview]
Message-ID: <20261125065631.3889665-25-chen-yu.chen@amd.com> (raw)
In-Reply-To: <20261125065631.3889665-1-chen-yu.chen@amd.com>
From: Gabe Teeger <gabe.teeger@amd.com>
[Why]
Some ASICs have more pipes than OTGs and OPPs. A stream could be
given a pipe without its own OTG and was then aliased to the last
OTG and OPP, which another stream already used. Both streams then
shared one OTG, so one of them stopped getting vblank interrupts.
[How]
Only pick a pipe as OTG master if it has its own OTG. If none is
free, drop another stream's ODM slices and let DML validation add
them back if needed. Remove the aliasing fallback. Skip pipes
without an OPP when acquiring an ODM slice.
Cc: Charlene Liu <charlene.liu@amd.com>
Signed-off-by: Gabe Teeger <gabe.teeger@amd.com>
Signed-off-by: Chenyu Chen <chen-yu.chen@amd.com>
---
.../gpu/drm/amd/display/dc/core/dc_resource.c | 64 ++++++++++++---
.../dc/resource/dcn42b/dcn42b_resource.c | 82 ++++++++++++++++++-
.../dc/resource/dcn42b/dcn42b_resource.h | 6 ++
3 files changed, 140 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index ec11a79811e7..cb537aa90ad5 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -4295,6 +4295,48 @@ static void mark_seamless_boot_stream(const struct dc *dc,
}
}
+/*
+ * Some ASICs (e.g. DCN 2.0.1 and DCN 4.2B) have more pipes than OTGs. A pipe
+ * without its own OTG can only be a secondary DPP pipe. As an OTG master it
+ * would share the OTG and OPP of another stream.
+ */
+static bool can_pipe_be_otg_master(const struct resource_pool *pool,
+ int pipe_idx)
+{
+ return pipe_idx >= 0 &&
+ (unsigned int)pipe_idx < pool->timing_generator_count;
+}
+
+/*
+ * Remove the ODM slices of the first stream that has more than one and return
+ * the first free pipe. DML re-evaluates the ODM slice count of that stream
+ * during validation. It adds the slices back if the timing needs them and
+ * enough OPPs are left, and fails validation otherwise.
+ */
+static int release_odm_slices_of_a_stream(
+ const struct dc_state *cur_ctx,
+ struct dc_state *new_ctx,
+ const struct resource_pool *pool)
+{
+ unsigned int i;
+
+ for (i = 0; i < pool->pipe_count; i++) {
+ struct pipe_ctx *otg_master = &new_ctx->res_ctx.pipe_ctx[i];
+
+ if (!resource_is_pipe_type(otg_master, OTG_MASTER) ||
+ resource_get_odm_slice_count(otg_master) == 1)
+ continue;
+
+ if (!resource_update_pipes_for_stream_with_slice_count(new_ctx,
+ cur_ctx, pool, otg_master->stream, 1))
+ return FREE_PIPE_INDEX_NOT_FOUND;
+
+ return resource_find_any_free_pipe(&new_ctx->res_ctx, pool);
+ }
+
+ return FREE_PIPE_INDEX_NOT_FOUND;
+}
+
/*
* Acquire a pipe as OTG master and assign to the stream in new dc context.
* return - true if OTG master pipe is acquired and new dc context is updated.
@@ -4349,7 +4391,7 @@ static bool acquire_otg_master_pipe_for_stream(
* Try to acquire a pipe not used in current resource context to avoid
* pipe swapping.
*/
- if (pipe_idx == FREE_PIPE_INDEX_NOT_FOUND)
+ if (!can_pipe_be_otg_master(pool, pipe_idx))
pipe_idx = recource_find_free_pipe_not_used_in_cur_res_ctx(
&cur_ctx->res_ctx, &new_ctx->res_ctx, pool);
/*
@@ -4357,12 +4399,19 @@ static bool acquire_otg_master_pipe_for_stream(
* secondary DPP pipe in current state as we prioritize to support more
* streams over supporting MPO planes.
*/
- if (pipe_idx == FREE_PIPE_INDEX_NOT_FOUND)
+ if (!can_pipe_be_otg_master(pool, pipe_idx))
pipe_idx = resource_find_free_pipe_used_as_cur_sec_dpp(
&cur_ctx->res_ctx, &new_ctx->res_ctx, pool);
- if (pipe_idx == FREE_PIPE_INDEX_NOT_FOUND)
+ if (!can_pipe_be_otg_master(pool, pipe_idx))
pipe_idx = resource_find_any_free_pipe(&new_ctx->res_ctx, pool);
- if (pipe_idx != FREE_PIPE_INDEX_NOT_FOUND) {
+ /*
+ * If the only free pipes have no OTG (e.g. pipe 3 on DCN 4.2B), free a
+ * pipe that has one by removing the ODM slices of another stream.
+ */
+ if (pipe_idx != FREE_PIPE_INDEX_NOT_FOUND &&
+ !can_pipe_be_otg_master(pool, pipe_idx))
+ pipe_idx = release_odm_slices_of_a_stream(cur_ctx, new_ctx, pool);
+ if (can_pipe_be_otg_master(pool, pipe_idx)) {
pipe_ctx = &new_ctx->res_ctx.pipe_ctx[pipe_idx];
memset(pipe_ctx, 0, sizeof(*pipe_ctx));
pipe_ctx->pipe_idx = (uint8_t)pipe_idx;
@@ -4376,13 +4425,6 @@ static bool acquire_otg_master_pipe_for_stream(
if (pool->dpps[pipe_idx])
pipe_ctx->plane_res.mpcc_inst = (uint8_t)pool->dpps[pipe_idx]->inst;
- if ((unsigned int)pipe_idx >= pool->timing_generator_count && pool->timing_generator_count != 0) {
- int tg_inst = pool->timing_generator_count - 1;
-
- pipe_ctx->stream_res.tg = pool->timing_generators[tg_inst];
- pipe_ctx->stream_res.opp = pool->opps[tg_inst];
- }
-
pipe_ctx->stream = stream;
} else {
pipe_idx = acquire_first_split_pipe(&new_ctx->res_ctx, pool, stream);
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c b/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
index 338c506588d9..aeecdd2daae2 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
@@ -1950,6 +1950,86 @@ static unsigned int dcn42b_get_max_hw_cursor_size(const struct dc *dc,
return dc->caps.max_cursor_size;
}
+/*
+ * DCN 4.2B has 4 pipes but only 3 OPPs. An OPP head needs its own OPP, so the
+ * pipe without one can only be a secondary DPP pipe.
+ */
+static bool dcn42b_can_pipe_be_opp_head(const struct resource_pool *pool,
+ int pipe_idx)
+{
+ return pipe_idx >= 0 && pool->opps[pipe_idx];
+}
+
+static int dcn42b_find_optimal_free_pipe_as_secondary_opp_head(
+ const struct resource_context *cur_res_ctx,
+ struct resource_context *new_res_ctx,
+ const struct resource_pool *pool,
+ const struct pipe_ctx *new_otg_master)
+{
+ const struct pipe_ctx *cur_otg_master;
+ int free_pipe_idx;
+
+ cur_otg_master = &cur_res_ctx->pipe_ctx[new_otg_master->pipe_idx];
+ free_pipe_idx = resource_find_free_pipe_used_as_sec_opp_head_by_cur_otg_master(
+ cur_res_ctx, new_res_ctx, cur_otg_master);
+
+ if (!dcn42b_can_pipe_be_opp_head(pool, free_pipe_idx))
+ free_pipe_idx = recource_find_free_pipe_not_used_in_cur_res_ctx(
+ cur_res_ctx, new_res_ctx, pool);
+
+ if (!dcn42b_can_pipe_be_opp_head(pool, free_pipe_idx))
+ free_pipe_idx = resource_find_any_free_pipe(new_res_ctx, pool);
+
+ if (!dcn42b_can_pipe_be_opp_head(pool, free_pipe_idx))
+ return FREE_PIPE_INDEX_NOT_FOUND;
+
+ return free_pipe_idx;
+}
+
+struct pipe_ctx *dcn42b_acquire_free_pipe_as_secondary_opp_head(
+ const struct dc_state *cur_ctx,
+ struct dc_state *new_ctx,
+ const struct resource_pool *pool,
+ const struct pipe_ctx *otg_master)
+{
+ int free_pipe_idx = dcn42b_find_optimal_free_pipe_as_secondary_opp_head(
+ &cur_ctx->res_ctx, &new_ctx->res_ctx,
+ pool, otg_master);
+ struct pipe_ctx *free_pipe;
+
+ if (free_pipe_idx >= 0) {
+ free_pipe = &new_ctx->res_ctx.pipe_ctx[free_pipe_idx];
+ free_pipe->pipe_idx = (uint8_t)free_pipe_idx;
+ free_pipe->stream = otg_master->stream;
+ free_pipe->stream_res.tg = otg_master->stream_res.tg;
+ free_pipe->stream_res.dsc = NULL;
+ free_pipe->stream_res.opp = pool->opps[free_pipe_idx];
+ free_pipe->plane_res.mi = pool->mis[free_pipe_idx];
+ free_pipe->plane_res.hubp = pool->hubps[free_pipe_idx];
+ free_pipe->plane_res.ipp = pool->ipps[free_pipe_idx];
+ free_pipe->plane_res.xfm = pool->transforms[free_pipe_idx];
+ free_pipe->plane_res.dpp = pool->dpps[free_pipe_idx];
+ free_pipe->plane_res.mpcc_inst = (uint8_t)pool->dpps[free_pipe_idx]->inst;
+ free_pipe->dsc_padding_params = otg_master->dsc_padding_params;
+ if (free_pipe->stream->timing.flags.DSC == 1) {
+ dcn20_acquire_dsc(free_pipe->stream->ctx->dc,
+ &new_ctx->res_ctx,
+ &free_pipe->stream_res.dsc,
+ free_pipe_idx);
+ ASSERT(free_pipe->stream_res.dsc);
+ if (free_pipe->stream_res.dsc == NULL) {
+ memset(free_pipe, 0, sizeof(*free_pipe));
+ free_pipe = NULL;
+ }
+ }
+ } else {
+ ASSERT(otg_master);
+ free_pipe = NULL;
+ }
+
+ return free_pipe;
+}
+
static struct resource_funcs dcn42b_res_pool_funcs = {
.destroy = dcn42b_destroy_resource_pool,
.link_enc_create = dcn42b_link_encoder_create,
@@ -1961,7 +2041,7 @@ static struct resource_funcs dcn42b_res_pool_funcs = {
.calculate_wm_and_dlg = NULL,
.populate_dml_pipes = NULL,
.acquire_free_pipe_as_secondary_dpp_pipe = dcn32_acquire_free_pipe_as_secondary_dpp_pipe,
- .acquire_free_pipe_as_secondary_opp_head = dcn32_acquire_free_pipe_as_secondary_opp_head,
+ .acquire_free_pipe_as_secondary_opp_head = dcn42b_acquire_free_pipe_as_secondary_opp_head,
.release_pipe = dcn20_release_pipe,
.add_stream_to_ctx = dcn30_add_stream_to_ctx,
.add_dsc_to_stream_resource = dcn20_add_dsc_to_stream_resource,
diff --git a/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.h b/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.h
index 484ba1455468..8b9e3e9723ed 100644
--- a/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.h
+++ b/drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.h
@@ -516,4 +516,10 @@ enum dc_status dcn42b_validate_bandwidth(struct dc *dc,
void dcn42b_prepare_mcache_programming(struct dc *dc, struct dc_state *context);
+struct pipe_ctx *dcn42b_acquire_free_pipe_as_secondary_opp_head(
+ const struct dc_state *cur_ctx,
+ struct dc_state *new_ctx,
+ const struct resource_pool *pool,
+ const struct pipe_ctx *otg_master);
+
#endif /* _DCN42B_RESOURCE_H_ */
--
2.43.0
next prev parent reply other threads:[~2026-11-25 6:59 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 6:54 [PATCH 00/27] DC Patches Nov 30 2026 Chenyu Chen
2026-11-25 6:54 ` [PATCH 01/27] drm/amd/display: Avoid per-entry long division in __drm_lut32_to_dc_gamma Chenyu Chen
2026-11-25 6:54 ` [PATCH 02/27] drm/amd/display: Capture more diagnostic register state Chenyu Chen
2026-11-25 6:54 ` [PATCH 03/27] drm/amd/display: Add debug option to force DP link rate Chenyu Chen
2026-11-25 6:54 ` [PATCH 04/27] drm/amd/display: Reject Replay activation on an inactive link Chenyu Chen
2026-11-25 6:54 ` [PATCH 05/27] drm/amd/display: Decouple PROGRAM_CURSOR_UPDATE_NOW from dc and pipe_ctx Chenyu Chen
2026-11-25 6:54 ` [PATCH 06/27] drm/amd/display: Add DPMS-v2 init Chenyu Chen
2026-11-25 6:54 ` [PATCH 07/27] drm/amd/display: Expose per-CRTC pstate method in connector debugfs Chenyu Chen
2026-11-25 6:54 ` [PATCH 08/27] drm/amd/display: Add DPMS-v2 tx init Chenyu Chen
2026-11-25 6:54 ` [PATCH 09/27] drm/amd/display: Derive DCN6 DSCCLK range from DISPCLK Chenyu Chen
2026-11-25 6:54 ` [PATCH 10/27] drm/amd/display: Carry the stream and plane update bits in update_flags Chenyu Chen
2026-11-25 6:55 ` [PATCH 11/27] drm/amd/display: Add the vsync flip to the DC2 seamless update Chenyu Chen
2026-11-25 6:55 ` [PATCH 12/27] drm/amd/display: Preserve bandwidth floors in overrides Chenyu Chen
2026-11-25 6:55 ` [PATCH 13/27] drm/amd/display: Set HDMI bypass earlier Chenyu Chen
2026-11-25 6:55 ` [PATCH 14/27] drm/amd/display: Add DMUB timer reference clock to ref_clocks Chenyu Chen
2026-11-25 6:55 ` [PATCH 15/27] drm/amd/display: Guard connector I2C transfer without DDC pin Chenyu Chen
2026-11-28 9:43 ` Eren Özen
2026-11-25 6:55 ` [PATCH 16/27] drm/amd/display: Refactor ABM_SET_PIPE and ABM_SET_IMMEDIATE_DISABLE Chenyu Chen
2026-11-25 6:55 ` [PATCH 17/27] drm/amd/display: Implement link_set_dpms_off_v2 Chenyu Chen
2026-11-25 6:55 ` [PATCH 18/27] drm/amd/display: Add the immediate flip to the DC2 seamless update Chenyu Chen
2026-11-25 6:55 ` [PATCH 19/27] drm/amd/display: Test amdgpu_dm_dmub alt-ch apertures Chenyu Chen
2026-11-25 6:55 ` [PATCH 20/27] drm/amd/display: Test amdgpu_dm_dmub SET_CONFIG sync wait Chenyu Chen
2026-11-25 6:55 ` [PATCH 21/27] drm/amd/display: Test amdgpu_dm_dmub AUX transfer timeout Chenyu Chen
2026-11-25 6:55 ` [PATCH 22/27] drm/amd/display: Test amdgpu_dm_dmub fused IO replies Chenyu Chen
2026-11-25 6:55 ` [PATCH 23/27] drm/amd/display: Use Z8 enter plus exit for vblank reserve Chenyu Chen
2026-11-25 6:55 ` Chenyu Chen [this message]
2026-11-25 6:55 ` [PATCH 25/27] drm/amd/display: Count planes, not pipes, in the surface check Chenyu Chen
2026-11-25 6:55 ` [PATCH 26/27] drm/amd/display: [FW Promotion] Release 0.1.86.0 Chenyu Chen
2026-11-25 6:55 ` [PATCH 27/27] drm/amd/display: Promote DC to 3.2.409 Chenyu Chen
2026-11-27 5:44 ` [PATCH 00/27] DC Patches Nov 30 2026 Chung, ChiaHsuan (Tom)
2026-11-30 14:10 ` Wheeler, Daniel
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=20261125065631.3889665-25-chen-yu.chen@amd.com \
--to=chen-yu.chen@amd.com \
--cc=PingLei.Lin@amd.com \
--cc=Ray.Wu@amd.com \
--cc=alex.hung@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=aurabindo.pillai@amd.com \
--cc=charlene.liu@amd.com \
--cc=chiahsuan.chung@amd.com \
--cc=daniel.wheeler@amd.com \
--cc=gabe.teeger@amd.com \
--cc=harry.wentland@amd.com \
--cc=ivan.lipski@amd.com \
--cc=jerry.zuo@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.