[PATCH] drm/atomic-state-helper: Clear ignore_damage_clips on state duplication

From: Michael Still

Date: Mon Nov 30 2026 - 03:34:30 EST


__drm_atomic_helper_plane_duplicate_state() clears the plane state
fields that describe one commit only, such as fb_damage_clips, but not
ignore_damage_clips, which was added beside it as another per-commit
hint. Once a driver sets the flag, every state later duplicated from
that one inherits it.

vmwgfx, and virtio-gpu in stable kernels, set it only when the plane's
framebuffer changes, which on most systems is first the initial
modeset. From then on every commit ignores its damage clips and
drm_atomic_helper_damage_iter_init() reports the whole plane as
damaged. On virtio-gpu that makes every DRM_IOCTL_MODE_DIRTYFB on a
dumb buffer a full-plane transfer and RESOURCE_FLUSH: a client dirtying
a 480x360 region of a 1280x800 buffer each frame has QEMU flush
1280x800 every time.

Clear it on duplication, like the other per-commit fields, so it
applies only to the commit whose atomic_check set it. Every current
user assigns it on each check where it should apply, so none relies on
it persisting. Document that in the kernel-doc for the field.

virtio-gpu has recomputed the flag itself since v7.4, but vmwgfx has
not been fixed anywhere and no stable branch has taken the virtio-gpu
change, so the helper is the one place that covers vmwgfx, every stable
branch and the next user of the flag at once.

Fixes: 35ed38d58257 ("drm: Allow drivers to indicate the damage helpers to ignore damage clips")
Cc: stable@xxxxxxxxxxxxxxx # v6.6+
Signed-off-by: Michael Still <mikal@xxxxxxxxxxx>
---
Notes:

Based on drm-misc-next (479e381e77dc). It also applies cleanly, with no
fuzz, to drm-misc-fixes (1c986bc5918c), mainline (4dce97c6c265, v7.4-rc4+)
and stable v6.12.119. Built on drm-misc-next with allmodconfig on x86-64:
drivers/gpu/drm/ builds without a new warning, and scripts/kernel-doc
reports none for include/drm/drm_plane.h.

Tested on virtio-gpu with a Debian 6.12.101 guest kernel whose
virtgpu_plane.c still sets the flag only on fb change: rebuilding
drm_kms_helper.ko with this change and leaving virtio-gpu.ko stock,
a static test program drawing into a 1280x800 dumb buffer and calling
DRM_IOCTL_MODE_DIRTYFB on a 480x360 region at 30 fps (plus an 80x28
region once a second) gives these QEMU virtio_gpu_cmd_res_flush traces
over ~12 seconds:

unpatched: 380 flushes, all 1280x800+0+0
patched: 381 flushes, 362 x 480x360+437+241, 13 x 80x28+24+740,
5 x 1280x800+0+0 (modeset and initial full dirty),
1 x 8x16

That measurement would show no difference on v7.4 or later, where
virtio-gpu recomputes the flag itself; it still holds for every stable
branch that has the flag, all of which carry the conditional
assignment: 6.6.y (where 35ed38d58257 arrived in v6.6.15, hence v6.6+
above), 6.12.y, 6.18.y, 7.2.y and 7.3.y, checked on 2026-11-28. 6.1.y
and older predate the flag. vmwgfx was build-tested only.

a9cc9905ddb7 ("drm/virtio: Recalculate ignore_damage_clips on every
update") fixed this for virtio-gpu alone, in v7.4. It has no Fixes: or
stable tag and depends on 730f8554f35c, so no stable kernel carries it
and every stable branch with the flag still has it sticky. vmwgfx has
not been fixed anywhere. The other setters of the flag are unaffected
either way: gud sets it from a per-device flag on every check, and the
drm/ms91xx driver currently on the list assigns it unconditionally. The
alternative to this patch is the same "flag = condition" change in
vmwgfx_kms.c, but that leaves the next user of the flag open to the same
mistake, and still asks stable for the two virtio-gpu commits rather
than one line.

Per Documentation/process/generated-content.rst: this change and the
first draft of this changelog were written with Claude Code (Anthropic's
Claude Opus models), asked to find why virtio-gpu guests report
full-plane damage for small DIRTYFB regions and to fix it in the DRM
core. It also built and ran the virtio-gpu test rig quoted above. I
reviewed the change and the measurement and am responsible for both.

drivers/gpu/drm/drm_atomic_state_helper.c | 1 +
include/drm/drm_plane.h | 4 ++++
2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c
index 406157a3660f..fa92eb93cc60 100644
--- a/drivers/gpu/drm/drm_atomic_state_helper.c
+++ b/drivers/gpu/drm/drm_atomic_state_helper.c
@@ -330,6 +330,7 @@ void __drm_atomic_helper_plane_duplicate_state(struct drm_plane *plane,
state->fence = NULL;
state->commit = NULL;
state->fb_damage_clips = NULL;
+ state->ignore_damage_clips = false;
state->color_mgmt_changed = false;
}
EXPORT_SYMBOL(__drm_atomic_helper_plane_duplicate_state);
diff --git a/include/drm/drm_plane.h b/include/drm/drm_plane.h
index 410d7b02b77a..431535dc108c 100644
--- a/include/drm/drm_plane.h
+++ b/include/drm/drm_plane.h
@@ -203,6 +203,10 @@ struct drm_plane_state {
*
* Set by drivers to indicate the drm_atomic_helper_damage_iter_init()
* helper that the @fb_damage_clips blob property should be ignored.
+ * Like @fb_damage_clips, this only applies to the commit it is set
+ * in: __drm_atomic_helper_plane_duplicate_state() clears it, so
+ * drivers must set it again in each &drm_plane_helper_funcs.atomic_check
+ * where damage clips should be ignored.
*
* See :ref:`damage_tracking_properties` for more information.
*/
--
2.47.3