AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Schwartz <matthew.schwartz@linux.dev>
To: amd-gfx@lists.freedesktop.org
Cc: Harry Wentland <harry.wentland@amd.com>,
	Leo Li <sunpeng.li@amd.com>,
	Rodrigo Siqueira <siqueira@igalia.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Ivan Lipski <ivan.lipski@amd.com>,
	Fangzhi Zuo <jerry.zuo@amd.com>,
	Aurabindo Pillai <aurabindo.pillai@amd.com>,
	Pei-Hsin Yang <peihsiny@valvesoftware.com>,
	Matthew Schwartz <matthew.schwartz@linux.dev>
Subject: [PATCH 1/2] drm/amd/display: Rebuild the VRR vtotal limits on a modeset
Date: Wed, 25 Nov 2026 21:36:05 -0800	[thread overview]
Message-ID: <20261126053606.12286-2-matthew.schwartz@linux.dev> (raw)
In-Reply-To: <20261126053606.12286-1-matthew.schwartz@linux.dev>

mod_freesync_build_vrr_params() returns early when the VRR state, the
calculated refresh limits and the fixed refresh target are unchanged,
so a modeset between two modes with the same refresh rate keeps the old
mode's v_total_min/max while VRR stays active. With BTR enabled they
are recalculated on the next flip or the vupdate after it. Without BTR
they stay until six flips come in below the refresh range. Going from
1080p60 to 4K60 on a 40-60 Hz sink, where BTR is off, leaves limits of
1125 and 1687 lines on a 2250-line timing, and they are programmed into
the OTG on every vupdate.

Commit 33c995709121 ("drm/amd/display: Allow VRR params change if
unsynced with the stream") resynced the limits for the inactive state
only. Clear the saved VRR params on a modeset so they are always
rebuilt from the new stream.

Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
index 318b0c5c1dcb..c4f5670fab38 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_freesync.c
@@ -408,6 +408,16 @@ void amdgpu_dm_update_stream_irq_parameters(
 	spin_lock_irqsave(&adev_to_drm(adev)->event_lock, flags);
 	vrr_params = acrtc->dm_irq_params.vrr_params;
 
+	/*
+	 * The vtotal limits are in lines of the timing they were calculated
+	 * for. Rebuild them when a modeset replaces that timing.
+	 */
+	if (drm_atomic_crtc_needs_modeset(&new_crtc_state->base)) {
+		memset(&vrr_params, 0, sizeof(vrr_params));
+		vrr_params.adjust.v_total_min = new_stream->timing.v_total;
+		vrr_params.adjust.v_total_max = new_stream->timing.v_total;
+	}
+
 	if (new_crtc_state->vrr_supported &&
 	    config.min_refresh_in_uhz &&
 	    config.max_refresh_in_uhz) {
-- 
2.54.0 (Apple Git-157)


  reply	other threads:[~2026-11-26  8:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  5:36 [PATCH 0/2] drm/amd/display: Rebuild the VRR vtotal limits on a modeset Matthew Schwartz
2026-11-26  5:36 ` Matthew Schwartz [this message]
2026-11-26  8:26   ` [PATCH 1/2] " sashiko-bot
2026-11-26  5:36 ` [PATCH 2/2] drm/amd/display: Test VRR vtotal limits across " Matthew Schwartz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261126053606.12286-2-matthew.schwartz@linux.dev \
    --to=matthew.schwartz@linux.dev \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=ivan.lipski@amd.com \
    --cc=jerry.zuo@amd.com \
    --cc=peihsiny@valvesoftware.com \
    --cc=siqueira@igalia.com \
    --cc=sunpeng.li@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox