Skip to content

Commit 4d12c36

Browse files
committed
drm/vc4: crtc: Move the BO handling out of common page-flip callback
We'll soon introduce another completion callback source that won't need to use the BO reference counting, so let's move it around to create a function we will be able to share between both callbacks. Reviewed-by: Melissa Wen <mwen@igalia.com> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220610115149.964394-11-maxime@cerno.tech
1 parent 2523e9d commit 4d12c36

1 file changed

Lines changed: 20 additions & 14 deletions

File tree

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -802,21 +802,8 @@ vc4_async_page_flip_complete(struct vc4_async_flip_state *flip_state)
802802
drm_crtc_vblank_put(crtc);
803803
drm_framebuffer_put(flip_state->fb);
804804

805-
/* Decrement the BO usecnt in order to keep the inc/dec calls balanced
806-
* when the planes are updated through the async update path.
807-
* FIXME: we should move to generic async-page-flip when it's
808-
* available, so that we can get rid of this hand-made cleanup_fb()
809-
* logic.
810-
*/
811-
if (flip_state->old_fb) {
812-
struct drm_gem_cma_object *cma_bo;
813-
struct vc4_bo *bo;
814-
815-
cma_bo = drm_fb_cma_get_gem_obj(flip_state->old_fb, 0);
816-
bo = to_vc4_bo(&cma_bo->base);
817-
vc4_bo_dec_usecnt(bo);
805+
if (flip_state->old_fb)
818806
drm_framebuffer_put(flip_state->old_fb);
819-
}
820807

821808
kfree(flip_state);
822809
}
@@ -825,8 +812,27 @@ static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb)
825812
{
826813
struct vc4_async_flip_state *flip_state =
827814
container_of(cb, struct vc4_async_flip_state, cb.seqno);
815+
struct vc4_bo *bo = NULL;
816+
817+
if (flip_state->old_fb) {
818+
struct drm_gem_cma_object *cma_bo =
819+
drm_fb_cma_get_gem_obj(flip_state->old_fb, 0);
820+
bo = to_vc4_bo(&cma_bo->base);
821+
}
828822

829823
vc4_async_page_flip_complete(flip_state);
824+
825+
/*
826+
* Decrement the BO usecnt in order to keep the inc/dec
827+
* calls balanced when the planes are updated through
828+
* the async update path.
829+
*
830+
* FIXME: we should move to generic async-page-flip when
831+
* it's available, so that we can get rid of this
832+
* hand-made cleanup_fb() logic.
833+
*/
834+
if (bo)
835+
vc4_bo_dec_usecnt(bo);
830836
}
831837

832838
/* Implements async (non-vblank-synced) page flips.

0 commit comments

Comments
 (0)