Skip to content

Commit f6766fb

Browse files
committed
drm/vc4: crtc: Move the BO Handling out of Common Page-Flip Handler
The function vc4_async_page_flip() handles asynchronous page-flips in the vc4 driver. However, it mixes some generic code with code that should only be run on older generations that have the GPU handled by the vc4 driver. Let's split the generic part out of vc4_async_page_flip() and into a common function that we be reusable by an handler made for the BCM2711. Reviewed-by: Melissa Wen <mwen@igalia.com> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220610115149.964394-12-maxime@cerno.tech
1 parent 4d12c36 commit f6766fb

1 file changed

Lines changed: 48 additions & 25 deletions

File tree

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -835,40 +835,21 @@ static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb)
835835
vc4_bo_dec_usecnt(bo);
836836
}
837837

838-
/* Implements async (non-vblank-synced) page flips.
839-
*
840-
* The page flip ioctl needs to return immediately, so we grab the
841-
* modeset semaphore on the pipe, and queue the address update for
842-
* when V3D is done with the BO being flipped to.
843-
*/
844-
static int vc4_async_page_flip(struct drm_crtc *crtc,
845-
struct drm_framebuffer *fb,
846-
struct drm_pending_vblank_event *event,
847-
uint32_t flags)
838+
static int
839+
vc4_async_page_flip_common(struct drm_crtc *crtc,
840+
struct drm_framebuffer *fb,
841+
struct drm_pending_vblank_event *event,
842+
uint32_t flags)
848843
{
849844
struct drm_device *dev = crtc->dev;
850845
struct drm_plane *plane = crtc->primary;
851-
int ret = 0;
852846
struct vc4_async_flip_state *flip_state;
853847
struct drm_gem_cma_object *cma_bo = drm_fb_cma_get_gem_obj(fb, 0);
854848
struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
855849

856-
/* Increment the BO usecnt here, so that we never end up with an
857-
* unbalanced number of vc4_bo_{dec,inc}_usecnt() calls when the
858-
* plane is later updated through the non-async path.
859-
* FIXME: we should move to generic async-page-flip when it's
860-
* available, so that we can get rid of this hand-made prepare_fb()
861-
* logic.
862-
*/
863-
ret = vc4_bo_inc_usecnt(bo);
864-
if (ret)
865-
return ret;
866-
867850
flip_state = kzalloc(sizeof(*flip_state), GFP_KERNEL);
868-
if (!flip_state) {
869-
vc4_bo_dec_usecnt(bo);
851+
if (!flip_state)
870852
return -ENOMEM;
871-
}
872853

873854
drm_framebuffer_get(fb);
874855
flip_state->fb = fb;
@@ -902,6 +883,48 @@ static int vc4_async_page_flip(struct drm_crtc *crtc,
902883
return 0;
903884
}
904885

886+
/* Implements async (non-vblank-synced) page flips.
887+
*
888+
* The page flip ioctl needs to return immediately, so we grab the
889+
* modeset semaphore on the pipe, and queue the address update for
890+
* when V3D is done with the BO being flipped to.
891+
*/
892+
static int vc4_async_page_flip(struct drm_crtc *crtc,
893+
struct drm_framebuffer *fb,
894+
struct drm_pending_vblank_event *event,
895+
uint32_t flags)
896+
{
897+
struct drm_device *dev = crtc->dev;
898+
struct vc4_dev *vc4 = to_vc4_dev(dev);
899+
struct drm_gem_cma_object *cma_bo = drm_fb_cma_get_gem_obj(fb, 0);
900+
struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
901+
int ret;
902+
903+
if (WARN_ON_ONCE(vc4->is_vc5))
904+
return -ENODEV;
905+
906+
/*
907+
* Increment the BO usecnt here, so that we never end up with an
908+
* unbalanced number of vc4_bo_{dec,inc}_usecnt() calls when the
909+
* plane is later updated through the non-async path.
910+
*
911+
* FIXME: we should move to generic async-page-flip when
912+
* it's available, so that we can get rid of this
913+
* hand-made prepare_fb() logic.
914+
*/
915+
ret = vc4_bo_inc_usecnt(bo);
916+
if (ret)
917+
return ret;
918+
919+
ret = vc4_async_page_flip_common(crtc, fb, event, flags);
920+
if (ret) {
921+
vc4_bo_dec_usecnt(bo);
922+
return ret;
923+
}
924+
925+
return 0;
926+
}
927+
905928
int vc4_page_flip(struct drm_crtc *crtc,
906929
struct drm_framebuffer *fb,
907930
struct drm_pending_vblank_event *event,

0 commit comments

Comments
 (0)