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=1796347308; b=NxQVUbye+PTSRuNOWVYizzHfXP24UqQ+/xXQ7/c5lbURNsh2SxWcJUwxy7b6qVvpBzwQ p/78d+Pb1VNUTP2L/sCmTlek38DTtcv1bGZFTiN5o6Pwkm6rIPSDuZ7Glf7y/6DPWwRA+ aE3ol1EjH31IHf7Zvx3s8VVmErKm/Wp31988btBLou1wcDDIoiO5VFoD9meCECWIhDOz6 L/tg1V1Q0Uqe6hQ+UinoIqIjY133AQdzzd9Yxmjv8bzz08iy53Zy/J9q8gCgI09cZO1XO aVK7YSRJDsU9JsFDKg4pAGfmfs6J+z0MzSDg45cNldUREtcSmXMcome+jcy6piv7mVQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796347308; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=tgcBtubMz2e6OjpfwpFXNvp+5hHWJq51P4Y2eMmmoRA=; b=SdK20q3PPxQJhs9TpwZ0hCcZrspNM8sn/2il5MPbsGu3zS7cRcuETjkXKdkw8/kVK54b SuH6Bc8H9IarupDqF6A33daETDniYaBFhu2BBadMuTkqPreNqAmfsacLe78XHySfXyCp9 T0JNoPyMVc/lzC9H3AZvbPKvHH4dttF/QtPUEgE1PsPogQABJOGiJ1qU4uIIXURlhPK20 Fjsc3jmDUN0JCBubPTcw145dO4qjNsSz/cjxXy/OIvczlmd+eUqvus6MvTYyJyaxzAeUw F04GHq9bqTpLHAu/oGcfI2BrTJd4Uswc9wHhF4JZ5wqOrsIXNNELYK+c7grq1vyzjPA== 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=AfoczONf; 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 D4EF0606A322 for ; Fri, 4 Dec 2026 01:21:48 +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=AfoczONf Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7F311F000C2; Fri, 4 Dec 2026 01:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796347308; bh=tgcBtubMz2e6OjpfwpFXNvp+5hHWJq51P4Y2eMmmoRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AfoczONfSENxHyQxYNpY9hLEoOv2Ei5EHYcT/wIC60nRZ0//jrRwDIl2ZqjGcRAP/ PjLssTeCqpsWQUOnan9monY7eOLbYThYf4+1jAoA3+yIjnUL9zca2W93NBfoo/kkBk EifYT6CoZBMJO4EjG175bV+HCQOTXxobtS1JHxDrjPyz7T85rRIwUVbWmPivATQv73 bRqgKwcKVvkW9FiFDP+SpS+rlgPl91MKGbEjtwQx6eQC9YFOJYyMO6dTp6XeA1ZOpl NgOsVeViOCdv9iwlTnGY8G+laPgcHRnUpwou3IAjcxfRCrXiD+fGl6gFjnEuxp7VxM QUkCk0Lkzoi7w== From: Sasha Levin To: stable@vger.kernel.org Cc: Davey Hughes , Harry Wentland , Wayne Lin , Alex Deucher , Sasha Levin Subject: [PATCH 6.1.y] drm/amd/display: Keep FreeSync flip timing across plane resets Date: Thu, 3 Dec 2026 20:21:46 -0500 Message-ID: <20261204012059.1615167-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120216-omission-washtub-8d4d@gregkh> References: <2026120216-omission-washtub-8d4d@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: adapted to older tree: context differs (missing KUNIT helpers, drm_atomic_state instead of drm_atomic_commit, extra dc_state arg) and the gamma_correction pointer/color_mgmt condition differ. ] 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 28c164bfb7a50..8bbdad7edba37 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -7880,6 +7880,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 dc_state *dc_state, struct drm_device *dev, @@ -7956,6 +7975,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