950-0906-drm-vc4-crtc-Move-the-BO-handling-out-of-common-page.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From e2b51ac3278847aa79089b4a1b94b8d762af0052 Mon Sep 17 00:00:00 2001
  2. From: Maxime Ripard <[email protected]>
  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. We'll soon introduce another completion callback source that won't need
  7. to use the BO reference counting, so let's move it around to create a
  8. function we will be able to share between both callbacks.
  9. Signed-off-by: Maxime Ripard <[email protected]>
  10. ---
  11. drivers/gpu/drm/vc4/vc4_crtc.c | 34 ++++++++++++++++++++--------------
  12. 1 file changed, 20 insertions(+), 14 deletions(-)
  13. --- a/drivers/gpu/drm/vc4/vc4_crtc.c
  14. +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
  15. @@ -830,21 +830,8 @@ vc4_async_page_flip_complete(struct vc4_
  16. drm_crtc_vblank_put(crtc);
  17. drm_framebuffer_put(flip_state->fb);
  18. - /* Decrement the BO usecnt in order to keep the inc/dec calls balanced
  19. - * when the planes are updated through the async update path.
  20. - * FIXME: we should move to generic async-page-flip when it's
  21. - * available, so that we can get rid of this hand-made cleanup_fb()
  22. - * logic.
  23. - */
  24. - if (flip_state->old_fb) {
  25. - struct drm_gem_cma_object *cma_bo;
  26. - struct vc4_bo *bo;
  27. -
  28. - cma_bo = drm_fb_cma_get_gem_obj(flip_state->old_fb, 0);
  29. - bo = to_vc4_bo(&cma_bo->base);
  30. - vc4_bo_dec_usecnt(bo);
  31. + if (flip_state->old_fb)
  32. drm_framebuffer_put(flip_state->old_fb);
  33. - }
  34. kfree(flip_state);
  35. }
  36. @@ -853,8 +840,27 @@ static void vc4_async_page_flip_seqno_co
  37. {
  38. struct vc4_async_flip_state *flip_state =
  39. container_of(cb, struct vc4_async_flip_state, cb.seqno);
  40. + struct vc4_bo *bo = NULL;
  41. +
  42. + if (flip_state->old_fb) {
  43. + struct drm_gem_cma_object *cma_bo =
  44. + drm_fb_cma_get_gem_obj(flip_state->old_fb, 0);
  45. + bo = to_vc4_bo(&cma_bo->base);
  46. + }
  47. vc4_async_page_flip_complete(flip_state);
  48. +
  49. + /*
  50. + * Decrement the BO usecnt in order to keep the inc/dec
  51. + * calls balanced when the planes are updated through
  52. + * the async update path.
  53. + *
  54. + * FIXME: we should move to generic async-page-flip when
  55. + * it's available, so that we can get rid of this
  56. + * hand-made cleanup_fb() logic.
  57. + */
  58. + if (bo)
  59. + vc4_bo_dec_usecnt(bo);
  60. }
  61. static void vc4_async_page_flip_fence_complete(struct dma_fence *fence,