2023-11-19 10:57:53

by Javier Martinez Canillas

[permalink] [raw]
Subject: [PATCH v3 0/5] drm: Allow the damage helpers to handle buffer damage

Hello,

This series is to fix an issue that surfaced after damage clipping was
enabled for the virtio-gpu by commit 01f05940a9a7 ("drm/virtio: Enable
fb damage clips property for the primary plane").

After that change, flickering artifacts was reported to be present with
both weston and wlroots wayland compositors when running in a virtual
machine. The cause was identified by Sima Vetter, who pointed out that
virtio-gpu does per-buffer uploads and for this reason it needs to do
a buffer damage handling, instead of frame damage handling.

Their suggestion was to extend the damage helpers to cover that case
and given that there's isn't a buffer damage accumulation algorithm
(e.g: buffer age), just do a full plane update if the framebuffer that
is attached to a plane changed since the last plane update (page-flip).

It is a v3 that addresses issues pointed out by Thomas Zimmermann and
Simon Ser in v2:

https://lists.freedesktop.org/archives/dri-devel/2023-November/430896.html

Patch #1 adds a ignore_damage_clips field to struct drm_plane_state to be
set by drivers that want the damage helpers to ignore the damage clips.

Patch #2 fixes the virtio-gpu damage handling logic by asking the damage
helper to ignore the damage clips if the framebuffer attached to a plane
has changed since the last page-flip.

Patch #3 does the same but for the vmwgfx driver that also needs to handle
buffer damage and should have the same issue (although I haven't tested it
due not having a VMWare setup).

Patch #4 adds to the KMS damage tracking kernel-doc some paragraphs about
damage tracking types and references to links that explain frame damage vs
buffer damage.

Finally patch #5 adds an item to the DRM todo, about the need to implement
some buffer damage accumulation algorithm instead of just doing full plane
updates in this case.

Because commit 01f05940a9a7 landed in v6.4, the first 2 patches are marked
as Fixes and Cc stable.

I've tested this on a VM with weston, was able to reproduce the issue
reported and the patches did fix the problem.

Best regards,
Javier

Changes in v3:
- Fix typo in the kernel-doc (Simon Ser).
- Add a paragraph explaining what the problem in the kernel is and
make it clear that the refeference documents are related to how
user-space handles this case (Thomas Zimmermann).

Changes in v2:
- Add a struct drm_plane_state .ignore_damage_clips to set in the plane's
.atomic_check, instead of having different helpers (Thomas Zimmermann).
- Set struct drm_plane_state .ignore_damage_clips in virtio-gpu plane's
.atomic_check instead of using a different helpers (Thomas Zimmermann).
- Set struct drm_plane_state .ignore_damage_clips in vmwgfx plane's
.atomic_check instead of using a different helpers (Thomas Zimmermann).

Javier Martinez Canillas (5):
drm: Allow drivers to indicate the damage helpers to ignore damage
clips
drm/virtio: Disable damage clipping if FB changed since last page-flip
drm/vmwgfx: Disable damage clipping if FB changed since last page-flip
drm/plane: Extend damage tracking kernel-doc
drm/todo: Add entry about implementing buffer age for damage tracking

Documentation/gpu/todo.rst | 20 ++++++++++++++++++++
drivers/gpu/drm/drm_damage_helper.c | 3 ++-
drivers/gpu/drm/drm_plane.c | 26 ++++++++++++++++++++++++++
drivers/gpu/drm/virtio/virtgpu_plane.c | 10 ++++++++++
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 11 +++++++++++
include/drm/drm_plane.h | 8 ++++++++
6 files changed, 77 insertions(+), 1 deletion(-)

--
2.41.0


2023-11-19 10:58:17

by Javier Martinez Canillas

[permalink] [raw]
Subject: [PATCH v3 5/5] drm/todo: Add entry about implementing buffer age for damage tracking

Currently, only damage tracking for frame damage is supported. If a driver
needs to do buffer damage (e.g: the framebuffer attached to plane's state
has changed since the last page-flip), the damage helpers just fallback to
a full plane update.

Add en entry in the TODO about implementing buffer age or any other damage
accumulation algorithm for buffer damage handling.

Suggested-by: Simon Ser <[email protected]>
Signed-off-by: Javier Martinez Canillas <[email protected]>
Reviewed-by: Simon Ser <[email protected]>
Reviewed-by: Thomas Zimmermann <[email protected]>
---

(no changes since v1)

Documentation/gpu/todo.rst | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index b62c7fa0c2bc..5c43a958814b 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -782,6 +782,26 @@ Contact: Hans de Goede

Level: Advanced

+Buffer age or other damage accumulation algorithm for buffer damage handling
+============================================================================
+
+Drivers that do per-buffer uploads, need a buffer damage handling (rather than
+frame damage like drivers that do per-plane or per-CRTC uploads), but there is
+no support to get the buffer age or any other damage accumulation algorithm.
+
+For this reason, the damage helpers just fallback to a full plane update if the
+framebuffer attached to a plane has changed since the last page-flip.
+
+This should be improved to get damage tracking properly working on drivers that
+do per-buffer uploads.
+
+More information about damage tracking and references to learning materials in
+`Damage Tracking Properties <https://docs.kernel.org/gpu/drm-kms.html#damage-tracking-properties>`_
+
+Contact: Javier Martinez Canillas <[email protected]>
+
+Level: Advanced
+
Outside DRM
===========

--
2.41.0

2023-11-20 02:49:51

by Zack Rusin

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] drm: Allow the damage helpers to handle buffer damage

On Sun, 2023-11-19 at 11:56 +0100, Javier Martinez Canillas wrote:
> Hello,
>
> This series is to fix an issue that surfaced after damage clipping was
> enabled for the virtio-gpu by commit 01f05940a9a7 ("drm/virtio: Enable
> fb damage clips property for the primary plane").
>
> After that change, flickering artifacts was reported to be present with
> both weston and wlroots wayland compositors when running in a virtual
> machine. The cause was identified by Sima Vetter, who pointed out that
> virtio-gpu does per-buffer uploads and for this reason it needs to do
> a buffer damage handling, instead of frame damage handling.
>
> Their suggestion was to extend the damage helpers to cover that case
> and given that there's isn't a buffer damage accumulation algorithm
> (e.g: buffer age), just do a full plane update if the framebuffer that
> is attached to a plane changed since the last plane update (page-flip).
>
> It is a v3 that addresses issues pointed out by Thomas Zimmermann and
> Simon Ser in v2:
>
> https://lists.freedesktop.org/archives/dri-devel/2023-November/430896.html
>
> Patch #1 adds a ignore_damage_clips field to struct drm_plane_state to be
> set by drivers that want the damage helpers to ignore the damage clips.
>
> Patch #2 fixes the virtio-gpu damage handling logic by asking the damage
> helper to ignore the damage clips if the framebuffer attached to a plane
> has changed since the last page-flip.
>
> Patch #3 does the same but for the vmwgfx driver that also needs to handle
> buffer damage and should have the same issue (although I haven't tested it
> due not having a VMWare setup).
>
> Patch #4 adds to the KMS damage tracking kernel-doc some paragraphs about
> damage tracking types and references to links that explain frame damage vs
> buffer damage.
>
> Finally patch #5 adds an item to the DRM todo, about the need to implement
> some buffer damage accumulation algorithm instead of just doing full plane
> updates in this case.
>
> Because commit 01f05940a9a7 landed in v6.4, the first 2 patches are marked
> as Fixes and Cc stable.
>
> I've tested this on a VM with weston, was able to reproduce the issue
> reported and the patches did fix the problem.
>
> Best regards,
> Javier
>
> Changes in v3:
> - Fix typo in the kernel-doc (Simon Ser).
> - Add a paragraph explaining what the problem in the kernel is and
> make it clear that the refeference documents are related to how
> user-space handles this case (Thomas Zimmermann).
>
> Changes in v2:
> - Add a struct drm_plane_state .ignore_damage_clips to set in the plane's
> .atomic_check, instead of having different helpers (Thomas Zimmermann).
> - Set struct drm_plane_state .ignore_damage_clips in virtio-gpu plane's
> .atomic_check instead of using a different helpers (Thomas Zimmermann).
> - Set struct drm_plane_state .ignore_damage_clips in vmwgfx plane's
> .atomic_check instead of using a different helpers (Thomas Zimmermann).
>
> Javier Martinez Canillas (5):
> drm: Allow drivers to indicate the damage helpers to ignore damage
> clips
> drm/virtio: Disable damage clipping if FB changed since last page-flip
> drm/vmwgfx: Disable damage clipping if FB changed since last page-flip
> drm/plane: Extend damage tracking kernel-doc
> drm/todo: Add entry about implementing buffer age for damage tracking
>
> Documentation/gpu/todo.rst | 20 ++++++++++++++++++++
> drivers/gpu/drm/drm_damage_helper.c | 3 ++-
> drivers/gpu/drm/drm_plane.c | 26 ++++++++++++++++++++++++++
> drivers/gpu/drm/virtio/virtgpu_plane.c | 10 ++++++++++
> drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 11 +++++++++++
> include/drm/drm_plane.h | 8 ++++++++
> 6 files changed, 77 insertions(+), 1 deletion(-)
>

Looks good. Thanks. For the series:
Reviewed-by: Zack Rusin <[email protected]>

z