From 730f8554f35c5a7c404fbba964a6cf9d45908be5 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 3 Sep 2026 17:15:51 -0400 Subject: [PATCH] drm/virtio: preserve damage clips for rendered resources virtio_gpu_plane_atomic_check() unconditionally ignores FB_DAMAGE_CLIPS when the framebuffer changes. This forces a full resource flush on every page flip when a compositor rotates through multiple framebuffers, even when userspace supplies accumulated per-buffer damage. The full update is required for dumb buffers because their contents are uploaded per buffer. Rendered resources are already coherent on the host, so replacing their damage with the full plane only discards useful information. Restrict ignore_damage_clips to dumb buffers. This allows damage-aware compositors to propagate partial updates through RESOURCE_FLUSH while preserving the existing full-upload behavior for dumb buffers. Signed-off-by: Christian Hergert Reviewed-by: Lyude Paul Signed-off-by: Lyude Paul Signed-off-by: Dmitry Osipenko Link: https://patch.msgid.link/20260903211914.1109100-2-lyude@redhat.com --- drivers/gpu/drm/virtio/virtgpu_plane.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index 946f163013b8..8225085ce6c0 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -105,6 +105,7 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane, plane); struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state, plane); + struct virtio_gpu_object *bo; bool is_cursor = plane->type == DRM_PLANE_TYPE_CURSOR; struct drm_crtc_state *crtc_state; int ret; @@ -115,9 +116,12 @@ static int virtio_gpu_plane_atomic_check(struct drm_plane *plane, /* * Ignore damage clips if the framebuffer attached to the plane's state * has changed since the last plane update (page-flip). In this case, a - * full plane update should happen because uploads are done per-buffer. + * full plane update should happen for dumb buffers because uploads are + * done per-buffer. Rendered resources are already coherent on the host, + * so preserve userspace's accumulated per-buffer damage for those. */ - if (old_plane_state->fb != new_plane_state->fb) + bo = gem_to_virtio_gpu_obj(new_plane_state->fb->obj[0]); + if (old_plane_state->fb != new_plane_state->fb && bo->dumb) new_plane_state->ignore_damage_clips = true; crtc_state = drm_atomic_get_crtc_state(state,