@@ -61,6 +61,7 @@ struct mtk_drm_crtc {
6161
6262 /* lock for display hardware access */
6363 struct mutex hw_lock ;
64+ bool config_updating ;
6465};
6566
6667struct mtk_crtc_state {
@@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
9798static void mtk_drm_finish_page_flip (struct mtk_drm_crtc * mtk_crtc )
9899{
99100 drm_crtc_handle_vblank (& mtk_crtc -> base );
100- if (mtk_crtc -> pending_needs_vblank ) {
101+ if (! mtk_crtc -> config_updating && mtk_crtc -> pending_needs_vblank ) {
101102 mtk_drm_crtc_finish_page_flip (mtk_crtc );
102103 mtk_crtc -> pending_needs_vblank = false;
103104 }
@@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
425426 }
426427}
427428
428- static void mtk_drm_crtc_hw_config (struct mtk_drm_crtc * mtk_crtc )
429+ static void mtk_drm_crtc_update_config (struct mtk_drm_crtc * mtk_crtc ,
430+ bool needs_vblank )
429431{
430432#if IS_REACHABLE (CONFIG_MTK_CMDQ )
431433 struct cmdq_pkt * cmdq_handle ;
@@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
436438 int i ;
437439
438440 mutex_lock (& mtk_crtc -> hw_lock );
441+ mtk_crtc -> config_updating = true;
442+ if (needs_vblank )
443+ mtk_crtc -> pending_needs_vblank = true;
444+
439445 for (i = 0 ; i < mtk_crtc -> layer_nr ; i ++ ) {
440446 struct drm_plane * plane = & mtk_crtc -> planes [i ];
441447 struct mtk_plane_state * plane_state ;
@@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
472478 cmdq_pkt_flush_async (cmdq_handle , ddp_cmdq_cb , cmdq_handle );
473479 }
474480#endif
481+ mtk_crtc -> config_updating = false;
475482 mutex_unlock (& mtk_crtc -> hw_lock );
476483}
477484
@@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
532539 return ;
533540
534541 plane_helper_funcs -> atomic_update (plane , state );
535- mtk_drm_crtc_hw_config (mtk_crtc );
542+ mtk_drm_crtc_update_config (mtk_crtc , false );
536543}
537544
538545static void mtk_drm_crtc_atomic_enable (struct drm_crtc * crtc ,
@@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
582589 }
583590 mtk_crtc -> pending_planes = true;
584591
585- mtk_drm_crtc_hw_config (mtk_crtc );
592+ mtk_drm_crtc_update_config (mtk_crtc , false );
586593 /* Wait for planes to be disabled */
587594 drm_crtc_wait_one_vblank (crtc );
588595
@@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
618625 struct mtk_drm_crtc * mtk_crtc = to_mtk_crtc (crtc );
619626 int i ;
620627
621- if (mtk_crtc -> event )
622- mtk_crtc -> pending_needs_vblank = true;
623628 if (crtc -> state -> color_mgmt_changed )
624629 for (i = 0 ; i < mtk_crtc -> ddp_comp_nr ; i ++ ) {
625630 mtk_ddp_gamma_set (mtk_crtc -> ddp_comp [i ], crtc -> state );
626631 mtk_ddp_ctm_set (mtk_crtc -> ddp_comp [i ], crtc -> state );
627632 }
628- mtk_drm_crtc_hw_config (mtk_crtc );
633+ mtk_drm_crtc_update_config (mtk_crtc , !! mtk_crtc -> event );
629634}
630635
631636static const struct drm_crtc_funcs mtk_crtc_funcs = {
0 commit comments