drm/amd/display: Make dc_state_update const in commit path

[Why]
The state-update commit path only reads the caller's update
descriptor, it never mutates the dc_state_update root. Making the
pointer const documents that contract.

[How]
Add const to the updates parameter of dc_update_state and
dc_check_state_update. Mark the single-assignment locals in
dc_update_state_init const and replace the memset plus
field-by-field assignment with a compound literal initializer.

Reviewed-by: Dominik Kaszewski <dominik.kaszewski@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Signed-off-by: Wayne Lin <wayne.lin@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Wenjing Liu 2026-07-07 17:15:48 -04:00 committed by Alex Deucher
parent 52771a3254
commit a63f63f473
2 changed files with 23 additions and 23 deletions

View File

@ -3281,7 +3281,7 @@ static struct dc_update_descriptor check_update_surfaces_for_stream(
*/
struct dc_update_descriptor dc_check_state_update(
const struct dc_check_config *check_config,
struct dc_state_update *updates)
const struct dc_state_update *updates)
{
struct dc_update_descriptor desc = {0};
@ -6263,7 +6263,7 @@ static void dc_update_scratch_release(struct dc *dc,
* @updates: root update object carrying stream, plane, and probe updates
* Return: true on success, false on failure.
*/
bool dc_update_state(struct dc *dc, struct dc_state_update *updates)
bool dc_update_state(struct dc *dc, const struct dc_state_update *updates)
{
struct dc_update_scratch_space *scratch;
bool more = true;
@ -8524,11 +8524,11 @@ struct dc_update_scratch_space *dc_update_state_init(
{
const enum dce_version version = dc->ctx->dce_version;
struct dc_update_scratch_space *scratch = dc_update_scratch_acquire(dc);
bool has_stream_or_plane = updates->stream || updates->stream_update || updates->surface_updates;
bool has_probe = updates->probe_updates;
bool surface_without_stream = updates->surface_updates && !updates->stream;
bool stream_update_without_stream = updates->stream_update && !updates->stream;
bool bad_surface_count = updates->surface_count > 0 && !updates->surface_updates;
const bool has_stream_or_plane = updates->stream || updates->stream_update || updates->surface_updates;
const bool has_probe = updates->probe_updates;
const bool surface_without_stream = updates->surface_updates && !updates->stream;
const bool stream_update_without_stream = updates->stream_update && !updates->stream;
const bool bad_surface_count = updates->surface_count > 0 && !updates->surface_updates;
if (!scratch)
return NULL;
@ -8543,20 +8543,20 @@ struct dc_update_scratch_space *dc_update_state_init(
return NULL;
}
memset(scratch, 0, sizeof(*scratch));
scratch->dc = dc;
scratch->surface_updates = updates->surface_updates;
scratch->surface_count = updates->surface_count;
scratch->stream = updates->stream;
scratch->stream_update = updates->stream_update;
scratch->probe_updates = updates->probe_updates;
scratch->update_v3 = version >= DCN_VERSION_4_01
|| version == DCN_VERSION_3_2
|| version == DCN_VERSION_3_21;
scratch->do_clear_update_bits = version >= DCN_VERSION_1_0;
scratch->new_context = NULL;
scratch->flow = UPDATE_V3_FLOW_INVALID;
*scratch = (struct dc_update_scratch_space){
.dc = dc,
.surface_updates = updates->surface_updates,
.surface_count = updates->surface_count,
.stream = updates->stream,
.stream_update = updates->stream_update,
.probe_updates = updates->probe_updates,
.update_v3 = version >= DCN_VERSION_4_01
|| version == DCN_VERSION_3_2
|| version == DCN_VERSION_3_21,
.do_clear_update_bits = version >= DCN_VERSION_1_0,
.new_context = NULL,
.flow = UPDATE_V3_FLOW_INVALID,
};
return scratch;
}

View File

@ -2125,7 +2125,7 @@ struct dc_state_update {
*/
struct dc_update_descriptor dc_check_state_update(
const struct dc_check_config *check_config,
struct dc_state_update *updates);
const struct dc_state_update *updates);
/**
* dc_update_state - Commit an absolute dc_state_update.
@ -2134,7 +2134,7 @@ struct dc_update_descriptor dc_check_state_update(
*
* Return: true on success, false on failure.
*/
bool dc_update_state(struct dc *dc, struct dc_state_update *updates);
bool dc_update_state(struct dc *dc, const struct dc_state_update *updates);
struct dc_update_scratch_space;