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 <[email protected]>
---
.../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)