From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.234 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249579; b=POrFvcnDZYCR+nDjc5PQMd+n9+oZ/8lJsZuSV79yq3ogklWzGWNKURr8Q9IyYeprNpjc WHuwbTaIHJ8hAwS0W/RuMidbCswMG2uPru7+ibbuhtcx+0afOfIp+AHojN2XBNhQTD8SC likd+HvGPJaCSVvpLCz6hQdFNZRo4OT7iy8L3gbG7BPYogS2Gdu4v49wsijNverLWfVZN 3arCkA7PR2uVCs0ZbFtmpBluL/IS/WtOzQSZ7/wFbR4II7HRy8LOzfsdSQcZ/6qd7J5p7 eX8HcyNDpx/GnC0T44WPSqYvWAlMYDukvnuj+Viaqh4TD0d62WEPPdboxpZ0Ed47Ktw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249579; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=eORrSuwXi9SfUi8dAoSrPgbo/GzcsOG4TAXlepvLuXY=; b=0afGelfOY2VuCGL0gUEo2YSK/7ZJ2PhR9n/rUfAv8bXjntInZzSotdwv5UD3lI368MNc 8tMQEJc39Ths0qjJkJ/n7tNX7JciY8pt/RqV95WkUiJEwU/36fZ85FANpGhQxD0HUh0Yi d28k3GkKvepEAdarVXFwYOPAF9zzAnyg/fsad4FoQPiElnirXx1TVTtm/mWkH9HmqKsOT hK847UJSl2YbGyUVEzltEJczN/YLqFZpsG7Ak/k+XpCFsNFQs1mGQtQbpZfKmgKZF7hST 64SXCJXu7SVt7i8lQ0+Zyo4BGPVLKQDF3WnzyZDk4EGGQeolicJX8Asx8y6DZVcYAtQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cwooper.dev; spf=pass smtp.mailfrom=cwooper.dev; dkim=pass header.d=cwooper.dev header.i=@cwooper.dev header.a=rsa-sha256 header.s=key1 header.b=O+qaFzIH; arc=none smtp.remote-ip=95.215.58.234 Received: from mta1.migadu.com (out-234.mta1.migadu.com [95.215.58.234]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BE6C606A6A3 for ; Wed, 2 Dec 2026 22:12:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7BE6C606A6A3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cwooper.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cwooper.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=cwooper.dev header.i=@cwooper.dev header.a=rsa-sha256 header.s=key1 header.b=O+qaFzIH X-Envelope-To: stable@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=xOQjqIELyY6dGtHurXKeZW5bcHnJwr4+q58rFp3JFeA=; c=simple/simple; d=cwooper.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796249576; v=1; x=1796854376; b=O+qaFzIHyLlYkRpdp2lTI/VDl1bmrOdh+noiGmVl4E1+PVJzFn3i35B7N2d/3rDX1j/OYWJH XHHSBOwfs8C7MT1Rkwl6V6KPpNslSQAG3glTMRhTMPxh4NxxZuqglisFPkw7tUdmzZbrbqSsB0D Sv3KxkuCoFc4dQ/gon2K+yjUxmpD8NrpbW9xBoFwBjDtNAVZSFXKkH96sitM/ZjaCRFAKEXjrfN XqmiZnziH6g0qbbSrSZoxOhZ81IibtKQgajsTExCKG5WJFjXaxph4R2bR9AlQIFtEMybs2sLl2M hjBX5aGrpgYjPO1f5pJ2/FKbLMwTLwpPnslB7Qrbe7obA== X-Envelope-To: stable@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 7082d269086a5a58; Wed, 02 Dec 2026 22:12:56 +0000 X-Mizu-Trace-ID: 7082d269086a5a58 X-Migadu-Flow: FLOW_OUT From: Cooper Morgan To: stable@vger.kernel.org Cc: Harry Wentland , Wayne Lin , Alex Deucher Subject: [PATCH 6.12.y] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets Date: Wed, 2 Dec 2026 14:12:45 -0800 Message-ID: <20261202221246.1123318-1-ext-github@cwooper.dev> X-Mailer: git-send-email 2.56.1 In-Reply-To: <2026120247-thesaurus-quit-2eeb@gregkh> References: <2026120247-thesaurus-quit-2eeb@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Cooper Morgan Signed-off-by: Wayne Lin Signed-off-by: Alex Deucher (cherry picked from commit 8f91c13d9a14085216725f60b55546fce5c2dd19) Cc: stable@vger.kernel.org (cherry picked from commit 76850a457474a629dc0ceffaafb3aed78ff5f469) [ Cooper: Dropped the KUnit test hunks, since 6.12.y has no amdgpu_dm_freesync_test.c. In freesync.c, resolved a context conflict: 6.12.y still has mod_freesync_get_vmin_vmax() and mod_freesync_get_v_position() above build_vrr_infopacket_data_v1(), so the new helper goes after them. The code change is unchanged. ] Signed-off-by: Cooper Morgan --- I built amdgpu on 6.12.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 ab62a76d48cf..aad1959f3f1d 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c @@ -575,6 +575,12 @@ bool mod_freesync_get_v_position(struct mod_freesync *mod_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) @@ -618,15 +624,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