Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/simple-helper: drm_gem_simple_display_pipe_prepare_fb as default

It's tedious to review this all the time, and my audit showed that
arcpgu actually forgot to set this.

Make this the default and stop worrying.

Again I sprinkled WARN_ON_ONCE on top to make sure we don't have
strange combinations of hooks: cleanup_fb without prepare_fb doesn't
make sense, and since simpler drivers are all new they better be GEM
based drivers.

v2: Warn and bail when it's _not_ a GEM driver (Noralf)

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

Acked-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Noralf Trønnes <noralf@tronnes.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/20210623162456.3373469-1-daniel.vetter@ffwll.ch

+15 -4
+10 -2
drivers/gpu/drm/drm_simple_kms_helper.c
··· 9 9 #include <drm/drm_atomic.h> 10 10 #include <drm/drm_atomic_helper.h> 11 11 #include <drm/drm_bridge.h> 12 + #include <drm/drm_drv.h> 13 + #include <drm/drm_gem_atomic_helper.h> 12 14 #include <drm/drm_managed.h> 13 15 #include <drm/drm_plane_helper.h> 14 16 #include <drm/drm_probe_helper.h> ··· 227 225 struct drm_simple_display_pipe *pipe; 228 226 229 227 pipe = container_of(plane, struct drm_simple_display_pipe, plane); 230 - if (!pipe->funcs || !pipe->funcs->prepare_fb) 231 - return 0; 228 + if (!pipe->funcs || !pipe->funcs->prepare_fb) { 229 + if (WARN_ON_ONCE(!drm_core_check_feature(plane->dev, DRIVER_GEM))) 230 + return 0; 231 + 232 + WARN_ON_ONCE(pipe->funcs && pipe->funcs->cleanup_fb); 233 + 234 + return drm_gem_simple_display_pipe_prepare_fb(pipe, state); 235 + } 232 236 233 237 return pipe->funcs->prepare_fb(pipe, state); 234 238 }
+5 -2
include/drm/drm_simple_kms_helper.h
··· 116 116 * the documentation for the &drm_plane_helper_funcs.prepare_fb hook for 117 117 * more details. 118 118 * 119 - * Drivers which always have their buffers pinned should use 120 - * drm_gem_simple_display_pipe_prepare_fb() for this hook. 119 + * For GEM drivers who neither have a @prepare_fb nor @cleanup_fb hook 120 + * set drm_gem_simple_display_pipe_prepare_fb() is called automatically 121 + * to implement this. Other drivers which need additional plane 122 + * processing can call drm_gem_simple_display_pipe_prepare_fb() from 123 + * their @prepare_fb hook. 121 124 */ 122 125 int (*prepare_fb)(struct drm_simple_display_pipe *pipe, 123 126 struct drm_plane_state *plane_state);