From patchwork Thu Apr 18 03:51:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10906455 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2989161F for ; Thu, 18 Apr 2019 03:51:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B08928BE1 for ; Thu, 18 Apr 2019 03:51:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F43928BE6; Thu, 18 Apr 2019 03:51:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4848B28BE1 for ; Thu, 18 Apr 2019 03:51:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C3EA46E0BC; Thu, 18 Apr 2019 03:51:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by gabe.freedesktop.org (Postfix) with ESMTPS id C14DE6E0BB; Thu, 18 Apr 2019 03:51:48 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id a184so1032453wma.2; Wed, 17 Apr 2019 20:51:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+s5zZebVbm3q8RmRllG8UW8bQ86n6OW0eFbTMHp0kxM=; b=IHNYT/hdrgCbV/25o39K2ovnb0RBWh0v7rFNDNaNnrWjCYXWQORr2mQoSByOMgv720 kauCzYmCFzVcXBC3tJed5vM5lhlZyvTeUXZ+kOV7IxnmkKFA54vz+jk7T5+whXk9wcEj vsF4aHndKjrHnR1HbMJFQrLAPG1wCEKCd2N/IdpePJpNtXSAAo1/Dm9IQJMxIgBq94iq i16t5SNMTYjc7rJv8AnfdNa5bbokI/6f7nWGA0qKyqo+bTohVV1ZfXiMypuvNkp/5hrH KDUUiGoov75VSyrSZRaNVcfA+LB2OrDBQj8JaWdfxeHz2PNE2X3rii63XKse48NHDenQ scSQ== X-Gm-Message-State: APjAAAVpgBJpSg8jGeCo8Gr8zYAYD0xi340OQhn+y8l8Hyh8wcC3ryVi FPG4ETqLwrYjboXaVXDLyTOp/ffO X-Google-Smtp-Source: APXvYqxjJMugn5S5ziyfClsLac+q5q4P8480DB/fNjVrxBk1/bv5zMYYXrpqNjThoMHSO0xINtEC7g== X-Received: by 2002:a7b:c00e:: with SMTP id c14mr1226483wmb.110.1555559507337; Wed, 17 Apr 2019 20:51:47 -0700 (PDT) Received: from twisty.localdomain ([2a01:c23:7856:4600:55b4:804e:196c:cde9]) by smtp.gmail.com with ESMTPSA id x192sm665054wmf.48.2019.04.17.20.51.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 20:51:46 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH 1/4] drm/amd/display: Add some debug output for VRR BTR. Date: Thu, 18 Apr 2019 05:51:19 +0200 Message-Id: <20190418035122.15791-2-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190418035122.15791-1-mario.kleiner.de@gmail.com> References: <20190418035122.15791-1-mario.kleiner.de@gmail.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+s5zZebVbm3q8RmRllG8UW8bQ86n6OW0eFbTMHp0kxM=; b=eYBQ0B4uMyHjs92tI07xmmAl5VF5sB5rFH/GgLxsG2iH3nNb3OzjBtHK9BaOySS9Ls XLtinhGGXCP4FJHFnMOMJZjh0H8vG5o49+g0ZRcKKF5VhYAhjIC3+PuO+6O40bt/b3sO z0R0Gpt5NAq+SOo1rnTUEvJ65doiwC7i10we85it93Y2ceTwtQ1DQ6p1k/ZwuRhDTz18 dJ0ngYXV/em8PejlJTjrVfFxtlkRFQk+gNqVNWR0F+Tt1gDN9E4kAChmPLkYd9RKbqU0 w6nzZWfg+pSPBcjd+m82j4vx7F/xy5+J3Vk8WtatJjeW05cbbOcH9++kAYEmatxs9Gr0 QuCA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nicholas.kazlauskas@amd.com, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Helps with debugging issues with low framerate compensation. Signed-off-by: Mario Kleiner --- .../amd/display/modules/freesync/freesync.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index 3d867e34f8b3..71274683da04 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c @@ -1041,6 +1041,11 @@ void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync, average_render_time_in_us += last_render_time_in_us; average_render_time_in_us /= DC_PLANE_UPDATE_TIMES_MAX; + DRM_DEBUG_DRIVER("vrr flip: avg %d us, last %d us, max %d us\n", + average_render_time_in_us, + last_render_time_in_us, + in_out_vrr->max_duration_in_us); + if (in_out_vrr->btr.btr_enabled) { apply_below_the_range(core_freesync, stream, @@ -1053,6 +1058,10 @@ void mod_freesync_handle_preflip(struct mod_freesync *mod_freesync, in_out_vrr); } + DRM_DEBUG_DRIVER("vrr btr_active:%d - num %d of dur %d us\n", + in_out_vrr->btr.btr_active, + in_out_vrr->btr.frames_to_insert, + in_out_vrr->btr.inserted_duration_in_us); } } @@ -1090,11 +1099,17 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, in_out_vrr->btr.inserted_duration_in_us); in_out_vrr->adjust.v_total_max = in_out_vrr->adjust.v_total_min; + DRM_DEBUG_DRIVER("btr start: c=%d, vtotal=%d\n", + in_out_vrr->btr.frames_to_insert, + in_out_vrr->adjust.v_total_min); } if (in_out_vrr->btr.frame_counter > 0) in_out_vrr->btr.frame_counter--; + DRM_DEBUG_DRIVER("btr upd: count %d\n", + in_out_vrr->btr.frame_counter); + /* Restore FreeSync */ if (in_out_vrr->btr.frame_counter == 0) { in_out_vrr->adjust.v_total_min = @@ -1103,6 +1118,9 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, in_out_vrr->adjust.v_total_max = calc_v_total_from_refresh(stream, in_out_vrr->min_refresh_in_uhz); + DRM_DEBUG_DRIVER("btr end: vtotal_min=%d/max=%d\n", + in_out_vrr->adjust.v_total_min, + in_out_vrr->adjust.v_total_max); } } From patchwork Thu Apr 18 03:51:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10906463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16FAF18FD for ; Thu, 18 Apr 2019 03:51:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00A9028BDD for ; Thu, 18 Apr 2019 03:51:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E925C28BE5; Thu, 18 Apr 2019 03:51:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A9E0D28BDD for ; Thu, 18 Apr 2019 03:51:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B3276E0BE; Thu, 18 Apr 2019 03:51:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 27DE76E0BD; Thu, 18 Apr 2019 03:51:51 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id f14so459481wrj.5; Wed, 17 Apr 2019 20:51:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3CyfB0mw/wqAd1bq2GO9R/cFbPVKQ2dzKueWsobLosk=; b=WX8drCqmaGc7StaulS3zR6NjDVDHc8lrABtJVpIwzZBkKiCKlPPDj4qAbLSDX70Edx TstuWgF2zj7LbVEYWgFeiM6KbgL8BhAUMsIPuO5wDTMjIzWNk7CoAYXhNgnJxmk4pJgg XlDjoCMivNvOVnJIagvi6FxLTkSvmPAtmwpBVN5/mUrPnVmtrb5kTi8bQSXd47qjbMq4 rVylS2Q+WCpW0oQVF9YCiba+D45GM32j6HFgK34L8kW1VbErljYta2I8/cgxndEJSiNZ DaXlAEiMnTpP/As1a8hNw8Z0V75zWiaVe6TRin6VQKebym24f0yLP85h2z9x0H56yuAZ zTuw== X-Gm-Message-State: APjAAAUoTiZFPKnCIThPk+VWodXta9Xcj7I8vfVJvZTE78iQINgdz2kV OoeXKK9doo1fLYIloYg/WKlyoxQ+ X-Google-Smtp-Source: APXvYqzpM7/XnFwAFCbVYDFCwda04EwHgHt6Vl7jDGvUUJJv8culvleD9ZTs04bDDvW74VukjDoLpw== X-Received: by 2002:a5d:6947:: with SMTP id r7mr26156157wrw.167.1555559509708; Wed, 17 Apr 2019 20:51:49 -0700 (PDT) Received: from twisty.localdomain ([2a01:c23:7856:4600:55b4:804e:196c:cde9]) by smtp.gmail.com with ESMTPSA id x192sm665054wmf.48.2019.04.17.20.51.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 20:51:49 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH 2/4] drm/amd/display: Fix and simplify apply_below_the_range() Date: Thu, 18 Apr 2019 05:51:20 +0200 Message-Id: <20190418035122.15791-3-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190418035122.15791-1-mario.kleiner.de@gmail.com> References: <20190418035122.15791-1-mario.kleiner.de@gmail.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3CyfB0mw/wqAd1bq2GO9R/cFbPVKQ2dzKueWsobLosk=; b=LvfaDd2ZNh2M+IwKu5Y33/570eBEGFnKKy9rDvk+2RU4NNfNYzZQfLN9P8NGP+3EHr 2ql1Z0K99f+2D37aIbBWg5KqY2BI97kVDxxO2BrsF+TlRbftZzTS50rdcWUUg7zf5s9V V7PSVkQmnCDpSmWgRWUjceYqpvr5gEjvVAxtc5iZpCTP9zZnYJ5kGIYzF8Bpj4ErFobC uT70/f/p+DQd+tswI8IljqzqZdFhDwkuUXGnvhYJCTJre0Ry72lZDjFBAxXivG2ayyTZ gxIZmnLBqTEcsFMcwC0DISgOYXhRGlJ9OxPS5H1fOUdnKcmyLicRcO7ZbWWyDofcYmwQ O5zQ== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nicholas.kazlauskas@amd.com, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The comparison of inserted_frame_duration_in_us against a duration calculated from max_refresh_in_uhz is both wrong in its math and not needed, as the min_duration_in_us value is already cached in in_out_vrr for reuse. No need to recalculate it wrongly at each invocation. Signed-off-by: Mario Kleiner Reviewed-by: Nicholas Kazlauskas --- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index 71274683da04..e56543c36eba 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c @@ -437,10 +437,8 @@ static void apply_below_the_range(struct core_freesync *core_freesync, inserted_frame_duration_in_us = last_render_time_in_us / frames_to_insert; - if (inserted_frame_duration_in_us < - (1000000 / in_out_vrr->max_refresh_in_uhz)) - inserted_frame_duration_in_us = - (1000000 / in_out_vrr->max_refresh_in_uhz); + if (inserted_frame_duration_in_us < in_out_vrr->min_duration_in_us) + inserted_frame_duration_in_us = in_out_vrr->min_duration_in_us; /* Cache the calculated variables */ in_out_vrr->btr.inserted_duration_in_us = From patchwork Thu Apr 18 03:51:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10906465 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0654917E0 for ; Thu, 18 Apr 2019 03:51:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E407428BDD for ; Thu, 18 Apr 2019 03:51:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D85EC28BE5; Thu, 18 Apr 2019 03:51:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9A66D28BDD for ; Thu, 18 Apr 2019 03:51:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A1BE6E0C0; Thu, 18 Apr 2019 03:51:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 826116E0BF; Thu, 18 Apr 2019 03:51:53 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id k17so1011864wrx.10; Wed, 17 Apr 2019 20:51:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BESZkc6wbEkzEo4EMB8XfajzL1iBb9J7EwpQt4g0Ino=; b=uOekskFVOcvEU90eCmDpnUcZ1AgAR8v5yeLg4ouAlUMOHLfSCtEv2uQqaLJbjuARMQ BeKgIDyz7NCuhO53iuWwkbXeGIEebe6t6d8BcrVistPXkdITofwdMqdKvlaL69ska77r GbHAtuyiNZjk26aXAWLzSC4uWX+1xdnfNf1Hom8Uyl1HjOk9mVvut23m6zvBAH6AK1Y1 1fXjPkOp2Nu4OpZOGJj3waaNCa6Kh3QVywpmRO6GI+K1Ne327NJCM4iVDWXA98O4pEIV HkE6Meh6WRFeM9G/usmJ0Jg23kGjy1M5scU3f7VQFQnuYeUcaPVWx85UFZrBf6VcLBJM 7+eA== X-Gm-Message-State: APjAAAXN7CUHU9K/oLupp1vNIBq9GTtan1IgLlqCzS0K4r3DksRc9yvW mwBc5Lu2qipiDj0EdhX7/GmKfLyS X-Google-Smtp-Source: APXvYqz6FJwf436Joz9qbousdjePbhsaq4EDLsFVvXGXmWL6tI9CX6qv6bzBYgUO6T71fHLds0lBcQ== X-Received: by 2002:adf:f5c7:: with SMTP id k7mr30435367wrp.197.1555559511682; Wed, 17 Apr 2019 20:51:51 -0700 (PDT) Received: from twisty.localdomain ([2a01:c23:7856:4600:55b4:804e:196c:cde9]) by smtp.gmail.com with ESMTPSA id x192sm665054wmf.48.2019.04.17.20.51.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 20:51:51 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH 3/4] drm/amd/display: Enter VRR BTR earlier. Date: Thu, 18 Apr 2019 05:51:21 +0200 Message-Id: <20190418035122.15791-4-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190418035122.15791-1-mario.kleiner.de@gmail.com> References: <20190418035122.15791-1-mario.kleiner.de@gmail.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BESZkc6wbEkzEo4EMB8XfajzL1iBb9J7EwpQt4g0Ino=; b=qkdaz+RaW9JXc1EPBud/yVX5H6PLMj8Mf3eRGlkd/kLM5aU1jfx3827m00TRB+M0C1 tcqFyOfSjQGUHJHkO5nsIQgs8fWr+hGPWvcRHYARSWyZzC6JA61aAiQJ0GBFQhsj67Fa IjBjkMfkSeM5SjvO0NGGD1IkzSOo4UY+q3je8ghBTNEoB68MG8zCXn0nSwz4r81ypZ3/ 25omjhaE5yS4JHvv0VfQDuHEdNMypYrig4boNM2dUh7ZuCRhXYgbP0ij4sP3/oqxn1eH lzpvwlPIjTEA4GKL00EPB1U9WvT6n7MXKeXlbHteSWRjiC24GeB5rrcn+sHdS7enKKSh 7uRg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nicholas.kazlauskas@amd.com, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use a 2 msecs switching headroom not only for slightly delayed exiting of BTR mode, but now also for entering it a bit before the max frame duration is exceeded. With slowly changing time delay between successive flips or with a bit of jitter in arrival of flips, this adapts vblank early and prevents missed vblanks at the border between non-BTR and BTR. Testing on DCE-8, DCE-11 and DCN-1.0 shows that this more often avoids skipped frames when moving across the BTR boundary, especially on DCE-8 and DCE-11 with the followup commit for dealing with pre-DCE-12 hw. Signed-off-by: Mario Kleiner --- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index e56543c36eba..a965ab5466dc 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c @@ -350,7 +350,7 @@ static void apply_below_the_range(struct core_freesync *core_freesync, in_out_vrr->btr.frame_counter = 0; in_out_vrr->btr.btr_active = false; } - } else if (last_render_time_in_us > max_render_time_in_us) { + } else if (last_render_time_in_us + BTR_EXIT_MARGIN > max_render_time_in_us) { /* Enter Below the Range */ in_out_vrr->btr.btr_active = true; } From patchwork Thu Apr 18 03:51:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10906467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A85AA17E0 for ; Thu, 18 Apr 2019 03:52:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EA2228BDD for ; Thu, 18 Apr 2019 03:52:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F9C328BE6; Thu, 18 Apr 2019 03:52:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D16C28BDD for ; Thu, 18 Apr 2019 03:52:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 873126E0C3; Thu, 18 Apr 2019 03:51:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 40FA86E0C1; Thu, 18 Apr 2019 03:51:55 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id z6so5962228wmi.0; Wed, 17 Apr 2019 20:51:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Z9wQUpWG+/bXv2aC0gDN2RCc/ZGpiHgI9OyD5oePBNg=; b=hBIZBw9sK9jzCPzJrR3aWSLGn+duFKQsE0p8oOh7MGXOyjMoRAOZNM9NPHn1uY1Tyg Vrt9MaBrfIVYj+ePF89NJlzA9js5QzUmGapUX5/Cvwco0arKN/tj2B/Iq1+RH4lgGNeK c3ICoZpEs/lGbwKIFw6E2P19FFraJy27naJ1UG/Qa8i07ieHDSzWaw4NysJLM5gCLaPO B67bod2yBWhbEMSGVTiUSytfsn/zB2+yGB2OP5FDtqq5g1T7/uOvvwiyHfqLUXPBPWYl keyX+hRi5XClwNedAF0vEAMSYjlYqkVK83rBSlGDOVzOfH2lU33PUJe66GaTZpgGWZH9 oQaw== X-Gm-Message-State: APjAAAXk8AuoruFdla0f7rKaML/O4E9H0a6HEv/uXR85YxJ5AzZHcCe2 nEsWkIDlW0kDGCu/IHmpI3zsYAuh X-Google-Smtp-Source: APXvYqwGqFXZ7+rKNUyy5WHyJ6OaXR21gzVwV6ut3wjN2acxSZrwostAnf5GimpksbQvF7BMfHwAAQ== X-Received: by 2002:a1c:4d12:: with SMTP id o18mr1199779wmh.81.1555559513322; Wed, 17 Apr 2019 20:51:53 -0700 (PDT) Received: from twisty.localdomain ([2a01:c23:7856:4600:55b4:804e:196c:cde9]) by smtp.gmail.com with ESMTPSA id x192sm665054wmf.48.2019.04.17.20.51.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 20:51:52 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH 4/4] drm/amd/display: Compensate for pre-DCE12 BTR-VRR hw limitations. Date: Thu, 18 Apr 2019 05:51:22 +0200 Message-Id: <20190418035122.15791-5-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190418035122.15791-1-mario.kleiner.de@gmail.com> References: <20190418035122.15791-1-mario.kleiner.de@gmail.com> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z9wQUpWG+/bXv2aC0gDN2RCc/ZGpiHgI9OyD5oePBNg=; b=iTshvKkUrhrNQ9Kwgd4UsSYsgBcwXMH+UB7+nO6i/6MsL5JUC8vC4bzR2Mf73U+WtK ldvhoS8iiIXJGm4wfgHSsGe1yWgP+54zfAimjesybzZsFaFnOhfoSUw7xZW/IettGSEx Oh7F5AShBVTl81anm2M45QFyz3g0YIJAEadVwZ7mUfI464hhPFxLsvOgMFV5vMY8+C49 VjXWZ90CdYApZ1SGNbawxIo+hgKKh7GCpE5hNTJGxuRlZOchXGM/0uvo6rg0gUG7ZwI9 eo2RqeKxZUdEIv6HRWtU0ywC2x8ABTF1oCR7Dk1xfW8+sXay2NJOsRUpdgPeWFt5Eiez kftw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nicholas.kazlauskas@amd.com, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Pre-DCE12 needs special treatment for BTR / low framerate compensation for more stable behaviour: According to comments in the code and some testing on DCE-8 and DCE-11, DCE-11 and earlier only apply VTOTAL_MIN/MAX programming with a lag of one frame, so the special BTR hw programming for intermediate fixed duration frames must be done inside the current frame at flip submission in atomic commit tail, ie. one vblank earlier, and the fixed refresh intermediate frame mode must be also terminated one vblank earlier on pre-DCE12 display engines. To achieve proper termination on < DCE-12 shift the point when the switch-back from fixed vblank duration to variable vblank duration happens from the start of VBLANK (vblank irq, as done on DCE-12+) to back-porch or end of VBLANK (handled by vupdate irq handler). We must leave the switch-back code inside VBLANK irq for DCE12+, as before. Doing this, we get much better behaviour of BTR for up-sweeps, ie. going from short to long frame durations (~high to low fps) and for constant framerate flips, as tested on DCE-8 and DCE-11. Behaviour is still not quite as good as on DCN-1 though. On down-sweeps, going from long to short frame durations (low fps to high fps) < DCE-12 is a little bit improved, although by far not as much as for up-sweeps and constant fps. Signed-off-by: Mario Kleiner --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 76b6e621793f..9c8c94f82b35 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -364,6 +364,7 @@ static void dm_vupdate_high_irq(void *interrupt_params) struct amdgpu_device *adev = irq_params->adev; struct amdgpu_crtc *acrtc; struct dm_crtc_state *acrtc_state; + unsigned long flags; acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_VUPDATE); @@ -381,6 +382,22 @@ static void dm_vupdate_high_irq(void *interrupt_params) */ if (amdgpu_dm_vrr_active(acrtc_state)) drm_crtc_handle_vblank(&acrtc->base); + + if (acrtc_state->stream && adev->family < AMDGPU_FAMILY_AI && + acrtc_state->vrr_params.supported && + acrtc_state->freesync_config.state == VRR_STATE_ACTIVE_VARIABLE) { + spin_lock_irqsave(&adev->ddev->event_lock, flags); + mod_freesync_handle_v_update( + adev->dm.freesync_module, + acrtc_state->stream, + &acrtc_state->vrr_params); + + dc_stream_adjust_vmin_vmax( + adev->dm.dc, + acrtc_state->stream, + &acrtc_state->vrr_params.adjust); + spin_unlock_irqrestore(&adev->ddev->event_lock, flags); + } } } @@ -390,6 +407,7 @@ static void dm_crtc_high_irq(void *interrupt_params) struct amdgpu_device *adev = irq_params->adev; struct amdgpu_crtc *acrtc; struct dm_crtc_state *acrtc_state; + unsigned long flags; acrtc = get_crtc_by_otg_inst(adev, irq_params->irq_src - IRQ_TYPE_VBLANK); @@ -412,9 +430,10 @@ static void dm_crtc_high_irq(void *interrupt_params) */ amdgpu_dm_crtc_handle_crc_irq(&acrtc->base); - if (acrtc_state->stream && + if (acrtc_state->stream && adev->family >= AMDGPU_FAMILY_AI && acrtc_state->vrr_params.supported && acrtc_state->freesync_config.state == VRR_STATE_ACTIVE_VARIABLE) { + spin_lock_irqsave(&adev->ddev->event_lock, flags); mod_freesync_handle_v_update( adev->dm.freesync_module, acrtc_state->stream, @@ -424,6 +443,7 @@ static void dm_crtc_high_irq(void *interrupt_params) adev->dm.dc, acrtc_state->stream, &acrtc_state->vrr_params.adjust); + spin_unlock_irqrestore(&adev->ddev->event_lock, flags); } } } @@ -4880,6 +4900,8 @@ static void update_freesync_state_on_stream( { struct mod_vrr_params vrr_params = new_crtc_state->vrr_params; struct dc_info_packet vrr_infopacket = {0}; + struct amdgpu_device *adev = dm->adev; + unsigned long flags; if (!new_stream) return; @@ -4899,6 +4921,14 @@ static void update_freesync_state_on_stream( new_stream, flip_timestamp_in_us, &vrr_params); + + if (adev->family < AMDGPU_FAMILY_AI && + amdgpu_dm_vrr_active(new_crtc_state)) { + spin_lock_irqsave(&adev->ddev->event_lock, flags); + mod_freesync_handle_v_update(dm->freesync_module, + new_stream, &vrr_params); + spin_unlock_irqrestore(&adev->ddev->event_lock, flags); + } } mod_freesync_build_vrr_infopacket(