Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Cooper Morgan <ext-github@cwooper.dev>
To: stable@vger.kernel.org
Cc: Harry Wentland <harry.wentland@amd.com>,
	Wayne Lin <Wayne.Lin@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>
Subject: [PATCH 7.3.y] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets
Date: Wed,  2 Dec 2026 14:11:47 -0800	[thread overview]
Message-ID: <20261202221148.1120643-1-ext-github@cwooper.dev> (raw)
In-Reply-To: <2026120237-immovable-extrude-a2cc@gregkh>

commit 76850a457474a629dc0ceffaafb3aed78ff5f469 upstream.

The v1 and v2 FreeSync infopackets carry the minimum and maximum
refresh rate in one byte each, and build_vrr_infopacket_data_v1() casts
the rate in Hz to unsigned char. On a sink whose range goes above
255 Hz the value wraps: a 320 Hz mode is advertised as a 64 Hz maximum.

Sinks that treat the field as authoritative misbehave once the wrapped
value lands inside their range. An MSI MAG 271QPX32 (48-320 Hz) over
native DP looks like a ~720p image upscaled to the full screen at 320 Hz
and runs its self-test pattern at 305-315 Hz, while 300 Hz (wrapping to
44 Hz, below its minimum) is fine. Capping the EDID range at 255 Hz, so
the packet says 255, gives a correct picture at 320 Hz.

Saturate the fields at 255 Hz instead of wrapping.

Capping v1 at 255 as a fallback was suggested by oystersuki in the linked
issue.

Fixes: 98e6436d3af5 ("drm/amd/display: Refactor FreeSync module")
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/5988
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Cooper Morgan <ext-github@cwooper.dev>
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 8f91c13d9a14085216725f60b55546fce5c2dd19)
Cc: stable@vger.kernel.org
(cherry picked from commit 76850a457474a629dc0ceffaafb3aed78ff5f469)
[ Cooper: Dropped the KUnit test hunks, since 7.3.y's
  amdgpu_dm_freesync_test.c predates the tests they extend. The
  freesync.c change is unchanged. ]
Signed-off-by: Cooper Morgan <ext-github@cwooper.dev>
---
I built amdgpu on 7.3.y (x86_64 defconfig, DRM_AMDGPU=m) with no new
warnings. The fix is the same on every tree, and I tested it on hardware
on a 7.2.13-based kernel: an MSI MAG 271QPX32 at 320 Hz shows a correct
picture and VRR works.

The companion fix 6a9d5e2f06cd ("drm/amd/display: Use FreeSync v3
infopacket for sinks above 255 Hz") also got Cc: stable, but please
don't take it on its own. It needs a follow-up that isn't in mainline
yet ("drm/amd/display: Store the AMD VSDB version for DP sinks without
Replay"). Without that, the v3 packet is never sent to DP sinks
without Replay.

 .../gpu/drm/amd/display/modules/freesync/freesync.c  | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
index f154a619b533..21165855cb92 100644
--- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
+++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
@@ -571,6 +571,12 @@ static bool vrr_settings_require_update(struct core_freesync *core_freesync,
 	return false;
 }
 
+/* v1/v2 packets hold each rate in one byte; saturate instead of wrapping. */
+static unsigned char vrr_refresh_hz_u8(unsigned int refresh_in_uhz)
+{
+	return min((refresh_in_uhz + 500000) / 1000000, 255U);
+}
+
 static void build_vrr_infopacket_data_v1(const struct mod_vrr_params *vrr,
 		struct dc_info_packet *infopacket,
 		bool freesync_on_desktop)
@@ -614,15 +620,15 @@ static void build_vrr_infopacket_data_v1(const struct mod_vrr_params *vrr,
 	/* PB7 = FreeSync Minimum refresh rate (Hz) */
 	if (vrr->state == VRR_STATE_ACTIVE_VARIABLE ||
 			vrr->state == VRR_STATE_ACTIVE_FIXED) {
-		infopacket->sb[7] = (unsigned char)((vrr->min_refresh_in_uhz + 500000) / 1000000);
+		infopacket->sb[7] = vrr_refresh_hz_u8(vrr->min_refresh_in_uhz);
 	} else {
-		infopacket->sb[7] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000);
+		infopacket->sb[7] = vrr_refresh_hz_u8(vrr->max_refresh_in_uhz);
 	}
 
 	/* PB8 = FreeSync Maximum refresh rate (Hz)
 	 * Note: We should never go above the field rate of the mode timing set.
 	 */
-	infopacket->sb[8] = (unsigned char)((vrr->max_refresh_in_uhz + 500000) / 1000000);
+	infopacket->sb[8] = vrr_refresh_hz_u8(vrr->max_refresh_in_uhz);
 }
 
 static void build_vrr_infopacket_data_v3(const struct mod_vrr_params *vrr,
-- 
2.56.1


      reply	other threads:[~2026-12-02 22:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 12:36 FAILED: patch "[PATCH] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync" failed to apply to 7.3-stable tree gregkh
2026-12-02 22:11 ` Cooper Morgan [this message]

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=20261202221148.1120643-1-ext-github@cwooper.dev \
    --to=ext-github@cwooper.dev \
    --cc=Wayne.Lin@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=stable@vger.kernel.org \
    /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