This is a note to let you know that I've just added the patch titled drm/amd/display: Retain phantom plane/stream if validation fails to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: drm-amd-display-retain-phantom-plane-stream-if-validation-fails.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From stable-owner@xxxxxxxxxxxxxxx Fri Aug 11 23:09:25 2023 From: Mario Limonciello <mario.limonciello@xxxxxxx> Date: Fri, 11 Aug 2023 16:07:06 -0500 Subject: drm/amd/display: Retain phantom plane/stream if validation fails To: <stable@xxxxxxxxxxxxxxx> Cc: <Tianci.Yin@xxxxxxx>, <Richard.Gong@xxxxxxx>, <Aurabindo.Pillai@xxxxxxx>, Mario Limonciello <mario.limonciello@xxxxxxx> Message-ID: <20230811210708.14512-9-mario.limonciello@xxxxxxx> From: Alvin Lee <Alvin.Lee2@xxxxxxx> commit 9b216b7e38f5381bcc3ad21c5ac614aa577ab8f2 upstream [Description] - If we fail validation, we should retain the phantom stream/planes - Full updates assume that phantom pipes will be fully removed, but if validation fails we keep the phantom pipes - Therefore we have to retain the plane/stream if validation fails (since the refcount is decremented before validation, and the expectation is that it's fully freed when the old dc_state is released) Reviewed-by: Jun Lei <Jun.Lei@xxxxxxx> Acked-by: Brian Chang <Brian.Chang@xxxxxxx> Signed-off-by: Alvin Lee <Alvin.Lee2@xxxxxxx> Tested-by: Daniel Wheeler <daniel.wheeler@xxxxxxx> Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx> Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/gpu/drm/amd/display/dc/core/dc.c | 13 +++++++++ drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c | 22 ++++++++++++++++ drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.h | 3 ++ drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c | 1 drivers/gpu/drm/amd/display/dc/inc/core_types.h | 1 5 files changed, 40 insertions(+) --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -3149,6 +3149,19 @@ static bool update_planes_and_stream_sta if (update_type == UPDATE_TYPE_FULL) { if (!dc->res_pool->funcs->validate_bandwidth(dc, context, false)) { + /* For phantom pipes we remove and create a new set of phantom pipes + * for each full update (because we don't know if we'll need phantom + * pipes until after the first round of validation). However, if validation + * fails we need to keep the existing phantom pipes (because we don't update + * the dc->current_state). + * + * The phantom stream/plane refcount is decremented for validation because + * we assume it'll be removed (the free comes when the dc_state is freed), + * but if validation fails we have to increment back the refcount so it's + * consistent. + */ + if (dc->res_pool->funcs->retain_phantom_pipes) + dc->res_pool->funcs->retain_phantom_pipes(dc, dc->current_state); BREAK_TO_DEBUGGER(); goto fail; } --- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c @@ -1719,6 +1719,27 @@ static struct dc_stream_state *dcn32_ena return phantom_stream; } +void dcn32_retain_phantom_pipes(struct dc *dc, struct dc_state *context) +{ + int i; + struct dc_plane_state *phantom_plane = NULL; + struct dc_stream_state *phantom_stream = NULL; + + for (i = 0; i < dc->res_pool->pipe_count; i++) { + struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; + + if (!pipe->top_pipe && !pipe->prev_odm_pipe && + pipe->plane_state && pipe->stream && + pipe->stream->mall_stream_config.type == SUBVP_PHANTOM) { + phantom_plane = pipe->plane_state; + phantom_stream = pipe->stream; + + dc_plane_state_retain(phantom_plane); + dc_stream_retain(phantom_stream); + } + } +} + // return true if removed piped from ctx, false otherwise bool dcn32_remove_phantom_pipes(struct dc *dc, struct dc_state *context) { @@ -2035,6 +2056,7 @@ static struct resource_funcs dcn32_res_p .update_soc_for_wm_a = dcn30_update_soc_for_wm_a, .add_phantom_pipes = dcn32_add_phantom_pipes, .remove_phantom_pipes = dcn32_remove_phantom_pipes, + .retain_phantom_pipes = dcn32_retain_phantom_pipes, }; static uint32_t read_pipe_fuses(struct dc_context *ctx) --- a/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.h +++ b/drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.h @@ -83,6 +83,9 @@ bool dcn32_release_post_bldn_3dlut( bool dcn32_remove_phantom_pipes(struct dc *dc, struct dc_state *context); +void dcn32_retain_phantom_pipes(struct dc *dc, + struct dc_state *context); + void dcn32_add_phantom_pipes(struct dc *dc, struct dc_state *context, display_e2e_pipe_params_st *pipes, --- a/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c @@ -1619,6 +1619,7 @@ static struct resource_funcs dcn321_res_ .update_soc_for_wm_a = dcn30_update_soc_for_wm_a, .add_phantom_pipes = dcn32_add_phantom_pipes, .remove_phantom_pipes = dcn32_remove_phantom_pipes, + .retain_phantom_pipes = dcn32_retain_phantom_pipes, }; static uint32_t read_pipe_fuses(struct dc_context *ctx) --- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h +++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h @@ -234,6 +234,7 @@ struct resource_funcs { unsigned int index); bool (*remove_phantom_pipes)(struct dc *dc, struct dc_state *context); + void (*retain_phantom_pipes)(struct dc *dc, struct dc_state *context); void (*get_panel_config_defaults)(struct dc_panel_config *panel_config); }; Patches currently in stable-queue which might be from stable-owner@xxxxxxxxxxxxxxx are queue-6.1/drm-amd-display-fix-the-build-when-drm_amd_dc_dcn-is-not-set.patch queue-6.1/drm-amd-pm-fulfill-powerplay-peak-profiling-mode-shader-memory-clock-settings.patch queue-6.1/drm-amd-display-handle-virtual-hardware-detect.patch queue-6.1/drm-amd-display-use-update-plane-and-stream-routine-for-dcn32x.patch queue-6.1/drm-amd-display-avoid-abm-when-odm-combine-is-enabled-for-edp.patch queue-6.1/drm-amd-pm-fulfill-swsmu-peak-profiling-mode-shader-memory-clock-settings.patch queue-6.1/drm-amd-pm-avoid-unintentional-shutdown-due-to-temperature-momentary-fluctuation.patch queue-6.1/drm-amd-display-update-otg-instance-in-the-commit-stream.patch queue-6.1/drm-amd-pm-expose-swctf-threshold-setting-for-legacy-powerplay.patch queue-6.1/drm-amd-display-add-function-for-validate-and-update-new-stream.patch queue-6.1/drm-amd-display-trigger-timing-sync-only-if-tg-is-running.patch queue-6.1/drm-amd-display-handle-seamless-boot-stream.patch queue-6.1/drm-amd-display-retain-phantom-plane-stream-if-validation-fails.patch queue-6.1/drm-amd-display-disable-phantom-otg-after-enable-for-plane-disable.patch