From patchwork Fri Apr 26 10:50:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10919023 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 4862B92A for ; Fri, 26 Apr 2019 10:51:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3645F28DF6 for ; Fri, 26 Apr 2019 10:51:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 270E828DFA; Fri, 26 Apr 2019 10:51:03 +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 D447D28DFA for ; Fri, 26 Apr 2019 10:51:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5FA7889226; Fri, 26 Apr 2019 10:51:01 +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 035328921A; Fri, 26 Apr 2019 10:51:00 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id h18so3756917wml.1; Fri, 26 Apr 2019 03:50:59 -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=8UYZB4FXzLEMZ4nLNMup+ABlWt/sOs7nMPhx300ztGc=; b=mNkEA1JRBgf2E5jvDUMhqv5ts4dFDLfA95t1o4WRrfSR+1mLJw2RYeOCPkClKEEy7z AR8MDGUkxAO524lK2Bf81glIiW8Xuhtva+7NJTE23bkN+SIMcAE5bRMSc5fuLwcOgLZs LOhVi0XHAMQPQD33OjdMWmlF5bjCVzNgBqxtmJCdpTC6Y1jKzZ+RjL7uDomQ1NZ3upwH Krb9Jp/mHwm4uP3NN248tNFe2+acN6WKSd2EPs+hyCla4kjWo69hMFyKp4Y1HgDsFUZM FeBYuEfFItnd6pmo0oLcqrb0kKGv/Ddjm0QY7kpfqmcOnlYmEKZfhJeAFWfX5m7tmRcN BZeg== X-Gm-Message-State: APjAAAVwGZfm/M2VxXDeNe6lsHKmoVNbcVLjARpn5P3KEpGRJW8f5S9/ mzMRoWXcKPiISIYul0Sb6MXJEcN8 X-Google-Smtp-Source: APXvYqzU2Q+syvv+T0SdHTHtxuoVB3QQu8OQoQqRaqFUD5c6W2JwJKLjZquJfDoalgooq5w9CgPqxA== X-Received: by 2002:a1c:6c17:: with SMTP id h23mr7144667wmc.122.1556275858540; Fri, 26 Apr 2019 03:50:58 -0700 (PDT) Received: from twisty.localdomain ([2a01:c22:c870:100:55b4:804e:196c:cde9]) by smtp.gmail.com with ESMTPSA id f128sm31201538wme.28.2019.04.26.03.50.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 03:50:58 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH 1/3] drm/amd/display: Fix and simplify apply_below_the_range() Date: Fri, 26 Apr 2019 12:50:14 +0200 Message-Id: <20190426105016.12210-2-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426105016.12210-1-mario.kleiner.de@gmail.com> References: <20190426105016.12210-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=8UYZB4FXzLEMZ4nLNMup+ABlWt/sOs7nMPhx300ztGc=; b=EvhqbSdsX0MJFoaJ9GtVb/0zAgj2lAho7/5BMMLCC6AsSZinkmC7+QRF952VvcGWvB 41JHwkqLawRrbqSRcZl/ce2DCn4tIPrPmNxIunmTMdDOCjYrIMlU1E2vSPaYat82fp5O tC0U3xpSJA10IWkwAiox2fgeK8Klb/pu9HDxYzoZEl/cvIUduZKiD3iFHLupLOzsq6bH 3Ou8sh+Rw7DitOseOS8xBcDf3mApLFDx3izu6pXLBYEPKLAQF6/H6jAv1VC+Yjq5gFeE 3+wubcQuJZcUztmis4zem8Lxj/BlHkHJlZ8D4QzIw6FabT19LomwcXxww3XyK8xcyjf8 9/1w== 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 Fri Apr 26 10:50:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10919025 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 C8B8A14C0 for ; Fri, 26 Apr 2019 10:51:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8DEA28BCA for ; Fri, 26 Apr 2019 10:51:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACE9928DF9; Fri, 26 Apr 2019 10:51:07 +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 6A8B428DFC for ; Fri, 26 Apr 2019 10:51:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 01D0189193; Fri, 26 Apr 2019 10:51:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 89C6E88ED5; Fri, 26 Apr 2019 10:51:04 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id c12so3793621wrt.8; Fri, 26 Apr 2019 03:51:04 -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=OAsWBN/G2rhbWIiCPM5JwtTii5VwYnIMPlj38ZtWwzczuA6cYS3KHtzbpiZok7N1N9 WD+b3Sk0QMnkNv21oTBVBjwVn10KSlZEhLCYc519YFtWKkHvOxLcVz3aWZKDvyErOiu3 difTFUJZafApk3/ewNOpyTZpQg2c5IzwUseUdHNbduQ+I5h1zJlMPY3Mg05LRtEoPz6S 5QOkCDK+zzvaieNhOJeWn2swdv9AqWmo+GGqnEe8BZ19440rY9DuqU3Q7FSSEF9vhCU7 7SgV9+DGZ1vZhv5yLQ31IHVj4TeOyuuBByDtNlNxckae2Jng99XQJWnvkQ5hXiqQG1Qa a3XQ== X-Gm-Message-State: APjAAAWriqgE5eij34b80SkbvefWEivcdDcST258rloc0e6jBFbASOFN nmJVaYOCudKPfNZ2VBGt8dpWwdnt X-Google-Smtp-Source: APXvYqwy86xO4ra6Vd5EcorCgmdDOwiixGS8jUt2aHfsUjRkU9GiVW6EDgDj3dElGY5r9xD8dYu9/g== X-Received: by 2002:adf:e711:: with SMTP id c17mr14727205wrm.57.1556275862868; Fri, 26 Apr 2019 03:51:02 -0700 (PDT) Received: from twisty.localdomain ([2a01:c22:c870:100:55b4:804e:196c:cde9]) by smtp.gmail.com with ESMTPSA id f128sm31201538wme.28.2019.04.26.03.51.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 03:51:02 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH 2/3] drm/amd/display: Enter VRR BTR earlier. Date: Fri, 26 Apr 2019 12:50:15 +0200 Message-Id: <20190426105016.12210-3-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426105016.12210-1-mario.kleiner.de@gmail.com> References: <20190426105016.12210-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=k9PA/0GEDj+stpgAEpee4BehTzvKgFKLnXu4k3u52+KuT6aKYzYDo2SYcGbhwnlXeB eXobKSLzJVhPi+CGuhA0XCgDrnoQR+f0iGRR5ltKHxmawvWvHiLzyn5mNk6YSmqiNTaP XoT4I1Z5g8+BmjBChUcigBqPCtV0WEMpp2iaK6grtsNZoh4TCIXyJkMdZiNYYpNtwMPj r99abHDxUaV1dRDgtOqoDgsDkekB2fTnu2RV5k/RwNMqrHyHqwkKVJP6meGCOkdmAHAG fSL+Th3TiGlOv2wmp0YtfqZCkaLq6UB/a18RMcgj9S3phJWFsG9NN4indz4OHbEtjk8A nqsg== 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 Fri Apr 26 10:50:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10919027 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 5D3DA92A for ; Fri, 26 Apr 2019 10:51:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CDFA28BBB for ; Fri, 26 Apr 2019 10:51:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4143628BA3; Fri, 26 Apr 2019 10:51:13 +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 BE98F28D69 for ; Fri, 26 Apr 2019 10:51:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD6AF89209; Fri, 26 Apr 2019 10:51:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 10C22891F8; Fri, 26 Apr 2019 10:51:07 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id a9so3818307wrp.6; Fri, 26 Apr 2019 03:51:06 -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=uBgM7GcRqFlmQVX1XMSH8amXpHz6Rkj0yOQ9qfRbuug=; b=EbTEcQ+I+3coDcPGkwpRbDY+GZqIxdf4GPnyQ+6dnFIoiKY+pQkwuMxxGPxO+9ZT22 xIwJ8yXaU2d6cAjc8JDe223+OgSn9Y0YUiUZlBMCIeoagrEbDYw8iLE6Uwdw2wvmtuYu l+3eajYuLnlO6dbs4FDwGXi7MQVWgRZNvv8QHpHOUVlZckajuIM0r/o7tcXBXKTvLGsu JhEq2ul7YgiSqwrBYXwV+c0mPSJqQDQ4lLOpWgZkYq5PChOI/Tk+1OXOHsqvedQPOGwL PwsK1EF5AO8UT3P2AfMdpng1F4CuEo2AXFPVADw2JIgLMO++/6hYYUpGYsZRpyJdHdBO wj1A== X-Gm-Message-State: APjAAAVCUmUTnZ3BHZAq1iFONNNTM8f1T32TdUiXl9c6Ji/SsBCRUUaE DnaXxPN+RgLBeHzNBqYmw/epCzBQ X-Google-Smtp-Source: APXvYqzApoGt0R3XdyOQI3wkENf2rwsItH6BmzC5oq9osVWns9RBzK5C6AMEQkaKa2k6iqz2iCM3gQ== X-Received: by 2002:a5d:5284:: with SMTP id c4mr2819078wrv.281.1556275865433; Fri, 26 Apr 2019 03:51:05 -0700 (PDT) Received: from twisty.localdomain ([2a01:c22:c870:100:55b4:804e:196c:cde9]) by smtp.gmail.com with ESMTPSA id f128sm31201538wme.28.2019.04.26.03.51.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 03:51:04 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH 3/3] drm/amd/display: Compensate for pre-DCE12 BTR-VRR hw limitations. (v2) Date: Fri, 26 Apr 2019 12:50:16 +0200 Message-Id: <20190426105016.12210-4-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190426105016.12210-1-mario.kleiner.de@gmail.com> References: <20190426105016.12210-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=uBgM7GcRqFlmQVX1XMSH8amXpHz6Rkj0yOQ9qfRbuug=; b=p1L97fI/hg7RoL8szpvghVM91jDP3PSLoSfg2RCsTA2P0yCOcgUxT6vf6ztvxfH915 3o3t2HmnUkLWBf8fxCuMVneUXuE4js3Uy5ldOfVGMtDQqXt6c400rF1FlsVnuR9mSeGS XNIu2jg5MrZpjY04+6vt50hJquSAj1nioQDq0LuQThCcOXDgHnjmSAaG27oSzVKuriZJ l1skJujlSNZ5z2zoEopUlTSt6j3A0HGS6umBUx173Rjf/tVDNtbaFn6FXU1cmWAxbYYt JZ7AqxStRBkGThMSfN9HwuoDE2x/m8AMr2wCiFO1ZROWAAPqi0ifBJrDiAmqgA/zXu8d pZJw== 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. v2: Fix some wrong locking, as pointed out by Nicholas. Signed-off-by: Mario Kleiner --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 45 +++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) 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..7241e1f3ebec 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); } } } @@ -4878,8 +4898,10 @@ static void update_freesync_state_on_stream( struct dc_plane_state *surface, u32 flip_timestamp_in_us) { - struct mod_vrr_params vrr_params = new_crtc_state->vrr_params; + struct mod_vrr_params vrr_params; struct dc_info_packet vrr_infopacket = {0}; + struct amdgpu_device *adev = dm->adev; + unsigned long flags; if (!new_stream) return; @@ -4892,6 +4914,9 @@ static void update_freesync_state_on_stream( if (!new_stream->timing.h_total || !new_stream->timing.v_total) return; + spin_lock_irqsave(&adev->ddev->event_lock, flags); + vrr_params = new_crtc_state->vrr_params; + if (surface) { mod_freesync_handle_preflip( dm->freesync_module, @@ -4899,6 +4924,12 @@ 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)) { + mod_freesync_handle_v_update(dm->freesync_module, + new_stream, &vrr_params); + } } mod_freesync_build_vrr_infopacket( @@ -4930,6 +4961,8 @@ static void update_freesync_state_on_stream( new_crtc_state->base.crtc->base.id, (int)new_crtc_state->base.vrr_enabled, (int)vrr_params.state); + + spin_unlock_irqrestore(&adev->ddev->event_lock, flags); } static void pre_update_freesync_state_on_stream( @@ -4937,8 +4970,10 @@ static void pre_update_freesync_state_on_stream( struct dm_crtc_state *new_crtc_state) { struct dc_stream_state *new_stream = new_crtc_state->stream; - struct mod_vrr_params vrr_params = new_crtc_state->vrr_params; + struct mod_vrr_params vrr_params; struct mod_freesync_config config = new_crtc_state->freesync_config; + struct amdgpu_device *adev = dm->adev; + unsigned long flags; if (!new_stream) return; @@ -4950,6 +4985,9 @@ static void pre_update_freesync_state_on_stream( if (!new_stream->timing.h_total || !new_stream->timing.v_total) return; + spin_lock_irqsave(&adev->ddev->event_lock, flags); + vrr_params = new_crtc_state->vrr_params; + if (new_crtc_state->vrr_supported && config.min_refresh_in_uhz && config.max_refresh_in_uhz) { @@ -4970,6 +5008,7 @@ static void pre_update_freesync_state_on_stream( sizeof(vrr_params.adjust)) != 0); new_crtc_state->vrr_params = vrr_params; + spin_unlock_irqrestore(&adev->ddev->event_lock, flags); } static void amdgpu_dm_handle_vrr_transition(struct dm_crtc_state *old_state,