1 From e2b51ac3278847aa79089b4a1b94b8d762af0052 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 2 May 2022 15:25:20 +0200
4 Subject: [PATCH] drm/vc4: crtc: Move the BO handling out of common
7 We'll soon introduce another completion callback source that won't need
8 to use the BO reference counting, so let's move it around to create a
9 function we will be able to share between both callbacks.
11 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
13 drivers/gpu/drm/vc4/vc4_crtc.c | 34 ++++++++++++++++++++--------------
14 1 file changed, 20 insertions(+), 14 deletions(-)
16 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
17 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
18 @@ -846,21 +846,8 @@ vc4_async_page_flip_complete(struct vc4_
19 drm_crtc_vblank_put(crtc);
20 drm_framebuffer_put(flip_state->fb);
22 - /* Decrement the BO usecnt in order to keep the inc/dec calls balanced
23 - * when the planes are updated through the async update path.
24 - * FIXME: we should move to generic async-page-flip when it's
25 - * available, so that we can get rid of this hand-made cleanup_fb()
28 - if (flip_state->old_fb) {
29 - struct drm_gem_cma_object *cma_bo;
32 - cma_bo = drm_fb_cma_get_gem_obj(flip_state->old_fb, 0);
33 - bo = to_vc4_bo(&cma_bo->base);
34 - vc4_bo_dec_usecnt(bo);
35 + if (flip_state->old_fb)
36 drm_framebuffer_put(flip_state->old_fb);
41 @@ -869,8 +856,27 @@ static void vc4_async_page_flip_seqno_co
43 struct vc4_async_flip_state *flip_state =
44 container_of(cb, struct vc4_async_flip_state, cb.seqno);
45 + struct vc4_bo *bo = NULL;
47 + if (flip_state->old_fb) {
48 + struct drm_gem_cma_object *cma_bo =
49 + drm_fb_cma_get_gem_obj(flip_state->old_fb, 0);
50 + bo = to_vc4_bo(&cma_bo->base);
53 vc4_async_page_flip_complete(flip_state);
56 + * Decrement the BO usecnt in order to keep the inc/dec
57 + * calls balanced when the planes are updated through
58 + * the async update path.
60 + * FIXME: we should move to generic async-page-flip when
61 + * it's available, so that we can get rid of this
62 + * hand-made cleanup_fb() logic.
65 + vc4_bo_dec_usecnt(bo);
68 static void vc4_async_page_flip_fence_complete(struct dma_fence *fence,