Skip to contentSkip to conversation

drm/amd/display: Drop stream_for_cursor from dcn10_apply_ctx_for_surface

PATCH In review Michel Dänzer 2 participants 2 messages Nov 14, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Drop stream_for_cursor from dcn10_apply_ctx_for_surface

From: Michel Dänzer <[email protected]>

The main motivation was that it was at least theoretically possible for stream_for_cursor to be dereferenced when it was NULL.

The code also becomes slightly smaller, and hopefully easier to understand.

---
 .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c   | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +9 -12
index b5d048b364a4..d1093ba29336 100644
@@ -2124,26 +2124,23 @@ static void dcn10_apply_ctx_for_surface(
 	}
 
 	if (num_planes > 0) {
-		struct dc_stream_state *stream_for_cursor = NULL;
-
 		program_all_pipe_in_tree(dc, top_pipe_to_program, context);
 
 		for (i = 0; i < dc->res_pool->pipe_count; i++) {
 			struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
 
 			if (stream == pipe_ctx->stream) {
-				stream_for_cursor = pipe_ctx->stream;
-				break;
-			}
-		}
+				/* TODO: this is a hack w/a for switching from mpo to pipe split */
+				if (stream->cursor_attributes.address.quad_part != 0) {
+					struct dc_cursor_position position = { 0 };
 
-		/* TODO: this is a hack w/a for switching from mpo to pipe split */
-		if (stream_for_cursor->cursor_attributes.address.quad_part != 0) {
-			struct dc_cursor_position position = { 0 };
+					dc_stream_set_cursor_position(pipe_ctx->stream, &position);
+					dc_stream_set_cursor_attributes(pipe_ctx->stream,
+									&stream->cursor_attributes);
+				}
 
-			dc_stream_set_cursor_position(stream_for_cursor, &position);
-			dc_stream_set_cursor_attributes(stream_for_cursor,
-				&stream_for_cursor->cursor_attributes);
+				break;
+			}
 		}
 	}
 
Signature · 6 lines
2.15.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20171114175742.2761-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw
Quoted 8 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

The main motivation was that it was at least theoretically possible for stream_for_cursor to be dereferenced when it was NULL.

The code also becomes slightly smaller, and hopefully easier to understand.

Thanks. We've actually just reworked this code, cleaning it up a bit more. Will send this as part of the next DC patches soon.

Harry

Quoted 36 lines
---
 .../drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c   | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +6 -9
index b5d048b364a4..d1093ba29336 100644
@@ -2124,26 +2124,23 @@ static void dcn10_apply_ctx_for_surface(
 	}
 
 	if (num_planes > 0) {
-		struct dc_stream_state *stream_for_cursor = NULL;
-
 		program_all_pipe_in_tree(dc, top_pipe_to_program, context);
 
 		for (i = 0; i < dc->res_pool->pipe_count; i++) {
 			struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
 
 			if (stream == pipe_ctx->stream) {
-				stream_for_cursor = pipe_ctx->stream;
-				break;
-			}
-		}
+				/* TODO: this is a hack w/a for switching from mpo to pipe split */
+				if (stream->cursor_attributes.address.quad_part != 0) {
+					struct dc_cursor_position position = { 0 };
 
-		/* TODO: this is a hack w/a for switching from mpo to pipe split */
-		if (stream_for_cursor->cursor_attributes.address.quad_part != 0) {
-			struct dc_cursor_position position = { 0 };
+					dc_stream_set_cursor_position(pipe_ctx->stream, &position);
+					dc_stream_set_cursor_attributes(pipe_ctx->stream,
+									&stream->cursor_attributes);

drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c static void dcn10_apply_ctx_for_surface( · line 2146

Quoted 10 lines
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +3 -3
+				}
 
-			dc_stream_set_cursor_position(stream_for_cursor, &position);
-			dc_stream_set_cursor_attributes(stream_for_cursor,
-				&stream_for_cursor->cursor_attributes);
+				break;
+			}
 		}
 	}
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx