Skip to content

Commit e7d4e14

Browse files
tobiasjakobialexdeucher
authored andcommitted
drm/amd/display: handle nulled pipe context in DCE110's set_drr()
As set_drr() is called from IRQ context, it can happen that the pipe context has been nulled by dc_state_destruct(). Apply the same protection here that is already present for dcn35_set_drr() and dcn10_set_drr(). I.e. fetch the tg pointer first (to avoid a race with dc_state_destruct()), and then check the local copy before using it. Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3142 Fixes: 06ad7e1 ("drm/amd/display: Destroy DC context while keeping DML and DML2") Acked-by: Alex Deucher <[email protected]> Signed-off-by: Tobias Jakobi <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 375b035 commit e7d4e14

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,13 +2096,20 @@ static void set_drr(struct pipe_ctx **pipe_ctx,
20962096
* as well.
20972097
*/
20982098
for (i = 0; i < num_pipes; i++) {
2099-
pipe_ctx[i]->stream_res.tg->funcs->set_drr(
2100-
pipe_ctx[i]->stream_res.tg, &params);
2101-
2102-
if (adjust.v_total_max != 0 && adjust.v_total_min != 0)
2103-
pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control(
2104-
pipe_ctx[i]->stream_res.tg,
2105-
event_triggers, num_frames);
2099+
/* dc_state_destruct() might null the stream resources, so fetch tg
2100+
* here first to avoid a race condition. The lifetime of the pointee
2101+
* itself (the timing_generator object) is not a problem here.
2102+
*/
2103+
struct timing_generator *tg = pipe_ctx[i]->stream_res.tg;
2104+
2105+
if ((tg != NULL) && tg->funcs) {
2106+
if (tg->funcs->set_drr)
2107+
tg->funcs->set_drr(tg, &params);
2108+
if (adjust.v_total_max != 0 && adjust.v_total_min != 0)
2109+
if (tg->funcs->set_static_screen_control)
2110+
tg->funcs->set_static_screen_control(
2111+
tg, event_triggers, num_frames);
2112+
}
21062113
}
21072114
}
21082115

0 commit comments

Comments
 (0)