aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2018-11-18 20:07:52 -0500
committerDave Airlie <airlied@redhat.com>2018-11-18 20:07:52 -0500
commit9235dd441af43599b9cdcce599a3da4083fcad3c (patch)
tree5f8a79cc2d378f05e807c6c5e388394b8e86319d /drivers/gpu/drm/amd/display/modules/freesync/freesync.c
parentd7563c55ef9fc1fd2301b8708b3c1f53509d6745 (diff)
parent36b486bc682114a2f1001cbf1a87f21ae381bfc1 (diff)
Merge branch 'drm-next-4.21' of git://people.freedesktop.org/~agd5f/linux into drm-next
New features for 4.21: amdgpu: - Support for SDMA paging queue on vega - Put compute EOP buffers into vram for better performance - Share more code with amdkfd - Support for scanout with DCC on gfx9 - Initial kerneldoc for DC - Updated SMU firmware support for gfx8 chips - Rework CSA handling for eventual support for preemption - XGMI PSP support - Clean up RLC handling - Enable GPU reset by default on VI, SOC15 dGPUs - Ring and IB test cleanups amdkfd: - Share more code with amdgpu ttm: - Move global init out of the drivers scheduler: - Track if schedulers are ready for work - Timeout/fault handling changes to facilitate GPU recovery Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexdeucher@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20181114165113.3751-1-alexander.deucher@amd.com
Diffstat (limited to 'drivers/gpu/drm/amd/display/modules/freesync/freesync.c')
-rw-r--r--drivers/gpu/drm/amd/display/modules/freesync/freesync.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index 4018c7180d00..620a171620ee 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -37,6 +37,8 @@
37#define RENDER_TIMES_MAX_COUNT 10 37#define RENDER_TIMES_MAX_COUNT 10
38/* Threshold to exit BTR (to avoid frequent enter-exits at the lower limit) */ 38/* Threshold to exit BTR (to avoid frequent enter-exits at the lower limit) */
39#define BTR_EXIT_MARGIN 2000 39#define BTR_EXIT_MARGIN 2000
40/*Threshold to exit fixed refresh rate*/
41#define FIXED_REFRESH_EXIT_MARGIN_IN_HZ 4
40/* Number of consecutive frames to check before entering/exiting fixed refresh*/ 42/* Number of consecutive frames to check before entering/exiting fixed refresh*/
41#define FIXED_REFRESH_ENTER_FRAME_COUNT 5 43#define FIXED_REFRESH_ENTER_FRAME_COUNT 5
42#define FIXED_REFRESH_EXIT_FRAME_COUNT 5 44#define FIXED_REFRESH_EXIT_FRAME_COUNT 5
@@ -257,40 +259,14 @@ static void apply_below_the_range(struct core_freesync *core_freesync,
257 if (in_out_vrr->btr.btr_active) { 259 if (in_out_vrr->btr.btr_active) {
258 in_out_vrr->btr.frame_counter = 0; 260 in_out_vrr->btr.frame_counter = 0;
259 in_out_vrr->btr.btr_active = false; 261 in_out_vrr->btr.btr_active = false;
260
261 /* Exit Fixed Refresh mode */
262 } else if (in_out_vrr->fixed.fixed_active) {
263
264 in_out_vrr->fixed.frame_counter++;
265
266 if (in_out_vrr->fixed.frame_counter >
267 FIXED_REFRESH_EXIT_FRAME_COUNT) {
268 in_out_vrr->fixed.frame_counter = 0;
269 in_out_vrr->fixed.fixed_active = false;
270 }
271 } 262 }
272 } else if (last_render_time_in_us > max_render_time_in_us) { 263 } else if (last_render_time_in_us > max_render_time_in_us) {
273 /* Enter Below the Range */ 264 /* Enter Below the Range */
274 if (!in_out_vrr->btr.btr_active && 265 in_out_vrr->btr.btr_active = true;
275 in_out_vrr->btr.btr_enabled) {
276 in_out_vrr->btr.btr_active = true;
277
278 /* Enter Fixed Refresh mode */
279 } else if (!in_out_vrr->fixed.fixed_active &&
280 !in_out_vrr->btr.btr_enabled) {
281 in_out_vrr->fixed.frame_counter++;
282
283 if (in_out_vrr->fixed.frame_counter >
284 FIXED_REFRESH_ENTER_FRAME_COUNT) {
285 in_out_vrr->fixed.frame_counter = 0;
286 in_out_vrr->fixed.fixed_active = true;
287 }
288 }
289 } 266 }
290 267
291 /* BTR set to "not active" so disengage */ 268 /* BTR set to "not active" so disengage */
292 if (!in_out_vrr->btr.btr_active) { 269 if (!in_out_vrr->btr.btr_active) {
293 in_out_vrr->btr.btr_active = false;
294 in_out_vrr->btr.inserted_duration_in_us = 0; 270 in_out_vrr->btr.inserted_duration_in_us = 0;
295 in_out_vrr->btr.frames_to_insert = 0; 271 in_out_vrr->btr.frames_to_insert = 0;
296 in_out_vrr->btr.frame_counter = 0; 272 in_out_vrr->btr.frame_counter = 0;
@@ -375,7 +351,12 @@ static void apply_fixed_refresh(struct core_freesync *core_freesync,
375 bool update = false; 351 bool update = false;
376 unsigned int max_render_time_in_us = in_out_vrr->max_duration_in_us; 352 unsigned int max_render_time_in_us = in_out_vrr->max_duration_in_us;
377 353
378 if (last_render_time_in_us + BTR_EXIT_MARGIN < max_render_time_in_us) { 354 //Compute the exit refresh rate and exit frame duration
355 unsigned int exit_refresh_rate_in_milli_hz = ((1000000000/max_render_time_in_us)
356 + (1000*FIXED_REFRESH_EXIT_MARGIN_IN_HZ));
357 unsigned int exit_frame_duration_in_us = 1000000000/exit_refresh_rate_in_milli_hz;
358
359 if (last_render_time_in_us < exit_frame_duration_in_us) {
379 /* Exit Fixed Refresh mode */ 360 /* Exit Fixed Refresh mode */
380 if (in_out_vrr->fixed.fixed_active) { 361 if (in_out_vrr->fixed.fixed_active) {
381 in_out_vrr->fixed.frame_counter++; 362 in_out_vrr->fixed.frame_counter++;