]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/atomic-helper: make drm_gem_plane_helper_prepare_fb the default
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 23 Jun 2021 16:22:00 +0000 (18:22 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 24 Jun 2021 13:35:13 +0000 (15:35 +0200)
There's a bunch of atomic drivers who don't do this quite correctly,
luckily most of them aren't in wide use or people would have noticed
the tearing.

By making this the default we avoid the constant audit pain and can
additionally remove a ton of lines from vfuncs for a bit more clarity
in smaller drivers.

While at it complain if there's a cleanup_fb hook but no prepare_fb
hook, because that makes no sense. I haven't found any driver which
violates this, but better safe than sorry.

Subsequent patches will reap the benefits.

v2: It's neither ... nor, not not (Sam)

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210623162200.3372056-1-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_gem_atomic_helper.c
include/drm/drm_modeset_helper_vtables.h

index bc3487964fb5e710f6d397434866a77bc888ecf7..f7bf1ea62d587173ad95602821f2b01bfa981fc0 100644 (file)
@@ -35,6 +35,7 @@
 #include <drm/drm_damage_helper.h>
 #include <drm/drm_device.h>
 #include <drm/drm_drv.h>
+#include <drm/drm_gem_atomic_helper.h>
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_print.h>
 #include <drm/drm_self_refresh_helper.h>
@@ -2405,6 +2406,15 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
                        ret = funcs->prepare_fb(plane, new_plane_state);
                        if (ret)
                                goto fail;
+               } else {
+                       WARN_ON_ONCE(funcs->cleanup_fb);
+
+                       if (!drm_core_check_feature(dev, DRIVER_GEM))
+                               continue;
+
+                       ret = drm_gem_plane_helper_prepare_fb(plane, new_plane_state);
+                       if (ret)
+                               goto fail;
                }
        }
 
index a27135084ae5c8cc43c600c71f6c46c9518f91e1..bc9396f2a0ed02d44d20d827ced5d4ab29bce5e5 100644 (file)
  * GEM based framebuffer drivers which have their buffers always pinned in
  * memory.
  *
+ * This function is the default implementation for GEM drivers of
+ * &drm_plane_helper_funcs.prepare_fb if no callback is provided.
+ *
  * See drm_atomic_set_fence_for_plane() for a discussion of implicit and
  * explicit fencing in atomic modeset updates.
  */
index f3a4b47b39866fec3087ee25e7bfd14ebc3a35e1..fdfa9f37ce05e20e089bcec5725aaafbc50dd5c6 100644 (file)
@@ -1178,8 +1178,11 @@ struct drm_plane_helper_funcs {
         * equivalent functionality should be implemented through private
         * members in the plane structure.
         *
-        * Drivers which always have their buffers pinned should use
-        * drm_gem_plane_helper_prepare_fb() for this hook.
+        * For GEM drivers who neither have a @prepare_fb nor @cleanup_fb hook
+        * set drm_gem_plane_helper_prepare_fb() is called automatically to
+        * implement this. Other drivers which need additional plane processing
+        * can call drm_gem_plane_helper_prepare_fb() from their @prepare_fb
+        * hook.
         *
         * The helpers will call @cleanup_fb with matching arguments for every
         * successful call to this hook.