Commit f5b69101 authored by Michael Strauss's avatar Michael Strauss Committed by Alex Deucher
Browse files

drm/amd/display: Cache streams targeting link when performing LT automation



[WHY]
Last LT automation update can cause crash by referencing current_state and
calling into dc_update_planes_and_stream which may clobber current_state.

[HOW]
Cache relevant stream pointers and iterate through them instead of relying
on the current_state.

Reviewed-by: default avatarWenjing Liu <wenjing.liu@amd.com>
Signed-off-by: default avatarMichael Strauss <michael.strauss@amd.com>
Signed-off-by: default avatarIvan Lipski <ivan.lipski@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 327aba7f
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -76,6 +76,9 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
	uint8_t count;
	int i;

	struct dc_stream_state *streams_on_link[MAX_PIPES];
	int num_streams_on_link = 0;

	needs_divider_update = (link->dc->link_srv->dp_get_encoding_format(link_setting) !=
	link->dc->link_srv->dp_get_encoding_format((const struct dc_link_settings *) &link->cur_link_settings));

@@ -138,11 +141,18 @@ static void dp_retrain_link_dp_test(struct dc_link *link,
		pipes[i]->stream_res.tg->funcs->enable_crtc(pipes[i]->stream_res.tg);

	// Set DPMS on with stream update
	for (i = 0; i < state->stream_count; i++)
		if (state->streams[i] && state->streams[i]->link && state->streams[i]->link == link) {
			stream_update.stream = state->streams[i];
	// Cache all streams on current link since dc_update_planes_and_stream might kill current_state
	for (i = 0; i < MAX_PIPES; i++) {
		if (state->streams[i] && state->streams[i]->link && state->streams[i]->link == link)
			streams_on_link[num_streams_on_link++] = state->streams[i];
	}

	for (i = 0; i < num_streams_on_link; i++) {
		if (streams_on_link[i] && streams_on_link[i]->link && streams_on_link[i]->link == link) {
			stream_update.stream = streams_on_link[i];
			stream_update.dpms_off = &dpms_off;
			dc_update_planes_and_stream(state->clk_mgr->ctx->dc, NULL, 0, state->streams[i], &stream_update);
			dc_update_planes_and_stream(state->clk_mgr->ctx->dc, NULL, 0, streams_on_link[i], &stream_update);
		}
	}
}