History

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.

Maxime Ripard committed 4 years ago

Commit f6766fb1 parent 4d12c361 file · +48 −25Browse files

Unified · Split

drivers/gpu/drm/vc4/vc4_crtc.c+48−25
@@ -835,40 +835,21 @@ static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb) · 834 unmodified lines
835 vc4_bo_dec_usecnt(bo);835 vc4_bo_dec_usecnt(bo);
836}836}
837 837
838/* Implements async (non-vblank-synced) page flips.838static int
839 *839vc4_async_page_flip_common(struct drm_crtc *crtc,
840 * The page flip ioctl needs to return immediately, so we grab the840 struct drm_framebuffer *fb,
841 * modeset semaphore on the pipe, and queue the address update for841 struct drm_pending_vblank_event *event,
842 * when V3D is done with the BO being flipped to.842 uint32_t flags)
843 */
844static 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)
848{843{
849 struct drm_device *dev = crtc->dev;844 struct drm_device *dev = crtc->dev;
850 struct drm_plane *plane = crtc->primary;845 struct drm_plane *plane = crtc->primary;
851 int ret = 0;
852 struct vc4_async_flip_state *flip_state;846 struct vc4_async_flip_state *flip_state;
853 struct drm_gem_cma_object *cma_bo = drm_fb_cma_get_gem_obj(fb, 0);847 struct drm_gem_cma_object *cma_bo = drm_fb_cma_get_gem_obj(fb, 0);
854 struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);848 struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
855 849
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
867 flip_state = kzalloc(sizeof(*flip_state), GFP_KERNEL);850 flip_state = kzalloc(sizeof(*flip_state), GFP_KERNEL);
868 if (!flip_state) {851 if (!flip_state)
869 vc4_bo_dec_usecnt(bo);
870 return -ENOMEM;852 return -ENOMEM;
871 }
872 853
873 drm_framebuffer_get(fb);854 drm_framebuffer_get(fb);
874 flip_state->fb = fb;855 flip_state->fb = fb;
@@ -902,6 +883,48 @@ static int vc4_async_page_flip(struct drm_crtc *crtc, · 27 unmodified lines
902 return 0;883 return 0;
903}884}
904 885
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 */
892static 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
905int vc4_page_flip(struct drm_crtc *crtc,928int vc4_page_flip(struct drm_crtc *crtc,
906 struct drm_framebuffer *fb,929 struct drm_framebuffer *fb,
907 struct drm_pending_vblank_event *event,930 struct drm_pending_vblank_event *event,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t