OSDN Git Service

drm/amd/display: Retain phantom pipes when min transition into subvp (#7358)
authorAlvin Lee <Alvin.Lee2@amd.com>
Thu, 17 Nov 2022 16:55:52 +0000 (11:55 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 29 Nov 2022 16:03:38 +0000 (11:03 -0500)
[Description]
- When entering into a SubVP config that requires a minimal
  transition we need to retain phantom pipes and also restore
  the mall config
- This is because the min transition will remove phantom pipes
  from the context (shallow copy) and not restore it's original
  state
- This is just a workaround, and needs a proper fix

Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Jasdeep Dhillon <jdhillon@amd.com>
Signed-off-by: Alvin Lee <Alvin.Lee2@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c
drivers/gpu/drm/amd/display/dc/dc_stream.h
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.h
drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
drivers/gpu/drm/amd/display/dc/inc/core_types.h

index 5e08922..87994ae 100644 (file)
@@ -3954,6 +3954,7 @@ bool dc_update_planes_and_stream(struct dc *dc,
        struct dc_state *context;
        enum surface_update_type update_type;
        int i;
+       struct mall_temp_config mall_temp_config;
 
        /* In cases where MPO and split or ODM are used transitions can
         * cause underflow. Apply stream configuration with minimal pipe
@@ -3985,11 +3986,29 @@ bool dc_update_planes_and_stream(struct dc *dc,
 
        /* on plane removal, minimal state is the new one */
        if (force_minimal_pipe_splitting && !is_plane_addition) {
+               /* Since all phantom pipes are removed in full validation,
+                * we have to save and restore the subvp/mall config when
+                * we do a minimal transition since the flags marking the
+                * pipe as subvp/phantom will be cleared (dc copy constructor
+                * creates a shallow copy).
+                */
+               if (dc->res_pool->funcs->save_mall_state)
+                       dc->res_pool->funcs->save_mall_state(dc, context, &mall_temp_config);
                if (!commit_minimal_transition_state(dc, context)) {
                        dc_release_state(context);
                        return false;
                }
-
+               if (dc->res_pool->funcs->restore_mall_state)
+                       dc->res_pool->funcs->restore_mall_state(dc, context, &mall_temp_config);
+
+               /* If we do a minimal transition with plane removal and the context
+                * has subvp we also have to retain back the phantom stream / planes
+                * since the refcount is decremented as part of the min transition
+                * (we commit a state with no subvp, so the phantom streams / planes
+                * had to be removed).
+                */
+               if (dc->res_pool->funcs->retain_phantom_pipes)
+                       dc->res_pool->funcs->retain_phantom_pipes(dc, context);
                update_type = UPDATE_TYPE_FULL;
        }
 
index e0cee96..dfd3df1 100644 (file)
@@ -160,6 +160,17 @@ struct mall_stream_config {
        struct dc_stream_state *paired_stream;  // master / slave stream
 };
 
+/* Temp struct used to save and restore MALL config
+ * during validation.
+ *
+ * TODO: Move MALL config into dc_state instead of stream struct
+ * to avoid needing to save/restore.
+ */
+struct mall_temp_config {
+       struct mall_stream_config mall_stream_config[MAX_PIPES];
+       bool is_phantom_plane[MAX_PIPES];
+};
+
 struct dc_stream_state {
        // sink is deprecated, new code should not reference
        // this pointer
index 67b43e7..e4dbc83 100644 (file)
@@ -2069,6 +2069,8 @@ static struct resource_funcs dcn32_res_pool_funcs = {
        .add_phantom_pipes = dcn32_add_phantom_pipes,
        .remove_phantom_pipes = dcn32_remove_phantom_pipes,
        .retain_phantom_pipes = dcn32_retain_phantom_pipes,
+       .save_mall_state = dcn32_save_mall_state,
+       .restore_mall_state = dcn32_restore_mall_state,
 };
 
 
index d4a37f3..13fbc57 100644 (file)
 extern struct _vcs_dpi_ip_params_st dcn3_2_ip;
 extern struct _vcs_dpi_soc_bounding_box_st dcn3_2_soc;
 
-/* Temp struct used to save and restore MALL config
- * during validation.
- *
- * TODO: Move MALL config into dc_state instead of stream struct
- * to avoid needing to save/restore.
- */
-struct mall_temp_config {
-       struct mall_stream_config mall_stream_config[MAX_PIPES];
-       bool is_phantom_plane[MAX_PIPES];
-};
-
 struct dcn32_resource_pool {
        struct resource_pool base;
 };
index b66fe62..3406e77 100644 (file)
@@ -1622,6 +1622,8 @@ static struct resource_funcs dcn321_res_pool_funcs = {
        .add_phantom_pipes = dcn32_add_phantom_pipes,
        .remove_phantom_pipes = dcn32_remove_phantom_pipes,
        .retain_phantom_pipes = dcn32_retain_phantom_pipes,
+       .save_mall_state = dcn32_save_mall_state,
+       .restore_mall_state = dcn32_restore_mall_state,
 };
 
 
index 108bffb..525f8f0 100644 (file)
@@ -243,6 +243,8 @@ struct resource_funcs {
        bool (*remove_phantom_pipes)(struct dc *dc, struct dc_state *context, bool fast_update);
        void (*retain_phantom_pipes)(struct dc *dc, struct dc_state *context);
        void (*get_panel_config_defaults)(struct dc_panel_config *panel_config);
+       void (*save_mall_state)(struct dc *dc, struct dc_state *context, struct mall_temp_config *temp_config);
+       void (*restore_mall_state)(struct dc *dc, struct dc_state *context, struct mall_temp_config *temp_config);
 };
 
 struct audio_support{