From: Wenjing Liu <[email protected]> [Why] dc_validate_with_context() took a C array of per-stream elements plus a separate count. This flat array cannot be extended to carry global objects without widening the signature further.
[How] Rename the per-stream element to dc_validation_stream, and make dc_validation_set a root struct holding streams[MAX_STREAMS] and stream_count. Update dc_validate_with_context() to take a single const dc_validation_set * and propagate the new shape through all DC-layer callers and helpers. Remove the never-implemented dce112_validate_with_context declaration and the orphaned dce100 forward-declare. No behavior change. Reviewed-by: Dominik Kaszewski <[email protected]> Signed-off-by: Wenjing Liu <[email protected]> Signed-off-by: Wayne Lin <[email protected]> --- drivers/gpu/drm/amd/display/dc/core/dc.c | 11 ++-- .../gpu/drm/amd/display/dc/core/dc_resource.c | 60 +++++++++---------- drivers/gpu/drm/amd/display/dc/dc.h | 22 +++++-- drivers/gpu/drm/amd/display/dc/inc/resource.h | 3 +- .../dc/resource/dce100/dce100_resource.h | 1 - .../dc/resource/dce112/dce112_resource.h | 7 --- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index f1805b03f0db..3fa577a02df1 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -2479,7 +2479,7 @@ enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params unsigned int i, j; struct dc_state *context; enum dc_status res = DC_OK; - struct dc_validation_set set[MAX_STREAMS] = {0}; + struct dc_validation_set set = {0}; struct pipe_ctx *pipe; bool handle_exit_odm2to1 = false; @@ -2512,14 +2512,15 @@ enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params dc_stream_log(dc, stream); - set[i].stream = stream; + set.streams[i].stream = stream; if (status) { - set[i].plane_count = (uint8_t)status->plane_count; + set.streams[i].plane_count = (uint8_t)status->plane_count; for (j = 0; j < (unsigned int)status->plane_count; j++) - set[i].plane_states[j] = status->plane_states[j]; + set.streams[i].plane_states[j] = status->plane_states[j]; } } + set.stream_count = (uint8_t)params->stream_count; /* ODM Combine 2:1 power optimization is only applied for single stream * scenario, it uses extra pipes than needed to reduce power consumption @@ -2543,7 +2544,7 @@ enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params context->power_source = params->power_source; - res = dc_validate_with_context(dc, set, params->stream_count, context, DC_VALIDATE_MODE_AND_PROGRAMMING); + res = dc_validate_with_context(dc, &set, context, DC_VALIDATE_MODE_AND_PROGRAMMING); /* * Only update link encoder to stream assignment after bandwidth validation passed. diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index b21d41df0fab..d9492a460c2a 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -4325,8 +4325,7 @@ bool dc_resource_is_dsc_encoding_supported(const struct dc *dc) static bool planes_changed_for_existing_stream(struct dc_state *context, struct dc_stream_state *stream, - const struct dc_validation_set set[], - unsigned int set_count) + const struct dc_validation_set *set) { unsigned int i, j; struct dc_stream_status *stream_status = NULL; @@ -4343,18 +4342,18 @@ static bool planes_changed_for_existing_stream(struct dc_state *context, return false; } - for (i = 0; i < set_count; i++) - if (set[i].stream == stream) + for (i = 0; i < set->stream_count; i++) + if (set->streams[i].stream == stream) break; - if (i == set_count) + if (i == set->stream_count) ASSERT(0); - if (set[i].plane_count != stream_status->plane_count) + if (set->streams[i].plane_count != stream_status->plane_count) return true; - for (j = 0; j < set[i].plane_count; j++) - if (set[i].plane_states[j] != stream_status->plane_states[j]) + for (j = 0; j < set->streams[i].plane_count; j++) + if (set->streams[i].plane_states[j] != stream_status->plane_states[j]) return true; return false; @@ -4363,23 +4362,22 @@ static bool planes_changed_for_existing_stream(struct dc_state *context, static bool add_all_planes_for_stream( const struct dc *dc, struct dc_stream_state *stream, - const struct dc_validation_set set[], - unsigned int set_count, + const struct dc_validation_set *set, struct dc_state *state) { unsigned int i, j; - for (i = 0; i < set_count; i++) - if (set[i].stream == stream) + for (i = 0; i < set->stream_count; i++) + if (set->streams[i].stream == stream) break; - if (i == set_count) { + if (i == set->stream_count) { dm_error("Stream %p not found in set!\n", stream); return false; } - for (j = 0; j < set[i].plane_count; j++) - if (!dc_state_add_plane(dc, stream, set[i].plane_states[j], state)) + for (j = 0; j < set->streams[i].plane_count; j++) + if (!dc_state_add_plane(dc, stream, set->streams[i].plane_states[j], state)) return false; return true; @@ -4389,8 +4387,7 @@ static bool add_all_planes_for_stream( * dc_validate_with_context - Validate and update the potential new stream in the context object * * @dc: Used to get the current state status - * @set: An array of dc_validation_set with all the current streams reference - * @set_count: Total of streams + * @set: Root validation object holding all streams and their planes * @context: New context * @validate_mode: identify the validation mode * @@ -4404,8 +4401,7 @@ static bool add_all_planes_for_stream( * In case of success, return DC_OK (1), otherwise, return a DC error. */ enum dc_status dc_validate_with_context(struct dc *dc, - const struct dc_validation_set set[], - unsigned int set_count, + const struct dc_validation_set *set, struct dc_state *context, enum dc_validate_mode validate_mode) { @@ -4426,8 +4422,8 @@ enum dc_status dc_validate_with_context(struct dc *dc, for (i = 0; i < old_stream_count; i++) { struct dc_stream_state *stream = context->streams[i]; - for (j = 0; j < set_count; j++) { - if (stream == set[j].stream) { + for (j = 0; j < set->stream_count; j++) { + if (stream == set->streams[j].stream) { found = true; break; } @@ -4440,8 +4436,8 @@ enum dc_status dc_validate_with_context(struct dc *dc, } /* Second, build a list of new streams */ - for (i = 0; i < set_count; i++) { - struct dc_stream_state *stream = set[i].stream; + for (i = 0; i < set->stream_count; i++) { + struct dc_stream_state *stream = set->streams[i].stream; for (j = 0; j < old_stream_count; j++) { if (stream == context->streams[j]) { @@ -4459,10 +4455,10 @@ enum dc_status dc_validate_with_context(struct dc *dc, /* Build a list of unchanged streams which is necessary for handling * planes change such as added, removed, and updated. */ - for (i = 0; i < set_count; i++) { + for (i = 0; i < set->stream_count; i++) { /* Check if stream is part of the delete list */ for (j = 0; j < del_streams_count; j++) { - if (set[i].stream == del_streams[j]) { + if (set->streams[i].stream == del_streams[j]) { found = true; break; } @@ -4471,7 +4467,7 @@ enum dc_status dc_validate_with_context(struct dc *dc, if (!found) { /* Check if stream is part of the add list */ for (j = 0; j < add_streams_count; j++) { - if (set[i].stream == add_streams[j]) { + if (set->streams[i].stream == add_streams[j]) { found = true; break; } @@ -4479,7 +4475,7 @@ enum dc_status dc_validate_with_context(struct dc *dc, } if (!found) - unchanged_streams[unchanged_streams_count++] = set[i].stream; + unchanged_streams[unchanged_streams_count++] = set->streams[i].stream; found = false; } @@ -4488,8 +4484,7 @@ enum dc_status dc_validate_with_context(struct dc *dc, for (i = 0; i < unchanged_streams_count; i++) { if (planes_changed_for_existing_stream(context, unchanged_streams[i], - set, - set_count)) { + set)) { if (!dc_state_rem_all_planes_for_stream(dc, unchanged_streams[i], @@ -4557,7 +4552,7 @@ enum dc_status dc_validate_with_context(struct dc *dc, if (res != DC_OK) goto fail; - if (!add_all_planes_for_stream(dc, add_streams[i], set, set_count, context)) { + if (!add_all_planes_for_stream(dc, add_streams[i], set, context)) { res = DC_FAIL_ATTACH_SURFACES; goto fail; } @@ -4567,9 +4562,8 @@ enum dc_status dc_validate_with_context(struct dc *dc, for (i = 0; i < unchanged_streams_count; i++) { if (planes_changed_for_existing_stream(context, unchanged_streams[i], - set, - set_count)) { - if (!add_all_planes_for_stream(dc, unchanged_streams[i], set, set_count, context)) { + set)) { + if (!add_all_planes_for_stream(dc, unchanged_streams[i], set, context)) { res = DC_FAIL_ATTACH_SURFACES; goto fail; } diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index f06539df7f0a..bc2ed23407cc 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -2182,9 +2182,9 @@ void dc_post_update_surfaces_to_stream( void dc_get_default_tiling_info(const struct dc *dc, struct dc_tiling_info *tiling_info); /** - * struct dc_validation_set - Struct to store surface/stream associations for validation + * struct dc_validation_stream - Per-stream surface/stream association for validation */ -struct dc_validation_set { +struct dc_validation_stream { /** * @stream: Stream state properties */ @@ -2201,6 +2201,21 @@ struct dc_validation_set { uint8_t plane_count; }; +/** + * struct dc_validation_set - Root validation input grouping all streams for a commit + */ +struct dc_validation_set { + /** + * @streams: Per-stream entries (stream + its planes) + */ + struct dc_validation_stream streams[MAX_STREAMS]; + + /** + * @stream_count: Number of active entries in @streams + */ + uint8_t stream_count; +}; + bool dc_validate_boot_timing(const struct dc *dc, const struct dc_sink *sink, struct dc_crtc_timing *crtc_timing); @@ -2208,8 +2223,7 @@ bool dc_validate_boot_timing(const struct dc *dc, enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state); enum dc_status dc_validate_with_context(struct dc *dc, - const struct dc_validation_set set[], - unsigned int set_count, + const struct dc_validation_set *set, struct dc_state *context, enum dc_validate_mode validate_mode); diff --git a/drivers/gpu/drm/amd/display/dc/inc/resource.h b/drivers/gpu/drm/amd/display/dc/inc/resource.h index 945cdcefb7d4..b64ba8c0adb1 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/resource.h +++ b/drivers/gpu/drm/amd/display/dc/inc/resource.h @@ -577,8 +577,7 @@ struct pipe_ctx *resource_find_free_secondary_pipe_legacy( const struct pipe_ctx *primary_pipe); bool resource_validate_attach_surfaces( - const struct dc_validation_set set[], - int set_count, + const struct dc_validation_set *set, const struct dc_state *old_context, struct dc_state *context, const struct resource_pool *pool); diff --git a/drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.h b/drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.h index dd150a4b4610..bc130793348a 100644 --- a/drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.h +++ b/drivers/gpu/drm/amd/display/dc/resource/dce100/dce100_resource.h @@ -33,7 +33,6 @@ struct dc; struct resource_pool; -struct dc_validation_set; struct resource_pool *dce100_create_resource_pool( uint8_t num_virtual_links, diff --git a/drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.h b/drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.h index 3efc4c55d2d2..f2493945b8f4 100644 --- a/drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.h +++ b/drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.h @@ -35,13 +35,6 @@ struct resource_pool *dce112_create_resource_pool( uint8_t num_virtual_links, struct dc *dc); -enum dc_status dce112_validate_with_context( - struct dc *dc, - const struct dc_validation_set set[], - int set_count, - struct dc_state *context, - struct dc_state *old_context); - enum dc_status dce112_validate_bandwidth( struct dc *dc, struct dc_state *context, -- 2.43.0
