From afc8935ef0fc04c87cd7e7749ff28c32be4f712a Mon Sep 17 00:00:00 2001 From: Dmytro Laktyushkin Date: Wed, 17 May 2017 16:56:56 -0400 Subject: [PATCH] drm/amd/display: revert dc_get_validate_context re-entrancy fix Apply dc_get_validate_context re-entrancy fix to dc_validate_resources instead Signed-off-by: Dmytro Laktyushkin Reviewed-by: Dmytro Laktyushkin Acked-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc.c | 71 +++++++++++++++++++++--- 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 0aafcc088284..773f0efc449b 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -653,6 +653,40 @@ void dc_destroy(struct dc **dc) *dc = NULL; } +static bool is_validation_required( + const struct core_dc *dc, + const struct dc_validation_set set[], + int set_count) +{ + const struct validate_context *context = dc->current_context; + int i, j; + + if (context->stream_count != set_count) + return true; + + for (i = 0; i < set_count; i++) { + + if (set[i].surface_count != context->stream_status[i].surface_count) + return true; + if (!is_stream_unchanged(DC_STREAM_TO_CORE(set[i].stream), context->streams[i])) + return true; + + for (j = 0; j < set[i].surface_count; j++) { + struct dc_surface temp_surf = { 0 }; + + temp_surf = *context->stream_status[i].surfaces[j]; + temp_surf.clip_rect = set[i].surfaces[j]->clip_rect; + temp_surf.dst_rect.x = set[i].surfaces[j]->dst_rect.x; + temp_surf.dst_rect.y = set[i].surfaces[j]->dst_rect.y; + + if (memcmp(&temp_surf, set[i].surfaces[j], sizeof(temp_surf)) != 0) + return true; + } + } + + return false; +} + struct validate_context *dc_get_validate_context( const struct dc *dc, const struct dc_validation_set set[], @@ -663,11 +697,16 @@ struct validate_context *dc_get_validate_context( struct validate_context *context; context = dm_alloc(sizeof(struct validate_context)); - if(context == NULL) + if (context == NULL) goto context_alloc_fail; + if (!is_validation_required(core_dc, set, set_count)) { + dc_resource_validate_ctx_copy_construct(core_dc->current_context, context); + return context; + } + result = core_dc->res_pool->funcs->validate_with_context( - core_dc, set, set_count, context, NULL); + core_dc, set, set_count, context, core_dc->current_context); context_alloc_fail: if (result != DC_OK) { @@ -690,16 +729,30 @@ bool dc_validate_resources( const struct dc_validation_set set[], uint8_t set_count) { - struct validate_context *ctx; + struct core_dc *core_dc = DC_TO_CORE(dc); + enum dc_status result = DC_ERROR_UNEXPECTED; + struct validate_context *context; - ctx = dc_get_validate_context(dc, set, set_count); - if (ctx) { - dc_resource_validate_ctx_destruct(ctx); - dm_free(ctx); - return true; + context = dm_alloc(sizeof(struct validate_context)); + if (context == NULL) + goto context_alloc_fail; + + result = core_dc->res_pool->funcs->validate_with_context( + core_dc, set, set_count, context, NULL); + +context_alloc_fail: + if (result != DC_OK) { + dm_logger_write(core_dc->ctx->logger, LOG_WARNING, + "%s:resource validation failed, dc_status:%d\n", + __func__, + result); } - return false; + dc_resource_validate_ctx_destruct(context); + dm_free(context); + context = NULL; + + return result == DC_OK; } bool dc_validate_guaranteed( -- 2.30.2