[Intel-gfx] [PATCH 12/17] drm/atomic: Integrate fence support

Sean Paul seanpaul at google.com
Thu Nov 6 18:43:10 CET 2014


On Sun, Nov 02, 2014 at 02:19:25PM +0100, Daniel Vetter wrote:
> This patch is for enabling async commits. It replaces an earlier
> approach which added an async boolean paramter to the ->prepare_fb
> callbacks. The idea is that prepare_fb picks up the right fence to
> synchronize against, which is then used by the synchronous commit
> helper. For async commits drivers can either register a callback to
> the fence or simply do the synchronous wait in their async work queue.
>
> v2: Remove unused variable.
>
> v3: Only wait for fences after the point of no return in the part
> of the commit function which can be run asynchronously. This is after
> the atomic state has been swapped in, hence now check
> plane->state->fence.
>
> Also add a WARN_ON to make sure we don't try to wait on a fence when
> there's no fb, just as a sanity check.
>
> Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>

Reviewed-by: Sean Paul <seanpaul at chromium.org>

> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 23 +++++++++++++++++++++++
>  include/drm/drm_crtc.h              |  3 +++
>  2 files changed, 26 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 26fe60356a0f..afdc376aa7e7 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -30,6 +30,7 @@
>  #include <drm/drm_plane_helper.h>
>  #include <drm/drm_crtc_helper.h>
>  #include <drm/drm_atomic_helper.h>
> +#include <linux/fence.h>
>
>  static void
>  drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
> @@ -704,6 +705,26 @@ void drm_atomic_helper_commit_post_planes(struct drm_device *dev,
>  }
>  EXPORT_SYMBOL(drm_atomic_helper_commit_post_planes);
>
> +static void wait_for_fences(struct drm_device *dev,
> +    struct drm_atomic_state *state)
> +{
> + int nplanes = dev->mode_config.num_total_plane;
> + int i;
> +
> + for (i = 0; i < nplanes; i++) {
> + struct drm_plane *plane = state->planes[i];
> +
> + if (!plane || !plane->state->fence)
> + continue;
> +
> + WARN_ON(!plane->state->fb);
> +
> + fence_wait(plane->state->fence, false);
> + fence_put(plane->state->fence);
> + plane->state->fence = NULL;
> + }
> +}
> +
>  static void
>  wait_for_vblanks(struct drm_device *dev, struct drm_atomic_state *old_state)
>  {
> @@ -801,6 +822,8 @@ int drm_atomic_helper_commit(struct drm_device *dev,
>   * current layout.
>   */
>
> + wait_for_fences(dev, state);
> +
>   drm_atomic_helper_commit_pre_planes(dev, state);
>
>   drm_atomic_helper_commit_planes(dev, state);
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index ddff25eb34d4..5c34665ebb9d 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -42,6 +42,7 @@ struct drm_object_properties;
>  struct drm_file;
>  struct drm_clip_rect;
>  struct device_node;
> +struct fence;
>
>  #define DRM_MODE_OBJECT_CRTC 0xcccccccc
>  #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0
> @@ -659,6 +660,7 @@ struct drm_connector {
>   * struct drm_plane_state - mutable plane state
>   * @crtc: currently bound CRTC, NULL if disabled
>   * @fb: currently bound fb
> + * @fence: optional fence to wait for before scanning out @fb
>   * @crtc_x: left position of visible portion of plane on crtc
>   * @crtc_y: upper position of visible portion of plane on crtc
>   * @crtc_w: width of visible portion of plane on crtc
> @@ -674,6 +676,7 @@ struct drm_connector {
>  struct drm_plane_state {
>   struct drm_crtc *crtc;
>   struct drm_framebuffer *fb;
> + struct fence *fence;
>
>   /* Signed dest location allows it to be partially off screen */
>   int32_t crtc_x, crtc_y;
> --
> 2.1.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx



More information about the Intel-gfx mailing list