public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Airlie <airlied@linux.ie>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH 07/15] drm/atomic-helper: make drm_gem_plane_helper_prepare_fb the default
Date: Tue, 22 Jun 2021 21:10:03 +0200	[thread overview]
Message-ID: <YNI1i1D88TWZU1vR@ravnborg.org> (raw)
In-Reply-To: <20210622165511.3169559-8-daniel.vetter@ffwll.ch>

Hi Daniel,

On Tue, Jun 22, 2021 at 06:55:03PM +0200, Daniel Vetter wrote:
> 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.
> 
> 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>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c      | 10 ++++++++++
>  drivers/gpu/drm/drm_gem_atomic_helper.c  |  3 +++
>  include/drm/drm_modeset_helper_vtables.h |  7 +++++--
>  3 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 531f2374b072..9f6c5f21c4d6 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -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>
> @@ -2408,6 +2409,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;
>  		}
>  	}
>  
> diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c b/drivers/gpu/drm/drm_gem_atomic_helper.c
> index a27135084ae5..bc9396f2a0ed 100644
> --- a/drivers/gpu/drm/drm_gem_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
> @@ -135,6 +135,9 @@
>   * 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.
>   */
> diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
> index f3a4b47b3986..4e727261dca5 100644
> --- a/include/drm/drm_modeset_helper_vtables.h
> +++ b/include/drm/drm_modeset_helper_vtables.h
> @@ -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 not @cleanup_fb hook
s/not/nor/ ??
> +	 * set drm_gem_plane_helper_prepare_fb() is called automatically to
              ^add comma?
> +	 * implement this.


Leave cleanup_fb out of the description to make it more readable.
In the description of cleanup_fb you can document that it is wrong to
have it without a matcching prepare_fb if you feel for it.

	Sam


         * 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.
> -- 
> 2.32.0.rc2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2021-06-22 19:10 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 16:54 [Intel-gfx] [PATCH 00/15] implicit fencing/dma-resv rules for shared buffers Daniel Vetter
2021-06-22 16:54 ` [Intel-gfx] [PATCH 01/15] dma-resv: Fix kerneldoc Daniel Vetter
2021-06-22 18:19   ` Alex Deucher
2021-06-22 18:49   ` Sam Ravnborg
2021-06-22 19:19     ` Daniel Vetter
2021-06-23  8:31   ` Christian König
2021-06-23 15:15     ` Daniel Vetter
2021-06-22 16:54 ` [Intel-gfx] [PATCH 02/15] dma-buf: Switch to inline kerneldoc Daniel Vetter
2021-06-22 18:24   ` Alex Deucher
2021-06-22 19:01   ` Sam Ravnborg
2021-06-22 19:21     ` Daniel Vetter
2021-06-23  8:32   ` Christian König
2021-06-23 16:17   ` [Intel-gfx] [PATCH] " Daniel Vetter
2021-06-23 17:33     ` Sam Ravnborg
2021-06-22 16:54 ` [Intel-gfx] [PATCH 03/15] dma-buf: Document dma-buf implicit fencing/resv fencing rules Daniel Vetter
2021-06-23  8:41   ` Christian König
2021-06-23 16:19   ` [Intel-gfx] [PATCH] " Daniel Vetter
2021-06-24  6:59     ` Dave Airlie
2021-06-24 11:08     ` [Intel-gfx] [Mesa-dev] " Daniel Stone
2021-06-24 11:23       ` Daniel Vetter
2021-06-22 16:55 ` [Intel-gfx] [PATCH 04/15] drm/panfrost: Shrink sched_lock Daniel Vetter
2021-06-23 16:52   ` Boris Brezillon
2021-06-22 16:55 ` [Intel-gfx] [PATCH 05/15] drm/panfrost: Use xarray and helpers for depedency tracking Daniel Vetter
2021-06-23 16:51   ` Boris Brezillon
2021-06-22 16:55 ` [Intel-gfx] [PATCH 06/15] drm/panfrost: Fix implicit sync Daniel Vetter
2021-06-23 16:47   ` Boris Brezillon
2021-06-23 19:17     ` Daniel Vetter
2021-06-22 16:55 ` [Intel-gfx] [PATCH 07/15] drm/atomic-helper: make drm_gem_plane_helper_prepare_fb the default Daniel Vetter
2021-06-22 19:10   ` Sam Ravnborg [this message]
2021-06-22 20:20     ` Daniel Vetter
2021-06-23 15:39       ` Sam Ravnborg
2021-06-23 16:22   ` [Intel-gfx] [PATCH] " Daniel Vetter
2021-06-22 16:55 ` [Intel-gfx] [PATCH 08/15] drm/<driver>: drm_gem_plane_helper_prepare_fb is now " Daniel Vetter
2021-06-24  8:32   ` Philipp Zabel
2021-06-22 16:55 ` [Intel-gfx] [PATCH 09/15] drm/armada: Remove prepare/cleanup_fb hooks Daniel Vetter
2021-06-24 12:46   ` Maxime Ripard
2021-06-22 16:55 ` [Intel-gfx] [PATCH 10/15] drm/vram-helpers: Create DRM_GEM_VRAM_PLANE_HELPER_FUNCS Daniel Vetter
2021-06-24  7:38   ` Thomas Zimmermann
2021-06-24  7:46   ` Thomas Zimmermann
2021-06-24 13:39     ` Daniel Vetter
2021-06-22 16:55 ` [Intel-gfx] [PATCH 11/15] drm/omap: Follow implicit fencing in prepare_fb Daniel Vetter
2021-06-22 16:55 ` [Intel-gfx] [PATCH 12/15] drm/simple-helper: drm_gem_simple_display_pipe_prepare_fb as default Daniel Vetter
2021-06-22 19:15   ` Sam Ravnborg
2021-06-23 16:24   ` [Intel-gfx] [PATCH] " Daniel Vetter
2021-06-23 17:34     ` Sam Ravnborg
2021-06-22 16:55 ` [Intel-gfx] [PATCH 13/15] drm/tiny: drm_gem_simple_display_pipe_prepare_fb is the default Daniel Vetter
2021-06-22 16:55 ` [Intel-gfx] [PATCH 14/15] drm/gem: Tiny kernel clarification for drm_gem_fence_array_add Daniel Vetter
2021-06-23  8:42   ` Christian König
2021-06-24 12:41     ` Daniel Vetter
2021-06-24 12:48       ` Christian König
2021-06-24 13:32         ` Daniel Vetter
2021-06-24 13:35           ` Christian König
2021-06-24 13:41             ` Daniel Vetter
2021-06-24 13:45               ` Christian König
2021-06-22 16:55 ` [Intel-gfx] [PATCH 15/15] RFC: drm/amdgpu: Implement a proper implicit fencing uapi Daniel Vetter
2021-06-23  9:45   ` Bas Nieuwenhuizen
2021-06-23 12:18     ` Daniel Vetter
2021-06-23 12:59       ` Christian König
2021-06-23 13:38         ` Bas Nieuwenhuizen
2021-06-23 13:44           ` Christian König
2021-06-23 13:49             ` Daniel Vetter
2021-06-23 14:02               ` Christian König
2021-06-23 14:50                 ` Daniel Vetter
2021-06-23 14:58                   ` Bas Nieuwenhuizen
2021-06-23 15:03                     ` Daniel Vetter
2021-06-23 15:07                       ` Christian König
2021-06-23 15:12                         ` Daniel Vetter
2021-06-23 15:15                           ` Christian König
2021-06-22 17:08 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for implicit fencing/dma-resv rules for shared buffers Patchwork
2021-06-22 17:11 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-06-22 17:38 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-06-22 19:12 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2021-06-23 17:05 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for implicit fencing/dma-resv rules for shared buffers (rev5) Patchwork
2021-06-23 17:07 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-06-23 17:35 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-06-23 21:04 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YNI1i1D88TWZU1vR@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox