Commit bd630a86 authored by Daniel Vetter's avatar Daniel Vetter
Browse files

drm/fb-helper: use gem_bo.resv, not dma_buf.resv in prepare_fb



With

commit 5f6ed987
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Fri Jun 14 22:35:57 2019 +0200

    drm/prime: automatically set gem_obj->resv on import

we consistently set drm_gem_bo.resv for imported buffers. Which means
we don't need to check the dma-buf in the prepare_fb helper, but can
generalize them so they're also useful for display+render drivers
which use gem_bo.resv to track their own rendering for their own
scanout buffers.

Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Eric Anholt <eric@anholt.net>
Cc: Rob Clark <robdclark@gmail.com>
Reviewed-by: default avatarEric Anholt <eric@anholt.net>
Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190625204208.5614-2-daniel.vetter@ffwll.ch
parent 5d177189
Loading
Loading
Loading
Loading
+14 −15
Original line number Diff line number Diff line
@@ -271,11 +271,11 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty);
 * @plane: Plane
 * @state: Plane state the fence will be attached to
 *
 * This function prepares a GEM backed framebuffer for scanout by checking if
 * the plane framebuffer has a DMA-BUF attached. If it does, it extracts the
 * exclusive fence and attaches it to the plane state for the atomic helper to
 * wait on. This function can be used as the &drm_plane_helper_funcs.prepare_fb
 * callback.
 * This function extracts the exclusive fence from &drm_gem_object.resv and
 * attaches it to plane state for the atomic helper to wait on. This is
 * necessary to correctly implement implicit synchronization for any buffers
 * shared as a struct &dma_buf. This function can be used as the
 * &drm_plane_helper_funcs.prepare_fb callback.
 *
 * There is no need for &drm_plane_helper_funcs.cleanup_fb hook for simple
 * gem based framebuffer drivers which have their buffers always pinned in
@@ -287,17 +287,15 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty);
int drm_gem_fb_prepare_fb(struct drm_plane *plane,
			  struct drm_plane_state *state)
{
	struct dma_buf *dma_buf;
	struct drm_gem_object *obj;
	struct dma_fence *fence;

	if (!state->fb)
		return 0;

	dma_buf = drm_gem_fb_get_obj(state->fb, 0)->dma_buf;
	if (dma_buf) {
		fence = reservation_object_get_excl_rcu(dma_buf->resv);
	obj = drm_gem_fb_get_obj(state->fb, 0);
	fence = reservation_object_get_excl_rcu(obj->resv);
	drm_atomic_set_fence_for_plane(state, fence);
	}

	return 0;
}
@@ -309,10 +307,11 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_prepare_fb);
 * @pipe: Simple display pipe
 * @plane_state: Plane state
 *
 * This function uses drm_gem_fb_prepare_fb() to check if the plane FB has a
 * &dma_buf attached, extracts the exclusive fence and attaches it to plane
 * state for the atomic helper to wait on. Drivers can use this as their
 * &drm_simple_display_pipe_funcs.prepare_fb callback.
 * This function uses drm_gem_fb_prepare_fb() to extract the exclusive fence
 * from &drm_gem_object.resv and attaches it to plane state for the atomic
 * helper to wait on. This is necessary to correctly implement implicit
 * synchronization for any buffers shared as a struct &dma_buf. Drivers can use
 * this as their &drm_simple_display_pipe_funcs.prepare_fb callback.
 *
 * See drm_atomic_set_fence_for_plane() for a discussion of implicit and
 * explicit fencing in atomic modeset updates.