From bd630a86be381992fac99f9ab82c5c5b43a5ee3b Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Tue, 25 Jun 2019 22:42:02 +0200 Subject: drm/fb-helper: use gem_bo.resv, not dma_buf.resv in prepare_fb With commit 5f6ed9879a414636405a2bd77f122881695959e4 Author: Daniel Vetter 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 Cc: Eric Anholt Cc: Rob Clark Reviewed-by: Eric Anholt Reviewed-by: Rob Clark Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20190625204208.5614-2-daniel.vetter@ffwll.ch --- drivers/gpu/drm/drm_gem_framebuffer_helper.c | 29 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'drivers/gpu/drm/drm_gem_framebuffer_helper.c') diff --git a/drivers/gpu/drm/drm_gem_framebuffer_helper.c b/drivers/gpu/drm/drm_gem_framebuffer_helper.c index 8fcbabf02dfd..a6426c95b383 100644 --- a/drivers/gpu/drm/drm_gem_framebuffer_helper.c +++ b/drivers/gpu/drm/drm_gem_framebuffer_helper.c @@ -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); - drm_atomic_set_fence_for_plane(state, fence); - } + 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. -- cgit v1.2.3