From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.110 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249595; b=31ylw7awiquj3O697SVuL5L0+43v/PSE3qHPkPEb3qF41U9aWN9goQhDEVb9irlZwJeD P9hZGJGv6d+4KIKKncx9i3bV18re7lxYni5hMdyhNum9GjfH2yS33fR9cfLHP6rmt6XGR tFT1tKPyWN+DzuYBQrYOgxt3AGY/NIJsdcs6xTcbWNTsFtlMBiN+Ne6e0JriJKQpj4wo8 iHYItRgx4xgKVpY8O2r+DNRADh22VuezeBOjiJ7eYu7hX3KhneNCinVmuGFfldHHU87+d SfcncbIf7yXlei3X5KxdVx8dURpeGppsmi1HNFeDTUNZ3uRj225eqciINxUX8Whp6sg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249595; 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=WoVbevUd/yc26Paeg1VVQn2Tq/ZmKHhk6AOY4lbi+74=; b=Z9o8QMstQFRKzMAPxr64nCO3jdqAuyi3vOMYS4sC0eRSPNOUAdEGp1wAEDy91Lj2/Hzn rpNix1/aAdTjpy2dck9xK67yULCmsDRmrEANrikTDQ+jvEyPLVEjt84ZANUBgdsq/Ha1V DzMLw33zIQsafGG8H0OPQodtIVWxJHw9AqVNFJk1zj+fJH7AAJaWCO6he926lHPIERyFf DGQMrvIAgkwYKbOBnd1W21YhKzV/HvVTN62P7UOjWD9v6tYh/uQ0ikdRq0c3UtW10GHKz vjjU3ZC1TzbKipp4k0DxPL7Lgvu1XjVxggIAcvIeEbt+z9cFKDYJHB6DwGiq73E5HaQ== 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=xs1T3J6F; arc=none smtp.remote-ip=91.218.175.110 Received: from mta0.migadu.com (out-110.mta0.migadu.com [91.218.175.110]) (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 1E78B606A681 for ; Wed, 2 Dec 2026 22:13:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1E78B606A681 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=xs1T3J6F X-Envelope-To: stable@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=V+yk6Hp/WoIHpbXUZtiwRfRC1Keoerg3PW7jNfLZ3Qk=; c=simple/simple; d=cwooper.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796249593; v=1; x=1796854393; b=xs1T3J6FyMPvOAexfB8rJCD5XS/ovZlqyLiZ4eMYY+rTqzuacSwrWIwGlC+yjxJu10evKVhb vcCYCl9I5S+tuk4MCyuLr9zLjCpdejsAIMKbt0t5tkzAFKoKLcuw98QjCHAwjM72LfLzQS9KwCa chNoOfM24E8OfpMjC5BL3CmhWALp0yaXkibAigiS4/V/s8ojr2oZrThp4vr/tyz5rJ7Ud4eyGW+ naw2jIEjhnSGQR16AbUMhF7SIkUvyOm+tTX4zsMWfMPJAIr+NJycVR0KDFA2LwwRKlJigpJwpJd gux0D7Jm6uy0o7k8LeL/DrTMXg76zJ1E3IQLJlGzvSgJw== X-Envelope-To: stable@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id ceb72cc743574ab1; Wed, 02 Dec 2026 22:13:12 +0000 X-Mizu-Trace-ID: ceb72cc743574ab1 X-Migadu-Flow: FLOW_OUT From: Cooper Morgan To: stable@vger.kernel.org Cc: Harry Wentland , Wayne Lin , Alex Deucher Subject: [PATCH 6.6.y] drm/amd/display: Saturate refresh rates in v1/v2 FreeSync infopackets Date: Wed, 2 Dec 2026 14:12:56 -0800 Message-ID: <20261202221258.1123670-1-ext-github@cwooper.dev> X-Mailer: git-send-email 2.56.1 In-Reply-To: <2026120200-bronzing-manliness-bdc7@gregkh> References: <2026120200-bronzing-manliness-bdc7@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.6.y has no amdgpu_dm_freesync_test.c. In freesync.c, resolved a context conflict: 6.6.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.6.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 0a1932a7e289..af08a896603b 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c @@ -564,6 +564,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) @@ -607,15 +613,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