* [PATCH 0/2] drm/amd/display: Rebuild the VRR vtotal limits on a modeset
@ 2026-11-26 5:36 Matthew Schwartz
2026-11-26 5:36 ` [PATCH 1/2] " Matthew Schwartz
2026-11-26 5:36 ` [PATCH 2/2] drm/amd/display: Test VRR vtotal limits across " Matthew Schwartz
0 siblings, 2 replies; 4+ messages in thread
From: Matthew Schwartz @ 2026-11-26 5:36 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Ivan Lipski, Fangzhi Zuo, Aurabindo Pillai, Pei-Hsin Yang,
Matthew Schwartz
A modeset between two modes with the same refresh rate keeps the
previous mode's v_total_min/max when VRR stays enabled across it, since
mod_freesync_build_vrr_params() only rebuilds them when the VRR state or
refresh range changes. Commit 33c995709121 handled this for the inactive
state. With VRR active and no BTR, the old limits stay in use for as
long as the client keeps flipping at the refresh rate.
This came up with gamescope, which keeps VRR_ENABLED set across mode
changes and, with its adaptive_sync_idle_hold option, presents on every
vblank while the Steam UI is focused. Switching from 1080p60 to 4K60 in
Steam's display settings then gave no picture on a number of HDMI
displays, a Dell S2721QS (40-60 Hz) and an LG CX among them. In the
Dell's log the atomic commit intervals after the switch were 8.3 ms,
12.5 ms and 20.8 ms. Those are 1125, 1687 and 1125 + 1687 lines of the
4K timing, the 1080p limits for 60 and 40 Hz. Without the hold the idle
UI flips slowly enough to reach the fixed refresh path, which rebuilds
the limits, so the problem stayed hidden.
Tested on an ASUS ROG Xbox Ally X20 (internal panel, 30-120 Hz) with a
7.3.1-based kernel and a small KMS test. It sets two 50 Hz modes with
vtotals of 2764 and 2592, turns VRR on in the first and flips at full
rate across a modeset to the second. Without patch 1 the second mode
flips every 21.33 ms, which is the first mode's v_total_min, until VRR
is toggled. With it the interval is 20.1 ms.
Patch 1 clears the saved VRR params on a modeset so they are rebuilt
from the new stream. Patch 2 adds KUnit cases for it.
Matthew Schwartz (2):
drm/amd/display: Rebuild the VRR vtotal limits on a modeset
drm/amd/display: Test VRR vtotal limits across a modeset
.../display/amdgpu_dm/amdgpu_dm_freesync.c | 10 ++++
.../amdgpu_dm/tests/amdgpu_dm_freesync_test.c | 52 +++++++++++++++++++
2 files changed, 62 insertions(+)
base-commit: da37959f4a22c6bb25a337fcc7946101c8a10f7b
--
2.54.0 (Apple Git-157)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] drm/amd/display: Rebuild the VRR vtotal limits on a modeset
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
2026-11-26 8:26 ` sashiko-bot
2026-11-26 5:36 ` [PATCH 2/2] drm/amd/display: Test VRR vtotal limits across " Matthew Schwartz
1 sibling, 1 reply; 4+ messages in thread
From: Matthew Schwartz @ 2026-11-26 5:36 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Ivan Lipski, Fangzhi Zuo, Aurabindo Pillai, Pei-Hsin Yang,
Matthew Schwartz
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)
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] drm/amd/display: Rebuild the VRR vtotal limits on a modeset
2026-11-26 5:36 ` [PATCH 1/2] " Matthew Schwartz
@ 2026-11-26 8:26 ` sashiko-bot
0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-26 8:26 UTC (permalink / raw)
To: Matthew Schwartz, amd-gfx
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/amd/display: missing Fixes trailer for VRR vtotal limits
modeset bug
--
commit 3bbede195cddea78c60d37613de49a067d814537
Author: Matthew Schwartz <matthew.schwartz@linux.dev>
> drm/amd/display: Rebuild the VRR vtotal limits on a modeset
>
> 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>
[Severity: Low]
585d450c76d1 ("drm/amd/display: Refactor to prevent crtc state access in
DM IRQ handler") moved vrr_params from dm_crtc_state to
acrtc->dm_irq_params and dropped the memset() that reset_freesync_config_for_crtc()
performed on a modeset. Should this include a Fixes tag:
Fixes: 585d450c76d1 ("drm/amd/display: Refactor to prevent crtc state access in DM IRQ handler")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126053606.12286-1-matthew.schwartz@linux.dev?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] drm/amd/display: Test VRR vtotal limits across a modeset
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 ` [PATCH 1/2] " Matthew Schwartz
@ 2026-11-26 5:36 ` Matthew Schwartz
1 sibling, 0 replies; 4+ messages in thread
From: Matthew Schwartz @ 2026-11-26 5:36 UTC (permalink / raw)
To: amd-gfx
Cc: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Ivan Lipski, Fangzhi Zuo, Aurabindo Pillai, Pei-Hsin Yang,
Matthew Schwartz
Check that amdgpu_dm_update_stream_irq_parameters() replaces saved
vtotal limits with the new timing's on a modeset, and keeps them on a
commit that is not one.
Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev>
---
.../amdgpu_dm/tests/amdgpu_dm_freesync_test.c | 52 +++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
index a2b13de2e9e9..ab8931a4d0dd 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_freesync_test.c
@@ -916,6 +916,56 @@ static void dm_test_update_stream_irq_parameters_fixed(struct kunit *test)
60000000U);
}
+static void dm_test_update_stream_irq_parameters_stale(struct kunit *test, bool modeset)
+{
+ struct amdgpu_device *adev = dm_kunit_alloc_adev(test);
+ struct amdgpu_crtc *acrtc;
+ struct dm_crtc_state crtc_state = { 0 };
+ struct mod_vrr_params *vrr_params;
+
+ acrtc = kunit_kzalloc(test, sizeof(*acrtc), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, acrtc);
+ crtc_state.base.crtc = &acrtc->base;
+ crtc_state.base.vrr_enabled = true;
+ crtc_state.base.mode_changed = modeset;
+ crtc_state.stream = dm_kunit_alloc_stream(test, NULL);
+ crtc_state.stream->timing.h_total = 4400;
+ crtc_state.stream->timing.v_total = 2250;
+ crtc_state.vrr_supported = true;
+ crtc_state.freesync_config.min_refresh_in_uhz = 40000000;
+ crtc_state.freesync_config.max_refresh_in_uhz = 60000000;
+ adev->dm.adev = adev;
+
+ /* Limits of a 1080p60 timing with a 40-60 Hz range */
+ vrr_params = &acrtc->dm_irq_params.vrr_params;
+ vrr_params->state = VRR_STATE_ACTIVE_VARIABLE;
+ vrr_params->adjust.v_total_min = 1125;
+ vrr_params->adjust.v_total_max = 1687;
+
+ amdgpu_dm_update_stream_irq_parameters(&adev->dm, &crtc_state);
+
+ KUNIT_EXPECT_EQ(test, vrr_params->adjust.v_total_min, modeset ? 2250U : 1125U);
+ KUNIT_EXPECT_EQ(test, vrr_params->adjust.v_total_max, modeset ? 2250U : 1687U);
+}
+
+/**
+ * dm_test_update_stream_irq_parameters_modeset - Test a modeset drops the saved vtotal limits
+ * @test: The KUnit test context
+ */
+static void dm_test_update_stream_irq_parameters_modeset(struct kunit *test)
+{
+ dm_test_update_stream_irq_parameters_stale(test, true);
+}
+
+/**
+ * dm_test_update_stream_irq_parameters_no_modeset - Test saved vtotal limits survive a flip
+ * @test: The KUnit test context
+ */
+static void dm_test_update_stream_irq_parameters_no_modeset(struct kunit *test)
+{
+ dm_test_update_stream_irq_parameters_stale(test, false);
+}
+
/* Tests for amdgpu_dm_handle_vrr_transition() */
/**
@@ -1118,6 +1168,8 @@ static struct kunit_case amdgpu_dm_freesync_tests[] = {
KUNIT_CASE(dm_test_update_stream_irq_parameters_variable),
KUNIT_CASE(dm_test_update_stream_irq_parameters_inactive),
KUNIT_CASE(dm_test_update_stream_irq_parameters_fixed),
+ KUNIT_CASE(dm_test_update_stream_irq_parameters_modeset),
+ KUNIT_CASE(dm_test_update_stream_irq_parameters_no_modeset),
/* amdgpu_dm_handle_vrr_transition */
KUNIT_CASE(dm_test_handle_vrr_transition_inactive),
KUNIT_CASE(dm_test_handle_vrr_transition_round_trip),
--
2.54.0 (Apple Git-157)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-26 8:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/2] " Matthew Schwartz
2026-11-26 8:26 ` sashiko-bot
2026-11-26 5:36 ` [PATCH 2/2] drm/amd/display: Test VRR vtotal limits across " Matthew Schwartz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox