From c1b471b983723ea5cad5f09f6e517229627cb1a7 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 8 Aug 2019 09:03:46 -0500 Subject: [PATCH 3/3] drm/amd/display: update bw_calcs to take pipe sync into account Properly set all_displays_in_sync so that when the data is propagated to powerplay, it's set properly and we can enable mclk switching when all monitors are in sync. Signed-off-by: Alex Deucher --- .../gpu/drm/amd/display/dc/calcs/dce_calcs.c | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c index 9f12e21f8b9b..e792e8bed41c 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c @@ -25,6 +25,7 @@ #include +#include "resource.h" #include "dm_services.h" #include "dce_calcs.h" #include "dc.h" @@ -2991,6 +2992,9 @@ bool bw_calcs(struct dc_context *ctx, int pipe_count, struct dce_bw_output *calcs_output) { + int i, j; + int group_size = 1; + struct pipe_ctx *unsynced_pipes[MAX_PIPES] = { NULL }; struct bw_calcs_data *data = kzalloc(sizeof(struct bw_calcs_data), GFP_KERNEL); if (!data) @@ -2998,8 +3002,32 @@ bool bw_calcs(struct dc_context *ctx, populate_initial_data(pipe, pipe_count, data); - /*TODO: this should be taken out calcs output and assigned during timing sync for pplib use*/ - calcs_output->all_displays_in_sync = false; + for (i = 0; i < pipe_count; i++) { + struct pipe_ctx *pipe_set[MAX_PIPES]; + + if (!unsynced_pipes[i]) + continue; + + pipe_set[0] = unsynced_pipes[i]; + unsynced_pipes[i] = NULL; + + /* Add tg to the set, search rest of the tg's for ones with + * same timing, add all tgs with same timing to the group + */ + for (j = i + 1; j < pipe_count; j++) { + if (!unsynced_pipes[j]) + continue; + + if (resource_are_streams_timing_synchronizable( + unsynced_pipes[j]->stream, + pipe_set[0]->stream)) { + pipe_set[group_size] = unsynced_pipes[j]; + unsynced_pipes[j] = NULL; + group_size++; + } + } + } + calcs_output->all_displays_in_sync = (group_size == pipe_count) ? true : false; if (data->number_of_displays != 0) { uint8_t yclk_lvl, sclk_lvl; -- 2.20.1