Skip to content

Commit da03801

Browse files
Jason-JH.LinChun-Kuang Hu
authored andcommitted
drm/mediatek: Move mtk_crtc_finish_page_flip() to ddp_cmdq_cb()
mtk_crtc_finish_page_flip() is used to notify userspace that a page flip has been completed, allowing userspace to free the frame buffer of the last frame and commit the next frame. In MediaTek's hardware design for configuring display hardware by using GCE, `DRM_EVENT_FLIP_COMPLETE` should be notified to userspace after GCE has finished configuring all display hardware settings for each atomic_commit(). Currently, mtk_crtc_finish_page_flip() cannot guarantee that GCE has configured all the display hardware settings of the last frame. Therefore, to increase the accuracy of the timing for notifying `DRM_EVENT_FLIP_COMPLETE` to userspace, mtk_crtc_finish_page_flip() should be moved to ddp_cmdq_cb(). Fixes: 7f82d9c ("drm/mediatek: Clear pending flag when cmdq packet is done") Signed-off-by: Jason-JH.Lin <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 36684e9 commit da03801

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

drivers/gpu/drm/mediatek/mtk_crtc.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ static void mtk_drm_finish_page_flip(struct mtk_crtc *mtk_crtc)
112112

113113
drm_crtc_handle_vblank(&mtk_crtc->base);
114114

115+
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
116+
if (mtk_crtc->cmdq_client.chan)
117+
return;
118+
#endif
119+
115120
spin_lock_irqsave(&mtk_crtc->config_lock, flags);
116121
if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
117122
mtk_crtc_finish_page_flip(mtk_crtc);
@@ -284,10 +289,8 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
284289
state = to_mtk_crtc_state(mtk_crtc->base.state);
285290

286291
spin_lock_irqsave(&mtk_crtc->config_lock, flags);
287-
if (mtk_crtc->config_updating) {
288-
spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
292+
if (mtk_crtc->config_updating)
289293
goto ddp_cmdq_cb_out;
290-
}
291294

292295
state->pending_config = false;
293296

@@ -315,10 +318,15 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
315318
mtk_crtc->pending_async_planes = false;
316319
}
317320

318-
spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
319-
320321
ddp_cmdq_cb_out:
321322

323+
if (mtk_crtc->pending_needs_vblank) {
324+
mtk_crtc_finish_page_flip(mtk_crtc);
325+
mtk_crtc->pending_needs_vblank = false;
326+
}
327+
328+
spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
329+
322330
mtk_crtc->cmdq_vblank_cnt = 0;
323331
wake_up(&mtk_crtc->cb_blocking_queue);
324332
}
@@ -606,13 +614,18 @@ static void mtk_crtc_update_config(struct mtk_crtc *mtk_crtc, bool needs_vblank)
606614
*/
607615
mtk_crtc->cmdq_vblank_cnt = 3;
608616

617+
spin_lock_irqsave(&mtk_crtc->config_lock, flags);
618+
mtk_crtc->config_updating = false;
619+
spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
620+
609621
mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle);
610622
mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0);
611623
}
612-
#endif
624+
#else
613625
spin_lock_irqsave(&mtk_crtc->config_lock, flags);
614626
mtk_crtc->config_updating = false;
615627
spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
628+
#endif
616629

617630
mutex_unlock(&mtk_crtc->hw_lock);
618631
}

0 commit comments

Comments
 (0)