drm/amd/display: Fix crash on setting VRR with no display connected
authorHarry VanZyllDeJong <hvanzyll@amd.com>
Tue, 11 Jan 2022 20:11:42 +0000 (15:11 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 12 Apr 2022 18:17:48 +0000 (14:17 -0400)
[HOW&WHY]
VRR was getting set at the same time
the timing generator would be null when there was no display
connected. Added null check to the timing generator variable
so it does not get referenced if it is null.

Reviewed-by: Harry Vanzylldejong <harry.vanzylldejong@amd.com>
Reviewed-by: Evgenii Krasnikov <Evgenii.Krasnikov@amd.com>
Reviewed-by: Nicholas Choi <Nicholas.Choi@amd.com>
Acked-by: Pavle Kotarac <Pavle.Kotarac@amd.com>
Signed-off-by: Harry VanZyllDeJong <hvanzyll@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c

index c84011caa73ca0cbd62af75ab77f1d4a0c731727..6c69fd3bc77a959f20e0fe67600c17f0233ec13b 100644 (file)
@@ -3053,12 +3053,16 @@ void dcn10_set_drr(struct pipe_ctx **pipe_ctx,
         * as well.
         */
        for (i = 0; i < num_pipes; i++) {
-               pipe_ctx[i]->stream_res.tg->funcs->set_drr(
-                       pipe_ctx[i]->stream_res.tg, &params);
-               if (adjust.v_total_max != 0 && adjust.v_total_min != 0)
-                       pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control(
-                                       pipe_ctx[i]->stream_res.tg,
-                                       event_triggers, num_frames);
+               if ((pipe_ctx[i]->stream_res.tg != NULL) && pipe_ctx[i]->stream_res.tg->funcs) {
+                       if (pipe_ctx[i]->stream_res.tg->funcs->set_drr)
+                               pipe_ctx[i]->stream_res.tg->funcs->set_drr(
+                                       pipe_ctx[i]->stream_res.tg, &params);
+                       if (adjust.v_total_max != 0 && adjust.v_total_min != 0)
+                               if (pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control)
+                                       pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control(
+                                               pipe_ctx[i]->stream_res.tg,
+                                               event_triggers, num_frames);
+               }
        }
 }