From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796347076; b=sciL5mWvo2stfORxWRgq4yvGPMUZlJFJa1l0XI22wQOHjUVIg86TZloQJ+plaPgGld8j IKheHnY9IRfbmsbVHbdscjC/PZIBNM3rvBTNI8jQJhl8q5hZYXDhGaf5U7GotO/WfJumg GO+87Ns9EHYm4uca0/7rciEjI9oPn3QizzGiUR6c4W5BEuLSSXc4f4m84shf4XdCddmjF y8n6hnwcM/i3nXMFrQQZNtgi8c0Ond9/F+4K/cv1U8WYA6kdXCSDNElo6en6ig1wYwr5c TGYLZhk6ouY3Lq+W3cBYslgu00hOvJ8/PLk6s0cw5/+3x7NNezZFLBvxRbULsp53Zdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796347076; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=zZv+vlZAH6CbHGId01e/PKld3a888DR0v8VbLrop6Cw=; b=zBxCTx4gCBYFuMrvYbbxHrCgK+UUtKNQYYMZS2EV4k95bfr3/z620IvluoPkZhx/JymZ xgnfA3qJx9a0goV7aZ6iCVExCAK/JWtIRd8nWGQCDCf8Ljc4DAgvBVfn397GkQthPUIF1 kaIrU7wdUjfwIcT8klaAEyB99jtRHd1JCNycJ3dX4vg5q9MluD29IUpXt3+PfysyhCAZy 3cEZ5T4/5fStYydxs5uEMtvlIv5FrIC039q+UcQ5rayXTq66vKYBc+ApWh2TlpAKiAhjG KeCGOqovZPmYbYH8HdAfkWrxmeXWSiqcf/w3FD2z2UyTbn/KUUkx0CutVlI51yMnBZQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Dn74G3A1; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C63D9606A322 for ; Fri, 4 Dec 2026 01:17:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Dn74G3A1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 930581F000C2; Fri, 4 Dec 2026 01:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796347076; bh=zZv+vlZAH6CbHGId01e/PKld3a888DR0v8VbLrop6Cw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Dn74G3A1KR/kzBvoHZLsCIj/YnX97uentF/kYVbP48cWOeWmkl6zLdE/M+0Q8eM/x WFMHmh6uKAEHhpnXfIoIkclzrSd2mzwp0+9IDfxaOS3j2yK3hWtzdTOXiAdLywPH/6 95tO4aKTewNN0IetlS3SdfZgCA/BN8V7gNboFlCIrqWtjjwTvwYVhnwZrfbwLx7Kf2 zPuU67KMj4Z9f17xsj27uefZjVzZW6nx2I8zJW2vXcOmlekv7ZcHIe7neYqwz1VKeu 1E1+3x50qpJ2uFbMs6I/5NfmYV/X1bgJT1QNV6oLtYrhkSmJg/MSklXyejvt2opJKs mcJ7Ehjz5MHTA== From: Sasha Levin To: stable@vger.kernel.org Cc: Davey Hughes , Harry Wentland , Wayne Lin , Alex Deucher , Sasha Levin Subject: [PATCH 6.6.y] drm/amd/display: Keep FreeSync flip timing across plane resets Date: Thu, 3 Dec 2026 20:17:54 -0500 Message-ID: <20261204011700.1606802-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120215-protector-guts-cb53@gregkh> References: <2026120215-protector-guts-cb53@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 From: Davey Hughes [ Upstream commit fff46a322847a54cf11d5af3d7fc7fa07bc71b29 ] dm_update_plane_state() replaces the DC plane with a newly allocated one whenever the plane is reset. The new plane's flip timing is zero, and mod_freesync_handle_preflip() runs before DC stores the new plane's first flip timestamp, so FreeSync takes the 32-bit microsecond timestamp itself as the last render time: the monotonic clock modulo about 71.6 minutes. On a panel with below-the-range compensation (BTR), that engages BTR and pins the frame time at the BTR mid-point (13.447 ms on a 48-165 Hz panel). A panel without BTR (max refresh below twice the min) goes through the fixed refresh path instead and locks to its max refresh after six frames. It takes a reset on every flip to keep the panel there, and color management changes reset the plane. DRM sets color_mgmt_changed whenever a color property is given a different blob, even one with the same contents, and KWin 6.8.1 with HDR enabled and its color accuracy setting at "Prefer efficiency" sets a new GAMMA_LUT blob on every commit (current KWin master no longer does). Plane resets for CRTC color changes, added by commit 7316c4ad2996 ("drm/amd/display: Reset planes for color management changes"), and later for plane color properties and colorops, made this reachable on every flip. Copy the flip timing from the old DC plane into the new one when the plane stays on the same CRTC. Do it in amdgpu_dm_commit_planes() before the preflip, after drm_atomic_helper_wait_for_dependencies() has waited for the previous commit, so the copy holds that commit's flip and does not race with DC writing it. This covers both the BTR and the fixed refresh path. A plane that is newly enabled or moved to another CRTC still starts without history. Fixes: 180db303ff46 ("drm/amd/display: Add below the range support for FreeSync") Reviewed-by: Harry Wentland Signed-off-by: Davey Hughes Signed-off-by: Wayne Lin Signed-off-by: Alex Deucher (cherry picked from commit 4acf82d2a2dcca2d7df8649ecafb3da6c1245003) Cc: stable@vger.kernel.org [ sashal: Placed the new flip-time helper directly above amdgpu_dm_commit_planes() because the KUnit helpers it follows upstream are missing, and adjusted the context for the older atomic-state type and color-management condition. ] Signed-off-by: Sasha Levin --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index de16398e0ca07..5eb7d2afe4aa1 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -8109,6 +8109,25 @@ static inline uint32_t get_mem_type(struct drm_framebuffer *fb) return abo->tbo.resource ? abo->tbo.resource->mem_type : 0; } +/* + * FreeSync times each frame from the plane's previous flip, and a plane + * reset gives the new DC plane zeroed flip timing, so copy it over. Do + * this at commit time, not in atomic check: by then the previous commit + * has finished writing it. + */ +static void +dm_plane_inherit_flip_time(struct dc_plane_state *dc_plane_state, + struct drm_plane_state *old_plane_state, + struct drm_plane_state *new_plane_state) +{ + struct dc_plane_state *old_dc_plane_state = + to_dm_plane_state(old_plane_state)->dc_state; + + if (old_dc_plane_state && old_dc_plane_state != dc_plane_state && + old_plane_state->crtc == new_plane_state->crtc) + dc_plane_state->time = old_dc_plane_state->time; +} + static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, struct drm_device *dev, struct amdgpu_display_manager *dm, @@ -8185,6 +8204,9 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, if (!dc_plane) continue; + dm_plane_inherit_flip_time(dc_plane, old_plane_state, + new_plane_state); + bundle->surface_updates[planes_count].surface = dc_plane; if (new_pcrtc_state->color_mgmt_changed) { bundle->surface_updates[planes_count].gamma = dc_plane->gamma_correction; -- 2.53.0