From: Jimmy Kizito <jimmy.kiz...@amd.com>

[Why]
Link encoder assignment tracking variables need to be (re)initialised
whenever dc_state is (re)initialised. Otherwise variables used for
dynamic encoder assignment (especially the link encoder availability
pool) are out of sync with dc_state and future encoder assignments are
invalid.

[How]
Initialise encoder assignment variables when creating new dc_state
resource.

Reviewed-by: Jun Lei <jun....@amd.com>
Acked-by: Anson Jacob <anson.ja...@amd.com>
Signed-off-by: Jimmy Kizito <jimmy.kiz...@amd.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc.c              | 5 +----
 drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c | 4 ++--
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c     | 3 +++
 drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h     | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index e76a2aa65a82..39ad3854bfe4 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1016,8 +1016,6 @@ static bool dc_construct(struct dc *dc,
                goto fail;
        }
 
-       dc_resource_state_construct(dc, dc->current_state);
-
        if (!create_links(dc, init_params->num_virtual_links))
                goto fail;
 
@@ -1027,8 +1025,7 @@ static bool dc_construct(struct dc *dc,
        if (!create_link_encoders(dc))
                goto fail;
 
-       /* Initialise DIG link encoder resource tracking variables. */
-       link_enc_cfg_init(dc, dc->current_state);
+       dc_resource_state_construct(dc, dc->current_state);
 
        return true;
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
index 787aaa661a29..d3c789f26a02 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
@@ -242,7 +242,7 @@ static struct link_encoder *get_link_enc_used_by_link(
        return link_enc;
 }
 /* Clear all link encoder assignments. */
-static void clear_enc_assignments(struct dc *dc, struct dc_state *state)
+static void clear_enc_assignments(const struct dc *dc, struct dc_state *state)
 {
        int i;
 
@@ -261,7 +261,7 @@ static void clear_enc_assignments(struct dc *dc, struct 
dc_state *state)
 }
 
 void link_enc_cfg_init(
-               struct dc *dc,
+               const struct dc *dc,
                struct dc_state *state)
 {
        clear_enc_assignments(dc, state);
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 c32fdccd4d92..fabe1b83bd4f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -2224,6 +2224,9 @@ void dc_resource_state_construct(
                struct dc_state *dst_ctx)
 {
        dst_ctx->clk_mgr = dc->clk_mgr;
+
+       /* Initialise DIG link encoder resource tracking variables. */
+       link_enc_cfg_init(dc, dst_ctx);
 }
 
 
diff --git a/drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h 
b/drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h
index 10dcf6a5e9b1..a4e43b4826e0 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h
@@ -36,7 +36,7 @@
  * Initialise link encoder resource tracking.
  */
 void link_enc_cfg_init(
-               struct dc *dc,
+               const struct dc *dc,
                struct dc_state *state);
 
 /*
-- 
2.25.1

Reply via email to