a3a291d97eea51ae5e90f57ea609a8db2a22f659
[openwrt/staging/blogic.git] /
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
5 page-flip callback
6
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.
10
11 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
12 ---
13 drivers/gpu/drm/vc4/vc4_crtc.c | 34 ++++++++++++++++++++--------------
14 1 file changed, 20 insertions(+), 14 deletions(-)
15
16 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
17 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
18 @@ -830,21 +830,8 @@ vc4_async_page_flip_complete(struct vc4_
19 drm_crtc_vblank_put(crtc);
20 drm_framebuffer_put(flip_state->fb);
21
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()
26 - * logic.
27 - */
28 - if (flip_state->old_fb) {
29 - struct drm_gem_cma_object *cma_bo;
30 - struct vc4_bo *bo;
31 -
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);
37 - }
38
39 kfree(flip_state);
40 }
41 @@ -853,8 +840,27 @@ static void vc4_async_page_flip_seqno_co
42 {
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;
46 +
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);
51 + }
52
53 vc4_async_page_flip_complete(flip_state);
54 +
55 + /*
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.
59 + *
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.
63 + */
64 + if (bo)
65 + vc4_bo_dec_usecnt(bo);
66 }
67
68 static void vc4_async_page_flip_fence_complete(struct dma_fence *fence,