Commit bd630a86 authored by Daniel Vetter's avatar Daniel Vetter

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
...@@ -271,11 +271,11 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty); ...@@ -271,11 +271,11 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty);
* @plane: Plane * @plane: Plane
* @state: Plane state the fence will be attached to * @state: Plane state the fence will be attached to
* *
* This function prepares a GEM backed framebuffer for scanout by checking if * This function extracts the exclusive fence from &drm_gem_object.resv and
* the plane framebuffer has a DMA-BUF attached. If it does, it extracts the * attaches it to plane state for the atomic helper to wait on. This is
* exclusive fence and attaches it to the plane state for the atomic helper to * necessary to correctly implement implicit synchronization for any buffers
* wait on. This function can be used as the &drm_plane_helper_funcs.prepare_fb * shared as a struct &dma_buf. This function can be used as the
* callback. * &drm_plane_helper_funcs.prepare_fb callback.
* *
* There is no need for &drm_plane_helper_funcs.cleanup_fb hook for simple * 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 * gem based framebuffer drivers which have their buffers always pinned in
...@@ -287,17 +287,15 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty); ...@@ -287,17 +287,15 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_create_with_dirty);
int drm_gem_fb_prepare_fb(struct drm_plane *plane, int drm_gem_fb_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *state) struct drm_plane_state *state)
{ {
struct dma_buf *dma_buf; struct drm_gem_object *obj;
struct dma_fence *fence; struct dma_fence *fence;
if (!state->fb) if (!state->fb)
return 0; return 0;
dma_buf = drm_gem_fb_get_obj(state->fb, 0)->dma_buf; obj = drm_gem_fb_get_obj(state->fb, 0);
if (dma_buf) { fence = reservation_object_get_excl_rcu(obj->resv);
fence = reservation_object_get_excl_rcu(dma_buf->resv);
drm_atomic_set_fence_for_plane(state, fence); drm_atomic_set_fence_for_plane(state, fence);
}
return 0; return 0;
} }
...@@ -309,10 +307,11 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_prepare_fb); ...@@ -309,10 +307,11 @@ EXPORT_SYMBOL_GPL(drm_gem_fb_prepare_fb);
* @pipe: Simple display pipe * @pipe: Simple display pipe
* @plane_state: Plane state * @plane_state: Plane state
* *
* This function uses drm_gem_fb_prepare_fb() to check if the plane FB has a * This function uses drm_gem_fb_prepare_fb() to extract the exclusive fence
* &dma_buf attached, extracts the exclusive fence and attaches it to plane * from &drm_gem_object.resv and attaches it to plane state for the atomic
* state for the atomic helper to wait on. Drivers can use this as their * helper to wait on. This is necessary to correctly implement implicit
* &drm_simple_display_pipe_funcs.prepare_fb callback. * 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 * See drm_atomic_set_fence_for_plane() for a discussion of implicit and
* explicit fencing in atomic modeset updates. * explicit fencing in atomic modeset updates.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment