[PATCH 14/31] drm/amd/display: revert dc_get_validate_context re-entrancy fix

Harry Wentland harry.wentland at amd.com
Tue May 23 14:08:52 UTC 2017


From: Dmytro Laktyushkin <Dmytro.Laktyushkin at amd.com>

Apply dc_get_validate_context re-entrancy fix to dc_validate_resources instead

Change-Id: I8502010ff24f6b3b4ea932e1042fdca1a02a5a0c
Signed-off-by: Dmytro Laktyushkin <Dmytro.Laktyushkin at amd.com>
Reviewed-by: Dmytro Laktyushkin <Dmytro.Laktyushkin at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
 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.11.0



More information about the amd-gfx mailing list